zlib 1.2.0.5

This commit is contained in:
Mark Adler
2011-09-09 23:22:37 -07:00
parent 086e982175
commit 4b5a43a219
152 changed files with 14540 additions and 12588 deletions

View File

@@ -1,5 +1,4 @@
#include <memory.h>
#include "zfstream.h"
gzfilebuf::gzfilebuf() :
@@ -17,15 +16,13 @@ gzfilebuf::~gzfilebuf() {
}
gzfilebuf *gzfilebuf::open( const char *name,
int io_mode ) {
int io_mode ) {
if ( is_open() )
return NULL;
char char_mode[10];
char *p;
memset(char_mode,'\0',10);
p = char_mode;
char *p = char_mode;
if ( io_mode & ios::in ) {
mode = ios::in;
@@ -48,6 +45,9 @@ gzfilebuf *gzfilebuf::open( const char *name,
*p++ = '9';
}
// Put the end-of-string indicator
*p = '\0';
if ( (file = gzopen(name, char_mode)) == NULL )
return NULL;
@@ -58,15 +58,13 @@ gzfilebuf *gzfilebuf::open( const char *name,
}
gzfilebuf *gzfilebuf::attach( int file_descriptor,
int io_mode ) {
int io_mode ) {
if ( is_open() )
return NULL;
char char_mode[10];
char *p;
memset(char_mode,'\0',10);
p = char_mode;
char *p = char_mode;
if ( io_mode & ios::in ) {
mode = ios::in;
@@ -89,6 +87,9 @@ gzfilebuf *gzfilebuf::attach( int file_descriptor,
*p++ = '9';
}
// Put the end-of-string indicator
*p = '\0';
if ( (file = gzdopen(file_descriptor, char_mode)) == NULL )
return NULL;
@@ -112,13 +113,13 @@ gzfilebuf *gzfilebuf::close() {
}
int gzfilebuf::setcompressionlevel( short comp_level ) {
int gzfilebuf::setcompressionlevel( int comp_level ) {
return gzsetparams(file, comp_level, -2);
}
int gzfilebuf::setcompressionstrategy( short comp_strategy ) {
int gzfilebuf::setcompressionstrategy( int comp_strategy ) {
return gzsetparams(file, -2, comp_strategy);
@@ -151,7 +152,7 @@ int gzfilebuf::underflow() {
if ( out_waiting() ) {
if ( flushbuf() == EOF )
return EOF;
return EOF;
}
}
@@ -180,11 +181,11 @@ int gzfilebuf::overflow( int c ) {
setg(0,0,0);
} else {
if (in_avail()) {
return EOF;
return EOF;
}
if (out_waiting()) {
if (flushbuf() == EOF)
return EOF;
return EOF;
}
}
@@ -282,12 +283,11 @@ void gzfilestream_common::close() {
}
gzfilebuf *gzfilestream_common::rdbuf() {
gzfilebuf *gzfilestream_common::rdbuf()
{
return &buffer;
}
gzifstream::gzifstream() :
ios( gzfilestream_common::rdbuf() )
{

View File

@@ -1,6 +1,6 @@
#ifndef _zfstream_h
#define _zfstream_h
#ifndef zfstream_h
#define zfstream_h
#include <fstream.h>
#include "zlib.h"
@@ -16,8 +16,8 @@ public:
gzfilebuf *attach( int file_descriptor, int io_mode );
gzfilebuf *close();
int setcompressionlevel( short comp_level );
int setcompressionstrategy( short comp_strategy );
int setcompressionlevel( int comp_level );
int setcompressionstrategy( int comp_strategy );
inline int is_open() const { return (file !=NULL); }
@@ -98,18 +98,19 @@ private:
T val;
};
template<class T> gzofstream &operator<<(gzofstream &s,
const gzomanip<T> &m) {
template<class T> gzofstream &operator<<(gzofstream &s, const gzomanip<T> &m)
{
return (*m.func)(s, m.val);
}
inline gzofstream &setcompressionlevel( gzofstream &s, int l ) {
inline gzofstream &setcompressionlevel( gzofstream &s, int l )
{
(s.rdbuf())->setcompressionlevel(l);
return s;
}
inline gzofstream &setcompressionstrategy( gzofstream &s, int l ) {
inline gzofstream &setcompressionstrategy( gzofstream &s, int l )
{
(s.rdbuf())->setcompressionstrategy(l);
return s;
}
@@ -125,18 +126,3 @@ inline gzomanip<int> setcompressionstrategy(int l)
}
#endif