Shar for iRMX86 systems
pete at stc.co.uk
pete at stc.co.uk
Wed Jul 30 23:02:59 AEST 1986
This is a version of shar for Intel systems running iRMX86.
I use it for packing sources that I've developed on my
86/330 into a handy form for downloading to the VAX 11/785
for putting under SCCS.
I would appreciate email if:
- You download this program and find it useful.
- You find bug(s).
- You think that there is insufficient demand for iRMX86
software to justify posting it to net.sources. Please be
reasonable in your flaming. I tend to ignore rants.
IMPORTANT NOTE.
You will need to modify LQMAIN.A86 and reassemble it. The
reason for this is that LQMAIN.A86 attempts to provide
a UNIX-style argc,argv,envp set of arguments for main().
This defeats the Human Interface command line parsing calls.
I cannot post my modified copy as it is copyright Mark
Williams (and probably Intel as well) so I can only indicate
what needs to be done:
You should remove all the argc, argv code and the call to
FREDIR. Then assemble it with asm86.
You will need to edit SHAR.CSD to reflect your own setup.
Then compile and link it with SUBMIT SHAR.
SHAR.HLP belongs in your /helps directory, SHAR in /utils.
Peter Kendell <pete at tcom.stc.co.uk>
...!mcvax!ukc!stc!pete
"Lord Finchley tried to mend the Electric Light,
Himself.
It Struck him Dead! And Serve him Right!
It is the Duty of the Wealthy Man,
To give Employment to the Artisan."
-----Cut Here-----Cut Here-----Cut Here-----Cut Here-----
#!/bin/sh
# shar: Shell Archiver
# Run the following text with /bin/sh to create:
#
# shar.hlp
# shar.c
# shar.csd
echo x - extracting shar.hlp
sed 's/^X//' << 'SHAR_EOF' > shar.hlp
X SYNTAX TYPE: command
X shar pathnames [TO/OVER/AFTER pathname]
X VERBOSE
X CUT
X DELIMITER = delim
X
X PARAMETERS
X VERBOSE Display names of files in the archive during packing
X and extraction.
X CUT Put a --Cut here-- line at the start of the archive.
X DELIMITER Put an alternative delimiter string at the end of
X each file in the archive. Default is SHAR_EOF.
X
X DESCRIPTION
X Build a shell archive for distribution of a set of human-readable
X files. The archive is unpacked by feeding it to the Bourne shell
X on a UNIX* system. The default name for the archive file is SHAR.OUT.
X
X REFERENCES
X None
X
X AUTHOR
X Peter Kendell (Based on code written by Michael A. Thomson).
X
X PROBLEMS OR RESTRICTIONS
X No more than 64 files may be packed into an archive.
X
X *UNIX is a trademark of AT&T in the USA and other countries.T
SHAR_EOF
echo x - extracting shar.c
sed 's/^X//' << 'SHAR_EOF' > shar.c
X/*
X** cshar.c
X*/
X
X/*
XShar puts readable text files together in a package
Xfrom which they are easy to extract. The original version
Xwas a shell script posted to the net, shown below:
X #Date: Mon Oct 18 11:08:34 1982
X #From: decvax!microsof!uw-beave!jim (James Gosling at CMU)
X AR=$1
X shift
X for i do
X echo a - $i
X echo "echo x - $i" >>$AR
X echo "cat >$i <<'!Funky!Stuff!'" >>$AR
X cat $i >>$AR
X echo "!Funky!Stuff!" >>$AR
X done
XI rewrote this version in C to provide better diagnostics
Xand to run faster. The main difference is that my version
Xdoes not affect any files because it prints to the standard
Xoutput. Mine also has a -v (verbose) option.
X*/
X/*
X * I have made several mods to this program:
X *
X * 1) the -----cut Here-----... now preceds the script.
X * 2) the cat has been changed to a sed which removes a prefix
X * character from the beginning of each line of the extracted
X * file, this prefix character is added to each line of the archived
X * files and is not the same as the first character of the
X * file delimeter.
X * 3) added several options:
X * -c - add the -----cut Here-----... line.
X * -d'del' - change the file delimeter to del.
X *
X * Michael A. Thompson
X * Dalhousie University
X * Halifax, N.S., Canada.
X */
X
X/*
X * I fixed this for iRMX86 by removing all *IX type calls,
X * in particular, this version cannot generate checksums.
X * I've also added HI based command line parsing and overwrite
X * checking.
X *
X * Peter Kendell STC July 1986
X */
X
X#include <stdio.h>
X#include <udi.h>
X
X#define TRUE 1
X#define FALSE 0
X
X#define TO 1
X#define OVER 2
X#define AFTER 3
X
X#define DELIM "SHAR_EOF"/* put after each file */
X#define PREFIX1 'X' /* goes in front of each line */
X#define PREFIX2 'Y' /* goes in front of each line if delim
X starts with PREFIX1 */
X#define PREFIX (delim[0] == PREFIX1 ? PREFIX2 : PREFIX1)
X#define INPATHS 64 /* Max no of files to shar */
X
Xunsigned status; /* result of RMX call */
X
Xstatic char delim[16], /* option to provide alternate delimiter */
X progname[64]; /* This program's name */
X
Xchar *program; /* The name used in error messages */
X
Xint cut = FALSE, /* option to provide -cut here- line */
X verbose = FALSE; /* option to provide append/extract feedback */
X
XFILE *outfile; /* Where the shared stuff goes */
X
Xextern char *malloc (),
X rq$c$get$parameter (),
X rq$c$get$output$pathname ();
X
Xextern void rq$c$get$input$pathname (),
X rq$c$get$command$name (),
X rq$s$delete$connection (),
X usage ();
X
Xextern connection rq$c$get$output$connection ();
X
X
Xvoid dummy_exception_handler ()
X
X/*
X * Just to stop RMX barfing when a system call doesn't return E$OK
X */
X
X{}
X
X
Xint main ()
X
X{
X int result = FALSE,
X argc;
X
X char *argv[INPATHS],
X **av,
X indexp,
X preposition;
X
X static char inpath[256],
X outpath[64],
X name[16],
X val[16];
X
X connection conn;
X
X/*
X * Kill the exception handler and get the name of this program.
X */
X
X dq$trap$exception (dummy_exception_handler, &status);
X rq$c$get$command$name (progname, (sizeof progname) - 1, &status);
X
X for (
X program = progname + strlen (progname);
X program >= progname;
X program--
X )
X if (*program == ':' || *program == '/')
X {
X program++;
X break;
X }
X
X/*
X * Get the inpathlist
X */
X
X rq$c$get$input$pathname (inpath, (sizeof inpath) - 1, &status);
X
X if (!strlen (inpath)) /* No input list */
X usage ();
X
X/*
X * Get and open the output file, checking a la RMX.
X */
X
X preposition = rq$c$get$output$pathname (outpath, (sizeof outpath) - 1,
X "TO SHAR.OUT", &status);
X conn = rq$c$get$output$connection (outpath, 0, &status);
X
X if (status != E$OK)
X exit (1);
X
X rq$s$delete$connection (conn, &status);
X
X switch (preposition)
X {
X case TO:
X case OVER:
X if ((outfile = fopen (outpath, "w")) == NULL)
X {
X sprintf (stderr, "%s: fatal, can't write %s %s\n", program,
X (preposition == TO) ? "to" : "over", outpath);
X exit (1);
X }
X break;
X
X case AFTER:
X if ((outfile = fopen (outpath, "a")) == NULL)
X {
X sprintf (stderr, "%s: fatal, can't write after %s\n",
X program, outpath);
X exit (1);
X }
X break;
X
X default:
X break;
X }
X
X/*
X * Get the parameters
X */
X
X strcpy (delim, DELIM);
X
X while (rq$c$get$parameter (name, (sizeof name) - 1, val, (sizeof val) - 1,
X &indexp, (char *) 0, &status))
X if (strlen (name))
X if (*name == 'D' || *name == 'd')
X strcpy (delim, val + 1);
X else
X usage ();
X else
X if (*(val + 1) == 'c' || *(val + 1) == 'C')
X cut = TRUE;
X else
X if (*(val + 1) == 'v' || *(val + 1) == 'V')
X verbose = TRUE;
X else
X usage ();
X
X/*
X * Build the array of input file names
X */
X
X for (
X argc = 0;
X argc < INPATHS;
X rq$c$get$input$pathname (inpath, (sizeof inpath) - 1, &status),
X argc++
X )
X {
X if (!strlen (inpath))
X break;
X
X argv[argc] = malloc (strlen (inpath));
X strcpy (argv[argc], inpath);
X }
X
X if (header (argc, argv))
X exit (1);
X
X av = argv;
X
X while (argc--)
X result += shar (*av++);
X
X fputs ("exit\n", outfile);
X exit (result);
X}
X
X
Xint header (argc, argv)
Xint argc;
Xchar **argv;
X
X{
X int i,
X problems = FALSE;
X
X for (i = 0; i < argc; i++)
X
X if (access (argv[i]))
X {
X fprintf (stderr, "%s: error, can't read %s\n", program, argv[i]);
X problems++;
X }
X
X if (problems)
X return (problems);
X
X if (cut)
X fputs ("-----Cut Here-----Cut Here-----Cut Here-----Cut Here-----\n",
X outfile);
X
X fputs ("#!/bin/sh\n", outfile);
X fprintf (outfile, "#\t%s: Shell Archiver\n", program);
X fputs ("#\tRun the following text with /bin/sh to create:\n#\n", outfile);
X
X for (i = 0; i < argc; i++)
X fprintf (outfile, "#\t %s\n", argv[i]);
X
X return (0);
X}
X
X
Xint shar (file)
Xchar *file;
X
X{
X char line[BUFSIZ];
X FILE *ioptr;
X
X if (ioptr = fopen (file, "r"))
X {
X if (verbose)
X {
X fprintf (stderr, "%s: appending %s\n", program, file);
X fprintf (outfile, "echo x - extracting %s\n", file);
X }
X
X fprintf (outfile, "sed 's/^%c//' << '%s' > %s\n", PREFIX, delim, file);
X
X while (fgets (line, BUFSIZ, ioptr))
X {
X fputc (PREFIX, outfile);
X fputs (line, outfile);
X }
X
X fclose (ioptr);
X fputs (delim, outfile);
X fputc ('\n', outfile);
X return (0);
X }
X else
X {
X fprintf (stderr, "%s: error, can't open %s\n", program, file);
X return (1);
X }
X}
X
X
Xaccess (filename)
Xchar *filename;
X
X/*
X * All that's needed to work under RMX
X */
X
X{
X FILE *test;
X
X if ((test = fopen (filename, "r")) == NULL)
X return -1;
X else
X {
X fclose (test);
X return 0;
X }
X}
X
Xvoid usage ()
X
X{
X fprintf (stderr,
X"Usage: %s filelist [TO || OVER || AFTER outputfile] [D=delimiter], [V], [C]\n",
X program);
X exit (1);
X}
SHAR_EOF
echo x - extracting shar.csd
sed 's/^X//' << 'SHAR_EOF' > shar.csd
Xcc86 shar.c large include (/lib/cc86/) print (shar.mp0) &
Xoptimize (2) verbose
Xcopy shar.mp0
Xlink86 lqmain.obj, shar.obj, &
X/lib/cc86/lclib.lib, &
X/lib/rmx86/large.lib, &
X/lib/cc86/lcifl.lib, /lib/rmx86/lpifl.lib, &
X/lib/cc86/hcifl.lib, /lib/rmx86/hpifl.lib, &
X/lib/cc86/ecifl.lib, /lib/rmx86/epifl.lib, &
X/lib/cc86/icifl.lib, /lib/rmx86/ipifl.lib, &
X/lib/cc86/rcifl.lib, /lib/rmx86/rpifl.lib, &
X/lib/pasc86/87null.lib &
Xto shar &
Xbind map fastload segsize (stack(+400h)) &
Xpurge mempool (50000, 0FFFF0H)
Xcopy shar.mp0,shar.mp1 over shar.lst
Xdelete shar.mp?,shar.obj
SHAR_EOF
exit
--
Peter Kendell <pete at tcom.stc.co.uk>
...!mcvax!ukc!stc!pete
"Lord Finchley tried to mend the Electric Light,
Himself.
It Struck him Dead! And Serve him Right!
It is the Duty of the Wealthy Man,
To give Employment to the Artisan."
More information about the Comp.sources.unix
mailing list