Regenerate Japanese resources
[cygwin-setup.git] / compress_gz.h
blobc7ae14b228e6466790978c535bfe5f88655de4c6
1 /*
2 * Copyright (c) 2001, Robert Collins.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
10 * http://www.gnu.org/
12 * Written by Robert Collins <rbtcollins@hotmail.com>
16 #ifndef SETUP_COMPRESS_GZ_H
17 #define SETUP_COMPRESS_GZ_H
19 #include "compress.h"
20 #include <zlib.h>
22 class compress_gz:public compress
24 public:
25 /* assumes decompression */
26 compress_gz (io_stream *);
27 /* the mode allows control, but this implementation only does compression */
28 compress_gz (io_stream *, const char *);
29 /* read data (duh!) */
30 virtual ssize_t read (void *buffer, size_t len);
31 /* provide data to (double duh!) */
32 virtual ssize_t write (const void *buffer, size_t len);
33 /* read data without removing it from the class's internal buffer */
34 virtual ssize_t peek (void *buffer, size_t len);
35 virtual off_t tell ();
36 virtual off_t seek (off_t where, io_stream_seek_t whence);
37 /* try guessing this one */
38 virtual int error ();
39 /* Find out the next stream name -
40 * ie for foo.tar.gz, at offset 0, next_file_name = foo.tar
41 * for foobar that is an compress, next_file_name is the next
42 * extractable filename.
44 virtual const char *next_file_name ()
46 return NULL;
48 virtual int set_mtime (time_t);
49 virtual time_t get_mtime ();
50 virtual mode_t get_mode ();
51 /* Use seek EOF, then tell (). get_size won't do this incase you are sucking down
52 * over a WAN :} */
53 virtual size_t get_size () {return 0;};
54 virtual void release_original (); /* give up ownership of original io_stream */
55 /* if you are still needing these hints... give up now! */
56 virtual ~ compress_gz ();
57 private:
58 compress_gz ()
61 char peekbuf[512];
62 size_t peeklen;
63 void construct ();
64 void check_header ();
65 int get_byte ();
66 unsigned long getLong ();
67 void putLong (unsigned long);
68 void destroy ();
69 int do_flush (int);
70 io_stream *original;
71 bool owns_original;
72 const char *openmode;
73 /* from zlib */
74 z_stream stream;
75 int z_err; /* error code for last stream operation */
76 int z_eof; /* set if end of input file */
77 unsigned char *inbuf; /* input buffer */
78 unsigned char *outbuf; /* output buffer */
79 uLong crc; /* crc32 of uncompressed data */
80 char *msg; /* error message */
81 int transparent; /* 1 if input file is not a .gz file */
82 char mode; /* 'w' or 'r' */
83 off_t startpos; /* start of compressed data in file (header skipped) */
86 #endif /* SETUP_COMPRESS_GZ_H */