Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/17/84 chuqui version 1.9 3/12/85; site unisoft.UUCP Path: utzoo!watmath!clyde!bonnie!akgua!gatech!seismo!lll-crg!lll-lcc!unisoft!fnf From: fnf@unisoft.UUCP Newsgroups: net.micro.amiga Subject: make for amiga (part 1 of 2) Message-ID: <609@unisoft.UUCP> Date: Wed, 4-Dec-85 20:24:53 EST Article-I.D.: unisoft.609 Posted: Wed Dec 4 20:24:53 1985 Date-Received: Sat, 7-Dec-85 04:13:37 EST Distribution: net Organization: UniSoft Systems, Berkeley Lines: 1857 Here is a much hacked up version of a make posted to net.sources earlier this year. This particular copy is known to run on the amiga under version 1.0 of AmigaDos, and on unix under system V. One thing I have not yet tested is the local archiver facility (lar). -Fred #--------CUT---------CUT---------CUT---------CUT--------# ######################################################### # # # This is a shell archive file. To extract files: # # # # 1) Make a directory for the files. # # 2) Write a file, such as "file.shar", containing # # this archive file into the directory. # # 3) Type "sh file.shar". Do not use csh. # # # ######################################################### # # echo Extracting Makefile: sed 's/^Z//' >Makefile <<\STUNKYFLUFF Z# Z# MSDOS Make utility Z# (compile with Wizard C version 2.0) Z# Z ZCC = cc Z#CFLAGS = -O -DDBUG ZCFLAGS = -O Z#LIBS = -ldbug ZLIBS = Z ZH = make.h Z ZFILES = $H make.c macro.c token.c parsedir.c file.c osdate.c execute.c Z Z# This version of make currently does not grok continuation lines with Z# escaped newlines. To avoid extra long lines, we define some intermediate Z# macros. Z ZOBJS1 = make.o macro.o token.o parsedir.o file.o osdate.o ZOBJS2 = getdir.o lwtol.o execute.o sys.o ZOBJS = $(OBJS1) $(OBJS2) Z ZLSRC1 = make.c macro.c token.c parsedir.c file.c osdate.c ZLSRC2 = getdir.c lwtol.c execute.c sys.c ZLSRC = $(LSRC1) $(LSRC2) Z ZDOCUMENTATION = readme make.man makefile Z Zall : pdmake Z Zpdmake : $(OBJS) Z $(CC) -o pdmake $(OBJS) $(LIBS) Z Zmake.o : make.c $H Z $(CC) $(CFLAGS) -c make.c Z Zmacro.o : macro.c $H Z $(CC) $(CFLAGS) -c macro.c Z Ztoken.o : token.c $H Z $(CC) $(CFLAGS) -c token.c Z Zparsedir.o : parsedir.c $H Z $(CC) $(CFLAGS) -c parsedir.c Z Zfile.o : file.c $H Z $(CC) $(CFLAGS) -c file.c Z Zexecute.o : execute.c $H Z $(CC) $(CFLAGS) -c execute.c Z Zosdate.o : osdate.c $H lar.h Z $(CC) $(CFLAGS) -c osdate.c Z Zsys.o : sys.c $H Z $(CC) $(CFLAGS) -c sys.c Z Z# Z# Makefile for lar. Z# Z Zlar.exe : lwtol.o getdir.o lar.o Z link lar+lwtol+getdir,lar,lar/map Z Zlar.o : lar.lar ( lar.c lar.h ) Z cc -c lar.c Z Z# Z# Files shared by lar and make. Z# Z Zgetdir.o : getdir.c lar.h Z $(CC) $(CFLAGS) -c getdir.c Z Zlwtol.o : lwtol.c lar.h Z $(CC) $(CFLAGS) -c lwtol.c Z Z# Z# Print files associated with MAKE Z# Z Zprint : Z print make.man $(FILES) makefile Z Z# Z# collect source and documentation files Z# Z Zcollect : Z lar uv make.lar $(FILES) $(DOCUMENTATION) Z lar uv lar.lar lar.c lar.h lwtol.c getdir.c Z lar rv make.lar Z lar rv lar.lar Z Z# Z# copy to distribution disk (on A:) Z# Zdistribution : Z copy readme a: Z copy make.man a: Z copy makefile a: Z copy make.c a: Z copy macro.c a: Z copy token.c a: Z copy parsedir.c a: Z copy file.c a: Z copy osdate.c a: Z copy execute.c a: Z copy lar.h a: Z copy lar.c a: Z copy getdir.c a: Z copy lwtol.c a: Z copy makemake.exe a: Z Z Z Zlint: Z lint $(LSRC) >lint.out STUNKYFLUFF set `sum Makefile` if test 03906 != $1 then echo Makefile: Checksum error. Is: $1, should be: 03906. fi # # echo Extracting execute.c: sed 's/^Z//' >execute.c <<\STUNKYFLUFF Z#ifndef AMIGA Z# include Z#endif Z Z#ifdef MSDOS Z# include Z#endif Z Z#include Z#include Z#include "make.h" Z Z#ifndef FALSE Z# define FALSE (0) Z#endif Z Z#ifndef TRUE Z# define TRUE (1) Z#endif Z Z#define BUFFSIZ (256) Z Z#ifdef MSDOS Zextern char *searchpath (); Z#endif Z Zextern char *getenv (); Z Z#ifdef MSDOS Zextern int _envseg; Z#ifndef NOREALEXECUTE Zstatic char param[256]; Zstatic char cmd[256]; Zstatic char *cmds[] = { Z "break", Z "chdir", Z "cd", Z "cls", Z "copy", Z "ctty", Z "date", Z "del", Z "erase", Z "dir", Z "echo", Z "exit", Z "for", Z "goto", Z "if", Z "mkdir", Z "md", Z "path", Z "pause", Z "prompt", Z "rem", Z "ren", Z "rename", Z "rmdir", Z "rd", Z "set", Z "shift", Z "time", Z "type", Z "ver", Z "verify", Z "vol", Z 0 Z}; Z#endif /* !NOREALEXECUTE */ Z#endif /* MSDOS */ Z Zexecute (str, noexecflag) Zchar *str; Zint noexecflag; Z{ Z auto char tmp[BUFFSIZ]; Z auto char buf[10]; Z register int index = 0; Z register int rval; Z extern int ignore_errors; Z Z DBUG_ENTER ("execute"); Z tmp[0] = EOS; Z while (*str != EOS) { Z if (*str == '\n') { Z tmp[index] = EOS; Z index = 0; Z str++; Z if ((rval = run (tmp, noexecflag)) != 0 && !ignore_errors) { Z fputs ("***Error Code ", stderr); Z itoa (rval, buf); Z fputs (buf, stderr); Z fputc ('\n', stderr); Z DBUG_RETURN (rval); Z } Z } else if (index == (BUFFSIZ - 1)) { Z fputs ("Command Too Long: ", stderr); Z fputs (str, stderr); Z fputs ("\nShorten.\n", stderr); Z DBUG_RETURN (-1); Z } else { Z tmp[index++] = *str++; Z } Z } Z DBUG_RETURN (0); Z} Z Z Z Z#ifdef TESTING Zmain () Z{ Z auto char temp[128]; Z Z for (;;) { Z printf ("Command: "); Z gets (temp); Z if (temp[0] == EOS) { Z break; Z } Z printf (" Execute: %d\n", run (temp)); Z } Z} Z#endif Z Z/* run(str) Z * char *str; Z * returns the value of the executed command. If the command is Z * an MS-DOS resident command the command.com is executed else Z * the program is invoked (looking down the PATH). Z * Z * Written: Bradley N. Davis University of Utah VCIS group Z * Date: 4-Jan-84 Z * Z */ Z Zstatic int run (str, noexecflag) Zchar *str; Zint noexecflag; Z{ Z#ifdef MSDOS Z auto struct execp ep; Z auto struct SREGS segs; Z#else Z extern int system (); Z#endif Z auto int status = 0; Z Z DBUG_ENTER ("run"); Z while (*str == '\t' || *str == ' ') { Z str++; Z } Z putchar ('\t'); Z puts (str); Z fflush (stdout); Z if (!noexecflag) { Z#ifndef NOREALEXECUTE Z#ifdef MSDOS Z if (str[0] == EOS) { /* Blank Line? push to subshell */ Z strcpy (cmd, getenv ("COMSPEC")); Z param[0] = EOS; Z segread (&segs); Z ep.ex_envseg = _envseg; Z ep.ex_cmdadd = (unsigned) param; Z ep.ex_cmdseg = segs.ss; Z ep.ex_fcb1ad = 0; Z ep.ex_fcb1sg = 0; Z ep.ex_fcb2ad = 0; Z ep.ex_fcb2sg = 0; Z status = (exec (cmd, 0, &ep)); Z } else if (resident (str)) { Z status = (system (str)); Z } else { Z status = (program (cmd, param)); Z } Z#else Z CHECK_ABORT; Z status = system (str); Z#endif /* MSDOS */ Z#endif /* !NOREALEXECUTE */ Z } Z DBUG_3 ("sys", "subcommand returns status %d", status); Z DBUG_RETURN (status); Z} Z Z/* Z * resident(str) Z * char *str; Z * returns true if the command in str is an MS-DOS resident Z * command. Z * Z * Written: Bradley N. Davis University of Utah VCIS group Z * Date: 4-Jan-84 Z * Z */ Z Z#define iswhite(ch) (ch == ' ' || ch == '\t') Z Z#ifdef MSDOS Z#ifndef NOREALEXECUTE Zstatic int resident (str) Zchar *str; Z{ Z register char **t; Z extern char *strpbrk (); Z register int i; Z register int j; Z Z DBUG_ENTER ("resident"); Z while (iswhite (*str)) { Z str++; /* trim blanks */ Z } Z if (str[1] == ':' && isalpha (str[0])) { /* look for x: */ Z DBUG_RETURN (TRUE); Z } Z if (strpbrk (str, "<>|") != NULL) { /* redirection? use system */ Z DBUG_RETURN (TRUE); Z } Z i = 0; Z while (isalnum (*str)) { Z if (isupper (*str)) { Z cmd[i++] = *str++ - 'A' + 'a'; Z } else { Z cmd[i++] = *str++; Z } Z } Z cmd[i] = EOS; Z for (t = cmds; *t; t++) { Z if (strcmp (*t, cmd) == 0) { Z DBUG_RETURN (TRUE); Z } Z } Z strcat (cmd, ".bat"); /* Batch file? use system */ Z if (searchpath (cmd) != 0) { Z cmd[i] = EOS; Z DBUG_RETURN (TRUE); Z } Z cmd[i] = EOS; Z j = strlen (str); Z i = 1; Z while ((param[i++] = *str++) != 0); Z param[0] = j; Z param[j + 1] = '\r'; Z DBUG_RETURN (FALSE); Z} Z Zstatic int program (pcmd, pparam) Zchar *pcmd; Zchar *pparam; Z{ Z#ifdef MSDOS Z auto struct execp ep; Z auto struct SREGS segs; Z register char *pathp; Z register int len; Z Z DBUG_ENTER ("program"); Z len = strlen (pcmd); Z strcat (pcmd, ".com"); Z pathp = searchpath (pcmd); Z if (pathp == 0) { Z pcmd[len] = EOS; Z strcat (pcmd, ".exe"); Z pathp = searchpath (pcmd); Z if (pathp == 0) { Z pcmd[len] = EOS; Z errno = ENOENT; Z DBUG_RETURN (-1); Z } Z } Z segread (&segs); Z ep.ex_envseg = _envseg; Z ep.ex_cmdadd = (unsigned) pparam; Z ep.ex_cmdseg = segs.ss; Z ep.ex_fcb1ad = 0; Z ep.ex_fcb1sg = 0; Z ep.ex_fcb2ad = 0; Z ep.ex_fcb2sg = 0; Z DBUG_RETURN (exec (pathp, 0, &ep)); Z#else Z fprintf (stderr, "Urk -- 'program()' unimplemented!\n"); Z DBUG_RETURN (0); Z#endif Z} Z#endif /* !NOREALEXECUTE */ Z#endif /* MSDOS */ Z Z Z#ifdef AMIGA Z/* Z * Do explicit check for abort. When Enable_Abort is non-zero, Z * Chk_Abort() cause program termination if CNTRL-C or CNTRL-D has Z * been received. Thus, we temporarily set it back to zero while we Z * do the explicit test, so we can do our own clean up and exit. Z * Note that if the -V flag was used, we spit out a confirming message Z * that we are quitting. Z * Z */ Z Zvoid Check_Abort () Z{ Z DBUG_ENTER ("Check_Abort"); Z DBUG_2 ("abort", "do explicit test for CNTRL-C"); Z DISABLE_ABORT; Z if (Chk_Abort () != 0) { Z exit (1); Z } Z ENABLE_ABORT; Z DBUG_VOID_RETURN; Z} Z Z#endif /* AMIGA */ STUNKYFLUFF set `sum execute.c` if test 63439 != $1 then echo execute.c: Checksum error. Is: $1, should be: 63439. fi # # echo Extracting file.c: sed 's/^Z//' >file.c <<\STUNKYFLUFF Z#include Z#include "make.h" Z Zstatic FILENODE *addtolist (); Zstatic FILENODE *afnode (); Z Z/* Z * Return file-node for 'fname'. Z * If it doesn't exist, then create one. Z */ Z ZFILENODE *filenode (fname) Zchar *fname; Z{ Z register FILENODE *f; Z Z DBUG_ENTER ("filenode"); Z DBUG_3 ("fnode", "locate or create node for file '%s'", fname); Z if ((f = gfile (fname)) == (FILENODE *) NULL) { Z f = afnode (fname); Z } Z DBUG_RETURN (f); Z} Z Z/* Z * Add a dependency to the node 'fnd'. Z * 'fnd' will depend on 'fname'. Z * Z * Returns dependent node associated with 'fname'. Z */ Z ZFILENODE *addfile (fnd, fname) ZFILENODE *fnd; Zchar *fname; Z{ Z register NODE *n; Z register FILENODE *f; Z Z DBUG_ENTER ("addfile"); Z if (fnd == (FILENODE *) NULL) { /* punt if no root file */ Z fputs ("No current root, can't add dependency '", stderr); Z fputs (fname, stderr); Z fputs ("%s'\n", stderr); Z DBUG_RETURN ((FILENODE *) NULL); Z } Z DBUG_4 ("fdep", "add dependency of '%s' on '%s'", fnd -> fname, fname); Z f = filenode (fname); Z if ((n = (NODE *) Calloc (1, sizeof (NODE))) == (NODE *) NULL) { Z allerr (); Z } Z n -> nnext = fnd -> fnode; Z fnd -> fnode = n; Z n -> nfile = f; Z DBUG_RETURN (f); Z} Z Z Z/* Z * Add a line of method-text to the node 'fnode'. Z */ Z Zvoid addmeth (fnode, methtext) ZFILENODE *fnode; Zchar *methtext; Z{ Z register int len; Z register char *new; Z extern void free (); Z Z DBUG_ENTER ("addmeth"); Z if (fnode != (FILENODE *) NULL && methtext != NULL) { Z len = strlen (methtext) + 2; Z if (fnode -> fmake == NULL) { Z if ((fnode -> fmake = (char *) Calloc (1, 1)) == NULL) { Z allerr (); Z } Z *(fnode -> fmake) = '\0'; Z } Z len += strlen (fnode -> fmake); Z /* Lattice C does not have 'realloc()', so this kludges around it: */ Z if ((new = (char *) Calloc (1, len)) == NULL) { Z allerr (); Z } Z strcpy (new, fnode -> fmake); Z free (fnode -> fmake); Z fnode -> fmake = new; Z strcat (fnode -> fmake, methtext); Z len = strlen (fnode -> fmake); Z if (len > 0 && fnode -> fmake[len - 1] != '\n') { Z strcat (fnode -> fmake, "\n"); Z } Z } Z DBUG_VOID_RETURN; Z} Z Z/* Z * Add token to the parent list. Return the pointer to the new parent. Z * If token is already on the parent list, simply return the pointer found. Z */ Z Zstatic FILENODE *addtolist (tok, list) Zchar *tok; ZNODE **list; Z{ Z register NODE *search; Z register NODE *newnode; Z Z DBUG_ENTER ("addtolist"); Z for (search = *list; search != (NODE *) NULL; search = search -> nnext) { Z if (STRSAME (search -> nfile -> fname, tok)) { Z DBUG_RETURN (search -> nfile); Z } Z } Z /* token not found so far... add it to list */ Z if ((newnode = (NODE *) Calloc (1, sizeof (NODE))) == (NODE *) NULL) { Z allerr (); Z } Z search = *list; Z *list = newnode; Z newnode -> nnext = search; Z if ((newnode -> nfile = (FILENODE *) Calloc (1, sizeof (FILENODE))) == (FILENODE *) NULL) { Z allerr (); Z } Z if ((newnode -> nfile -> fname = (char *) Calloc (1, strlen (tok) + 1)) == NULL) { Z allerr (); Z } Z strcpy (newnode -> nfile -> fname, tok); Z newnode -> nfile -> fdate = (DATE) NULL; Z newnode -> nfile -> fnode = (NODE *) NULL; Z newnode -> nfile -> parent = (FILENODE *) NULL; Z newnode -> nfile -> fflag = 0; Z newnode -> nfile -> fnext = NULL; Z DBUG_RETURN (newnode -> nfile); Z} Z Zstatic NODE *parentlist = (NODE *) NULL; Z ZFILENODE *addparent (tok) Zchar *tok; Z{ Z FILENODE *np; Z Z DBUG_ENTER ("addparent"); Z np = addtolist (tok, &parentlist); Z DBUG_RETURN (np); Z} Z Z#ifdef FUNNYLIBS Z Zisonlibrary (f) /* return SUCCEED if f is a library. */ ZFILENODE *f; /* set f->fdate to parent's date */ Z{ Z DBUG_ENTER ("isonlibrary"); Z if (f -> fflag & LIBRARY) { Z getdate (f -> parent); Z f -> fdate = f -> parent -> fdate; Z DBUG_RETURN (SUCCEED); Z } Z DBUG_RETURN (FAILURE); Z} Z Z#else Z Z/* Z * Add file node fnd to library list. Z */ Z Zstatic FILENODE *librarylist = (FILENODE *) NULL; Z Zvoid AddToLibrary (fnd) ZFILENODE *fnd; Z{ Z register NODE *n; Z Z DBUG_ENTER ("AddToLibrary"); Z DBUG_3 ("lib", "add node for '%s' to library list", fnd -> fname); Z if (librarylist == (FILENODE *) NULL) { Z if ((librarylist = (FILENODE *) Calloc (1, sizeof (FILENODE))) == (FILENODE *) NULL) { Z allerr (); Z } Z librarylist -> fnode = (NODE *) NULL; Z } Z if ((n = (NODE *) Calloc (1, sizeof (NODE))) == (NODE *) NULL) { Z allerr (); Z } Z n -> nnext = librarylist -> fnode; Z librarylist -> fnode = n; Z n -> nfile = fnd; Z DBUG_VOID_RETURN; Z} Z Z/* Z * Return SUCCEED if filenode f is a direct descendant of a library; Z * set f->fdate to parent's time. Z */ Z Zisonlibrary (f) ZFILENODE *f; Z{ Z register NODE *lib; Z register NODE *dep; Z Z DBUG_ENTER ("isonlibrary"); Z DBUG_3 ("isonlib", "Searching for: %s", f -> fname); Z if (librarylist == (FILENODE *) NULL) { Z DBUG_RETURN (FAILURE); Z } Z for (lib = librarylist->fnode; lib != (NODE *)NULL; lib = lib->nnext) { Z for (dep = lib->nfile->fnode; dep != (NODE *)NULL; dep = dep->nnext) { Z DBUG_3 ("dep", "Examining: %s", dep -> nfile -> fname); Z if (f == dep -> nfile) { /* found it!! */ Z DBUG_3 ("dep", "found %s", dep -> nfile -> fname); Z DBUG_3 ("dep", "depends on %s", lib -> nfile -> fname); Z f -> fdate = lib -> nfile -> fdate; /* update time */ Z DBUG_RETURN (SUCCEED); Z } Z } Z } Z DBUG_RETURN (FAILURE); Z} Z#endif Z Zisanarchive (f) /* return SUCCEED if f is an archive */ ZFILENODE *f; /* set f->fdate to date in parent's */ Z{ /* archive directory */ Z DATE getarchdate (); Z Z DBUG_ENTER ("isanarchive"); Z if (f -> fflag & ARCHIVE) { Z f -> fdate = getarchdate (f -> parent -> fname, f -> fname); Z DBUG_RETURN (SUCCEED); Z } Z DBUG_RETURN (FAILURE); Z} Z ZNODE *deletelist = (NODE *) NULL; Z Z#ifdef LAR Zextract (f) ZFILENODE *f; Z{ Z DBUG_ENTER ("extract"); Z DBUG_3 ("extr", "extracting %s for archivehood", f -> fname); Z if (f -> fflag & ARCHIVE) { Z DBUG_3 ("extr", "copying %s for archivehood", f -> fname); Z#ifndef NOREALEXTRACT Z copyfile (f -> parent -> fname, f -> fname); Z#endif Z /* delete f->fname at end of run */ Z (void) addtolist (f -> fname, &deletelist); Z DBUG_RETURN (SUCCEED); Z } Z DBUG_RETURN (FAILURE); Z} Z#endif Z Zvoid cleanuparchives () Z{ Z register NODE *search; Z Z DBUG_ENTER ("cleanuparchives"); Z for (search=deletelist; search != (NODE *)NULL; search = search->nnext) { Z fputs ("Purging ", stdout); Z puts (search -> nfile -> fname); Z#ifndef NOREALDELETE Z unlink (search -> nfile -> fname); Z#endif Z } Z DBUG_VOID_RETURN; Z} Z Z Z/* Z * Get a filenode for the file called 'fn'. Z * Returns (FILENODE *) NULL if the node doesn't exist. Z */ Z ZFILENODE *gfile (fn) Zchar *fn; Z{ Z register FILENODE *f; Z Z DBUG_ENTER ("gfile"); Z DBUG_3 ("fnode", "look for file node '%s'", fn); Z for (f = froot; f != (FILENODE *) NULL; f = f -> fnext) { Z if (STRSAME (fn, f -> fname)) { Z DBUG_2 ("fnode", "found it"); Z break; Z } Z } Z DBUG_RETURN (f); Z} Z Z Z/* Z * Alloc space for a new file node. Z * Z * Note that when this routine is called, it has already been Z * determined that there is no existing node with this name, so Z * we don't need to check again. Z * Z * Also note that the method string pointer is set to a dynamically Z * allocated null string, rather than a static null string (""), because Z * it is latter freed when expanding the method string. Z * Z */ Z Zstatic FILENODE *afnode (name) Zchar *name; Z{ Z FILENODE *f; Z Z DBUG_ENTER ("afnode"); Z DBUG_3 ("fnode", "allocate a new node for file '%s'", name); Z if ((f = (FILENODE *) Calloc (1, sizeof (FILENODE))) == (FILENODE *) NULL) { Z allerr (); Z } Z if ((f -> fname = (char *) Calloc (1, strlen (name) + 1)) == NULL) { Z allerr (); Z } Z strcpy (f -> fname, name); Z if ((f -> fmake = (char *) Calloc (1, 1)) == NULL) { Z allerr (); Z } Z *(f -> fmake) = '\0'; Z f -> fdate = (DATE) NULL; Z f -> fnode = (NODE *) NULL; Z f -> parent = (FILENODE *) NULL; Z f -> fflag = 0; Z f -> fnext = froot; Z froot = f; Z DBUG_RETURN (f); Z} Z Z/* Z * Print dependency tree. Z */ Z Zvoid prtree () Z{ Z register FILENODE *f; Z register NODE *n; Z extern char *printdate (); Z Z DBUG_ENTER ("prtree"); Z for (f = froot; f != (FILENODE *) NULL; f = f -> fnext) { Z fputs (f -> fname, stdout); Z fputs ((f -> fflag & ROOTP) ? " (root)" : "", stdout); Z fputs ((f -> fflag & REBUILT) ? " (rebuilt)" : "", stdout); Z fputs ((f -> fflag & LIBRARY) ? " (library)" : "", stdout); Z fputs ((f -> fflag & EXTRACT) ? " (extracted)" : "", stdout); Z fputs ((f -> fflag & ARCHIVE) ? " (archive)" : "", stdout); Z fputs (printdate (f -> fdate), stdout); Z fputc ('\n', stdout); Z if (f -> parent != (FILENODE *) NULL) { Z fputs ("Parent is: ", stdout); Z fputs (f -> parent -> fname, stdout); Z fputc ('\n', stdout); Z fputs ("Parental Date:", stdout); Z fputs (printdate (f -> parent -> fdate), stdout); Z fputc ('\n', stdout); Z } Z if (f -> fmake != NULL) { Z puts (f -> fmake); Z } Z puts ("Dependents: "); Z for (n = f -> fnode; n != (NODE *) NULL; n = n -> nnext) { Z fputc ('\t', stdout); Z puts ((n -> nfile) -> fname); Z } Z fputc ('\n', stdout); Z } Z DBUG_VOID_RETURN; Z} STUNKYFLUFF set `sum file.c` if test 36039 != $1 then echo file.c: Checksum error. Is: $1, should be: 36039. fi # # echo Extracting getdir.c: sed 's/^Z//' >getdir.c <<\STUNKYFLUFF Z#include "lar.h" Z Z#if unix || AMIGA Z# include "make.h" /* To pick up remappings */ Z#endif Z Zvoid getdir (f) Zfildesc f; Z{ Z extern int nslots; Z extern struct ludir ldir[MAXFILES]; Z char *getname (); Z static void error (); Z Z DBUG_ENTER ("getdir"); Z lseek (f, 0L, 0); /* rewind f */ Z if (_read (f, (char *) & ldir[0], DSIZE) != DSIZE) { Z error ("No directory\n"); Z } Z if (!equal (getname ((char *)ldir[0].l_name, (char *)ldir[0].l_ext),"larformt.arc")) { Z error ("This is not a LAR format archive!!"); Z } Z if (lwtol (ldir[0].l_datetime) != -1L) { Z error ("This is not a LAR format archive!!"); Z } Z nslots = (int) (lwtol (ldir[0].l_len) / DSIZE); Z if (_read (f, (char *) & ldir[1], DSIZE * nslots) != DSIZE * nslots) { Z error ("Can't read directory - is it a library?"); Z } Z DBUG_VOID_RETURN; Z} Z Z/* convert nm.ex to a Unix style string */ Zchar *getname (nm, ex) Zchar *nm; Zchar *ex; Z{ Z static char namebuf[14]; Z register char *cp; Z register char *dp; Z register char *ocp; Z Z DBUG_ENTER ("getname"); Z for (cp = namebuf, dp = nm; *dp != ' ' && dp != nm + 8;) { Z *cp++ = isupper (*dp) ? tolower (*dp++) : *dp++; Z } Z *cp++ = '.'; Z ocp = cp; Z for (dp = ex; *dp != ' ' && dp != ex + 3;) { Z *cp++ = isupper (*dp) ? tolower (*dp++) : *dp++; Z } Z if (cp == ocp) { /* no extension */ Z --cp; /* eliminate dot */ Z } Z *cp = '\0'; Z DBUG_RETURN (namebuf); Z} Z Zvoid cant (name) Zchar *name; Z{ Z#ifdef unix Z extern int errno; Z extern char *sys_errlist[]; Z#endif Z Z fputs (name, stderr); Z fputs (": ", stderr); Z#ifdef unix Z fputs (sys_errlist[errno], stderr); Z#else Z fputs ("", stderr); Z#endif Z fputs ("\n", stderr); Z fflush (stderr); Z exit (1); Z} Z Zvoid error (str) Zchar *str; Z{ Z fputs ("lar: ", stderr); Z fputs (str, stderr); Z fputs ("\n", stderr); Z fflush (stderr); Z exit (1); Z} Z Z/* Z * This itoa doesn't call in the floating point library: Z * CI C86 does an sprintf! Z */ Z Zvoid itoa (val, buf) Zint val; Zchar *buf; Z{ Z register int i; Z register int j; Z auto char tbuf[10]; Z Z if (val == 0) { Z buf[0] = '0'; Z buf[1] = '\0'; Z return; Z } Z i = 9; Z while (val != 0) { Z tbuf[i--] = (val % 10) + '0'; Z val /= 10; Z } Z i++; Z for (j = 0; i <= 9; i++, j++) { Z buf[j] = tbuf[i]; Z } Z buf[j] = '\0'; Z} STUNKYFLUFF set `sum getdir.c` if test 58729 != $1 then echo getdir.c: Checksum error. Is: $1, should be: 58729. fi # # echo Extracting lar.c: sed 's/^Z//' >lar.c <<\STUNKYFLUFF Z/* Z * Lar - LAR format library file maintainer Z * by Stephen C. Hemminger Z * linus!sch or sch@Mitre-Bedford Z * Z * Heavily hacked for MS-DOS by Eric C. Brown Z * utah-cs!brownc or brownc@utah-cs Z * Z * Usage: lar key library [files] ... Z * Z * Key functions are: Z * u - Update, add files to library Z * t - Table of contents Z * e - Extract files from library Z * a - extract All files from library Z * p - Print files in library Z * d - Delete files in library Z * r - Reorganize library Z * Other keys: Z * v - Verbose Z * Z * This program is public domain software, no warranty intended or Z * implied. Z * Z * DESCRPTION Z * Lar is a MS-DOS program to manipulate program libraries. Z * The primary use of lar is to combine several files together Z * to reduce disk space used. Z * Lar maintains the date and time of files in the library, so Z * that Make can extract the date/time for rebuilding a file. Z * When files are restored, the file has the original date/time Z * rather than the date/time when the file was extracted. Z * The original CP/M library program LU is the product Z * of Gary P. Novosielski. Z * Z * PORTABILITY Z * The code is modeled after the Software tools archive program, Z * and is setup for Version 7 Unix. It does not make any assumptions Z * about byte ordering, explict and's and shift's are used. Z * If you have a dumber C compiler, you may have to recode new features Z * like structure assignment, typedef's and enumerated types. Z * Z * * Unix is a trademark of Bell Labs. Z * ** CP/M is a trademark of Digital Research. Z */ Z#include "lar.h" Z Z/* Globals */ Zchar *fname[MAXFILES]; Zbool ftouched[MAXFILES]; Z Zstruct ludir ldir[MAXFILES]; Zint errcnt, nfiles, nslots; Zbool verbose = false; Z Zchar *getname(), *malloc(), *fgets(); Zlong fcopy(), lseek(), rlwtol(); Zint update(), reorg(), table(), extract(), print(), delete(), getall(); Z Ztypedef int (*PFI)(); Z Zmain (argc, argv) Zint argc; Zchar **argv; Z{ Z register char *flagp; Z char *aname; /* name of library file */ Z PFI function = (PFI) NULL; /* function to do on library */ Z /* set the function to be performed, but detect conflicts */ Z#define setfunc(val) if(function != (PFI) NULL) conflict(); else function = val Z Z if (argc < 3) Z help (); Z Z aname = argv[2]; Z filenames (argc, argv); Z Z for(flagp = argv[1]; *flagp; flagp++) Z switch (*flagp) { Z case 'u': Z setfunc(update); Z break; Z case 't': Z setfunc(table); Z break; Z case 'e': Z setfunc(extract); Z break; Z case 'a': Z setfunc(getall); Z break; Z case 'p': Z setfunc(print); Z break; Z case 'd': Z setfunc(delete); Z break; Z case 'r': Z setfunc(reorg); Z break; Z case 'v': Z verbose = true; Z break; Z default: Z help (); Z } Z Z if(function == (PFI) NULL) { Z fputs("No function key letter specified\n", stderr); Z help(); Z } Z Z (*function)(aname); Z exit(0); Z} Z Z/* print error message and exit */ Zhelp () { Zfputs ("Usage: lar {uteapdr}[v] library [files] ...\n", stderr); Zfputs ("Functions are:\n\tu - Update, add files to library\n", stderr); Zfputs ("\tt - Table of contents\n", stderr); Zfputs ("\te - Extract files from library\n", stderr); Zfputs ("\ta - extract All files from library\n", stderr); Zfputs ("\tp - Print files in library\n", stderr); Zfputs ("\td - Delete files in library\n", stderr); Zfputs ("\tr - Reorganize library\n", stderr); Z Zfputs ("Flags are:\n\tv - Verbose\n", stderr); Zexit (1); Z} Z Zconflict() { Zfputs ("Conficting keys\n", stderr); Zhelp(); Z} Z Z/* Z * This ltoa doesn't call in the floating point library: Z * CI C86 does an sprintf! Z */ Zltoa(val, buf) Zlong val; Zregister char *buf; Z{ Z register int i; Z int j; Z char tbuf[20]; Z Z if (val == 0) { Z buf[0] = '0'; Z buf[1] = '\0'; Z return; Z } Z Z i = 19; Z while (val != 0) { Z tbuf[i--] = (val % 10) + '0'; Z val /= 10; Z } Z Z i++; Z for (j = 0; i <= 19; i++, j++) Z buf[j] = tbuf[i]; Z Z buf[j] = '\0'; Z} Z Z/* Get file names, check for dups, and initialize */ Zfilenames (ac, av) Zint ac; Zchar **av; Z{ Z register int i, j=0; Z int k, loop; Z struct ffblk ff; Z bool iswild(); Z Z errcnt = 0; Z for (i = 0; i < ac - 3; i++) { Z if (iswild(av[i + 3])) { Z k = findfirst(av[i + 3], &ff, 0); Z while (k == 0) { Z fname[j] = malloc(strlen(ff.ff_name)+1); Z if (fname[j] == NULL) Z error("Out of core.."); Z strcpy(fname[j], ff.ff_name); Z for (loop = 0; ff.ff_name[loop] != 0; loop++) Z fname[j][loop] = tolower(ff.ff_name[loop]); Z ftouched[j] = false; Z if (j == MAXFILES) Z error ("Too many file names."); Z j++; Z k = findnext(&ff); Z } /* while */ Z } /* if-then */ Z else { /* not a wildcard */ Z fname[j] = av[i+3]; Z ftouched[j] = false; Z if (j == MAXFILES) Z error ("Too many file names."); Z j++; Z } /* else */ Z } /* for */ Z checkdups(j); Z} Z Zbool iswild(str) Zregister char *str; Z{ Z while (*str != '\0') { Z if (*str == '*' || *str == '?') Z return true; Z else str++; Z } Z return false; Z} Z Zcheckdups(i) Zregister int i; Z{ Z register int j; Z Z fname[i] = NULL; Z nfiles = i; Z for (i = 0; i < nfiles; i++) Z for (j = i + 1; j < nfiles; j++) Z if (equal (fname[i], fname[j])) { Z fputs (fname[i], stderr); Z error (": duplicate file name"); Z } Z} Z Ztable (lib) Zchar *lib; Z{ Z fildesc lfd; Z register int i; Z register struct ludir *lptr; Z long total, offset, size; Z int active = 0, unused = 0, deleted = 0, k; Z char *uname, buf[20]; Z Z if ((lfd = _open (lib, O_RDWR)) == SYS_ERROR) Z cant (lib); Z Z getdir (lfd); Z total = lwtol(ldir[0].l_len); Z if (verbose) { Z puts("Name Index Length"); Z fputs("Directory ", stdout); Z ltoa(total, buf); Z puts(buf); Z } Z Z for (i = 1, lptr = &ldir[1]; i < nslots; i++,lptr++) Z switch(lptr->l_stat) { Z case ACTIVE: Z active++; Z uname = getname(lptr->l_name, lptr->l_ext); Z if (filarg (uname)) Z if(verbose) { Z offset = lwtol(lptr->l_off); Z size = lwtol(lptr->l_len); Z fputs(uname, stdout); Z for (k = 1; k < 18 - strlen(uname); k++) Z fputc(' ', stdout); Z ltoa(offset, buf); Z fputs(buf, stdout); Z for (k = 1; k < 16 - strlen(buf); k++) Z fputc(' ', stdout); Z ltoa(size, buf); Z puts(buf, stdout); Z } Z else Z puts(uname); Z total += lwtol(lptr->l_len); Z break; Z case UNUSED: Z unused++; Z break; Z default: Z deleted++; Z } Z if(verbose) { Z puts("--------------------------------------"); Z fputs("Total bytes ", stdout); Z ltoa(total, buf); Z puts(buf); Z fputs("\nLibrary ", stdout); Z fputs(lib, stdout); Z fputs(" has ", stdout); Z itoa(nslots, buf); Z fputs(buf, stdout); Z fputs(" slots, ", stdout); Z itoa(deleted, buf); Z fputs(buf, stdout); Z fputs(" deleted ", stdout); Z itoa(active, buf); Z fputs(buf, stdout); Z fputs(" active, ", stdout); Z itoa(unused, buf); Z fputs(buf, stdout); Z puts(" unused"); Z } Z Z VOID _close (lfd); Z not_found (); Z} Z Zputdir (f) Zfildesc f; Z{ Z Z lseek(f, 0L, 0); /* rewind f */ Z if (_write (f, (char *) ldir, DSIZE * nslots) != nslots * DSIZE) Z error ("Can't write directory - library may be botched"); Z} Z Zinitdir (f) Zfildesc f; Z{ Z register int i; Z long numbytes; Z char line[80]; Z static struct ludir blankentry = { Z UNUSED, Z { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, Z { ' ', ' ', ' ' }, Z }; Z static struct ludir nameentry = { Z ACTIVE, Z { 'l', 'a', 'r', 'f', 'o', 'r', 'm', 't' }, Z { 'a', 'r', 'c' }, Z }; Z Z for (;;) { Z fputs ("Number of slots to allocate (1-255): ", stdout); Z if (fgets (line, 80, stdin) == NULL) Z error ("Eof when reading input"); Z nslots = atoi (line); Z if (nslots < 1) Z puts ("Must have at least one!"); Z else if (nslots > MAXFILES) Z puts ("Too many slots"); Z else Z break; Z } Z Z numbytes = nslots * DSIZE; Z Z for (i = 1; i < nslots; i++) Z ldir[i] = blankentry; Z ldir[0] = nameentry; Z ltolw (ldir[0].l_len, numbytes); Z ltolw (ldir[0].l_datetime, -1L); /* make funny date field */ Z Z putdir (f); Z} Z Zputname (cpmname, unixname) Zchar *cpmname, *unixname; Z{ Z register char *p1, *p2; Z Z for (p1 = unixname, p2 = cpmname; *p1; p1++, p2++) { Z while (*p1 == '.') { Z p2 = cpmname + 8; Z p1++; Z } Z if (p2 - cpmname < 11) Z *p2 = islower(*p1) ? toupper(*p1) : *p1; Z else { Z fputs (unixname, stderr); Z fputs (": name truncated\n", stderr); Z break; Z } Z } Z while (p2 - cpmname < 11) Z *p2++ = ' '; Z} Z Z/* filarg - check if name matches argument list */ Zfilarg (name) Zchar *name; Z{ Z register int i; Z Z if (nfiles <= 0) Z return 1; Z Z for (i = 0; i < nfiles; i++) Z if (equal (name, fname[i])) { Z ftouched[i] = true; Z return 1; Z } Z Z return 0; Z} Z Znot_found () { Z register int i; Z Z for (i = 0; i < nfiles; i++) Z if (!ftouched[i]) { Z fputs(fname[i], stderr); Z fputs(": not in library.\n", stderr); Z errcnt++; Z } Z} Z Zextract(name) Zchar *name; Z{ Z getfiles(name, false); Z} Z Zprint(name) Zchar *name; Z{ Z getfiles(name, true); Z} Z Zgetall (libname) Zchar *libname; Z{ Z fildesc lfd, ofd; Z register int i; Z register struct ludir *lptr; Z union timer timeunion; Z extern int errno; Z char *unixname; Z Z if ((lfd = _open (libname, O_RDWR)) == SYS_ERROR) Z cant (libname); Z Z getdir (lfd); Z Z for (i = 1, lptr = &ldir[1]; i < nslots; i++, lptr++) { Z if(lptr->l_stat != ACTIVE) Z continue; Z unixname = getname (lptr->l_name, lptr->l_ext); Z fputs(unixname, stderr); Z ofd = _creat(unixname, 0); Z if (ofd == SYS_ERROR) { Z fputs (" - can't create", stderr); Z errcnt++; Z } Z else { Z VOID lseek (lfd, (long) lwtol (lptr->l_off), 0); Z acopy (lfd, ofd, lwtol (lptr->l_len)); Z timeunion.realtime = lwtol(lptr->l_datetime); Z VOID setftime(ofd, &(timeunion.ftimep)); Z VOID _close (ofd); Z } Z putc('\n', stderr); Z } Z VOID _close (lfd); Z not_found (); Z} Z Zgetfiles (name, pflag) Zchar *name; Zbool pflag; Z{ Z fildesc lfd, ofd; Z register int i; Z register struct ludir *lptr; Z union timer timeunion; Z extern int errno; Z char *unixname; Z Z if ((lfd = _open (name, O_RDWR)) == SYS_ERROR) Z cant (name); Z Z ofd = pflag ? fileno(stdout) : SYS_ERROR; Z getdir (lfd); Z Z for (i = 1, lptr = &ldir[1]; i < nslots; i++, lptr++) { Z if(lptr->l_stat != ACTIVE) Z continue; Z unixname = getname (lptr->l_name, lptr->l_ext); Z if (!filarg (unixname)) Z continue; Z fputs(unixname, stderr); Z if (ofd != fileno(stdout)) Z ofd = _creat(unixname, 0); Z if (ofd == SYS_ERROR) { Z fputs (" - can't create", stderr); Z errcnt++; Z } Z else { Z VOID lseek (lfd, (long) lwtol (lptr->l_off), 0); Z acopy (lfd, ofd, lwtol (lptr->l_len)); Z timeunion.realtime = lwtol(lptr->l_datetime); Z if (ofd != fileno(stdout)) { Z VOID setftime(ofd, &(timeunion.ftimep)); Z VOID _close (ofd); Z } Z } Z putc('\n', stderr); Z } Z VOID _close (lfd); Z not_found (); Z} Z Zacopy (fdi, fdo, nbytes) /* copy nbytes from fdi to fdo */ Zfildesc fdi, fdo; Zlong nbytes; Z{ Z register int btr, retval; Z char blockbuf[BLOCK]; Z Z for (btr = (nbytes > BLOCK) ? BLOCK : (int) nbytes; btr > 0; Z nbytes -= BLOCK, btr = (nbytes > BLOCK) ? BLOCK : (int) nbytes) { Z if ((retval = _read(fdi, blockbuf, btr)) != btr) { Z if( retval == 0 ) { Z error("Premature EOF\n"); Z } Z if( retval == SYS_ERROR) Z error ("Can't read"); Z } Z if ((retval = _write(fdo, blockbuf, btr)) != btr) { Z if( retval == SYS_ERROR ) Z error ("Write Error"); Z } Z } Z} Z Zupdate (name) Zchar *name; Z{ Z fildesc lfd; Z register int i; Z Z if ((lfd = _open(name, O_RDWR)) == SYS_ERROR) { Z if ((lfd = _creat (name, 0)) == SYS_ERROR) { Z cant (name); Z } Z else Z initdir (lfd); Z } Z else Z getdir (lfd); /* read old directory */ Z Z if(verbose) Z fputs ("Updating files:\n", stderr); Z for (i = 0; i < nfiles; i++) Z addfil (fname[i], lfd); Z if (errcnt == 0) Z putdir (lfd); Z else Z fputs("fatal errors - library not changed\n", stderr); Z VOID _close (lfd); Z} Z Zaddfil (name, lfd) Zchar *name; Zfildesc lfd; Z{ Z fildesc ifd; Z register int i; Z register struct ludir *lptr; Z long byteoffs, numbytes; Z union timer timeunion; Z Z if ((ifd = _open(name, O_RDWR)) == SYS_ERROR) { Z fputs("LAR: can't find ", stderr); Z fputs(name, stderr); Z fputs(" to add\n", stderr); Z errcnt++; Z return; Z } Z if(verbose) { Z fputs(name, stderr); Z fputs("\n", stderr); Z } Z for (i = 1, lptr = ldir+1; i < nslots; i++, lptr++) { Z if (equal( getname (lptr->l_name, lptr->l_ext), name) ) /* update */ Z break; Z if (lptr->l_stat != ACTIVE) Z break; Z } Z if (i >= nslots) { Z fputs(name, stderr); Z fputs(": can't add library is full\n",stderr); Z errcnt++; Z return; Z } Z Z lptr->l_stat = ACTIVE; Z putname (lptr->l_name, name); Z byteoffs = lseek(lfd, 0L, 2); /* append to end; return byte offset */ Z Z ltolw (lptr->l_off, byteoffs); Z numbytes = fcopy (ifd, lfd); Z ltolw (lptr->l_len, numbytes); Z getftime(ifd, &(timeunion.ftimep)); Z ltolw (lptr->l_datetime, timeunion.realtime); Z VOID _close (ifd); Z} Z Zlong fcopy (ifd, ofd) /* copy file ifd (file) to ofd (library) */ Zfildesc ifd, ofd; Z{ Z long total = 0L; Z register int n; Z char blockbuf[BLOCK]; Z Z while ( (n = _read(ifd, blockbuf, BLOCK)) > 0) { Z if (_write(ofd, blockbuf, n) != n) Z error("write error"); Z total += (long) n; Z } Z return total; Z} Z Zdelete (lname) Zchar *lname; Z{ Z fildesc f; Z register int i; Z register struct ludir *lptr; Z Z if ((f = _open(lname, O_RDWR)) == SYS_ERROR) Z cant (lname); Z Z if (nfiles <= 0) Z error("delete by name only"); Z Z getdir (f); Z for (i = 0, lptr = ldir; i < nslots; i++, lptr++) { Z if (!filarg ( getname (lptr->l_name, lptr->l_ext))) Z continue; Z lptr->l_stat = DELETED; Z } Z Z not_found(); Z if (errcnt > 0) Z fputs ("errors - library not updated\n", stderr); Z else Z putdir (f); Z VOID _close (f); Z} Z Zreorg (name) Zchar *name; Z{ Z fildesc olib, nlib; Z int oldsize, k; Z register struct ludir *optr; Z register int i, j; Z struct ludir odir[MAXFILES], *nptr; Z char tmpname[80], buf[10]; Z char *mktemp(); Z Z strcpy(tmpname, mktemp("libXXXXXX")); Z Z if( (olib = _open(name, O_RDWR)) == SYS_ERROR) Z cant(name); Z Z if( (nlib = _creat(tmpname, 0)) == SYS_ERROR) Z cant(tmpname); Z Z getdir(olib); Z fputs("Old library has ", stdout); Z itoa(oldsize = nslots, buf); Z fputs(buf, stdout); Z puts(" slots."); Z/* copy ldir into odir */ Z for(i = 0, optr = ldir, nptr = odir ; i < nslots ; i++, optr++, nptr++) Z movmem((char *) optr, (char *) nptr, sizeof(struct ludir)); Z/* reinit ldir */ Z initdir(nlib); Z errcnt = 0; Z Z/* copy odir's files into ldir */ Z for (i = j = 1, optr = odir+1; i < oldsize; i++, optr++) { Z if( optr->l_stat == ACTIVE ) { Z if(verbose) { Z fputs("Copying: ", stderr); Z for (k = 0; k < 8; k++) Z fputc(optr->l_name[k], stderr); Z fputc('.', stderr); Z for (k = 0; k < 3; k++) Z fputc(optr->l_ext[k], stderr); Z fputc('\n', stderr); Z } Z copyentry( optr, olib, &ldir[j], nlib); Z if (++j >= nslots) { Z errcnt++; Z fputs("Not enough room in new library\n", stderr); Z break; Z } Z } Z } Z Z VOID _close(olib); Z putdir(nlib); Z VOID _close (nlib); Z Z if(errcnt == 0) { Z if (unlink(name) < 0 || rename(tmpname, name) < 0) { Z cant(name); Z exit(1); Z } Z } Z else Z fputs("Errors, library not updated\n", stderr); Z VOID unlink(tmpname); Z} Z Zcopyentry( old, of, new, nf ) Zstruct ludir *old, *new; Zfildesc of, nf; Z{ Z long byteoffs, numbytes; Z register int btr; Z char blockbuf[BLOCK]; Z Z new->l_stat = ACTIVE; Z movmem(old->l_name, new->l_name, 8); /* copy name */ Z movmem(old->l_ext, new->l_ext, 3); /* copy extension */ Z numbytes = lwtol(old->l_datetime); /* copy date & time */ Z ltolw(new->l_datetime, numbytes); Z VOID lseek(of, (long) lwtol(old->l_off), 0); Z byteoffs = lseek(nf, 0L, 2); /* append to end; return new pos. */ Z Z ltolw (new->l_off, byteoffs); Z numbytes = lwtol(old->l_len); Z ltolw (new->l_len, numbytes); Z Z for (btr = (numbytes > BLOCK) ? BLOCK : (int) numbytes; btr > 0; Z numbytes -= BLOCK, btr = (numbytes > BLOCK) ? BLOCK : (int) numbytes Z ) { Z if (_read(of, blockbuf, btr) != btr) { Z error ("Read Error in CopyEntry"); Z } Z if (_write(nf, blockbuf, btr) != btr) { Z error ("Write Error in CopyEntry"); Z } Z } Z} STUNKYFLUFF set `sum lar.c` if test 33295 != $1 then echo lar.c: Checksum error. Is: $1, should be: 33295. fi # # echo Extracting lar.h: sed 's/^Z//' >lar.h <<\STUNKYFLUFF Z/* LAR Version 2.0 */ Z Z#include Z#include Z#include Z Z#ifdef MSDOS Z# include Z# include Z#endif Z Z#define ACTIVE 00 Z#define UNUSED 0xff Z#define DELETED 0xfe Z Z#define MAXFILES (256) Z#define BLOCK (8192) Z#define DSIZE (sizeof(struct ludir)) Z Z#define equal(s1,s2) (strcmp(s1,s2)==0) Z Z/* if you don't have void type just define as int */ Z#define VOID void Z Z#define false (0) Z#define true ((char)0xff) Ztypedef unsigned char bool; Ztypedef unsigned char byte; Z Ztypedef struct { Z byte hibyte; Z byte mbyte2; Z byte mbyte1; Z byte lobyte; Z} lword; Z Ztypedef struct { Z byte hibyte; Z byte lobyte; Z} word; Z Z/* convert word to int */ Z#define wtoi(w) ((w.hibyte<<8)+w.lobyte) Z Z/* convert int to word */ Z#define itow(dst,src) (dst.hibyte=((src & 0xff00)>>8),dst.lobyte=(src&0x00ff)) Z Z/* convert lword to long */ Z/* works, but is much slower than stupid assembler routine Z#define lwtol(lw) (((long)lw.hibyte<<24)+((long)lw.mbyte2<<16)+((long)lw.mbyte1<<8)+(long)lw.lobyte) Z*/ Z Z Z/* cheap hack */ Zlong rlwtol (); Z#define lwtol(lw) rlwtol(&lw) Z Z#define ltolw(dst,src) (dst.hibyte = ((src & 0xff000000L) >> 24);\ Z dst.mbyte2 = ((src & 0x00ff0000L) >> 16);\ Z dst.mbyte1 = ((src & 0x0000ff00L) >> 8);\ Z dst.lobyte = (src & 0x000000ffL);) Z Z#ifdef MSDOS Zunion timer { Z struct ftime ftimep; Z long realtime; Z}; Z#endif Z Ztypedef int fildesc; Z Zstruct ludir { /* Internal library ldir structure */ Z byte l_stat; /* status of file */ Z byte l_name[8]; /* name */ Z byte l_ext[3]; /* extension */ Z lword l_off; /* offset in library */ Z lword l_len; /* length of file */ Z lword l_datetime; /* date and time of file. */ Z byte l_attrib; /* attributes of file */ Z byte l_startvol; /* starting disk number */ Z byte l_endvol; /* ending volume number */ Z word l_cksum; /* crc checksum */ Z char l_fill[3]; /* pad to 32 bytes */ Z}; Z Z#define SYS_ERROR (-1) STUNKYFLUFF set `sum lar.h` if test 06463 != $1 then echo lar.h: Checksum error. Is: $1, should be: 06463. fi # # echo Extracting lwtol.c: sed 's/^Z//' >lwtol.c <<\STUNKYFLUFF Z#include "lar.h" Z/* cheap hack */ Z Zlong rlwtol (lwa) Zregister lword *lwa; Z{ Z#ifdef ibmpc Z asm mov dh,[lwa] /* hibyte */ Z asm mov dl,[lwa + 1] /* mbyte1 */ Z asm mov ah,[lwa + 2] /* mbyte2 */ Z asm mov al,[lwa + 3] /* lobyte */ Z#else Z fprintf (stderr, "urk!! -- rlwtol not implemented, bye\n"); Z exit (1); Z#endif Z} STUNKYFLUFF set `sum lwtol.c` if test 05248 != $1 then echo lwtol.c: Checksum error. Is: $1, should be: 05248. fi echo ALL DONE BUNKY! exit 0