diff options
author | Erik Andersen <andersen@codepoet.org> | 2000-04-13 05:18:56 +0400 |
---|---|---|
committer | Erik Andersen <andersen@codepoet.org> | 2000-04-13 05:18:56 +0400 |
commit | 61677feff7f549a48267c2c0c50a7420de6e2599 (patch) | |
tree | 1ea829e51641647a35c552e289f4482ab9f5db27 /archival | |
parent | 62dc17a3b100496a5c7433cc598d674e244cb6f8 (diff) |
Upates to include copyright 2000 to everything
-Erik
Diffstat (limited to 'archival')
-rw-r--r-- | archival/gunzip.c | 170 | ||||
-rw-r--r-- | archival/gzip.c | 191 | ||||
-rw-r--r-- | archival/tar.c | 6 |
3 files changed, 184 insertions, 183 deletions
diff --git a/archival/gunzip.c b/archival/gunzip.c index 7aa896469..1a5cdba88 100644 --- a/archival/gunzip.c +++ b/archival/gunzip.c @@ -1,13 +1,33 @@ /* vi: set sw=4 ts=4: */ -/* zcat : stripped version based on gzip sources - Sven Rudolph <sr1@inf.tu-dresden.de> - */ +/* + * Gzip implementation for busybox + * + * Based on GNU gzip Copyright (C) 1992-1993 Jean-loup Gailly. + * + * Originally adjusted for busybox by Sven Rudolph <sr1@inf.tu-dresden.de> + * based on gzip sources + * + * Adjusted further by Erik Andersen <andersen@lineo.com>, <andersee@debian.org> + * to support files as well as stdin/stdout, and to generally behave itself wrt + * command line handling. + * + * 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 2 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ #include "internal.h" -#define bb_need_name_too_long -#define BB_DECLARE_EXTERN -#include "messages.c" - static const char gunzip_usage[] = "gunzip [OPTION]... FILE\n\n" "Uncompress FILE (or standard input if FILE is '-').\n\n" @@ -16,6 +36,18 @@ static const char gunzip_usage[] = "\t-c\tWrite output to standard output\n" "\t-t\tTest compressed file integrity\n"; + + /* These defines are very important for BusyBox. Without these, + * huge chunks of ram are pre-allocated making the BusyBox bss + * size Freaking Huge(tm), which is a bad thing.*/ +#define SMALL_MEM +#define DYN_ALLOC + +#define bb_need_name_too_long +#define BB_DECLARE_EXTERN +#include "messages.c" + + /* gzip (GNU zip) -- compress files with zip algorithm and 'compress' interface * Copyright (C) 1992-1993 Jean-loup Gailly * The unzip code was written and put in the public domain by Mark Adler. @@ -89,25 +121,6 @@ static char *license_msg[] = { #define get_char() get_byte() #define put_char(c) put_byte(c) -/* #include "gzip.h" */ - -/* gzip.h -- common declarations for all gzip modules - * 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 - -#ifdef __STDC__ -typedef void *voidp; -#else -typedef char *voidp; -#endif /* I don't like nested includes, but the string and io functions are used * too often @@ -118,7 +131,7 @@ typedef char *voidp; # if !defined(STDC_HEADERS) && !defined(NO_MEMORY_H) && !defined(__GNUC__) # include <memory.h> # endif -# define memzero(s, n) memset ((voidp)(s), 0, (n)) +# define memzero(s, n) memset ((void *)(s), 0, (n)) #else # include <strings.h> # define strchr index @@ -329,49 +342,46 @@ extern int save_orig_name; /* set if original name must be saved */ #define WARN(msg) {fprintf msg ; \ if (exit_code == OK) exit_code = WARNING;} -#define do_exit(c) exit(c) - - /* in unzip.c */ -extern int unzip OF((int in, int out)); +extern int unzip (int in, int out); /* in gzip.c */ -RETSIGTYPE abort_gzip OF((void)); +RETSIGTYPE abort_gzip (void); /* in deflate.c */ -void lm_init OF((int pack_level, ush * flags)); -ulg deflate OF((void)); +void lm_init (int pack_level, ush * flags); +ulg deflate (void); /* in trees.c */ -void ct_init OF((ush * attr, int *method)); -int ct_tally OF((int dist, int lc)); -ulg flush_block OF((char *buf, ulg stored_len, int eof)); +void ct_init (ush * attr, int *method); +int ct_tally (int dist, int lc); +ulg flush_block (char *buf, ulg stored_len, 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)); +void bi_init (file_t zipfile); +void send_bits (int value, int length); +unsigned bi_reverse (unsigned value, int length); +void bi_windup (void); +void copy_block (char *buf, unsigned len, int header); +extern int (*read_buf) (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 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, void * buf, unsigned cnt); #ifndef __linux__ -extern char *basename OF((char *fname)); +extern char *basename (char *fname); #endif /* not __linux__ */ -extern void read_error OF((void)); -extern void write_error OF((void)); +extern void read_error (void); +extern void write_error (void); /* in inflate.c */ -extern int inflate OF((void)); +extern int inflate (void); /* #include "lzw.h" */ @@ -415,8 +425,8 @@ extern int inflate OF((void)); extern int maxbits; /* max bits per code for LZW */ extern int block_mode; /* block compress mode -C compatible with 2.0 */ -extern int lzw OF((int in, int out)); -extern int unlzw OF((int in, int out)); +extern int lzw (int in, int out); +extern int unlzw (int in, int out); /* #include "revision.h" */ @@ -605,7 +615,7 @@ typedef struct direct dir_type; #if !defined(S_ISREG) && defined(S_IFREG) # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) #endif -typedef RETSIGTYPE(*sig_type) OF((int)); +typedef RETSIGTYPE(*sig_type) (int); #ifndef O_BINARY # define O_BINARY 0 /* creation mode for open() */ @@ -644,7 +654,7 @@ typedef RETSIGTYPE(*sig_type) OF((int)); #ifdef NO_OFF_T typedef long off_t; -off_t lseek OF((int fd, off_t offset, int whence)); +off_t lseek (int fd, off_t offset, int whence); #endif @@ -687,7 +697,7 @@ long header_bytes; /* number of bytes in gzip header */ /* local functions */ -local int get_method OF((int in)); +local int get_method (int in); #define strequ(s1, s2) (strcmp((s1),(s2)) == 0) @@ -773,7 +783,7 @@ int gunzip_main(int argc, char **argv) usage(gunzip_usage); if (strlen(*argv) > MAX_PATH_LEN) { fprintf(stderr, name_too_long, "gunzip"); - do_exit(WARNING); + exit(WARNING); } strcpy(ifname, *argv); @@ -781,13 +791,13 @@ int gunzip_main(int argc, char **argv) inFileNum = open(ifname, O_RDONLY); if (inFileNum < 0) { perror(ifname); - do_exit(WARNING); + exit(WARNING); } /* Get the time stamp on the input file. */ result = stat(ifname, &statBuf); if (result < 0) { perror(ifname); - do_exit(WARNING); + exit(WARNING); } ifile_size = statBuf.st_size; } @@ -812,7 +822,7 @@ int gunzip_main(int argc, char **argv) /* And get to work */ if (strlen(ifname) > MAX_PATH_LEN - 4) { fprintf(stderr, name_too_long, "gunzip"); - do_exit(WARNING); + exit(WARNING); } strcpy(ofname, ifname); pos = strstr(ofname, ".gz"); @@ -836,7 +846,7 @@ int gunzip_main(int argc, char **argv) #endif if (outFileNum < 0) { perror(ofname); - do_exit(WARNING); + exit(WARNING); } /* Set permissions on the file */ fchmod(outFileNum, statBuf.st_mode); @@ -860,7 +870,7 @@ int gunzip_main(int argc, char **argv) exit(FALSE); } } - do_exit(exit_code); + exit(exit_code); } @@ -953,7 +963,7 @@ int in; /* input file descriptor */ */ RETSIGTYPE abort_gzip() { - do_exit(ERROR); + exit(ERROR); } /* unzip.c -- decompress files in gzip or pkzip format. @@ -1027,7 +1037,7 @@ int in, out; /* input and output file descriptors */ ofd = out; method = get_method(ifd); if (method < 0) { - do_exit(exit_code); /* error message already emitted */ + exit(exit_code); /* error message already emitted */ } updcrc(NULL, 0); /* initialize crc */ @@ -1218,7 +1228,7 @@ void flush_window() */ void write_buf(fd, buf, cnt) int fd; -voidp buf; +void * buf; unsigned cnt; { unsigned n; @@ -1228,7 +1238,7 @@ unsigned cnt; write_error(); } cnt -= n; - buf = (voidp) ((char *) buf + n); + buf = (void *) ((char *) buf + n); } } @@ -1240,8 +1250,8 @@ unsigned cnt; # define const # endif -int strspn OF((const char *s, const char *accept)); -int strcspn OF((const char *s, const char *reject)); +int strspn (const char *s, const char *accept); +int strcspn (const char *s, const char *reject); /* ======================================================================== * Return the length of the maximum initial segment @@ -1493,15 +1503,15 @@ struct huft { /* Function prototypes */ -int huft_build OF((unsigned *, unsigned, unsigned, ush *, ush *, - struct huft **, int *)); -int huft_free OF((struct huft *)); -int inflate_codes OF((struct huft *, struct huft *, int, int)); -int inflate_stored OF((void)); -int inflate_fixed OF((void)); -int inflate_dynamic OF((void)); -int inflate_block OF((int *)); -int inflate OF((void)); +int huft_build (unsigned *, unsigned, unsigned, ush *, ush *, + struct huft **, int *); +int huft_free (struct huft *); +int inflate_codes (struct huft *, struct huft *, int, int); +int inflate_stored (void); +int inflate_fixed (void); +int inflate_dynamic (void); +int inflate_block (int *); +int inflate (void); /* The inflate algorithm uses a sliding 32K byte window on the uncompressed diff --git a/archival/gzip.c b/archival/gzip.c index 0a969d8db..55ec5bc4e 100644 --- a/archival/gzip.c +++ b/archival/gzip.c @@ -1,16 +1,42 @@ /* vi: set sw=4 ts=4: */ -/* gzip.c -- this is a stripped down version of gzip I put into busybox, it does - * only standard in to standard out with -9 compression. It also requires the - * zcat module for some important functions. +/* + * Gzip implementation for busybox + * + * Based on GNU gzip Copyright (C) 1992-1993 Jean-loup Gailly. + * + * Originally adjusted for busybox by Charles P. Wright <cpw@unix.asb.com> + * "this is a stripped down version of gzip I put into busybox, it does + * only standard in to standard out with -9 compression. It also requires + * the zcat module for some important functions." + * + * Adjusted further by Erik Andersen <andersen@lineo.com>, <andersee@debian.org> + * to support files as well as stdin/stdout, and to generally behave itself wrt + * command line handling. + * + * 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 2 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * Charles P. Wright <cpw@unix.asb.com> */ + #include "internal.h" -#ifdef BB_GZIP -//#ifndef BB_ZCAT -//#error you need zcat to have gzip support! -//#endif +/* These defines are very important for BusyBox. Without these, + * huge chunks of ram are pre-allocated making the BusyBox bss + * size Freaking Huge(tm), which is a bad thing.*/ +#define SMALL_MEM +#define DYN_ALLOC + static const char gzip_usage[] = "gzip [OPTION]... FILE\n\n" @@ -21,42 +47,12 @@ static const char gzip_usage[] = "\t-c\tWrite output to standard output instead of FILE.gz\n"; -/* gzip.h -- common declarations for all gzip modules - * 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 - -#ifdef __STDC__ -typedef void *voidp; -#else -typedef char *voidp; -#endif - /* I don't like nested includes, but the string and io functions are used * too often */ #include <stdio.h> -#if !defined(NO_STRING_H) || defined(STDC_HEADERS) -# include <string.h> -# if !defined(STDC_HEADERS) && !defined(NO_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 <string.h> +#define memzero(s, n) memset ((void *)(s), 0, (n)) #ifndef RETSIGTYPE # define RETSIGTYPE void @@ -121,13 +117,13 @@ extern int method; /* compression method */ #endif #ifdef DYN_ALLOC -# define EXTERN(type, array) extern type * near array -# define DECLARE(type, array, size) type * near array +# define EXTERN(type, array) extern type * array +# define DECLARE(type, array, size) type * array # define ALLOC(type, array, size) { \ - array = (type*)fcalloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \ + array = (type*)calloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \ if (array == NULL) errorMsg("insufficient memory"); \ } -# define FREE(array) {if (array != NULL) fcfree(array), array=NULL;} +# define FREE(array) {if (array != NULL) free(array), array=NULL;} #else # define EXTERN(type, array) extern type array[] # define DECLARE(type, array, size) type array[size] @@ -284,55 +280,55 @@ extern int save_orig_name; /* set if original name must be saved */ /* in zip.c: */ -extern int zip OF((int in, int out)); -extern int file_read OF((char *buf, unsigned size)); +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)); +extern int unzip (int in, int out); +extern int check_zipfile (int in); /* in unpack.c */ -extern int unpack OF((int in, int out)); +extern int unpack (int in, int out); /* in unlzh.c */ -extern int unlzh OF((int in, int out)); +extern int unlzh (int in, int out); /* in gzip.c */ -RETSIGTYPE abort_gzip OF((void)); +RETSIGTYPE abort_gzip (void); /* in deflate.c */ -void lm_init OF((ush * flags)); -ulg deflate OF((void)); +void lm_init (ush * flags); +ulg deflate (void); /* in trees.c */ -void ct_init OF((ush * attr, int *method)); -int ct_tally OF((int dist, int lc)); -ulg flush_block OF((char *buf, ulg stored_len, int eof)); +void ct_init (ush * attr, int *method); +int ct_tally (int dist, int lc); +ulg flush_block (char *buf, ulg stored_len, 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)); +void bi_init (file_t zipfile); +void send_bits (int value, int length); +unsigned bi_reverse (unsigned value, int length); +void bi_windup (void); +void copy_block (char *buf, unsigned len, int header); +extern int (*read_buf) (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 *add_envopt OF((int *argcp, char ***argvp, char *env)); -extern void read_error OF((void)); -extern void write_error OF((void)); -extern void display_ratio OF((long num, long den, FILE * file)); +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, void * buf, unsigned cnt); +extern char *strlwr (char *s); +extern char *add_envopt (int *argcp, char ***argvp, char *env); +extern void read_error (void); +extern void write_error (void); +extern void display_ratio (long num, long den, FILE * file); /* in inflate.c */ -extern int inflate OF((void)); +extern int inflate (void); /* lzw.h -- define the lzw functions. * Copyright (C) 1992-1993 Jean-loup Gailly. @@ -795,7 +791,7 @@ local int bi_valid; * are always zero. */ -int (*read_buf) OF((char *buf, unsigned size)); +int (*read_buf) (char *buf, unsigned size); /* Current input function. Set to mem_read for in-memory compression */ @@ -1148,16 +1144,16 @@ local config configuration_table = /* =========================================================================== * Prototypes for local functions. */ -local void fill_window OF((void)); +local void fill_window (void); -int longest_match OF((IPos cur_match)); +int longest_match (IPos cur_match); #ifdef ASMV -void match_init OF((void)); /* asm code initialization */ +void match_init (void); /* asm code initialization */ #endif #ifdef DEBUG -local void check_match OF((IPos start, IPos match, int length)); +local void check_match (IPos start, IPos match, int length); #endif /* =========================================================================== @@ -1708,7 +1704,7 @@ struct utimbuf { # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) #endif -typedef RETSIGTYPE(*sig_type) OF((int)); +typedef RETSIGTYPE(*sig_type) (int); #ifndef O_BINARY # define O_BINARY 0 /* creation mode for open() */ @@ -1743,7 +1739,7 @@ typedef RETSIGTYPE(*sig_type) OF((int)); #ifdef NO_OFF_T typedef long off_t; -off_t lseek OF((int fd, off_t offset, int whence)); +off_t lseek (int fd, off_t offset, int whence); #endif /* Separator for file name parts (see shorten_name()) */ @@ -2246,17 +2242,17 @@ extern unsigned near strstart; /* window offset of current string */ * Local (static) routines in this file. */ -local void init_block OF((void)); -local void pqdownheap OF((ct_data near * tree, int k)); -local void gen_bitlen OF((tree_desc near * desc)); -local void gen_codes OF((ct_data near * tree, int max_code)); -local void build_tree OF((tree_desc near * desc)); -local void scan_tree OF((ct_data near * tree, int max_code)); -local void send_tree OF((ct_data near * tree, int max_code)); -local int build_bl_tree OF((void)); -local void send_all_trees OF((int lcodes, int dcodes, int blcodes)); -local void compress_block OF((ct_data near * ltree, ct_data near * dtree)); -local void set_file_type OF((void)); +local void init_block (void); +local void pqdownheap (ct_data near * tree, int k); +local void gen_bitlen (tree_desc near * desc); +local void gen_codes (ct_data near * tree, int max_code); +local void build_tree (tree_desc near * desc); +local void scan_tree (ct_data near * tree, int max_code); +local void send_tree (ct_data near * tree, int max_code); +local int build_bl_tree (void); +local void send_all_trees (int lcodes, int dcodes, int blcodes); +local void compress_block (ct_data near * ltree, ct_data near * dtree); +local void set_file_type (void); #ifndef DEBUG @@ -3161,12 +3157,8 @@ char *s; /* Provide missing strspn and strcspn functions. */ -# ifndef __STDC__ -# define const -# endif - -int strspn OF((const char *s, const char *accept)); -int strcspn OF((const char *s, const char *reject)); +int strspn (const char *s, const char *accept); +int strcspn (const char *s, const char *reject); /* ======================================================================== * Return the length of the maximum initial segment @@ -3398,4 +3390,3 @@ unsigned size; isize += (ulg) len; return (int) len; } -#endif diff --git a/archival/tar.c b/archival/tar.c index 732f26ddc..4eda4c61a 100644 --- a/archival/tar.c +++ b/archival/tar.c @@ -2,9 +2,9 @@ /* * Mini tar implementation for busybox * - * Note, that as of BusyBox 0.43 tar has been completely rewritten from the - * ground up. It still has remnents of the old code lying about, but it pretty - * different (i.e. cleaner, less global variables, etc) + * Note, that as of BusyBox-0.43, tar has been completely rewritten from the + * ground up. It still has remnents of the old code lying about, but it is + * very different now (i.e. cleaner, less global variables, etc) * * Copyright (C) 2000 by Lineo, inc. * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org> |