Submitted By: Jim Gifford (patches at jg555 dot com)
Date: 2003-08-25
Initial Package Version: 2.10
Origin: Based on ftp://ftp.ibiblio.org/pub/Linux/utils/compress/zoo-2.10.linux.diff.gz
Description: Fixes zoo to compile under Linux

diff -Naur zoo.orig/ar.h zoo/ar.h
--- zoo.orig/ar.h	1991-07-05 16:00:00.000000000 +0000
+++ zoo/ar.h	2003-08-25 00:23:43.000000000 +0000
@@ -15,9 +15,9 @@
 /* uchar should be 8 bits or more */
 /* typedef unsigned char  uchar;   -- already in zoo.h */
 
-typedef unsigned int   uint;    /* 16 bits or more */
-typedef unsigned short ushort;  /* 16 bits or more */
-typedef unsigned long  ulong;   /* 32 bits or more */
+typedef unsigned int   my_uint;    /* 16 bits or more */
+typedef unsigned short my_ushort;  /* 16 bits or more */
+typedef unsigned long  my_ulong;   /* 32 bits or more */
 
 /* T_UINT16 must be #defined in options.h to be 
 a 16-bit unsigned integer type */
@@ -47,7 +47,7 @@
 /* ar.c */
 
 extern int unpackable;
-extern ulong origsize, compsize;
+extern my_ulong origsize, compsize;
 
 /* all the prototypes follow here for all files */
 
@@ -85,14 +85,14 @@
 void output PARMS((uint c , uint p ));
 void huf_encode_start PARMS((void ));
 void huf_encode_end PARMS((void ));
-uint decode_c PARMS((void ));
-uint decode_p PARMS((void ));
+my_uint decode_c PARMS((void ));
+my_uint decode_p PARMS((void ));
 void huf_decode_start PARMS((void ));
 
 /* IO.C */
 void make_crctable PARMS((void ));
 void fillbuf PARMS((int n ));
-uint getbits PARMS((int n ));
+my_uint getbits PARMS((int n ));
 void putbits PARMS((int n , uint x ));
 int fread_crc PARMS((uchar *p , int n , FILE *f ));
 void fwrite_crc PARMS((uchar *p , int n , FILE *f ));
diff -Naur zoo.orig/basename.c zoo/basename.c
--- zoo.orig/basename.c	1991-07-05 16:00:00.000000000 +0000
+++ zoo/basename.c	2003-08-25 00:23:43.000000000 +0000
@@ -18,7 +18,7 @@
 
 /* This function strips device/directory information from
 a pathname and returns just the plain filename */
-void basename (pathname, fname)
+void mybasename (pathname, fname)
 char *pathname;
 char fname[];
 {
diff -Naur zoo.orig/decode.c zoo/decode.c
--- zoo.orig/decode.c	1991-07-05 16:00:00.000000000 +0000
+++ zoo/decode.c	2003-08-25 00:23:43.000000000 +0000
@@ -27,7 +27,7 @@
 */
 
 int decode(count, buffer)
-uint count;
+my_uint count;
 uchar buffer[];
 	/* The calling function must keep the number of
 	   bytes to be processed.  This function decodes
@@ -37,8 +37,8 @@
 	   Call decode_start() once for each new file
 	   before calling this function. */
 {
-	static uint i;
-	uint r, c;
+	static my_uint i;
+	my_uint r, c;
 
 	r = 0;
 	while (--j >= 0) {
diff -Naur zoo.orig/lzh.c zoo/lzh.c
--- zoo.orig/lzh.c	1991-07-05 16:00:00.000000000 +0000
+++ zoo/lzh.c	2003-08-25 00:23:43.000000000 +0000
@@ -45,7 +45,7 @@
 
 	decode_start();
 	while (!decoded) {
-		n = decode((uint) DICSIZ, out_buf_adr); /* n = count of chars decoded */
+		n = decode((my_uint) DICSIZ, out_buf_adr); /* n = count of chars decoded */
 #ifdef COUNT_BYTES
 		bytes_decoded += n;	/*debug*/
 #endif
diff -Naur zoo.orig/lzh.h zoo/lzh.h
--- zoo.orig/lzh.h	1991-07-05 16:00:00.000000000 +0000
+++ zoo/lzh.h	2003-08-25 00:23:43.000000000 +0000
@@ -34,4 +34,4 @@
 #define CBIT 9  /* $\lfloor \log_2 NC \rfloor + 1$ */
 #define CODE_BIT  16  /* codeword length */
 
-extern ushort left[], right[];
+extern my_ushort left[], right[];
diff -Naur zoo.orig/makefile zoo/makefile
--- zoo.orig/makefile	1991-07-05 16:00:00.000000000 +0000
+++ zoo/makefile	2003-08-25 00:23:43.000000000 +0000
@@ -18,12 +18,12 @@
 
 MAKE = make	      # needed for some systems e.g. older BSD
 
-CC = cc
+CC = gcc
 CFLAGS =
 MODEL =
 EXTRA = -DBIG_MEM -DNDEBUG
 LINTFLAGS = -DLINT
-OPTIM = -O
+OPTIM = -O3
 DESTDIR = /usr/local/bin
 
 #List of all object files created for Zoo
@@ -50,6 +50,7 @@
 	@echo "generic:      generic **IX environment, minimal functionlity"
 	@echo "bsd:          4.3BSD or reasonable equivalent"
 	@echo "bsdansi:      4.3BSD with ANSI C"
+	@echo "linux:	     Linux for Alpha & i386"
 	@echo "ultrix:       ULTRIX 4.1"
 	@echo "convex:       Convex C200 series"
 	@echo "sysv:         System V Release 2 or 3; or SCO Xenix"
@@ -106,6 +107,10 @@
 convex:
 	$(MAKE) CFLAGS="-c $(OPTIM) -DBSD4_3 -DANSI_HDRS" $(TARGETS)
 
+# Linux
+linux:
+	$(MAKE) CFLAGS="-c $(OPTIM) -DSYS_V -DANSI_HDRS -DHAVE_MKDIR" $(TARGETS)
+
 # SysV.2, V.3, SCO Xenix
 sysv:
 	$(MAKE) CFLAGS="-c $(OPTIM) -DSYS_V" $(TARGETS)
@@ -235,7 +240,7 @@
 parse.o: zoofns.h zooio.h
 portable.o: /usr/include/stdio.h assert.h debug.h machine.h options.h
 portable.o: portable.h various.h zoo.h zoofns.h zooio.h
-prterror.o: /usr/include/stdio.h /usr/include/varargs.h options.h various.h
+prterror.o: /usr/include/stdio.h options.h various.h
 prterror.o: zoofns.h zooio.h
 sysv.o: /usr/include/sys/stat.h /usr/include/sys/types.h /usr/include/time.h
 sysv.o: nixmode.i nixtime.i
diff -Naur zoo.orig/maketbl.c zoo/maketbl.c
--- zoo.orig/maketbl.c	1991-07-05 16:00:00.000000000 +0000
+++ zoo/maketbl.c	2003-08-25 00:23:43.000000000 +0000
@@ -16,10 +16,10 @@
 int nchar;
 uchar bitlen[];
 int tablebits;
-ushort table[];
+my_ushort table[];
 {
-	ushort count[17], weight[17], start[18], *p;
-	uint i, k, len, ch, jutbits, avail, nextcode, mask;
+	my_ushort count[17], weight[17], start[18], *p;
+	my_uint i, k, len, ch, jutbits, avail, nextcode, mask;
 
 	for (i = 1; i <= 16; i++) count[i] = 0;
 	for (i = 0; i < nchar; i++) count[bitlen[i]]++;
@@ -27,7 +27,7 @@
 	start[1] = 0;
 	for (i = 1; i <= 16; i++)
 		start[i + 1] = start[i] + (count[i] << (16 - i));
-	if (start[17] != (ushort)((unsigned) 1 << 16))
+	if (start[17] != (my_ushort)((unsigned) 1 << 16))
 		prterror('f', "Bad decode table\n");
 
 	jutbits = 16 - tablebits;
@@ -41,7 +41,7 @@
         }
 
 	i = start[tablebits + 1] >> jutbits;
-	if (i != (ushort)((unsigned) 1 << 16)) {
+	if (i != (my_ushort)((unsigned) 1 << 16)) {
 		k = 1 << tablebits;
 		while (i != k) table[i++] = 0;
 	}
diff -Naur zoo.orig/maketree.c zoo/maketree.c
--- zoo.orig/maketree.c	1991-07-05 16:00:00.000000000 +0000
+++ zoo/maketree.c	2003-08-25 00:23:43.000000000 +0000
@@ -12,7 +12,7 @@
 
 static int    n, heapsize;
 static short  heap[NC + 1];
-static ushort *freq, *sortptr, len_cnt[17];
+static my_ushort *freq, *sortptr, len_cnt[17];
 static uchar  *len;
 
 static void count_len(i)  /* call with i = root */
@@ -33,7 +33,7 @@
 int root;
 {
 	int i, k;
-	uint cum;
+	my_uint cum;
 
 	for (i = 0; i <= 16; i++) len_cnt[i] = 0;
 	count_len(root);
@@ -75,10 +75,10 @@
 static void make_code(j, length, code)
 int j;
 uchar length[];
-ushort code[];
+my_ushort code[];
 {
 	int    i;
-	ushort start[18];
+	my_ushort start[18];
 
 	start[1] = 0;
 	for (i = 1; i <= 16; i++)
@@ -88,9 +88,9 @@
 
 int make_tree(nparm, freqparm, lenparm, codeparm)
 int nparm;
-ushort freqparm[];
+my_ushort freqparm[];
 uchar lenparm[];
-ushort codeparm[];
+my_ushort codeparm[];
 	/* make tree, calculate len[], return root */
 {
 	int i, j, k, avail;
diff -Naur zoo.orig/sysv.c zoo/sysv.c
--- zoo.orig/sysv.c	1991-07-05 16:00:00.000000000 +0000
+++ zoo/sysv.c	2003-08-25 00:23:43.000000000 +0000
@@ -129,6 +129,7 @@
 exists by the name of the needed directory.
 */
 
+#ifndef HAVE_MKDIR
 int mkdir(dirname)
 char *dirname;
 {
@@ -140,6 +141,7 @@
    }
 	return (0);
 }
+#endif
 
 /* No file truncate system call in older System V.  If yours has one,
 add it here -- see bsd.c for example.  It's ok for zootrunc to be
diff -Naur zoo.orig/zooadd.c zoo/zooadd.c
--- zoo.orig/zooadd.c	1991-07-05 16:00:00.000000000 +0000
+++ zoo/zooadd.c	2003-08-25 00:23:43.000000000 +0000
@@ -132,7 +132,7 @@
 
 if (zoo_file == NOFILE)
    prterror ('f', could_not_open, zoo_path);
-basename(zoo_path, zoo_fname);      /* get basename of archive */
+mybasename(zoo_path, zoo_fname);      /* get basename of archive */
 rootname (zoo_path, zoo_bak);       /* name without extension */
 strcat (zoo_bak, BACKUP_EXT);       /* name of backup of this archive */
 
@@ -222,7 +222,7 @@
 		break;
 	}
 
-   basename (this_path, this_fname);   /* get just filename for later */
+   mybasename (this_path, this_fname);   /* get just filename for later */
 
    this_file = zooopen(this_path, Z_READ);
    if (this_file == NOFILE) {
diff -Naur zoo.orig/zoofns.h zoo/zoofns.h
--- zoo.orig/zoofns.h	1991-07-05 16:00:00.000000000 +0000
+++ zoo/zoofns.h	2003-08-25 00:23:43.000000000 +0000
@@ -85,7 +85,7 @@
 void addfname PARMS ((char *, long, unsigned int, unsigned int, 
 							unsigned, unsigned));
 void add_version PARMS ((char *, struct direntry *));
-void basename PARMS ((char *, char []));
+void mybasename PARMS ((char *, char []));
 void break_off PARMS ((void));
 void close_file PARMS ((ZOOFILE));
 void comment PARMS ((char *, char *));
