Path: ns-mx!uunet!sun-barr!newstop!sun!amdahl!fadden From: fadden@uts.amdahl.com (Andy McFadden) Newsgroups: comp.binaries.apple2 Subject: NuLib v3.10 (UNIX) nulib.02 Message-ID: <577K02bW095r00@amdahl.uts.amdahl.com> Date: 1 Nov 91 04:11:29 GMT Reply-To: fadden@amdahl.uts.amdahl.com (Andy McFadden) Organization: Amdahl Corporation, Sunnyvale CA Lines: 1126 NuLib v3.10 - nulib.02 ---- Cut Here and feed the following to sh ---- #!/bin/sh # This is part 02 of a multipart archive # ============= nucomp.h ============== if test -f 'nucomp.h' -a X"$1" != X"-c"; then echo 'x - skipping nucomp.h (File already exists)' else echo 'x - extracting nucomp.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'nucomp.h' && /* X * nucomp.h - declarations for nucomp.c X * X * NuLib v3.1 October 1991 Freeware (distribute, don't sell) X * By Andy McFadden (fadden@cory.berkeley.edu) X */ X #ifdef BSD43 # define NO_SETVBUF #endif X #include #include #ifdef UNIX /* this is asking for trouble */ # include #else # ifdef IAPX286 # include # else # ifdef IAPX386 # include # else # include # endif # endif #endif #include X /*@H************************ < COMPRESS HEADER > **************************** * $@(#) compress.c,v 4.3 88/12/26 08:00:00 don Release ^ * * * * compress : compress.h * * * * port by : Donald J. Gloistein * * * * Source, Documentation, Object Code: * * released to Public Domain. This code is based on code as documented * * below in release notes. * * * *--------------------------- Module Description --------------------------* * THIS HEADER CONTAINS MUCH IMPLEMENTATION INFORMATION AND ASSUMPTIONS * * PLEASE PRINT IT OUT AND READ IT BEFORE COMPILING CODE FOR YOURSELF * * * * This header supports a number of compiler defines and predefines. * * Rather than explain all of them, please print the header and read the * * notes. Also the unix and xenix makefiles are commented for the * * various options. There continues to have a lot of Dos specific info in * * the header. This is to help on 16 bit Msdos machines to get their * * compiler to work properly. I make no appology for that, as this port * * began as a way to implement 16 bit compress on a segmented MsDos machine* * * * However, for Unix and Xenix, all you should have to define is -DXENIX * * or -DUNIX and compile. There may be a problem with whether your library * * supports alloc() or malloc(), but there is a define for that, also. * * * * This header can be maintained to keep up with the different compilers * * and systems. As distributed in don Release, the files will compile with * * no changes under Microsoft version 5.1 C compiler, and Xenix C compiler * * which is the Microsoft version 4 ported. If you are going to bind the * * code for use in MsDos and OS/2 machines, then you must uncomment the * * #define BIND in this header. Otherwise, this distribution of source * * detect Msdos and Xenix predefines from the compiler and adjust. * * * *--------------------------- Implementation Notes --------------------------* * * * compiled with : compress.fns * * * NOTE!!! Defaults of this code now are completely Unix, even for the * * msdos ports. That means that the program works as a filter, * * and will just sit there waiting for input from stdin if you * * issue just the command name. You must use -h or -? to get the * * full help screen now. Also, it will unlink (kill) as a default * * on successful compression and decompression. That means the * * source file will be erased. * * These defaults are changed with the FILTER and KEEPFLAG * * defines. * * * * NOTE!!! Compiler predefines were taken out of the compress.h header. * * You must either specify them on compile or uncomment the * * compiler define in this header. Compiling without doing these * * will result in a program that does unspecified actions. * * problems: * * The inpath and outpath is a bit kludged. It should work okay. * * Let me know if you have problems, especially under Unix. * * * * CAUTION: The bound version will run on Dos 2.x, but you must use the * * name compress.exe. If you rename the file, it will not run * * The unbound version will run on Dos 2.x with the name changed * * but due to the dos version, will not detect its own name. * * * * CAUTION: Non MsDos users. You must modify the _MAX_PATH defines for * * your operating system if it is different from the assumed * * standard. * * * * CAUTION: I have used a number of defines to make it possible to compile * * properly under a number of bit sizes and adjust for the memory * * allocation scheme needed. If you do not use a dos system, * * PLEASE pay attention to the defines for MAXSEG_64 and the one * * called SMALLMODEL. The SMALLMODEL define is set in the header * * but if you don't have a compiler that triggers the MAXSEG_64 * * define, you may end up with bad pointers. Becareful. * * * * Header for files using version 4 compress routines define MAIN * * in the file with defining instance of the global variables. * * There are a number of compilers for MsDos and Unix/Xenix. * * So the user must define the actions required. * * * * * * Defines: This header file contains most of the system wide defines. * * the purpose for this was to consolodate compiler differences * * into one area that is easily changed. * * * * define MAXBITS= if you want a different maximum bits. 16 bits will now * * run in about 400K of memory. * * define BIND if you are going to use Microsoft bind.exe program on the * * executable. * * * * define MSDOS if you are compiling under MsDos or PcDos and your compiler* * does not predefine it. * * * * Initials ---- Name --------------------------------- * * DjG Donald J. Gloistein, current port to MsDos 16 bit * * Plus many others, see rev.hst file for full list * * LvR Lyle V. Rains, many thanks for improved implementation * * of the compression and decompression routines. * *************************************************************************@H*/ X #ifndef FALSE /* let's get some sense to this */ #define FALSE 0 #define TRUE !FALSE #endif X #define NDEBUG #define NPROTO #define COMP40 /* take this out for a little more speed */ char *malloc(); #define ALLOCATE(x,y) malloc((unsigned int)x*y) #define FREEIT(ptr) free(ptr) #define NOSIGNAL /* what the hell is "SIGTYPE"? */ #define setbinary(fp) #define FAR #define CONST #define _MAX_DIR 64 X /* FILTER if you want the program to operate as a unix type filter */ /* if not defined TRUE, then issuing command without parameters will */ /* print a usage and help information */ /* Use -DFILTER=0 to deactivate filter operation */ #ifndef FILTER #define FILTER FALSE #endif X /* KEEPFLAG determines the default action on successful completion */ /* Unix convention is FALSE (erase input file) */ /* Use -DKEEPFLAG=1 to keep files as default or change here */ /* if you don't set it before here and you are compiling the debug */ /* version, then files will be kept. */ X #ifndef KEEPFLAG #define KEEPFLAG TRUE #endif X X X X /* the following tells the system that the maximum segment is 64k */ /* if your compiler is not one of these and has this limitation */ /* Because of this, this code should compile with minimum porting */ /* in the COMPUSI.XEN module to most unix systems. */ /* This is also used to keep array indexing to 16 bit integer */ /* if not predefined in compiler implementation, you must define */ /* it separately if applicable to your compiler/system */ X #define MAXSEG_64K X /* put this in if you are compiling in small code */ /* model and your compiler does not predefine it */ /* this is for CPU' with 64k segment limitation. */ /* Use this define for small code, it is used by */ /* the header to decide on value for NEARHEAP */ /* #define SMALLMODEL */ X /* does your system use far pointers ? if you want it enabled keep this */ /* if you have segment limit and compile in larger than 13 bits */ /* then you will have to use compact or large model if your compiler */ /* does not support far pointer keyword. */ X #ifndef FAR #define FAR #endif X /* What type does the alloc() function return, char or void? */ X #ifndef ALLOCTYPE #define ALLOCTYPE char #endif X /* Does your run time library support the ANSI functions for:*/ X /* reverse string set search? strrpbrk() if not: */ #define NO_REVSEARCH X /* Does your library include strrchr()? If not define this: */ /*#define NO_STRRCHR*//* unix/xenix module uses this function*/ X /* Does your library include strchr()? If not define this: */ /*#define NO_STRCHR*//* dos module uses this function. */ X /* definition for const key word if supported */ #ifndef CONST #define CONST #endif X X /* And now for some typedefs */ typedef unsigned short CODE; typedef unsigned char UCHAR; typedef unsigned int HASH; typedef int FLAG; X X /* X * You can define the value of MAXBITS to be anything betweeen MINBITS X * and MAXMAXBITS. This is will determine the maximum memory you will X * use and how the tables will be handled. I recommend you just leave X * it at MAXMAXBITS, because you can define DFLTBITS in compiling the X * module COMPRESS.C to set the default, and you can vary the number X * of bits at runtime by using the -b switch. X */ X X /* X * The only reason to change MAXBITS is if you absolutely must have X * faster performance. If you specify 14 bits, the tables will not X * be split; at 13 bits, you can fit in the MSDOS small memory model X * and allocate tables in near heap. X * This value is available to other modules through the variable maxbits. X */ X #define INITBITS 9 #define MINBITS 12 #define MAXMAXBITS 16 X #ifndef MAXBITS #define MAXBITS MAXMAXBITS #endif X #if (MAXBITS > MAXMAXBITS) #undef MAXBITS #define MAXBITS MAXMAXBITS #endif X #if (MAXBITS < MINBITS) #undef MAXBITS #define MAXBITS MINBITS #endif X X /* You should define DFLTBITS to be the default compression code X * bit length you desire on your system. X * (I define mine in the compiler command line in my Makefile.LvR) X * (I leave mine alone and keep to the maximum. DjG) X */ X #ifndef DFLTBITS #define DFLTBITS MAXBITS #endif #if (DFLTBITS < MINBITS) #undef DFLTBITS #define DFLTBITS MINBITS #endif #if (DFLTBITS > MAXBITS) #undef DFLTBITS #define DFLTBITS MAXBITS #endif X /* correcting for different types of pointer arithmatic */ /* probably won't have to change it */ #define NULLPTR(type) ((type FAR *) NULL) X X /* in making this program portable the following allocation and */ /* free functions are called, with the following parameters: */ /* ALLOCTYPE FAR *emalloc(unsigned int x, int y) */ /* void efree(ALLOCTYPE FAR *ptr) */ /* you must define the allocation function and the free function */ /* keep in mind that the casts must be correct for your compiler */ /* NOTE these are the two functions to change for allocating pointers to */ /* far data space if you are not using Microsoft C v.5.1 */ /* Consult your compiler manual and find the low level function that */ /* returns a far pointer when compiled in the small model. */ /* if your compiler does not support that, you will have to compile with */ /* a model that defaults to far pointers to data (compact or large model)*/ /* HERE ARE SOME SAMPLE PREDEFINED ONES */ X X /* default allocation function, in segmented addressing, must return */ /* a far pointer or compile with far pointer data as default */ #ifndef ALLOCATE #include #define ALLOCATE(x,y) malloc((unsigned int)x*y) #define FREEIT(ptr) free((ptr)) #endif X X # ifdef MAXSEG_64K # if MAXBITS > 14 # define SPLIT_HT TRUE # else # define SPLIT_HT 0 # endif # else # define SPLIT_HT 0 # endif X # ifdef MAXSEG_64K # if MAXBITS > 15 # define SPLIT_PFX TRUE # else # define SPLIT_PFX 0 # endif # else # define SPLIT_PFX 0 # endif X #ifndef BUFSIZ #define BUFSIZ 512 #endif X #ifdef NO_SETBUF #define NO_SETVBUF #endif X /* NuLib: comment: this ought to use setbuffer() if available */ #ifdef NO_SETVBUF # ifndef NO_SETBUF # define setvbuf(fp,buf,mode,size) setbuf((fp),(buf)) # define ZBUFSIZE BUFSIZ # define XBUFSIZE BUFSIZ # else # define setvbuf(fp,buf,mode,size) # define ZBUFSIZE (1) # define XBUFSIZE (1) # endif #else # ifdef NEARHEAP # define XBUFSIZE (0xC00) # define ZBUFSIZE (0x1800) # else # define XBUFSIZE (0x3000) /* 12k bytes */ # define ZBUFSIZE (0x6000) /* 24k bytes */ # endif #endif X #define UNUSED ((CODE)0) /* Indicates hash table value unused */ #define CLEAR ((CODE)256) /* Code requesting table to be cleared */ #define FIRSTFREE ((CODE)(CLEAR+1))/* First free code for token encoding */ #define MAXTOKLEN 512 /* Max chars in token; size of buffer */ #define OK 0 /* Result codes from functions: */ #define ERROR 1 #define NORMAL 0 X #define SIGNAL_ERROR -1 /* signal function error */ #define NOMEM 2 /* Ran out of memory */ #define TOKTOOBIG 3 /* Token longer than MAXTOKLEN chars */ #define READERR 4 /* I/O error on input */ #define WRITEERR 5 /* I/O error on output */ #define INFILEBAD 6 /* Infile not in compressed format */ #define CODEBAD 7 /* Infile contained a bad token code */ #define TABLEBAD 8 /* The tables got corrupted (!) */ #define NOSAVING 9 /* no saving in file size */ #define NOTOPENED 10 /* output file couldn't be opened */ #define YES 1 #define NO 0 X X #include "nucompfn.h" /* This has to come late... needs typedefs above */ X /* defines opening mode for files */ /* and suffixes for compressed file */ X X #define WRITE_FILE_TYPE FWRITE_STR /* NuLib: was "wb" */ #define READ_FILE_TYPE FREAD_STR /* NuLib: was "rb" */ #define SUFFIX ".Z" X /* Defines for third byte of header */ #define BIT_MASK 0x1f #define BLOCK_MASK 0x80 /* Masks 0x40 and 0x20 are free. I think 0x20 should mean that there is X a fourth header byte (for expansion). */ X X #define CHECK_GAP 10000L /* ratio check interval */ X #ifdef MAIN UCHAR magic_header[] = { 0x1F,0x9D }; /* 1F 9D */ X char rcs_ident[] = "@(#) compress,v 4.3 88/12/26 08:00:00 don Release $"; X int overwrite = 0; /* Do not overwrite unless given -f flag */ int maxbits = DFLTBITS; /* user settable max # bits/code */ X int exit_stat = 0; int keep = KEEPFLAG; /* True = don't kill file */ int keep_error = FALSE; /* True = keep output file even if error exist */ char *prog_name; char ifname[_MAX_DIR]; char inpath[_MAX_DIR]; char ofname [_MAX_DIR]; char outpath[_MAX_DIR]; int is_list = FALSE; /* flag for file parameters */ char endchar[1]; char xbuf[XBUFSIZE]; char zbuf[ZBUFSIZE]; char separator[] = "/"; X int nomagic = FALSE; /* Use a 3-byte magic number header, unless old file */ int zcat_flg = TRUE; /* Write output on stdout, suppress messages */ int quiet = TRUE; /* don't tell me about compression */ /* X * block compression parameters -- after all codes are used up, X * and compression rate changes, start over. X */ int block_compress = BLOCK_MASK; #ifdef COMP40 long int ratio = 0L; long checkpoint = CHECK_GAP; #endif X /* force the overwrite */ int force = 0; X #ifndef NDEBUG int verbose = FALSE; int debug = FALSE; #endif /* !NDEBUG */ X int do_decomp = FALSE; X #else /* not defining instance */ X extern UCHAR magic_header[]; extern char rcs_ident[]; extern int overwrite; extern int maxbits; X X extern int exit_stat; extern int keep; extern int keep_error; extern char *prog_name; extern char inpath[]; extern char outpath[]; extern int is_list; extern char endchar[]; extern char xbuf[]; extern char zbuf[]; extern char ifname[]; extern char ofname[]; extern char separator[]; extern int nomagic; extern int zcat_flg; extern int quiet; extern int block_compress; #ifdef COMP40 extern long int ratio; extern long checkpoint; #endif extern int force; X #ifndef NDEBUG extern int verbose; extern int debug; #endif /* !NDEBUG */ X extern int do_decomp; #endif X SHAR_EOF chmod 0644 nucomp.h || echo 'restore of nucomp.h failed' Wc_c="`wc -c < 'nucomp.h'`" test 18755 -eq "$Wc_c" || echo 'nucomp.h: original size 18755, current size' "$Wc_c" fi # ============= nucompfn.h ============== if test -f 'nucompfn.h' -a X"$1" != X"-c"; then echo 'x - skipping nucompfn.h (File already exists)' else echo 'x - extracting nucompfn.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'nucompfn.h' && /* X * nucompfn.h - function declarations for nucomp.c X * X * NuLib v3.1 October 1991 Freeware (distribute, don't sell) X * By Andy McFadden (fadden@cory.berkeley.edu) X */ X extern int u_compress(), X u_decompress(); X /* COMPRESS.FNS global function declarations */ /* this should be compatible with any type of declaration for external X functions. See compress.h for explaination */ #ifdef NPROTO extern void Usage(); extern int check_error(); extern char *name_index(); extern char *get_program_name(); #ifdef NO_STRCHR extern char *strchr(); #endif #ifdef NO_STRRCHR extern char *strrchr(); #endif #ifdef NO_REVSEARCH extern char *strrpbrk(); #endif extern int is_z_name(); extern int cl_block(); extern int make_z_name(); extern void unmake_z_name(); extern void compress(); extern void putcode(); extern void decompress(); extern CODE getcode(); extern void writeerr(); extern void copystat(); #ifndef NOSIGNAL extern int foreground(); extern SIGTYPE onintr(); extern SIGTYPE oops(); #endif extern void prratio(); extern void version(); #ifdef NEARHEAP extern ALLOCTYPE *emalloc(); extern void efree(); #else extern ALLOCTYPE FAR *emalloc(); extern void efree(); #endif extern int alloc_tables(); extern void init_tables(); extern int nextcode(); #else extern void Usage(int); extern int check_error(void); extern char *name_index(char *); extern int cl_block(void); extern char *get_program_name(char *); extern int is_z_name(char *); extern int make_z_name(char *); extern void unmake_z_name(char *); #ifdef NO_STRCHR extern char *strchr(char *,int); #endif #ifdef NO_STRRCHR extern char *strrchr(char *,int); #endif #ifdef NO_REVSEARCH extern char *strrpbrk(char *,char *); #endif extern void compress(void); extern void putcode(CODE,int); extern void decompress(void); extern CODE getcode(void); extern void writeerr(void); extern void copystat(char *,char *); #ifndef NOSIGNAL extern int foreground(void); extern SIGTYPE onintr(void); extern SIGTYPE oops(void); #endif extern void prratio(FILE *,long,long); extern void version(void); #ifdef NEARHEAP extern ALLOCTYPE *emalloc(unsigned int,int); extern void efree(ALLOCTYPE *); #else extern ALLOCTYPE FAR *emalloc(unsigned int,int); extern void efree(ALLOCTYPE FAR *); #endif extern int alloc_tables(CODE,HASH); extern void init_tables(void ); extern int nextcode(CODE *); #endif X SHAR_EOF chmod 0644 nucompfn.h || echo 'restore of nucompfn.h failed' Wc_c="`wc -c < 'nucompfn.h'`" test 2397 -eq "$Wc_c" || echo 'nucompfn.h: original size 2397, current size' "$Wc_c" fi # ============= nudefs.h ============== if test -f 'nudefs.h' -a X"$1" != X"-c"; then echo 'x - skipping nudefs.h (File already exists)' else echo 'x - extracting nudefs.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'nudefs.h' && /* X * nudefs.h - system-dependent typdefs, and global #defines and variables. X * X * NuLib v3.1 October 1991 Freeware (distribute, don't sell) X * By Andy McFadden (fadden@cory.berkeley.edu) X */ /* X * IMPORTANT: This file must be first on the list of #includes, since some X * include files will be processed based on these #defines X */ X X /* SYSTEM DEPENDENCIES */ typedef unsigned char onebyt; typedef unsigned short twobyt; typedef unsigned long fourbyt; X /* byte ordering; TRUE if high byte is first (68xxx), else FALSE (65xxx) */ extern int HiLo; /* actually part of numain.c */ X /* Setup for Apple //gs APW */ /* [ "APW" is automatically defined by the compiler ] */ X /* Setup for MS-DOS machines (80xxx based: IBM PC) */ /* [ "MSDOS" is defined by the compiler [MS C5.1 anyway] ] */ X /* Setup for other microcomputers (Macintosh, Amiga) */ /* ??? */ X /* Setup for AIX */ /* #define SYSV */ /* #define BSD_INCLUDES */ X /* Setup for BSD UNIX systems */ #define UNIX #define BSD43 X /* Setup for XENIX/386 */ /* NOTE: if you get error messages about readdir() and opendir() during */ /* linking, remove the leading '#' from the line "#CLIBS= -lx" in */ /* "Makefile" */ /* #define XENIX386 */ /* #define UNIX */ /* #define SYSV */ /* #define NO_RENAME */ /* no rename() call in C library */ X /* Setup for Amdahl UTS 2.1 */ /* #define UNIX */ /* #define SYSV */ /* #define NO_RENAME */ X /* Setup for AOS/VS @ DG */ /* #define UNIX */ /* #define DATAGENERAL */ /* #define AOSVS */ X /* Setup for other UNIX systems */ /* #define UNIX */ /* #define SYSV (or whatever) */ X /* use table lookups to get CRCs */ #define CRC_TAB X /* X * Some global defs X */ X /* errno wasn't defined in on some systems... */ #ifndef MSDOS extern int errno; #endif X /* Maximum file name length that we intend to handle (watch stack size!) */ #define MAXFILENAME 1024 X /* file operations */ #define S_ABS 0 /* seek absolute */ #define S_REL 1 /* seek relative */ #define S_END 2 /* seek from end */ X #ifdef UNIX /* stuff for open() */ # define WPERMS 0644 /* read/write for owner, read only for others */ # define FREAD_STR "r" # define FWRITE_STR "w" # define O_BINARY 0 /* for non-UNIX open(); easier than #ifdefs */ #else # ifdef APW # define WPERMS 0666 /* read/write for all; this may not work for some */ # define FREAD_STR "rb" # define FWRITE_STR "wb" # endif # ifdef MSDOS # define S_IREAD 0000400 /* read permission, owner */ # define S_IWRITE 0000200 /* write permission, owner */ # define WPERMS S_IREAD | S_IWRITE # define FREAD_STR "rb" # define FWRITE_STR "wb" # endif # ifndef WPERMS /* other system */ # define WPERMS 0666 /* +PORT+ */ # define FREAD_STR "rb" # define FWRITE_STR "wb" # endif #endif /*UNIX*/ X /* Time structure; same as TimeRec from misctool.h */ /* one-byte entries should not have alignment problems... */ typedef struct { X onebyt second; X onebyt minute; X onebyt hour; X onebyt year; X onebyt day; X onebyt month; X onebyt extra; X onebyt weekDay; } Time; X X /* X * global to entire program X */ extern int HiLo; /* byte ordering; FALSE on low-first (65816) */ extern int verbose; /* BOOLEAN: print verbose? */ extern int interact; /* BOOLEAN: interactive when overwriting? */ extern int dopack; /* BOOLEAN: do we want to pack/unpack? */ extern int doSubdir; /* BOOLEAN: expand subdirectories? */ extern int doExpand; /* BOOLEAN: expand archived filenames? */ extern int doMessages; /* BOOLEAN: do comments instead of data? */ extern int transfrom; /* how to do CR<->LF translation? (-1 = none) */ extern int transto; extern int packMethod; /* how to pack a file (thread_format) */ extern fourbyt defFileType; /* default file type */ extern fourbyt defAuxType; /* default aux type */ extern onebyt *pakbuf; /* used by compression routines; created once to */ X /* eliminate overhead involved in malloc()ing a 64K buffer */ extern char *prgName; /* for errors; don't like argv[0] */ X SHAR_EOF chmod 0644 nudefs.h || echo 'restore of nudefs.h failed' Wc_c="`wc -c < 'nudefs.h'`" test 3997 -eq "$Wc_c" || echo 'nudefs.h: original size 3997, current size' "$Wc_c" fi # ============= nuetc.h ============== if test -f 'nuetc.h' -a X"$1" != X"-c"; then echo 'x - skipping nuetc.h (File already exists)' else echo 'x - extracting nuetc.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'nuetc.h' && /* X * nuetc.h - declarations for nuetc.c X * X * NuLib v3.1 October 1991 Freeware (distribute, don't sell) X * By Andy McFadden (fadden@cory.berkeley.edu) X */ /* X * (this will be included by almost all source files; it should come last) X */ X /* define these if they haven't been already */ /* (typedef int BOOLEAN caused too many problems... #define is easier) */ #ifndef BOOLEAN # define BOOLEAN int #endif X #ifndef TRUE # define TRUE 1 # define FALSE 0 #endif X #ifdef UNIX # ifdef BSD43 X extern char *index(); /* BSD version */ X extern char *rindex(); # define INDEX(s, c) index(s, c) # define RINDEX(s, c) rindex(s, c) # else X extern char *strchr(); /* AT&T version */ X extern char *strrchr(); # define INDEX(s, c) strchr(s, c) # define RINDEX(s, c) strrchr(s, c) # endif #else X extern char *strchr(); /* APW, MSC */ X extern char *strrchr(); # define INDEX(s, c) strchr(s, c) # define RINDEX(s, c) strrchr(s, c) #endif X extern char tmpNameBuf[]; X /* external function declarations */ extern void Fatal(), X Quit(); extern void free(); extern char *Malloc(); X #ifdef APW extern void ToolErrChk(), X perror(); #endif X extern int strcasecmp(), X strncasecmp(); X extern void ArcfiCreate(), X Rename(); extern BOOLEAN Exists(); extern char *MakeTemp(); X extern void ExpandTime(); extern long ReduceTime(); extern Time *GetTime(); X SHAR_EOF chmod 0644 nuetc.h || echo 'restore of nuetc.h failed' Wc_c="`wc -c < 'nuetc.h'`" test 1366 -eq "$Wc_c" || echo 'nuetc.h: original size 1366, current size' "$Wc_c" fi # ============= nuext.h ============== if test -f 'nuext.h' -a X"$1" != X"-c"; then echo 'x - skipping nuext.h (File already exists)' else echo 'x - extracting nuext.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'nuext.h' && /* X * nuext.h - declarations for nuext.c X * X * NuLib v3.1 October 1991 Freeware (distribute, don't sell) X * By Andy McFadden (fadden@cory.berkeley.edu) X */ X #define MAXDEPTH 64 /* max subdir depth we will unpack */ X extern void NuExtract(); X SHAR_EOF chmod 0644 nuext.h || echo 'restore of nuext.h failed' Wc_c="`wc -c < 'nuext.h'`" test 250 -eq "$Wc_c" || echo 'nuext.h: original size 250, current size' "$Wc_c" fi # ============= nupak.h ============== if test -f 'nupak.h' -a X"$1" != X"-c"; then echo 'x - skipping nupak.h (File already exists)' else echo 'x - extracting nupak.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'nupak.h' && /* X * nupak.h - declarations for nupak.c X * X * NuLib v3.1 October 1991 Freeware (distribute, don't sell) X * By Andy McFadden (fadden@cory.berkeley.edu) X */ /* X * This has function declarations for all of the pack routines; that way we X * don't have to include .h files for all of the pack code. X */ X /* Pack/unpack buffer size; should be as big as read() & malloc() can take */ /* Note: must be AT LEAST 8200 bytes or things may break */ /* Bad things could happen if it's less than 12K */ #define PAKBUFSIZ 0xff80 X extern long packedSize; extern onebyt lastseen; X extern twobyt PackFile(); extern int UnpackFile(); /* BOOLEAN */ extern unsigned int crlf(); extern void Spin(), X FCopy(); X extern long pak_SHK(); /* pack P8 ShrinkIt format, in nushk.c */ extern void unpak_SQU(); /* unsqueeze, in nusq.c */ extern void unpak_SHK(); /* unShrink, in nushk.c */ X SHAR_EOF chmod 0644 nupak.h || echo 'restore of nupak.h failed' Wc_c="`wc -c < 'nupak.h'`" test 883 -eq "$Wc_c" || echo 'nupak.h: original size 883, current size' "$Wc_c" fi # ============= nupdel.h ============== if test -f 'nupdel.h' -a X"$1" != X"-c"; then echo 'x - skipping nupdel.h (File already exists)' else echo 'x - extracting nupdel.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'nupdel.h' && /* X * nupdel.h - declarations for NuUpdate and NuDelete X * X * NuLib v3.1 October 1991 Freeware (distribute, don't sell) X * By Andy McFadden (fadden@cory.berkeley.edu) X */ X X extern void NuDelete(), X NuUpdate(); X SHAR_EOF chmod 0644 nupdel.h || echo 'restore of nupdel.h failed' Wc_c="`wc -c < 'nupdel.h'`" test 217 -eq "$Wc_c" || echo 'nupdel.h: original size 217, current size' "$Wc_c" fi # ============= nuread.h ============== if test -f 'nuread.h' -a X"$1" != X"-c"; then echo 'x - skipping nuread.h (File already exists)' else echo 'x - extracting nuread.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'nuread.h' && /* X * nuread.h - linked list structures used for holding NuFX header data, X * and structure definitions for archive innards X * X * NuLib v3.1 October 1991 Freeware (distribute, don't sell) X * By Andy McFadden (fadden@cory.berkeley.edu) X */ /* X * (this will be included by all source files which access NuFX archives) X */ X X /* The NuFX master format version we output, and the maximum we can extract */ #define OURMVERS 2 #define MAXMVERS 2 X /* The NuFX record format version we output, and the maximum we can extract */ #define OURVERS 0 #define MAXVERS 3 X /* "NuFile" in alternating ASCII */ static onebyt MasterID[7] = { 0x4e, 0xf5, 0x46, 0xe9, 0x6c, 0xe5, 0x0 }; X /* "NuFX" in alternating ASCII */ static onebyt RecordID[5] = { 0x4e, 0xf5, 0x46, 0xd8, 0x0 }; X X /* X * Structure definitions for NuFX innards X */ X /* master header block */ typedef struct { X onebyt ID[6]; X twobyt master_crc; X fourbyt total_records; X Time arc_create_when; X Time arc_mod_when; X twobyt master_version; X onebyt reserved1[8]; X fourbyt master_eof; X onebyt reserved2[6]; } MHblock; #define MHsize 48 /* this should not change */ X /* record header block */ typedef struct { X onebyt ID[4]; X twobyt header_crc; X twobyt attrib_count; X twobyt version_number; X twobyt total_threads; X twobyt reserved1; X twobyt file_sys_id; X onebyt file_sys_info; X onebyt reserved2; X fourbyt access; X fourbyt file_type; X fourbyt extra_type; X twobyt storage_type; X Time create_when; X Time mod_when; X Time archive_when; X twobyt option_size; X /* future expansion here... */ } RHblock; #define RHsize 58 /* sizeof(RHblock) should work, but might not */ #define ATTSIZE 64 /* default attrib_count when creating new */ X /* X * This buffer must be able to contain three things (not all at once): X * - The master header block (size = MHsize) X * - The record header block (size = RHsize) X * - Attributes not specified in the RHblock (attrib_count - RHsize - 2) X * X * Currently, it only needs to be 64 bytes. Since it is allocated as local X * storage only once during execution, making it reasonably large should X * not cause any problems in performance but will make the program stable X * if it encounters an archive with a drastically expanded RHblock. X */ #define RECBUFSIZ 256 X /* thread record */ typedef struct { X twobyt thread_class; X twobyt thread_format; X twobyt thread_kind; X twobyt thread_crc; X fourbyt thread_eof; X fourbyt comp_thread_eof; } THblock; #define THsize 16 /* this should not change */ X X /* X * Definitions for the linked lists X * A linked list of Record headers, with linked lists of Threads attached X */ X /* thread nodes */ typedef struct TNode_s { X THblock *THptr; /* points to thread info */ X long fileposn; /* absolute position of this thread in the file */ X struct TNode_s *TNext; /* points to next thread node */ } TNode; X /* record nodes */ typedef struct RNode_s { X RHblock *RHptr; /* points to the record header block */ X char *filename; /* filename of record */ X twobyt filename_length; /* length of filename (as stored in record hdr) */ X twobyt real_fn_length; /* length of filename (actual) */ X TNode *TNodePtr; /* points to first thread node */ X fourbyt unc_len; /* total uncompressed length of all threads */ X fourbyt comp_len; /* total compressed length of all threads */ X struct RNode_s *RNext; /* points to next record node */ } RNode; X /* head of list */ typedef struct { X char *arc_name; /* filename of archive */ X MHblock *MHptr; /* points to master header */ X RNode *RNodePtr; /* points to first record node */ X long nextposn; /* abs. position in file to put next record (for ADD) */ } ListHdr; X X /* X * function declarations X */ X extern ListHdr *NuRead(); /* read archive info into memory */ extern void NuTest(); /* archive integrity check */ extern twobyt CalcCRC(); /* calculate a CRC on a range of bytes */ extern char *PrintDate(); /* print a date from a (Time *) struct */ extern void BCopy(); /* copy bytes: *src, *dest, num, order? */ extern void HiSwap(); /* swap bytes (maybe): *ptr, src_index, dst_index */ SHAR_EOF chmod 0644 nuread.h || echo 'restore of nuread.h failed' Wc_c="`wc -c < 'nuread.h'`" test 4187 -eq "$Wc_c" || echo 'nuread.h: original size 4187, current size' "$Wc_c" fi # ============= nuview.h ============== if test -f 'nuview.h' -a X"$1" != X"-c"; then echo 'x - skipping nuview.h (File already exists)' else echo 'x - extracting nuview.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'nuview.h' && /* X * nuview.h - declarations for nuview.c X * X * NuLib v3.1 October 1991 Freeware (distribute, don't sell) X * By Andy McFadden (fadden@cory.berkeley.edu) X */ X typedef enum { NAMEONLY, PROSHK, ARCZOO, FULL } outtype; X /* constant string declarations */ extern char *unknownStr; extern char *WD[]; extern char *MO[]; #define TCn 4 extern char *TC[]; #define TKn 3 extern char *TK[][TKn]; #define TFn 6 extern char *TF[]; #define BTFn 6 extern char *BTF[]; #define QTFn 6 extern char *QTF[]; #define FIDn 14 extern char *FID[]; #define STn 14 extern char *ST[]; extern char *FT[]; X extern void NuView(); extern char *PrintDate(); X SHAR_EOF chmod 0644 nuview.h || echo 'restore of nuview.h failed' Wc_c="`wc -c < 'nuview.h'`" test 630 -eq "$Wc_c" || echo 'nuview.h: original size 630, current size' "$Wc_c" fi true || echo 'restore of nuadd.c failed' echo End of part 2, continue with part 3 exit 0 -- fadden@uts.amdahl.com (Andy McFadden) fadden@cory.berkeley.edu (expires in December) [ Above opinions are mine, Amdahl has nothing to do with them, etc, etc. ]