Path: utzoo!attcan!uunet!mcvax!hp4nl!philmds!prle!cstw01!meulenbr From: meulenbr@cstw01.UUCP (Frans Meulenbroeks) Newsgroups: comp.os.minix Subject: (ST) patches for arc Message-ID: <320@cstw01.UUCP> Date: 14 Dec 88 09:16:39 GMT Reply-To: meulenbr@cst.UUCP () Organization: Centre for Software Technology, Philips Eindhoven Lines: 576 Hi! Here are some patches to get arc running under Minix ST. The patches are against arc 5.21 with the updates send out by Howard Chu. However it might work with the original 5.21 sources as well Initially the port was done using the native c compiler. Therefore an own created mktime is added, to overcome the problems with doubles in tmclock.c Later the latest update from Howard was added, and the gcc Makefile was created. I see no reason why it would not work under minix/cc any more. However, I have not tested this any more. Feel free to experiment. The archive contains: A Makefile for gcc. 4 context diffs for arc a subdirectory minix with a makefile and 4 additional routines. What you need to supply: arc 5.21 (posted to comp.sources.unix some time ago) Doug Gwyn's portable dir lib (posted several times) together with Jwahar Bammi's updates (posted 27 nov in this group) If you don't have these, and are only a few hops from me away, drop me a note, and I'll see if we can work something out. Apply: copy your arc files to some other place. Go to that dir create a subdir minix unshar the remainder of this archive. Look into the makefiles in the minix subdir and the arc dir, and modify them as seems appropriate. Look especially at CC. Hit make with the appropriate makefile. credits: Of course major credit goes to Howard Chu for doing the TOS port of arc. Some of the routines of minix come from the Sysvarcstuff. Also a lot of credit goes to Jwahar Bammi. He did the testing, created the makefiles for gnu, modified things to use Doug Gwyn's dir lib, and supplied also some stuff in the minix dir. (The only thing which came from me is mktime.c) Thank you very much Jwahar and Howard! disclaimer: I have not tested this very thoroughly after applying the latest fixes. All I can say is that it works on my system. I want to emphasize that I only use arc, and have never even looked into the marc stuff. If you want that, feel free to try it. I see no reason why this stuff won't work with minix/cc or on a PC. However no guarantees. Feel free to share this code. However, as usual, no warranty. Frans (signature at end) # This is a shell archive. # Remove everything above and including the cut line. # Then run the rest of the file through sh. -----cut here-----cut here-----cut here-----cut here----- #!/bin/sh # shar: Shell Archiver # Run the following text with /bin/sh to create: # Makefile.gcc # arccode.c.cdiff # arccvt.c.cdiff # arcdos.c.cdiff # arcmisc.c.cdiff # minix/Makefile.gcc # minix/mktime.c # minix/rename.c # minix/scandir.c # minix/utimes.c # This archive created: Wed Dec 14 09:49:48 1988 sed 's/^X//' << \SHAR_EOF > Makefile.gcc X# X# Makefile for Hack-attack 1.3 X# VAX 11/780 BSD4.2 "ARC" utility X# X# Originals from Dan Lanciani, James Turner, and others... X# X# Modified to support squashing, also added targets for the time routine X# library. -- Howard Chu, hyc@umix.cc.umich.edu, 4-11-88 X# X# Modified again by John Gilmore & Howard Chu, July 1988. X# X# I put SRCDIR on a real disk on the ST, but copy the makefile to a X# RAMdisk and compile from there. Makes things go a bit quicker... X# This has to be done in the shell, to get the trailing backslash X# specified correctly. e.g., setenv SRCDIR='d:\src\arc\' XSRCDIR = X XHEADER = $(SRCDIR)arc.h $(SRCDIR)arcs.h X X# Add a ".TTP" suffix to the executable files on an ST. X#PROG = .ttp XPROG = X X# SYSTEM defines your operating system: X# MSDOS for IBM PCs or other MSDOS machines X# GEMDOS for Atari ST (Predefined by MWC, so you don't need to define it.) X# BSD for Berkeley Unix X# SYSV for AT&T System V Unix X# (MTS for Michigan Terminal System, which requires a different makefile) X# (MTS also requires one of USEGFINFO or USECATSCAN for directory search) X# for minix use BSD and MINIX XSYSTEM = -DBSD=1 -DMINIX X X# For MWC 3.0 on the Atari ST, use: X#CFLAGS = -VCOMPAC -VPEEP XCFLAGS = -mshort -O $(SYSTEM) X X# Minix GCC need LDFLAGS to pick up correct library objects XLDFLAGS = -mshort X# doug gwyns portable dir library XDIR = -ldir X X# GNU's gcc is very nice, if you've got it. Otherwise just cc. XCC = mgcc X X# tmclock is only needed on Unix systems... but not on MINIX XTMCLOCK = X XOBJS = arc.o arcadd.o arccode.o arccvt.o arcdata.o arcdel.o arcdos.o \ Xarcext.o arcio.o arclst.o arclzw.o arcmatch.o arcpack.o arcrun.o \ Xarcsq.o arcsqs.o arcsvc.o arctst.o arcunp.o arcusq.o arcmisc.o X XMOBJ = marc.o arcdata.o arcdos.o arcio.o arcmatch.o arcmisc.o X Xarc$(PROG): $(OBJS) $(TMCLOCK) minix.a X $(CC) -o arc$(PROG) $(OBJS) $(TMCLOCK) minix.a $(DIR) $(LDFLAGS) X Xmarc$(PROG): $(MOBJ) $(TMCLOCK) minix.a X $(CC) -o marc$(PROG) $(MOBJ) $(TMCLOCK) minix.a $(DIR) $(LDFLAGS) X Xclean: X -rm *.o arc$(PROG) marc$(PROG) X Xarc.o: $(SRCDIR)arc.c $(HEADER) X $(CC) $(CFLAGS) -c $(SRCDIR)arc.c Xmarc.o: $(SRCDIR)marc.c $(HEADER) X $(CC) $(CFLAGS) -c $(SRCDIR)marc.c Xarcadd.o: $(SRCDIR)arcadd.c $(HEADER) X $(CC) $(CFLAGS) -c $(SRCDIR)arcadd.c Xarccode.o: $(SRCDIR)arccode.c $(HEADER) X $(CC) $(CFLAGS) -c $(SRCDIR)arccode.c Xarccvt.o: $(SRCDIR)arccvt.c $(HEADER) X $(CC) $(CFLAGS) -c $(SRCDIR)arccvt.c Xarcdata.o: $(SRCDIR)arcdata.c $(HEADER) X $(CC) $(CFLAGS) -c $(SRCDIR)arcdata.c Xarcdel.o: $(SRCDIR)arcdel.c $(HEADER) X $(CC) $(CFLAGS) -c $(SRCDIR)arcdel.c Xarcdir.o: $(SRCDIR)arcdir.c $(HEADER) X $(CC) $(CFLAGS) -c $(SRCDIR)arcdir.c Xarcdos.o: $(SRCDIR)arcdos.c $(HEADER) $(TWHEAD) X $(CC) $(CFLAGS) -c $(SRCDIR)arcdos.c Xarcext.o: $(SRCDIR)arcext.c $(HEADER) X $(CC) $(CFLAGS) -c $(SRCDIR)arcext.c Xarcio.o: $(SRCDIR)arcio.c $(HEADER) X $(CC) $(CFLAGS) -c $(SRCDIR)arcio.c Xarclst.o: $(SRCDIR)arclst.c $(HEADER) X $(CC) $(CFLAGS) -c $(SRCDIR)arclst.c Xarclzw.o: $(SRCDIR)arclzw.c $(HEADER) X $(CC) $(CFLAGS) -c $(SRCDIR)arclzw.c Xarcmatch.o: $(SRCDIR)arcmatch.c $(HEADER) X $(CC) $(CFLAGS) -c $(SRCDIR)arcmatch.c Xarcmisc.o: $(SRCDIR)arcmisc.c $(HEADER) X $(CC) $(CFLAGS) -c $(SRCDIR)arcmisc.c Xarcpack.o: $(SRCDIR)arcpack.c $(HEADER) X $(CC) $(CFLAGS) -c $(SRCDIR)arcpack.c Xarcrun.o: $(SRCDIR)arcrun.c $(HEADER) X $(CC) $(CFLAGS) -c $(SRCDIR)arcrun.c Xarcsq.o: $(SRCDIR)arcsq.c $(HEADER) X $(CC) $(CFLAGS) -c $(SRCDIR)arcsq.c Xarcsqs.o: $(SRCDIR)arcsqs.c $(HEADER) X $(CC) $(CFLAGS) -c $(SRCDIR)arcsqs.c Xarcsvc.o: $(SRCDIR)arcsvc.c $(HEADER) X $(CC) $(CFLAGS) -c $(SRCDIR)arcsvc.c Xarctst.o: $(SRCDIR)arctst.c $(HEADER) X $(CC) $(CFLAGS) -c $(SRCDIR)arctst.c Xarcunp.o: $(SRCDIR)arcunp.c $(HEADER) X $(CC) $(CFLAGS) -c $(SRCDIR)arcunp.c Xarcusq.o: $(SRCDIR)arcusq.c $(HEADER) X $(CC) $(CFLAGS) -c $(SRCDIR)arcusq.c X Xtmclock.o: $(SRCDIR)tmclock.c X $(CC) $(CFLAGS) -c $(SRCDIR)tmclock.c X Xminix.a: X cd minix; make -f Makefile.gcc minix.a; cp minix.a .. SHAR_EOF sed 's/^X//' << \SHAR_EOF > arccode.c.cdiff X*** arccode.c.orig Thu Oct 27 09:14:21 1988 X--- arccode.c Tue Dec 13 14:52:28 1988 X*************** X*** 32,38 **** X X unsigned char X code(c) /* encode some character */ X! char c; /* character to encode */ X { X if (p) { /* if password is in use */ X if (!*p) /* if we reached the end */ X--- 32,38 ---- X X unsigned char X code(c) /* encode some character */ X! int c; /* character to encode */ X { X if (p) { /* if password is in use */ X if (!*p) /* if we reached the end */ SHAR_EOF sed 's/^X//' << \SHAR_EOF > arccvt.c.cdiff X*** arccvt.c.orig Thu Oct 27 09:14:21 1988 X--- arccvt.c Tue Dec 13 14:52:35 1988 X*************** X*** 95,101 **** X long starts, ftell(); /* where the file goes */ X FILE *tmp, *fopen(); /* temporary file */ X X! if (!(tmp = fopen(tempname, "w+b"))) X abort("Unable to create temporary file %s", tempname); X X if (note) { X--- 95,101 ---- X long starts, ftell(); /* where the file goes */ X FILE *tmp, *fopen(); /* temporary file */ X X! if (!(tmp = fopen(tempname, "wb"))) X abort("Unable to create temporary file %s", tempname); X X if (note) { X*************** X*** 103,109 **** X fflush(stdout); X } X unpack(arc, tmp, hdr); /* unpack the entry */ X! fseek(tmp, 0L, 0); /* reset temp for reading */ X X starts = ftell(new); /* note where header goes */ X hdrver = ARCVER; /* anything but end marker */ X--- 103,111 ---- X fflush(stdout); X } X unpack(arc, tmp, hdr); /* unpack the entry */ X! fclose(tmp); X! if (!(tmp = fopen(tempname, "rb"))) X! abort("Unable to open temporary file %s", tempname); X X starts = ftell(new); /* note where header goes */ X hdrver = ARCVER; /* anything but end marker */ SHAR_EOF sed 's/^X//' << \SHAR_EOF > arcdos.c.cdiff X*** arcdos.c.orig Thu Oct 27 09:14:22 1988 X--- arcdos.c Tue Dec 13 14:52:41 1988 X*************** X*** 167,172 **** X--- 167,178 ---- X struct tm tm; X struct timeval tvp[2]; X int utimes(); X+ #ifdef MINIX X+ long mktime(); X+ #else X+ long tmclock(); X+ #endif X+ X tm.tm_sec = (time & 31) * 2; X tm.tm_min = (time >> 5) & 63; X tm.tm_hour = (time >> 11); X*************** X*** 173,182 **** X tm.tm_mday = date & 31; X tm.tm_mon = ((date >> 5) & 15) - 1; X tm.tm_year = (date >> 9) + 80; X tvp[0].tv_sec = tmclock(&tm); X tvp[1].tv_sec = tvp[0].tv_sec; X! tvp[0].tv_usec = tvp[1].tv_usec = 0; X! utimes(f, tvp); X #endif X } X X--- 179,193 ---- X tm.tm_mday = date & 31; X tm.tm_mon = ((date >> 5) & 15) - 1; X tm.tm_year = (date >> 9) + 80; X+ #ifdef MINIX X+ tvp[0].tv_sec = mktime(&tm); X+ #else X tvp[0].tv_sec = tmclock(&tm); X+ #endif X tvp[1].tv_sec = tvp[0].tv_sec; X! tvp[0].tv_usec = tvp[1].tv_usec = 0L; X! utimes(f, tvp); X! X #endif X } X SHAR_EOF sed 's/^X//' << \SHAR_EOF > arcmisc.c.cdiff X*** arcmisc.c.orig Thu Oct 27 09:14:24 1988 X--- arcmisc.c Tue Dec 13 14:49:34 1988 X*************** X*** 53,59 **** X--- 53,64 ---- X X #if UNIX X #include X+ #if MINIX X+ #include X+ #define DIRECT dirent X+ #else X #include X+ #endif X #include X int rename(), unlink(); X #endif X*************** X*** 62,69 **** X--- 67,76 ---- X #include X #define DIRECT dirent X #else X+ #ifndef MINIX X #define DIRECT direct X #endif X+ #endif X X #if BSD X char * X*************** X*** 180,186 **** X return ((char *) &result[0]); X } X X! #if MSDOS || SYSV X X int X alphasort(dirptr1, dirptr2) X--- 187,193 ---- X return ((char *) &result[0]); X } X X! #if MSDOS || SYSV || MINIX X X int X alphasort(dirptr1, dirptr2) SHAR_EOF sed 's/^X//' << \SHAR_EOF > minix/Makefile.gcc XAR = car XCC = mgcc XCFLAGS = -O -mshort X XOBJ = mktime.o rename.o scandir.o utimes.o X Xminix.a : $(OBJ) X rm -f minix.a X $(AR) srv minix.a $(OBJ) SHAR_EOF sed 's/^X//' << \SHAR_EOF > minix/mktime.c X#include X#include X X#define SECPERDAY 24*60*60L X Xstatic long yeartab[61] = X { SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 366, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 366, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 366, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 366, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 366, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 366, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 366, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 366, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 366, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 366, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 366, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 366, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 366, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 366, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 365, X SECPERDAY * 366, X SECPERDAY * 365, X SECPERDAY * 365 X }; X Xtime_t mktime(tmptr) Xstruct tm *tmptr; X{ X long res; X X res = yeartab[tmptr->tm_year - 70] + X tmptr->tm_yday * SECPERDAY + X tmptr->tm_hour * 3600L + X tmptr->tm_min * 60 + X tmptr->tm_sec; X X return(res); X} SHAR_EOF sed 's/^X//' << \SHAR_EOF > minix/rename.c X/* X * substitute for BSD/SVR3 rename() system call, from X * Janet Walz, walz@mimsy.umd.edu & Rich Salz, rsalz@pineapple.bbn.com X */ X Xint rename(oldname,newname) Xchar *oldname,*newname; X{ X (void)unlink(newname); X if(link(oldname,newname)) X return(-1); X return(unlink(oldname)); X} SHAR_EOF sed 's/^X//' << \SHAR_EOF > minix/scandir.c X/* X** SCANDIR X** Scan a directory, collecting all (selected) items into a an array. X*/ X#include X#include X#include X X#ifdef RCSID Xstatic char RCS[] = "$Header: scandir.c,v 1.1 87/12/29 21:35:56 rsalz Exp $"; X#endif /* RCSID */ X X/* Initial guess at directory size. */ X#define INITIAL_SIZE 20 X X/* A convenient shorthand. */ Xtypedef struct dirent ENTRY; X X/* Linked in later. */ Xextern char *malloc(); Xextern char *realloc(); Xextern char *strcpy(); X X Xint Xscandir(Name, List, Selector, Sorter) X char *Name; X ENTRY ***List; X int (*Selector)(); X int (*Sorter)(); X{ X register ENTRY **names; X register ENTRY *E; X register DIR *Dp; X register int i; X register int size; X X /* Get initial list space and open directory. */ X size = INITIAL_SIZE; X if ((names = (ENTRY **)malloc(size * sizeof names[0])) == NULL X || (Dp = opendir(Name)) == NULL) X return(-1); X X /* Read entries in the directory. */ X for (i = 0; E = readdir(Dp); ) X if (Selector == NULL || (*Selector)(E)) { X /* User wants them all, or he wants this one. */ X if (++i >= size) { X size <<= 1; X names = (ENTRY **)realloc((char *)names, size * sizeof names[0]); X if (names == NULL) { X closedir(Dp); X return(-1); X } X } X X /* Copy the entry. */ X#ifdef atarist X if ((names[i - 1] = (ENTRY *)malloc(DIRSIZ)) == NULL) { X#else X if ((names[i - 1] = (ENTRY *)malloc(E->d_reclen)) == NULL) { X#endif X closedir(Dp); X return(-1); X } X names[i - 1]->d_ino = E->d_ino; X#ifndef atarist X names[i - 1]->d_off = E->d_off; X names[i - 1]->d_reclen = E->d_reclen; X#endif X /* names[i - 1]->d_namlen = E->d_namlen; */ X (void)strcpy(names[i - 1]->d_name, E->d_name); X } X X /* Close things off. */ X names[i] = NULL; X *List = names; X closedir(Dp); X X /* Sort? */ X if (i && Sorter) X qsort((char *)names, i, sizeof names[0], Sorter); X X return(i); X} SHAR_EOF sed 's/^X//' << \SHAR_EOF > minix/utimes.c X X/* bsd utimes emulation for Sys V */ X/* by Jon Zeeff */ X X#include X X Xstruct timeval { X long tv_sec; X long tv_usec; X}; X Xutimes(path,tvp) Xchar *path; Xstruct timeval tvp[2]; X{ X time_t utimbuf[2]; X X utimbuf[0] = (time_t) tvp[0].tv_sec; X utimbuf[1] = (time_t) tvp[1].tv_sec; X X return utime(path,utimbuf); X} SHAR_EOF # End of shell archive exit 0 -- Frans Meulenbroeks (meulenbr@cst.prl.philips.nl) Centre for Software Technology ( or try: ...!mcvax!philmds!prle!cst!meulenbr)