1: #include <stdio.h>
   2: #include <ctype.h>
   3: #include <pwd.h>
   4: #include <sys/types.h>
   5: #include <sys/stat.h>
   6: 
   7: /*
   8:  * Gather -code file
   9:  *
  10:  * Code indicates the exit status.
  11:  * File is the primary file name.
  12:  * We don't deal with #include here.
  13:  */
  14: 
  15: char    *pxerrs[] = {
  16:     "NORMAL",
  17:     "CHR",
  18:     "DIVCHK",
  19:     "FDIVCHK",
  20:     "HALT",
  21:     "NILPTR",
  22:     "PASTEOF",
  23:     "SQRT",
  24:     "STKNEMP",
  25:     "SUBSCR",
  26:     "REFINAF",
  27:     "WRITE",
  28:     "CREATE",
  29:     "LN",
  30:     "BADOP",
  31:     "BADINUM",
  32:     "GOTO",
  33:     "CASE",
  34:     "SEEK",
  35:     "ALLOC",
  36:     "OUTOFMEM",
  37:     "CTTOT",
  38:     "TOODIGITS",
  39:     "MODCHK",
  40:     "BADFNUM",
  41:     "REMOVE",
  42:     "CLOSE",
  43:     "OPEN",
  44:     "ARGV",
  45:     "PACK",
  46:     "UNPACK",
  47:     "RANGE",
  48:     "ASRT",
  49:     "READIT",
  50:     "WRITEIT",
  51:     "BIGGIE",
  52:     "STLIM",
  53:     "STKOVFLO",
  54:     "INTR",
  55:     "FPOVFLO"
  56: };
  57: 
  58: char    *pierrs[] = {
  59:     "AOK",
  60:     "ERRS",
  61:     "NOSTART",
  62:     "DIED"
  63: };
  64: 
  65: char    gatherdir[] =   "/usr/tmp";
  66: #define GATHERID    7
  67: 
  68: main(argc, argv)
  69:     int argc;
  70:     char *argv[];
  71: {
  72:     FILE *control;
  73:     long curtime;
  74:     register int c;
  75:     char namebuf[10];
  76:     struct stat stbuf;
  77:     register char *cp;
  78:     struct passwd *pwp;
  79: 
  80:     argc--, argv++;
  81:     if (argc != 2 || argv[0][0] != '-' || !digit(argv[0][1]))
  82:         exit(1);
  83:     if (strcmp(argv[1], "px") != 0 && freopen(argv[1], "r", stdin) == NULL)
  84:         exit(1);
  85:     if (chdir(gatherdir) < 0)
  86:         exit(1);
  87:     if ((pwp = getpwuid(getuid())) == (struct passwd *)EOF
  88:         || pwp->pw_name == NULL)
  89:         exit(1);
  90:     if (chdir(pwp->pw_name) < 0)
  91:         exit(1);
  92:     control = fopen("control", "a");
  93:     if (control == NULL)
  94:         exit(1);
  95:     time(&curtime);
  96:     fstat(fileno(control), &stbuf);
  97:     fprintf(control, "%07D.p\t%s\t%s\t%s", stbuf.st_size,
  98:         decomp(argv[0], argv[1]), argv[1], ctime(&curtime));
  99:     fflush(control);
 100:     fclose(control);
 101:     sprintf(namebuf, "%07D.p", stbuf.st_size);
 102:     if (strcmp(argv[0], "-0") == 0 || strcmp(argv[1], "px") == 0 ||
 103:         strcmp(argv[0], "-2") == 0)
 104:         exit(1);
 105:     setuid(GATHERID);
 106:     if (freopen(namebuf, "w", stdout) == NULL)
 107:         exit(1);
 108:     for (;;) {
 109:         c = getc(stdin);
 110:         if (c < 0)
 111:             exit(0);
 112:         putchar(c);
 113:         if (ferror(stdout)) {
 114:             unlink(namebuf);
 115:             exit(1);
 116:         }
 117:     }
 118: }
 119: 
 120: any(c, cp)
 121:     int c;
 122:     char *cp;
 123: {
 124: 
 125:     while (*cp)
 126:         if (c == *cp++)
 127:             return (1);
 128:     return (0);
 129: }
 130: 
 131: digit(c)
 132:     char c;
 133: {
 134: 
 135:     return (c >= '0' && c <= '9');
 136: }
 137: 
 138: decomp(cp, dp)
 139:     register char *cp;
 140:     char *dp;
 141: {
 142:     register int i;
 143: 
 144:     if (*cp++ != '-')
 145:         return (--cp);
 146:     i = 0;
 147:     while (*cp)
 148:         i = i * 10 + *cp++ - '0';
 149:     if (strcmp(dp, "px") == 0) {
 150:         if (i < 0 || i >= ((sizeof pxerrs) / (sizeof pxerrs[0])))
 151:             return ("?????");
 152:         return (pxerrs[i]);
 153:     } else {
 154:         if (i < 0 || i >= ((sizeof pierrs) / (sizeof pierrs[0])))
 155:             return ("?????");
 156:         return (pierrs[i]);
 157:     }
 158: }

Defined functions

any defined in line 120; never used
decomp defined in line 138; used 1 times
  • in line 98
digit defined in line 131; used 1 times
  • in line 81
main defined in line 68; never used

Defined variables

gatherdir defined in line 65; used 1 times
  • in line 85
pierrs defined in line 58; used 3 times
pxerrs defined in line 15; used 3 times

Defined macros

GATHERID defined in line 66; used 1 times
Last modified: 1987-03-13
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2966
Valid CSS Valid XHTML 1.0 Strict