From:	MERC::"uunet!WKUVX1.BITNET!FILESERV-Mgr" 14-JUL-1992 12:52:50.60
To:	galaxy::gleeve
CC:	
Subj:	UUCODE.006-OF-008

-+-+-+-+-+-+-+-+ START OF PART 6 -+-+-+-+-+-+-+-+
X`09`09argv++; argc--;
X`09`7D else
X`09`09in = stdin;
X
X`09if (argc != 1) `7B
X`09`09printf("Usage: uudecode `5Binfile`5D\n");
X`09`09exit(2);
X`09`7D
X
X`09/* search for header line */
X`09for (;;) `7B
X`09`09if (fgets(buf, sizeof buf, in) == NULL) `7B
X`09`09`09fprintf(stderr, "No begin line\n");
X`09`09`09exit(3);
X`09`09`7D
X`09`09if (strncmp(buf, "begin ", 6) == 0)
X`09`09`09break;
X`09`7D
X`09(void)sscanf(buf, "begin %o %s", &mode, dest);
X
X#if !defined(MSDOS) && !defined(VMS)`09/* i.e., UNIX */
X`09/* handle `7Euser/file format */
X`09if (dest`5B0`5D == '`7E') `7B
X`09`09char *sl;
X`09`09struct passwd *getpwnam();
X`09`09struct passwd *user;
X`09`09char dnbuf`5B100`5D, *index(), *strcat(), *strcpy();
X
X`09`09sl = index(dest, '/');
X`09`09if (sl == NULL) `7B
X`09`09`09fprintf(stderr, "Illegal `7Euser\n");
X`09`09`09exit(3);
X`09`09`7D
X`09`09*sl++ = 0;
X`09`09user = getpwnam(dest+1);
X`09`09if (user == NULL) `7B
X`09`09`09fprintf(stderr, "No such user as %s\n", dest);
X`09`09`09exit(4);
X`09`09`7D
X`09`09strcpy(dnbuf, user->pw_dir);
X`09`09strcat(dnbuf, "/");
X`09`09strcat(dnbuf, sl);
X`09`09strcpy(dest, dnbuf);
X`09`7D
X#endif`09/* !defined(MSDOS) && !defined(VMS) */
X
X`09/* create output file */
X#ifdef MSDOS
X`09out = fopen(dest, "wb");`09/* Binary file */
X#else
X`09out = fopen(dest, "w");
X#endif
X`09if (out == NULL) `7B
X`09`09perror(dest);
X`09`09exit(4);
X`09`7D
X#if !defined(MSDOS) && !defined(VMS)`09/* i.e., UNIX */
X`09chmod(dest, mode);
X#endif
X
X`09decode(in, out);
X
X`09if (fgets(buf, sizeof buf, in) == NULL `7C`7C strcmp(buf, "end\n")) `7B
X`09`09fprintf(stderr, "No end line\n");
X`09`09exit(5);
X`09`7D
X`09exit(0);
X`7D
X
X/*
X * copy from in to out, decoding as you go along.
X */
Xdecode(in, out)
XFILE *in;
XFILE *out;
X`7B
X`09char buf`5B80`5D;
X`09char *bp;
X`09int n, i, expected;
X
X`09for (;;) `7B
X`09`09/* for each input line */
X`09`09if (fgets(buf, sizeof buf, in) == NULL) `7B
X`09`09`09printf("Short file\n");
X`09`09`09exit(10);
X`09`09`7D
X`09`09n = DEC(buf`5B0`5D);
X`09`09if ((n <= 0) `7C`7C (buf`5B0`5D == '\n'))
X`09`09`09break;
X
X`09`09/* Calculate expected # of chars and pad if necessary */
X`09`09expected = ((n+2)/3)<<2;
X`09`09for (i = strlen(buf)-1; i <= expected; i++) buf`5Bi`5D = ' ';
X
X`09`09bp = &buf`5B1`5D;
X`09`09while (n > 0) `7B
X`09`09`09outdec(bp, out, n);
X`09`09`09bp += 4;
X`09`09`09n -= 3;
X`09`09`7D
X`09`7D
X`7D
X
X/*
X * output a group of 3 bytes (4 input characters).
X * the input chars are pointed to by p, they are to
X * be output to file f.  n is used to tell us not to
X * output all of them at the end of the file.
X */
Xoutdec(p, f, n)
Xchar *p;
XFILE *f;
X`7B
X`09int c1, c2, c3;
X
X`09c1 = DEC(*p) << 2 `7C DEC(p`5B1`5D) >> 4;
X`09c2 = DEC(p`5B1`5D) << 4 `7C DEC(p`5B2`5D) >> 2;
X`09c3 = DEC(p`5B2`5D) << 6 `7C DEC(p`5B3`5D);
X`09if (n >= 1)
X`09`09putc(c1, f);
X`09if (n >= 2)
X`09`09putc(c2, f);
X`09if (n >= 3)
X`09`09putc(c3, f);
X`7D
X
X/*
X * Return the ptr in sp at which the character c appears;
X * NULL if not found
X */
X
X#define`09NULL`090
X
Xchar *
Xindex(sp, c)
Xregister char *sp, c;
X`7B
X`09do `7B
X`09`09if (*sp == c)
X`09`09`09return(sp);
X`09`7D while (*sp++);
X`09return(NULL);
X`7D
$ CALL UNPACK [.UUCODE.SMARTEST]UUDECODE.C;1 70287813
$ create 'f'
X/*
X * Copyright (c) 1983 Regents of the University of California.
X * All rights reserved.
X *
X * Redistribution and use in source and binary forms are permitted
X * provided that the above copyright notice and this paragraph are
X * duplicated in all such forms and that any documentation,
X * advertising materials, and other materials related to such
X * distribution and use acknowledge that the software was developed
X * by the University of California, Berkeley.  The name of the
X * University may not be used to endorse or promote products derived
X * from this software without specific prior written permission.
X * THIS SOFTWARE IS PROVIDED `60`60AS IS'' AND WITHOUT ANY EXPRESS OR
X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X */
X
X/*
X * Modified 12 April 1990 by Mark Adler for use on MSDOS systems with
X * Microsoft C and Turbo C.  Standard input problem fixed 29 April 1990
X * as per suggestion by Steve Harrold.
X *
X * Modifed 13 February 1991 by Greg Roelofs for use on VMS systems.
X * Compile and link normally (but note that the shared-image link option
X * produces a binary only 6 blocks long, as opposed to the 152-block one
X * produced by an ordinary link).  To set up the VMS symbol to run the
X * program ("run uuencode filename1 filename2 filename3" won't work), do:
X *`09`09uuencode :== "$disk:`5Bdirectory`5Duuencode.exe"
X * and don't forget the leading "$" or it still won't work.  The syntax
X * differs slightly from the Unix and MS-DOS versions since VMS has such
X * an awkward approach to redirection; run the program with no arguments
X * for the usage (or see USAGE below).  The output file is in VMS "stream-
X * LF" format but should be readable by MAIL, ftp, or anything else.
X */
X
X#ifndef lint
Xstatic char sccsid`5B`5D = "@(#)uuencode.c`095.6 (Berkeley) 7/6/88";
X#endif /* not lint */
X
X#ifdef __MSDOS__        /* For Turbo C */
X#define MSDOS 1
X#endif
X
X/*
X * uuencode `5Binput`5D output
X *
X * Encode a file so it can be mailed to a remote system.
X */
X#include <stdio.h>
X
X#ifdef VMS
X#  define OUT out`09/* force user to specify output file */
X#  define NUM_ARGS 3
X#  define USAGE "Usage: uuencode `5Binfile`5D remotefile uufile\n"
X#  include <types.h>
X#  include <stat.h>
X#else
X#  define OUT stdout`09/* Unix, MS-DOS:  anybody with decent redirection */
X#  define NUM_ARGS 2
X#  define USAGE "Usage: uuencode `5Binfile`5D remotefile\n"
X#  include <sys/types.h>
X#  include <sys/stat.h>
X#endif
X
X#if MSDOS
X#include <io.h>
X#include <fcntl.h>
X#endif
X
X/* ENC is the basic 1-character encoding function to make a char printing */
X#define ENC(c) ((c) ? ((c) & 077) + ' ': '`60')
X
Xmain(argc, argv)
Xchar **argv;
X`7B
X#ifdef VMS
X`09FILE *out;
X#endif
X`09FILE *in;
X`09struct stat sbuf;
X`09int mode;
X
X`09/* optional 1st argument */
X`09if (argc > NUM_ARGS) `7B
X`09`09if ((in = fopen(argv`5B1`5D, "r")) == NULL) `7B
X`09`09`09perror(argv`5B1`5D);
X`09`09`09exit(1);
X`09`09`7D
X`09`09argv++; argc--;
X`09`7D else
X`09`09in = stdin;
X
X#if MSDOS
X`09/* set input file mode to binary for MSDOS systems */
X`09setmode(fileno(in), O_BINARY);
X#endif
X
X`09if (argc != NUM_ARGS) `7B
X`09`09fprintf(stderr, USAGE);
X`09`09exit(2);
X`09`7D
X
X#ifdef VMS   /* mandatory 3rd argument is name of uuencoded file */
X`09if ((out = fopen(argv`5B2`5D, "w")) == NULL) `7B
X`09`09perror(argv`5B2`5D);
X`09`09exit(4);
X`09`7D
X#endif
X
X`09/* figure out the input file mode */
X`09if (fstat(fileno(in), &sbuf) < 0 `7C`7C !isatty(fileno(in)))
X`09`09mode = 0666 & `7Eumask(0666);
X`09else
X`09`09mode = sbuf.st_mode & 0777;
X`09fprintf(OUT, "begin %o %s\n", mode, argv`5B1`5D);
X
X`09encode(in, OUT);
X
X`09fprintf(OUT, "end\n");
X`09exit(0);
X`7D
X
X/*
X * copy from in to out, encoding as you go along.
X */
Xencode(in, out)
Xregister FILE *in;
Xregister FILE *out;
X`7B
X`09char buf`5B80`5D;
X`09register int i, n;
X
X`09for (;;) `7B
X`09`09/* 1 (up to) 45 character line */
X`09`09n = fread(buf, 1, 45, in);
X`09`09putc(ENC(n), out);
X
X`09`09for (i=0; i<n; i += 3)
X`09`09`09outdec(&buf`5Bi`5D, out);
X
X`09`09putc('\n', out);
X`09`09if (n <= 0)
X`09`09`09break;
X`09`7D
X`7D
X
X/*
X * output one group of 3 bytes, pointed at by p, on file f.
X */
Xoutdec(p, f)
Xregister char *p;
Xregister FILE *f;
X`7B
X`09register int c1, c2, c3, c4;
X
X`09c1 = *p >> 2;
X`09c2 = (*p << 4) & 060 `7C (p`5B1`5D >> 4) & 017;
X`09c3 = (p`5B1`5D << 2) & 074 `7C (p`5B2`5D >> 6) & 03;
X`09c4 = p`5B2`5D & 077;
X`09putc(ENC(c1), f);
X`09putc(ENC(c2), f);
X`09putc(ENC(c3), f);
X`09putc(ENC(c4), f);
X`7D
$ CALL UNPACK [.UUCODE.SMARTEST]UUENCODE.C;1 779330053
$ create 'f'
X$ !
X$ !`09"Makefile" for VMS versions of uuencode and uudecode
X$ !
X$ set verify`09! like "echo on", eh?
X$ define lnk$library sys$library:vaxcrtl.olb
X$ cc uuencode,uudecode
X$ link uuencode,sys$input:/opt
Xsys$share:vaxcrtl.exe/shareable
X$ link uudecode,sys$input:/opt
Xsys$share:vaxcrtl.exe/shareable
X$ set noverify
$ CALL UNPACK [.UUCODE.SMARTEST]UU_MAKE.COM;1 874736602
$ create 'f'
X/*
X * @(#)argproc.c 1.0 89/02/01`09`09Mark Pizzolato (mark@infopiz.uucp)`09
X */
X
X#ifndef lint
Xchar argproc_version`5B`5D = "@(#)argproc.c VMS uucp Version infopiz-1.0";
X#endif
X
X/* Include of "includes.h" removed, replaced by the following: */
X
X#include ctype
X#include descrip
X#include dvidef
X#include errno
X#include iodef
X#include setjmp
X#include stat
X#include stdlib`20
X#include stdio
X#include string
X     `20
X#define EXIT_OK 1`09`09/* image exit code */
X#define EXIT_ERR 0x10000000`09/* image exit code */
X`0C
X/*
X * getredirection() is intended to aid in porting C programs
X * to VMS (Vax-11 C) which does not support '>' and '<'
X * I/O redirection, along with a command line pipe mechanism
X * using the '`7C' AND background command execution '&'.
X * The piping mechanism will probably work with almost any 'filter' type
X * of program.  With suitable modification, it may useful for other
X * portability problems as well.
X *
X * Author:  Mark Pizzolato`09mark@infopiz.UUCP
X */
Xstruct list_item
X    `7B
X    struct list_item *next;
X    char *value;
X    `7D;
X
Xint
Xgetredirection(ac, av)
Xint`09`09*ac;
Xchar`09`09***av;
X/*
X * Process vms redirection arg's.  Exit if any error is seen.
X * If getredirection() processes an argument, it is erased
X * from the vector.  getredirection() returns a new argc and argv value.
X * In the event that a background command is requested (by a trailing "&"),
X * this routine creates a background subprocess, and simply exits the progra
Vm.
X *
X * Warning: do not try to simplify the code for vms.  The code
X * presupposes that getredirection() is called before any data is
X * read from stdin or written to stdout.
X *
X * Normal usage is as follows:
X *
X *`09main(argc, argv)
X *`09int`09`09argc;
X *    `09char`09`09*argv`5B`5D;
X *`09`7B
X *`09`09getredirection(&argc, &argv);
X *`09`7D
X */
X`7B
X    int`09`09`09argc = *ac;`09/* Argument Count`09  */
X    char`09`09**argv = *av;`09/* Argument Vector`09  */
X    char`09`09*ap;   `09`09/* Argument pointer`09  */
X    int`09       `09`09j;`09`09/* argv`5B`5D index`09`09  */
X    extern int`09`09errno;`09`09/* Last vms i/o error `09  */
X    int`09`09`09item_count = 0;`09/* Count of Items in List */
X    struct list_item `09*list_head = 0;`09/* First Item in List`09    */
X    struct list_item`09*list_tail;`09/* Last Item in List`09    */
X    char `09`09*in = NULL;`09/* Input File Name`09    */
X    char `09`09*out = NULL;`09/* Output File Name`09    */
X    char `09`09*outmode = "w";`09/* Mode to Open Output File */
X    int`09`09`09cmargc = 0;    `09/* Piped Command Arg Count  */
X    char`09`09**cmargv = NULL;/* Piped Command Arg Vector */
X    stat_t`09`09statbuf;`09/* fstat buffer`09`09    */
X
X    /*
X     * First handle the case where the last thing on the line ends with
X     * a '&'.  This indicates the desire for the command to be run in a
X     * subprocess, so we satisfy that desire.
X     */
X    ap = argv`5Bargc-1`5D;
X    if (0 == strcmp("&", ap))
X`09exit(background_process(--argc, argv));
X    if ('&' == ap`5Bstrlen(ap)-1`5D)
X`09`7B
X`09ap`5Bstrlen(ap)-1`5D = '\0';
X`09exit(background_process(argc, argv));
X`09`7D
X    /*
X     * Now we handle the general redirection cases that involve '>', '>>',
X     * '<', and pipes '`7C'.
X     */
X    for (j = 0; j < argc; ++j)
X`09`7B
X`09if (0 == strcmp("<", argv`5Bj`5D))
X`09    `7B
X`09    if (j+1 >= argc)
X`09`09`7B
X`09`09errno = EINVAL;
X`09`09perror("No input file");
X`09`09exit(EXIT_ERR);
X`09`09`7D
X`09    in = argv`5B++j`5D;
X`09    continue;
X`09    `7D
X`09if ('<' == *(ap = argv`5Bj`5D))
X`09    `7B
X`09    in = 1 + ap;
X`09    continue;
X`09    `7D
X`09if (0 == strcmp(">", ap))
X`09    `7B
X`09    if (j+1 >= argc)
X`09`09`7B
X`09`09errno = EINVAL;
X`09`09perror("No output file");
X`09`09exit(EXIT_ERR);
X`09`09`7D
X`09    out = argv`5B++j`5D;
X`09    continue;
X`09    `7D
X`09if ('>' == *ap)
X`09    `7B
X`09    if ('>' == ap`5B1`5D)
X`09`09`7B
X`09`09outmode = "a";
X`09`09if ('\0' == ap`5B2`5D)
X`09`09    out = argv`5B++j`5D;
X`09`09else
X`09`09    out = 2 + ap;
X`09`09`7D
X`09    else
X`09`09out = 1 + ap;
X`09    continue;
X`09    `7D
X`09if (0 == strcmp("`7C", argv`5Bj`5D))
X`09    `7B
X`09    if (j+1 >= argc)
X`09`09`7B
X`09`09errno = EPIPE;
X`09`09perror("No command to Pipe to");
X`09`09exit(EXIT_ERR);
X`09`09`7D
X`09    cmargc = argc-(j+1);
X`09    cmargv = &argv`5Bj+1`5D;
X`09    argc = j;
X`09    continue;
X`09    `7D
X`09if ('`7C' == *(ap = argv`5Bj`5D))
X`09    `7B
X`09    ++argv`5Bj`5D;
X`09    cmargc = argc-j;
X`09    cmargv = &argv`5Bj`5D;
X`09    argc = j;
X`09    continue;
X`09    `7D
X`09expand_wild_cards(ap, &list_head, &list_tail, &item_count);
X`09`7D
X    /*
X     * Allocate and fill in the new argument vector, Some Unix's terminate
X     * the list with an extra null pointer.
X     */
X    argv = *av = calloc(item_count+1, sizeof(char *));
X    for (j = 0; j < item_count; ++j, list_head = list_head->next)
X`09argv`5Bj`5D = list_head->value;
X    *ac = item_count;
X    if (cmargv != NULL)
X`09`7B
X`09char subcmd`5B1024`5D;
X`09static char *pipe_and_fork();
X
X`09if (out != NULL)
X`09    `7B
X`09    errno = EINVAL;
X`09    perror("Invalid '`7C' and '>' specified");
X`09    exit(EXIT_ERR);
X`09    `7D
X`09strcpy(subcmd, cmargv`5B0`5D);
X`09for (j = 1; j < cmargc; ++j)
X`09    `7B
X`09    strcat(subcmd, " \"");
X`09    strcat(subcmd, cmargv`5Bj`5D);
X`09    strcat(subcmd, "\"");
X`09    `7D
X`09out = pipe_and_fork(subcmd);
X`09outmode = "wb";
X`09`7D
X`09
X    /* Check for input from a pipe (mailbox) */
X
X    if(fstat(0, &statbuf) == 0)`7B
X`09if(strncmp(statbuf.st_dev, "MB", 2) == 0 `7C`7C`20
X`09    strncmp(statbuf.st_dev, "_MB", 3) == 0)`7B
X
X`09    /* Input from a pipe, reopen it in binary mode to disable`09*/
X`09    /* carriage control processing.`09`09`09`09*/
X
X`09    if (in != NULL)`7B
X`09`09errno = EINVAL;
X`09`09perror("Invalid '`7C' and '<' specified");
X`09`09exit(EXIT_ERR);
X`09`09`7D
X`09    freopen(statbuf.st_dev, "rb", stdin);
X`09    `7D
X`09`7D
X    else `7B
X`09perror("fstat failed");
X`09exit(EXIT_ERR);
X`09`7D
X    if ((in != NULL) && (NULL == freopen(in, "r", stdin, "mbc=32", "mbf=2"))
V)
X`09`7B
X`09perror(in);    `09       `09/* Can't find file`09`09*/
X`09exit(EXIT_ERR);`09`09/* Is a fatal error`09`09*/
X`09`7D
X    if ((out != NULL) && (NULL == freopen(out, outmode, stdout, "mbc=32", "m
Vbf=2")))
X`09`7B`09
X`09perror(ap);`09`09/* Error, can't write or append`09*/
X`09exit(EXIT_ERR);`09`09/* Is a fatal error`09`09*/
X`09`7D
X#ifdef DEBUG
X    fprintf(stderr, "Arglist:\n");
X    for (j = 0; j < *ac;  ++j)
X`09fprintf(stderr, "argv`5B%d`5D = '%s'\n", j, argv`5Bj`5D);
X#endif
X`7D
X
Xstatic add_item(head, tail, value, count)
Xstruct list_item **head;
Xstruct list_item **tail;
Xchar *value;
Xint *count;
X`7B
X    if (*head == 0)
X`09`7B
X`09if (NULL == (*head = calloc(1, sizeof(**head))))
X`09    `7B
X`09    errno = ENOMEM;
X`09    perror("");
X`09    exit(EXIT_ERR);
X`09    `7D
X`09*tail = *head;
X`09`7D
X    else
X`09if (NULL == ((*tail)->next = calloc(1, sizeof(**head))))
X`09    `7B
X`09    errno = ENOMEM;
X`09    perror("");
X`09    exit(EXIT_ERR);
X`09    `7D
X`09else
X`09    *tail = (*tail)->next;
X    (*tail)->value = value;
X    ++(*count);
X`7D
X
Xstatic expand_wild_cards(item, head, tail, count)
Xchar *item;
Xstruct ltem_list **head;
Xstruct ltem_list **tail;
Xint *count;
X`7B
Xint expcount = 0;
Xint context = 0;
Xint status;
Xint status_value;
Xint had_version;
X$DESCRIPTOR(filespec, item);
X$DESCRIPTOR(defaultspec, "SYS$DISK:`5B`5D*.*;");
X$DESCRIPTOR(resultspec, "");
X
X    if (strcspn(item, "*%") == strlen(item))
X`09`7B
X`09add_item(head, tail, item, count);
X`09return;
X`09`7D
X    resultspec.dsc$b_dtype = DSC$K_DTYPE_T;
X    resultspec.dsc$b_class = DSC$K_CLASS_D;
X    resultspec.dsc$a_pointer = NULL;
X    filespec.dsc$w_length = strlen(item);
X    /*
X     * Only return version specs, if the caller specified a version
X     */
X    had_version = strchr(item, ';');
X    while (1 == (1&lib$find_file(&filespec, &resultspec, &context,
X    `09`09`09`09 &defaultspec, 0, &status_value, &0)))
X`09`7B
X`09char *string;
X`09char *c;
X
X`09if (NULL == (string = calloc(1, resultspec.dsc$w_length+1)))
X`09    `7B
X`09    errno = ENOMEM;
X`09    perror("");
X`09    exit(EXIT_ERR);
X`09    `7D
X`09strncpy(string, resultspec.dsc$a_pointer, resultspec.dsc$w_length);
X`09string`5Bresultspec.dsc$w_length`5D = '\0';
X`09if (NULL == had_version)
X`09    *((char *)strrchr(string, ';')) = '\0';
X`09/*
X`09 * Be consistent with what the C RTL has already done to the rest of
X`09 * the argv items and lowercase all of these names.
X`09 */
X`09for (c = string; *c; ++c)
X`09    if (isupper(*c))
X`09`09*c = tolower(*c);
X`09add_item(head, tail, string, count);
X`09++expcount;
X`09`7D
X    if (expcount == 0)
X`09add_item(head, tail, item, count);
X    lib$sfree1_dd(&resultspec);
X    lib$find_file_end(&context);
X`7D
X
Xstatic int child_st`5B2`5D;`09/* Event Flag set when child process completes
V`09*/
X
Xstatic short child_chan;/* I/O Channel for Pipe Mailbox`09`09`09*/
X
Xstatic exit_handler(status)
Xint *status;
X`7B
Xshort iosb`5B4`5D;
X
X    if (0 == child_st`5B0`5D)
X`09`7B
X#ifdef DEBUG
X`09fprintf(stderr, "Waiting for Child Process to Finish . . .\n");
X#endif
X`09fflush(stdout);`09    /* Have to flush pipe for binary data to`09*/
X`09`09`09    /* terminate properly -- <tp@mccall.com>`09*/
X`09sys$qiow(0, child_chan, IO$_WRITEOF, iosb, 0, 0, 0, 0, 0, 0, 0, 0);
X`09sys$dassgn(child_chan);
X`09fclose(stdout);
X`09sys$purgws(0);
X`09sys$synch(0, child_st);
X`09`7D
X`7D
X
X#include syidef`09`09/* System Information Definitions`09*/
X
Xstatic sig_child(chan)
Xint chan;
X`7B
X#ifdef DEBUG
X    fprintf(stderr, "Child Completion AST\n");
X#endif
X    if (child_st`5B0`5D == 0)
X`09child_st`5B0`5D = 1;
X`7D
X
Xstatic struct exit_control_block
X    `7B
X    struct exit_control_block *flink;
X    int`09(*exit_routine)();
X    int arg_count;
X    int *status_address;
X    int exit_status;
X    `7D exit_block =
X    `7B
X    0,
X    exit_handler,
X    1,
X    &exit_block.exit_status,
X    0
X    `7D;
X
Xstatic char *pipe_and_fork(cmd)
Xchar *cmd;
X`7B
X    $DESCRIPTOR(cmddsc, cmd);
X    static char mbxname`5B64`5D;
X    $DESCRIPTOR(mbxdsc, mbxname);
X    short iosb`5B4`5D;
X    int status;
X    int pid;
X    struct
X`09`7B
X`09short dna_buflen;
X`09short dna_itmcod;
X`09char *dna_buffer;
X`09short *dna_retlen;
X`09int listend;
X`09`7D itmlst =
X`09`7B
X`09sizeof(mbxname),
X`09DVI$_DEVNAM,
X`09mbxname,
X`09&mbxdsc.dsc$w_length,
X`090
X`09`7D;
X    int mbxsize;
X    struct
X`09`7B
X`09short mbf_buflen;
X`09short mbf_itmcod;
X`09int *mbf_maxbuf;
X`09short *mbf_retlen;
X`09int listend;
X`09`7D syiitmlst =
X`09`7B
X`09sizeof(mbxsize),
X`09SYI$_MAXBUF,
X`09&mbxsize,
X`090,
X`090
X`09`7D;
X
X    cmddsc.dsc$w_length = strlen(cmd);
X    /*
X     * Get the SYSGEN parameter MAXBUF, and the smaller of it and 2048 as
X     * the size of the 'pipe' mailbox.
X     */
X    if (1 == (1&(vaxc$errno = sys$getsyiw(0, 0, 0, &syiitmlst, iosb, 0, 0, 0
V))))
X`09vaxc$errno = iosb`5B0`5D;
X    if (0 == (1&vaxc$errno))
X`09`7B
X `09errno = EVMSERR;
X`09perror("Can't get SYSGEN parameter value for MAXBUF");
X`09exit(EXIT_ERR);
X`09`7D
X    if (mbxsize > 2048)
X`09mbxsize = 2048;
X    if (0 == (1&(vaxc$errno = sys$crembx(0, &child_chan, mbxsize, mbxsize, 0
V, 0, 0))))
X`09`7B
X`09errno = EVMSERR;
X`09perror("Can't create pipe mailbox");
X`09exit(EXIT_ERR);
X`09`7D
X    if (1 == (1&(vaxc$errno = sys$getdviw(0, child_chan, 0, &itmlst, iosb,
X    `09`09`09`09`09  0, 0, 0))))
X`09vaxc$errno = iosb`5B0`5D;
X    if (0 == (1&vaxc$errno))
X`09`7B
X `09errno = EVMSERR;
X`09perror("Can't get pipe mailbox device name");
X`09exit(EXIT_ERR);
X`09`7D
X    mbxname`5Bmbxdsc.dsc$w_length`5D = '\0';
X#ifdef DEBUG
X    fprintf(stderr, "Pipe Mailbox Name = '%s'\n", mbxname);
X#endif
X    if (0 == (1&(vaxc$errno = lib$spawn(&cmddsc, &mbxdsc, 0, &1,
X    `09`09`09`09`090, &pid, child_st, &0, sig_child,
X    `09`09`09`09`09&child_chan))))
X`09`7B
X`09errno = EVMSERR;
X`09perror("Can't spawn subprocess");
X`09exit(EXIT_ERR);
X`09`7D
X#ifdef DEBUG
X    fprintf(stderr, "Subprocess's Pid = %08X\n", pid);
X#endif
X    sys$dclexh(&exit_block);
X    return(mbxname);
X`7D
X
Xbackground_process(argc, argv)
Xint argc;
Xchar **argv;
X`7B
Xchar command`5B2048`5D = "$";
X$DESCRIPTOR(value, command);
X$DESCRIPTOR(cmd, "BACKGROUND$COMMAND");
X$DESCRIPTOR(null, "NLA0:");
Xint pid;
X
X    strcat(command, argv`5B0`5D);
X    while (--argc)
X`09`7B
X`09strcat(command, " \"");
X`09strcat(command, *(++argv));
X`09strcat(command, "\"");
X`09`7D
X    value.dsc$w_length = strlen(command);
X    if (0 == (1&(vaxc$errno = lib$set_symbol(&cmd, &value))))
X`09`7B
X`09errno = EVMSERR;
X`09perror("Can't create symbol for subprocess command");
X`09exit(EXIT_ERR);
X`09`7D
X    if (0 == (1&(vaxc$errno = lib$spawn(&cmd, &null, 0, &17, 0, &pid))))
X`09`7B
X`09errno = EVMSERR;
X`09perror("Can't spawn subprocess");
X`09exit(EXIT_ERR);
X`09`7D
X#ifdef DEBUG
X    fprintf(stderr, "%s\n", command);
X#endif
X    fprintf(stderr, "%08X\n", pid);
X    return(EXIT_OK);
X`7D
X`0C
X/* got this off net.sources */
X
X#ifdef`09VMS
X#define`09index`09strchr
X#endif`09/*VMS*/
X
X/*
X * get option letter from argument vector
X */
Xint`09opterr = 1,`09`09/* useless, never set or used */
X`09optind = 1,`09`09/* index into parent argv vector */
X`09optopt;`09`09`09/* character checked for validity */
Xchar`09*optarg;`09`09/* argument associated with option */
X
X#define BADCH`09(int)'?'
X#define EMSG`09""
X#define tell(s)`09fputs(*nargv,stderr);fputs(s,stderr); \
X`09`09fputc(optopt,stderr);fputc('\n',stderr);return(BADCH);
X
Xgetopt(nargc,nargv,ostr)
Xint`09nargc;
Xchar`09**nargv,
X`09*ostr;
X`7B
X`09static char`09*place = EMSG;`09/* option letter processing */
X`09register char`09*oli;`09`09/* option letter list index */
X`09char`09*index();
X
X`09if(!*place) `7B`09`09`09/* update scanning pointer */
X`09`09if(optind >= nargc `7C`7C *(place = nargv`5Boptind`5D) != '-' `7C`7C !
V*++place) return(EOF);
X`09`09if (*place == '-') `7B`09/* found "--" */
X`09`09`09++optind;
X`09`09`09return(EOF);
X`09`09`7D
X`09`7D`09`09`09`09/* option letter okay? */
X`09if ((optopt = (int)*place++) == (int)':' `7C`7C !(oli = index(ostr,optopt
V))) `7B
X`09`09if(!*place) ++optind;
X`09`09tell(": illegal option -- ");
X`09`7D
X`09if (*++oli != ':') `7B`09`09/* don't need argument */
X`09`09optarg = NULL;
X`09`09if (!*place) ++optind;
X`09`7D
X`09else `7B`09`09`09`09/* need an argument */
X`09`09if (*place) optarg = place;`09/* no white space */
X`09`09else if (nargc <= ++optind) `7B`09/* no arg */
X`09`09`09place = EMSG;
X`09`09`09tell(": option requires an argument -- ");
X`09`09`7D
X`09 `09else optarg = nargv`5Boptind`5D;`09/* white space */
X`09`09place = EMSG;
X`09`09++optind;
X`09`7D
X`09return(optopt);`09`09`09/* dump back option letter */
X`7D
$ CALL UNPACK [.UUCODE.VAXC]ARGPROC.C;1 1661485956
$ create 'f'
Xsys$share:vaxcrtl.exe/share
$ CALL UNPACK [.UUCODE.VAXC]CRTL.OPT;1 1392527948
$ create 'f'
X.first
X`09def sys sys$library
X
Xall : uuencode.exe uudecode.exe uucat.exe
X`09! Done.
X
Xuuencode.exe : uuencode.obj argproc.obj
X`09$(link) $(linkflags) uuencode.obj,argproc.obj,crtl.opt/opt
X
Xuudecode.exe : uudecode.obj argproc.obj
X`09$(link) $(linkflags) uudecode.obj,argproc.obj,crtl.opt/opt
X
Xuucat.exe : uucat.obj argproc.obj
X`09$(link) $(linkflags) uucat.obj,argproc.obj,crtl.opt/opt
X
$ CALL UNPACK [.UUCODE.VAXC]DESCRIP.MMS;1 538268317
$ create 'f'
XEncoding of file DUA1:`5BHUNTER.FILESERV.UUCODE.VAXC`5DUUCAT.EXE;1
X`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`
V7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E`7E
X-@@QUETL:,ERU9DUEI%KF%DSEMUQRY%KUU5POQTQ.XUPXMTWUU5PAQ%KE!UQ;DCarl@C@5af@mDP
V@@Da
Xh@HAag@HB@:LHVHCb@Dal@8IJc@B<??af@Tb@Hah@Hb@mPPM1ABA5DGan@H@,@@C@DA@Xah@L2@S
VMADb
X@<ak?af@mJ@@DmCWKBVah@Fb@Z_;?_@mat@<ak@Bap@Baj@PAUU5PAQEavb@DXUL.@Cap@mENe-H
VXWI@
XE@SM-@SNao@A@C@Paf@JBb@Haf@D@m@@Daf@Hb@PAc@P@m@@0c@mBDb@Mc@0@@T@@;??C@LB@@=C
VB@Da
Xh@!b@Caf@0c@AKXUPXM$TT14W0@SL_@00ag@PH@@0ag@8b@DmBL%$PRQES_ACL1<A@OEag@!b@Ca
Vg@C@
XBPmJ4DUHIEUL=EL0DC@@<axj?C6Y@Hme@4&X#53L2@Pd"YVO2@Pf5MVX4)CHCE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