| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
#if 0 |
|---|
| 20 |
static const char *cvsid = |
|---|
| 21 |
"\n%%% $Id: compress.cc,v 2.3 2004/10/25 17:06:08 maxb Exp $\n"; |
|---|
| 22 |
#endif |
|---|
| 23 |
|
|---|
| 24 |
#include "win32.h" |
|---|
| 25 |
#include <stdio.h> |
|---|
| 26 |
#include "log.h" |
|---|
| 27 |
|
|---|
| 28 |
#include "io_stream.h" |
|---|
| 29 |
#include "compress.h" |
|---|
| 30 |
#include "zlib/zlib.h" |
|---|
| 31 |
#include "compress_gz.h" |
|---|
| 32 |
#include "compress_bz.h" |
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
#define longest_magic 3 |
|---|
| 44 |
|
|---|
| 45 |
io_stream * |
|---|
| 46 |
compress::decompress (io_stream * original) |
|---|
| 47 |
{ |
|---|
| 48 |
if (!original) |
|---|
| 49 |
return NULL; |
|---|
| 50 |
char magic[longest_magic]; |
|---|
| 51 |
if (original->peek (magic, longest_magic) > 0) |
|---|
| 52 |
{ |
|---|
| 53 |
if (memcmp (magic, "\037\213", 2) == 0) |
|---|
| 54 |
{ |
|---|
| 55 |
|
|---|
| 56 |
compress_gz *rv = new compress_gz (original); |
|---|
| 57 |
if (!rv->error ()) |
|---|
| 58 |
return rv; |
|---|
| 59 |
return NULL; |
|---|
| 60 |
} |
|---|
| 61 |
else if (memcmp (magic, "BZh", 3) == 0) |
|---|
| 62 |
{ |
|---|
| 63 |
compress_bz *rv = new compress_bz (original); |
|---|
| 64 |
if (!rv->error ()) |
|---|
| 65 |
return rv; |
|---|
| 66 |
return NULL; |
|---|
| 67 |
} |
|---|
| 68 |
} |
|---|
| 69 |
return NULL; |
|---|
| 70 |
} |
|---|
| 71 |
|
|---|
| 72 |
ssize_t |
|---|
| 73 |
compress::read (void *buffer, size_t len) |
|---|
| 74 |
{ |
|---|
| 75 |
log (LOG_TIMESTAMP, "compress::read called"); |
|---|
| 76 |
return 0; |
|---|
| 77 |
} |
|---|
| 78 |
|
|---|
| 79 |
ssize_t |
|---|
| 80 |
compress::write (void *buffer, size_t len) |
|---|
| 81 |
{ |
|---|
| 82 |
log (LOG_TIMESTAMP, "compress::write called"); |
|---|
| 83 |
return 0; |
|---|
| 84 |
} |
|---|
| 85 |
|
|---|
| 86 |
ssize_t |
|---|
| 87 |
compress::peek (void *buffer, size_t len) |
|---|
| 88 |
{ |
|---|
| 89 |
log (LOG_TIMESTAMP, "compress::peek called"); |
|---|
| 90 |
return 0; |
|---|
| 91 |
} |
|---|
| 92 |
|
|---|
| 93 |
long |
|---|
| 94 |
compress::tell () |
|---|
| 95 |
{ |
|---|
| 96 |
log (LOG_TIMESTAMP, "bz::tell called"); |
|---|
| 97 |
return 0; |
|---|
| 98 |
} |
|---|
| 99 |
|
|---|
| 100 |
int |
|---|
| 101 |
compress::error () |
|---|
| 102 |
{ |
|---|
| 103 |
log (LOG_TIMESTAMP, "compress::error called"); |
|---|
| 104 |
return 0; |
|---|
| 105 |
} |
|---|
| 106 |
|
|---|
| 107 |
const char * |
|---|
| 108 |
compress::next_file_name () |
|---|
| 109 |
{ |
|---|
| 110 |
log (LOG_TIMESTAMP, "compress::next_file_name called"); |
|---|
| 111 |
return NULL; |
|---|
| 112 |
} |
|---|
| 113 |
|
|---|
| 114 |
compress::~compress () |
|---|
| 115 |
{ |
|---|
| 116 |
log (LOG_BABBLE, "compress::~compress called"); |
|---|
| 117 |
return; |
|---|
| 118 |
} |
|---|