[net.sources] arc.shar.01

stu@jpusa1.UUCP (Stu Heiss) (09/30/86)

This is a resubmission of the arc 5.12 sources posted by Mike Farren.

WARNING!!!

Although I've managed to get this running on a 68k Unisoft (sys 5) box,
the code is not thoroughly tested.  I *do* know that it will handle
crunched files and am pretty sure packed also.  Some of the other formats
have not been tested although it probably works.  This program makes
assumptions about sizeof and endedness.  It was written for CI-C86
(8086 architecture) where sizeof and endedness is different for just about any
datatype than on a 68k box.  Since it works at all, I've probably caught most
(all?) of the dependencies.  The troublesome code is mostly (all?) in
arcunix.c which replaces arcdos.mac and arcdir.mac.  I've done the
typedefs for this machine only, but porting to others should now be
simple.  The most troublesome part is dealing with the arc headers
as you have to read the header into a buffer and parse it into a
structure.  I have, of course, converted the source to *not* need the
obscure macro processor.  The orriginal arcdos.mac and arcdir.mac are
included at the end of this for the sake of completeness.  They are not
converted.  I *have not* tried to get marc or xarc going although the
Makefile would lead you to believe otherwise.  They're of little use under
unix anyway.  Thanks to the poster of tm_to_time.c (included also) as
this is necessary for the time/date conversions between dos/unix.  Sorry
I can't remember who it was.

Following is a disclaimer from Mike's orriginal posting... - Stu

**** FLAMEPROOF SUIT ON ****

This is NOT a public domain program, but is copyrighted by System Enhancements
Associates.  They have released the compiled program as shareware, meaning 
that payment is NOT required for the program, but IS solicited.  I have
received explicit permission from Thom Henderson, the author of this program,
to post these sources.  No commercial intent is here, so please don't look
for it!

**** FLAMEPROOF SUIT OFF ***

Some notes towards a UNIX version of ARC:

1.  These sources represent the MS-DOS version of ARC.  As such, they have a
    few of the MS-DOS limitations, i.e., eight-letter filenames with a three-
    letter extension, limited use of pathnames, and assumption of a single-
    user, single task OS.  It would be nice to address these limitations
    for a UNIX version.

2.  The sources are not, strictly speaking, C sources.  They need to be
    preprocessed by a macro preprocesser.  The preprocessor used to produce
    them is called MACRO, and is a commercial product of SEA, the producers
    of ARC.  It should be a simple task to fake it, though, as the preprocessor
    does not appear to have been used extensively.

-------------

#       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:
#	arcdir.mac
#	arcdos.mac
echo shar: extracting arcdir.mac '(2310 characters)'
sed 's/^XX//' << \SHAR_EOF > arcdir.mac
XX/*  ARC - Archive utility - ARCDIR
XX
XX$define(tag,$$segment(@1,$$index(@1,=)+1))#
XX$define(version,Version $tag(
XXTED_VERSION DB =1.02), created on $tag(
XXTED_DATE DB =02/04/86) at $tag(
XXTED_TIME DB =01:36:09))#
XX$undefine(tag)#
XX    $version
XX
XX(C) COPYRIGHT 1985 by System Enhancement Associates; ALL RIGHTS RESERVED
XX
XX    By:  Thom Henderson
XX
XX    Description:
XX         This file contains the dir() routine used when adding files to an
XX         archive.  It is an adaptation of the CI-C86 library function
XX         filedir().  It differes in that it returns the file names one by
XX         one, instead of all at once.
XX
XX    Language:
XX         Computer Innovations Optimizing C86
XX*/
XX#include <stdio.h>
XX
XXstatic struct
XX{   char dummy[21];                    /* reserved for dos */
XX    unsigned char attribute;           /* returned attribute */
XX    unsigned time;
XX    unsigned date;
XX    long size;                         /* size of file */
XX    unsigned char fn[13];              /* string containing the filename */
XX}   ff_area;
XX
XXchar *dir(filename,mode)               /* get files, one by one */
XXchar *filename;                        /* template, or NULL */
XXint mode;                              /* search mode bits */
XX{
XX    struct { int ax,bx,cx,dx,si,di,ds,es; } reg;
XX    char *result, *alloc();
XX    static int first = 1;              /* true only on first call */
XX
XX#ifdef _C86_BIG
XX    reg.ds = ((unsigned long)filename) >> 16;
XX#else
XX    segread(&reg.si);                  /* get ds value */
XX#endif
XX    if(filename)                       /* if filename is given */
XX    {    reg.dx = filename;            /* then use it */
XX         reg.ax = 0x4e00;              /* and search for first */
XX    }
XX    else if(first)                     /* if no name and first call */
XX         return NULL;                  /* then not much we can do */
XX    else reg.ax = 0x4f00;              /* else search for next */
XX    first = 0;                         /* no longer first time */
XX
XX    reg.cx = mode;                     /* set search modes */
XX    bdos(0x1a,&ff_area);               /* set the transfer address */
XX
XX    if(sysint21(&reg,&reg)&1)
XX         return NULL;                  /* no more files */
XX
XX    result = alloc(strlen(ff_area.fn)+1);
XX    strcpy(result,ff_area.fn);         /* save name of file */
XX    return result;
XX}
SHAR_EOF
if test 2310 -ne "`wc -c arcdir.mac`"
then
echo shar: error transmitting arcdir.mac '(should have been 2310 characters)'
fi
echo shar: extracting arcdos.mac '(2261 characters)'
sed 's/^XX//' << \SHAR_EOF > arcdos.mac
XX/*  ARC - Archive utility - ARCDOS
XX
XX$define(tag,$$segment(@1,$$index(@1,=)+1))#
XX$define(version,Version $tag(
XXTED_VERSION DB =1.43), created on $tag(
XXTED_DATE DB =11/09/85) at $tag(
XXTED_TIME DB =22:24:44))#
XX$undefine(tag)#
XX    $version
XX
XX(C) COPYRIGHT 1985 by System Enhancement Associates; ALL RIGHTS RESERVED
XX
XX    By:  Thom Henderson
XX
XX    Description:
XX         This file contains certain DOS level routines that assist
XX         in doing fancy things with an archive, primarily reading and
XX         setting the date and time last modified.
XX
XX         These are, by nature, system dependant functions.  But they are
XX         also, by nature, very expendable.
XX
XX    Language:
XX         Computer Innovations Optimizing C86
XX*/
XX#include <stdio.h>
XX#include "arc.h"
XX#include "fileio2.h"                   /* needed for filehand */
XX
XXgetstamp(f,date,time)                  /* get a file's date/time stamp */
XXFILE *f;                               /* file to get stamp from */
XXunsigned int *date, *time;             /* storage for the stamp */
XX{
XX    struct {int ax,bx,cx,dx,si,di,ds,es;} reg;
XX
XX    reg.ax = 0x5700;                   /* get date/time */
XX    reg.bx = filehand(f);              /* file handle */
XX    if(sysint21(&reg,&reg)&1)          /* DOS call */
XX         printf("Get timestamp fail (%d)\n",reg.ax);
XX
XX    *date = reg.dx;                    /* save date/time */
XX    *time = reg.cx;
XX}
XX
XXsetstamp(f,date,time)                  /* set a file's date/time stamp */
XXFILE *f;                               /* file to set stamp on */
XXunsigned int date, time;               /* desired date, time */
XX{
XX    struct {int ax,bx,cx,dx,si,di,ds,es;} reg;
XX
XX    fflush(f);                         /* force any pending output */
XX
XX    reg.ax = 0x5701;                   /* set date/time */
XX    reg.bx = filehand(f);              /* file handle */
XX    reg.cx = time;                     /* desired time */
XX    reg.dx = date;                     /* desired date */
XX    if(sysint21(&reg,&reg)&1)          /* DOS call */
XX         printf("Set timestamp fail (%d)\n",reg.ax);
XX}
XX
XXstatic int filehand(stream)            /* find handle on a file */
XXstruct bufstr *stream;                 /* file to grab onto */
XX{
XX    return stream->bufhand;            /* return DOS 2.0 file handle */
XX}
SHAR_EOF
if test 2261 -ne "`wc -c arcdos.mac`"
then
echo shar: error transmitting arcdos.mac '(should have been 2261 characters)'
fi
#	End of shell archive
exit 0
-- 
Stu Heiss {ihnp4!jpusa1!stu}