4#include "zipios++/zipios-config.h"
6#include "zipios++/meta-iostreams.h"
19inline uint16 ztohs (
unsigned char *buf ) {
23 out = (
static_cast< uint16
>( buf[ 0 ] ) << 8 ) +
24 (
static_cast< uint16
>( buf[ 1 ] ) ) ;
30inline uint32 ztohl (
unsigned char *buf ) {
32 out = (
static_cast< uint32
>( buf[ 0 ] ) << 24 ) +
33 (
static_cast< uint32
>( buf[ 1 ] ) << 16 ) +
34 (
static_cast< uint32
>( buf[ 2 ] ) << 8 ) +
35 (
static_cast< uint32
>( buf[ 3 ] ) ) ;
42inline uint16 ztohs (
unsigned char *buf ) {
44 out = (
static_cast< uint16
>( buf[ 1 ] ) << 8 ) +
45 (
static_cast< uint16
>( buf[ 0 ] ) ) ;
50inline uint32 ztohl (
unsigned char *buf ) {
52 out = (
static_cast< uint32
>( buf[ 3 ] ) << 24 ) +
53 (
static_cast< uint32
>( buf[ 2 ] ) << 16 ) +
54 (
static_cast< uint32
>( buf[ 1 ] ) << 8 ) +
55 (
static_cast< uint32
>( buf[ 0 ] ) ) ;
68inline uint32 htozl (
unsigned char *buf ) {
73inline uint16 htozs (
unsigned char *buf ) {
78inline uint32 readUint32 ( istream &is ) {
79 static const int buf_len =
sizeof ( uint32 ) ;
80 unsigned char buf [ buf_len ] ;
82 while ( rsf < buf_len ) {
83 is.read (
reinterpret_cast< char *
>( buf ) + rsf, buf_len - rsf ) ;
86 return ztohl ( buf ) ;
89inline void writeUint32 ( uint32 host_val, ostream &os ) {
90 uint32 val = htozl(
reinterpret_cast< unsigned char *
>( &host_val ) ) ;
91 os.write(
reinterpret_cast< char *
>( &val ),
sizeof( uint32 ) ) ;
94inline uint16 readUint16 ( istream &is ) {
95 static const int buf_len =
sizeof ( uint16 ) ;
96 unsigned char buf [ buf_len ] ;
98 while ( rsf < buf_len ) {
99 is.read (
reinterpret_cast< char *
>( buf ) + rsf, buf_len - rsf ) ;
100 rsf += is.gcount () ;
102 return ztohs ( buf ) ;
105inline void writeUint16 ( uint16 host_val, ostream &os ) {
106 uint16 val = htozl(
reinterpret_cast< unsigned char *
>( &host_val ) ) ;
107 os.write(
reinterpret_cast< char *
>( &val ),
sizeof( uint16 ) ) ;
110inline void readByteSeq ( istream &is,
string &con,
int count ) {
111 char *buf =
new char [ count + 1 ] ;
113 while ( rsf < count && is ) {
114 is.read ( buf + rsf, count - rsf ) ;
117 buf [ count ] =
'\0' ;
123inline void writeByteSeq( ostream &os,
const string &con ) {
127inline void readByteSeq ( istream &is,
unsigned char *buf,
int count ) {
130 while ( rsf < count && is ) {
131 is.read (
reinterpret_cast< char *
>( buf ) + rsf, count - rsf ) ;
136inline void writeByteSeq ( ostream &os,
const unsigned char *buf,
int count ) {
137 os.rdbuf()->sputn(
reinterpret_cast< const char *
>( buf ), count ) ;
140inline void readByteSeq ( istream &is, vector < unsigned char > &vec,
int count ) {
141 unsigned char *buf =
new unsigned char [ count ] ;
143 while ( rsf < count && is ) {
144 is.read (
reinterpret_cast< char *
>( buf ) + rsf, count - rsf ) ;
148 vec.insert ( vec.end (), buf, buf + count ) ;
152inline void writeByteSeq ( ostream &os,
const vector < unsigned char > &vec ) {
154 os.rdbuf()->sputn(
reinterpret_cast< const char *
>( &( vec[ 0 ] ) ), vec.size() ) ;
159istream& operator>> ( istream &is,
ZipCDirEntry &zcdh ) ;
162ostream &operator<< ( ostream &os,
const ZipLocalEntry &zlh ) ;
163ostream &operator<< ( ostream &os,
const ZipCDirEntry &zcdh ) ;
The end of the Central directory structure.
Specialization of ZipLocalEntry, that add fields for storing the extra information,...
A concrete implementation of the abstract FileEntry base class for ZipFile entries,...
A struct containing fields for the entries in a zip file data descriptor, that trails the compressed ...
Header file containing classes and functions for reading the central directory and local header field...
Header file that defines some simple data types.