version 1.1, 1997/07/06 20:22:57 |
version 1.2, 2001/11/19 19:02:13 |
|
|
|
|
static u_char gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */ |
static u_char gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */ |
|
|
static int put_int32 __P((register gz_stream *, u_int32_t)); |
static int put_int32 __P((gz_stream *, u_int32_t)); |
static u_int32_t get_int32 __P((register gz_stream *)); |
static u_int32_t get_int32 __P((gz_stream *)); |
static int get_header __P((register gz_stream *)); |
static int get_header __P((gz_stream *)); |
static int get_byte __P((register gz_stream *)); |
static int get_byte __P((gz_stream *)); |
|
|
int |
int |
gz_check_header(fd, sb, ofn) |
gz_check_header(fd, sb, ofn) |
|
|
gz_close (cookie) |
gz_close (cookie) |
void *cookie; |
void *cookie; |
{ |
{ |
register gz_stream *s = (gz_stream*)cookie; |
gz_stream *s = (gz_stream*)cookie; |
int err = 0; |
int err = 0; |
|
|
if (s == NULL) |
if (s == NULL) |
|
|
void *cookie; |
void *cookie; |
int flush; |
int flush; |
{ |
{ |
register gz_stream *s = (gz_stream*)cookie; |
gz_stream *s = (gz_stream*)cookie; |
size_t len; |
size_t len; |
int done = 0; |
int done = 0; |
int err; |
int err; |
|
|
|
|
static int |
static int |
put_int32 (s, x) |
put_int32 (s, x) |
register gz_stream *s; |
gz_stream *s; |
u_int32_t x; |
u_int32_t x; |
{ |
{ |
if (write(s->z_fd, &x, 1) != 1) |
if (write(s->z_fd, &x, 1) != 1) |
|
|
|
|
static int |
static int |
get_byte(s) |
get_byte(s) |
register gz_stream *s; |
gz_stream *s; |
{ |
{ |
if (s->z_eof) |
if (s->z_eof) |
return EOF; |
return EOF; |
|
|
|
|
static u_int32_t |
static u_int32_t |
get_int32 (s) |
get_int32 (s) |
register gz_stream *s; |
gz_stream *s; |
{ |
{ |
register u_int32_t x; |
u_int32_t x; |
|
|
x = ((u_int32_t)(get_byte(s) & 0xff)); |
x = ((u_int32_t)(get_byte(s) & 0xff)); |
x |= ((u_int32_t)(get_byte(s) & 0xff))<<8; |
x |= ((u_int32_t)(get_byte(s) & 0xff))<<8; |
|
|
|
|
static int |
static int |
get_header(s) |
get_header(s) |
register gz_stream *s; |
gz_stream *s; |
{ |
{ |
int method; /* method byte */ |
int method; /* method byte */ |
int flags; /* flags byte */ |
int flags; /* flags byte */ |
|
|
char *buf; |
char *buf; |
int len; |
int len; |
{ |
{ |
register gz_stream *s = (gz_stream*)cookie; |
gz_stream *s = (gz_stream*)cookie; |
u_char *start = buf; /* starting point for crc computation */ |
u_char *start = buf; /* starting point for crc computation */ |
|
|
s->z_stream.next_out = buf; |
s->z_stream.next_out = buf; |
|
|
const char *buf; |
const char *buf; |
int len; |
int len; |
{ |
{ |
register gz_stream *s = (gz_stream*)cookie; |
gz_stream *s = (gz_stream*)cookie; |
|
|
s->z_stream.next_in = (char *)buf; |
s->z_stream.next_in = (char *)buf; |
s->z_stream.avail_in = len; |
s->z_stream.avail_in = len; |