[comp.sources.d] zoo archiver fixes

dhesi@bsu-cs.UUCP (Rahul Dhesi) (08/28/87)

1.   A speculative fix to make the zoo archiver work on machines on which
     `long' is longer than 32 bits.
2.   A patch to make the 4.3BSD `file' command recognize zoo archives.
3.   A patch to make the System V Release 2 `file' command recognize
     zoo archives.

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#     cray.bug      -- speculative fix for large word size machines
#     file.changes  -- how to make `file' recognize zoo archives
#     file.diff     -- context diff for 4.3BSD `file'
# This archive created: Thu Aug 27 16:22:59 1987
export PATH; PATH=/bin:/usr/bin:$PATH
echo shar: "extracting 'cray.bug'" '(1321 characters)'
if test -f 'cray.bug'
then
	echo shar: "will not over-write existing file 'cray.bug'"
else
sed 's/^X//' << \SHAR_EOF > 'cray.bug'
X                                 Cray Bug
X
XOn machines with `long' greater than 32 bits, zoo will create archives
Xcorrectly but will report an invalid archive and refuse to extract
Xthem.  The original bug report was for a Cray.
X
XSince I don't have a Cray, I'm not sure if the following fix will
Xwork.  Patch the file zoo.h as shown.  The basic idea is to define
XZOO_TAG such that its lowest 32 bits contain the bit pattern
Xcorresponding to the number 0xFDC4A7DC and the remaining bits, if any,
Xare zero.
X
XIf this fix doesn't work get me a guest account on your Cray and I will
Xfind another.
X
X                                    Rahul Dhesi 1987/08/27
X
Xdiff -c old/zoo.h ./zoo.h
X*** old/zoo.h	Wed Aug 26 20:12:54 1987
X--- ./zoo.h	Wed Aug 26 20:18:19 1987
X***************
X*** 58,64 ****
X  #define MINOR_EXT_VER 0
X  
X  #define CTRL_Z 26
X! #define ZOO_TAG ((unsigned long) 0xFDC4A7DC) /* A random choice */
X  #define TEXT "ZOO 1.50 Archive.\032"   /* Header text for archive. */
X  #define SIZ_TEXT  20                   /* Size of header text */
X  
X--- 58,64 ----
X  #define MINOR_EXT_VER 0
X  
X  #define CTRL_Z 26
X! #define ZOO_TAG ((unsigned long) 0xFDC4A7DCL) /* A random choice */
X  #define TEXT "ZOO 1.50 Archive.\032"   /* Header text for archive. */
X  #define SIZ_TEXT  20                   /* Size of header text */
X  
SHAR_EOF
fi
echo shar: "extracting 'file.changes'" '(1161 characters)'
if test -f 'file.changes'
then
	echo shar: "will not over-write existing file 'file.changes'"
else
sed 's/^X//' << \SHAR_EOF > 'file.changes'
X          Making the "file" command recognize zoo archives
X
XZoo archives have the following magic number:  Beginning at offset 20
Xdecimal, there are four bytes with the values 0xdc, 0xa7, 0xc4, and
X0xfd.  (But if you call the first byte of a zoo archive byte 1, then
Xthe magic bytes will be bytes 21 through 24.)
X
XTo make the "file" command identify zoo archives, changes can be made
Xas follows.
X
X4.3BSD:  See the file "file.diff" for a context diff that works with
Xthe 4.3BSD "file" command on a VAX-11/785.  I don't know if this will
Xalso work under 4.2BSD or with any other implementation of the "file"
Xcommand or on any other CPU.
X
XSystem V Release 2 (as exemplified by Microport System V/AT):  At the
Xend of the file "/etc/magic", add the following line:
X
X20	long		0xfdc4a7dc	zoo archive
X
XThis should work on a little-endian machine, in which the long value
X0xfdc4a7dc is stored with the least-significant byte first.  For a big-
Xendian machine, you will probably need to replace it with 0xdca7c4fd.
XThis assumes that long occupies 4 bytes.  If not, use a data type name
Xthat is exactly 4 bytes.
X
X                                    Rahul Dhesi 1987/08/27
SHAR_EOF
fi
echo shar: "extracting 'file.diff'" '(704 characters)'
if test -f 'file.diff'
then
	echo shar: "will not over-write existing file 'file.diff'"
else
sed 's/^X//' << \SHAR_EOF > 'file.diff'
XChanges needed to make the 4.3BSD "file" command recognize zoo
Xarchives.  Known to work on a VAX-11/785.
X
X                                    Rahul Dhesi 1987/08/27
X
X*** file.c.old	Thu Mar  6 19:34:29 1986
X--- file.c	Sat Feb 21 19:28:52 1987
X***************
X*** 172,181 ****
X--- 172,187 ----
X  	case 070707:
X  		printf("cpio data\n");
X  		return;
X  	}
X  
X+ 	if (buf[20] == (char) 0xdc && buf[21] == (char) 0xa7 && 
X+             		buf[22] == (char) 0xc4 && buf[23] == (char) 0xfd) {
X+ 		printf ("zoo archive\n");
X+ 		return;
X+ 	}
X+ 
X  	if (buf[0] == '#' && buf[1] == '!' && shellscript(buf+2, &mbuf))
X  		return;
X  	if (buf[0] == '\037' && buf[1] == '\235') {
X  		if (buf[2]&0x80)
X  			printf("block ");
SHAR_EOF
fi
exit 0
#	End of shell archive
-- 
Rahul Dhesi         UUCP:  {ihnp4,seismo}!{iuvax,pur-ee}!bsu-cs!dhesi