/* gzip.h -- common declarations for all gzip modules
- * Copyright (C) 1997, 1998, 1999, 2001 Free Software Foundation, Inc.
- * Copyright (C) 1992-1993 Jean-loup Gailly.
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License, see the file COPYING.
- */
-#if defined(__STDC__) || defined(PROTO)
-# define OF(args) args
-#else
-# define OF(args) ()
-#endif
+ Copyright (C) 1997-1999, 2001, 2006-2007, 2009-2018 Free Software
+ Foundation, Inc.
+
+ Copyright (C) 1992-1993 Jean-loup Gailly.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifdef __STDC__
typedef void *voidp;
typedef char *voidp;
#endif
+#ifndef __attribute__
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
+# define __attribute__(x)
+# endif
+#endif
+
/* I don't like nested includes, but the following headers are used
* too often
*/
#include <stdio.h>
-#include <sys/types.h> /* for off_t, time_t */
-#if defined HAVE_STRING_H || defined STDC_HEADERS
-# include <string.h>
-# if !defined STDC_HEADERS && defined HAVE_MEMORY_H && !defined __GNUC__
-# include <memory.h>
-# endif
-# define memzero(s, n) memset ((voidp)(s), 0, (n))
-#else
-# include <strings.h>
-# define strchr index
-# define strrchr rindex
-# define memcpy(d, s, n) bcopy((s), (d), (n))
-# define memcmp(s1, s2, n) bcmp((s1), (s2), (n))
-# define memzero(s, n) bzero((s), (n))
-#endif
+#include <sys/types.h> /* for off_t */
+#include <time.h>
+#include <string.h>
+#include <stdnoreturn.h>
+#define memzero(s, n) memset ((voidp)(s), 0, (n))
#ifndef RETSIGTYPE
# define RETSIGTYPE void
# define DECLARE(type, array, size) type * near array
# define ALLOC(type, array, size) { \
array = (type*)fcalloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
- if (array == NULL) error("insufficient memory"); \
+ if (!array) xalloc_die (); \
}
# define FREE(array) {if (array != NULL) fcfree(array), array=NULL;}
#else
extern int ofd; /* output file descriptor */
extern char ifname[]; /* input file name or "stdin" */
extern char ofname[]; /* output file name or "stdout" */
-extern char *progname; /* program name */
+extern char *program_name; /* program name */
-extern time_t time_stamp; /* original time stamp (modification time) */
+extern struct timespec time_stamp; /* original timestamp (modification time) */
extern off_t ifile_size; /* input file size, -1 for devices (debug only) */
typedef int file_t; /* Do not use stdio */
/* gzip flag byte */
#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
-#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
+#define HEADER_CRC 0x02 /* bit 1 set: CRC16 for the gzip header */
#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
#define COMMENT 0x10 /* bit 4 set: file comment present */
* distances are limited to MAX_DIST instead of WSIZE.
*/
-extern int decrypt; /* flag to turn on decryption */
extern int exit_code; /* program exit code */
extern int verbose; /* be verbose (-v) */
extern int quiet; /* be quiet (-q) */
/* Diagnostic functions */
#ifdef DEBUG
-# define Assert(cond,msg) {if(!(cond)) error(msg);}
+# define Assert(cond,msg) {if (!(cond)) gzip_error (msg);}
# define Trace(x) fprintf x
# define Tracev(x) {if (verbose) fprintf x ;}
# define Tracevv(x) {if (verbose>1) fprintf x ;}
#endif
#define WARN(msg) {if (!quiet) fprintf msg ; \
- if (exit_code == OK) exit_code = WARNING;}
+ if (exit_code == OK) exit_code = WARNING;}
- /* in zip.c: */
-extern int zip OF((int in, int out));
-extern int file_read OF((char *buf, unsigned size));
+ /* in zip.c: */
+extern int zip (int in, int out);
+extern int file_read (char *buf, unsigned size);
- /* in unzip.c */
-extern int unzip OF((int in, int out));
-extern int check_zipfile OF((int in));
+ /* in unzip.c */
+extern int unzip (int in, int out);
+extern int check_zipfile (int in);
- /* in unpack.c */
-extern int unpack OF((int in, int out));
+ /* in unpack.c */
+extern int unpack (int in, int out);
- /* in unlzh.c */
-extern int unlzh OF((int in, int out));
+ /* in unlzh.c */
+extern int unlzh (int in, int out);
- /* in gzip.c */
-RETSIGTYPE abort_gzip OF((void));
+ /* in gzip.c */
+extern noreturn void abort_gzip (void);
/* in deflate.c */
-void lm_init OF((int pack_level, ush *flags));
-off_t deflate OF((void));
+extern void lm_init (int pack_level, ush *flags);
+extern off_t deflate (void);
/* in trees.c */
-void ct_init OF((ush *attr, int *method));
-int ct_tally OF((int dist, int lc));
-off_t flush_block OF((char *buf, ulg stored_len, int pad, int eof));
+extern void ct_init (ush *attr, int *method);
+extern int ct_tally (int dist, int lc);
+extern off_t flush_block (char *buf, ulg stored_len, int pad, int eof);
/* in bits.c */
-void bi_init OF((file_t zipfile));
-void send_bits OF((int value, int length));
-unsigned bi_reverse OF((unsigned value, int length));
-void bi_windup OF((void));
-void copy_block OF((char *buf, unsigned len, int header));
-extern int (*read_buf) OF((char *buf, unsigned size));
-
- /* in util.c: */
-extern int copy OF((int in, int out));
-extern ulg updcrc OF((uch *s, unsigned n));
-extern void clear_bufs OF((void));
-extern int fill_inbuf OF((int eof_ok));
-extern void flush_outbuf OF((void));
-extern void flush_window OF((void));
-extern void write_buf OF((int fd, voidp buf, unsigned cnt));
-extern char *strlwr OF((char *s));
-extern char *base_name OF((char *fname));
-extern int xunlink OF((char *fname));
-extern void make_simple_name OF((char *name));
-extern char *add_envopt OF((int *argcp, char ***argvp, char *env));
-extern void error OF((char *m));
-extern void warning OF((char *m));
-extern void read_error OF((void));
-extern void write_error OF((void));
-extern void display_ratio OF((off_t num, off_t den, FILE *file));
-extern void fprint_off OF((FILE *, off_t, int));
-extern voidp xmalloc OF((unsigned int size));
-
- /* in inflate.c */
-extern int inflate OF((void));
-
- /* in yesno.c */
-extern int yesno OF((void));
+extern void bi_init (file_t zipfile);
+extern void send_bits (int value, int length);
+extern unsigned bi_reverse (unsigned value, int length) _GL_ATTRIBUTE_CONST;
+extern void bi_windup (void);
+extern void copy_block (char *buf, unsigned len, int header);
+extern int (*read_buf) (char *buf, unsigned size);
+
+ /* in util.c: */
+extern int copy (int in, int out);
+extern ulg updcrc (uch *s, unsigned n);
+extern void clear_bufs (void);
+extern int fill_inbuf (int eof_ok);
+extern void flush_outbuf (void);
+extern void flush_window (void);
+extern void write_buf (int fd, voidp buf, unsigned cnt);
+extern int read_buffer (int fd, voidp buf, unsigned int cnt);
+extern char *strlwr (char *s);
+extern char *gzip_base_name (char *fname) _GL_ATTRIBUTE_PURE;
+extern int xunlink (char *fname);
+extern void make_simple_name (char *name);
+extern char *add_envopt (int *argcp, char ***argvp, char const *env);
+extern noreturn void gzip_error (char const *m);
+extern noreturn void xalloc_die (void);
+extern void warning (char const *m);
+extern noreturn void read_error (void);
+extern noreturn void write_error (void);
+extern void display_ratio (off_t num, off_t den, FILE *file);
+extern void fprint_off (FILE *, off_t, int);
+
+ /* in inflate.c */
+extern int inflate (void);