1: #include "tp.h"
   2: 
   3: main(argc,argv)
   4: char **argv;
   5: {
   6:     register char c,*ptr;
   7:     extern cmd(), cmr(),cmx(), cmt();
   8: 
   9:     tname = tc;
  10:     command = cmr;
  11:     if ((narg = rnarg = argc) < 2)  narg = 2;
  12:     else {
  13:         ptr = argv[1];  /* get first argument */
  14:         parg = &argv[2];    /* pointer to second argument */
  15:         while (c = *ptr++) switch(c)  {
  16:             case '0':
  17:             case '1':
  18:             case '2':
  19:             case '3':
  20:             case '4':
  21:             case '5':
  22:             case '6':
  23:             case '7':
  24:                 tc[8] = c;
  25:                 mt[7] = c;
  26:                 continue;
  27: 
  28:             case 'f':
  29:                 tname = *parg++;
  30:                 narg--; rnarg--;
  31:                 continue;
  32:             case 'c':
  33:                 flags |= flc;  continue;
  34:             case 'd':
  35:                 setcom(cmd);  continue;
  36:             case 'i':
  37:                 flags |= fli;  continue;
  38:             case 'm':
  39:                 tname = mt;
  40:                 flags |= flm;
  41:                 continue;
  42:             case 'r':
  43:                 flags &= ~flu;  setcom(cmr);  continue;
  44:             case 's':
  45:                 flags |= fls; continue;
  46:             case 't':
  47:                 setcom(cmt);  continue;
  48:             case 'u':
  49:                 flags |= flu;  setcom(cmr);  continue;
  50:             case 'v':
  51:                 flags |= flv;  continue;
  52:             case 'w':
  53:                 flags |= flw;  continue;
  54:             case 'x':
  55:                 setcom(cmx);  continue;
  56:             default:
  57:                 useerr();
  58:         }
  59:     }
  60:     optap();
  61:     top = nptr = nameblk = sbrk(0);
  62:     (*command)();
  63: }
  64: 
  65: optap()
  66: {
  67:     extern cmr();
  68: 
  69:     if ((flags & flm) == 0) {   /*  DECTAPE */
  70:         tapsiz = TCSIZ;
  71:         ndirent = TCDIRS;
  72:         fio =open(tc,2);
  73:     } else {            /* MAGTAPE */
  74:         tapsiz = MTSIZ;
  75:         ndirent = MDIRENT;
  76:         if(command == cmr)
  77:             fio = open(tname,1);
  78:         else
  79:             fio = open(tname,0);
  80:     }
  81:     if (fio < 0)  {
  82:         printf("Tape open error\n");
  83:         done();
  84:     }
  85:     ndentb = ndirent/TPB;
  86:     edir = &dir[ndirent];
  87: }
  88: 
  89: setcom(newcom)
  90: int (*newcom)();
  91: {
  92:     extern cmr();
  93: 
  94:     if (command != cmr)     useerr();
  95:     command = newcom;
  96: }
  97: 
  98: useerr()
  99: {
 100:     printf("Bad usage\n");
 101:     done();
 102: }
 103: 
 104: /*/* COMMANDS */
 105: 
 106: cmd()
 107: {
 108:     extern delete();
 109: 
 110:     if (flags & (flm|flc))  useerr();
 111:     if (narg <= 2)          useerr();
 112:     rddir();
 113:     gettape(delete);
 114:     wrdir();
 115:     check();
 116: }
 117: 
 118: cmr()
 119: {
 120:     if (flags & (flc|flm))      clrdir();
 121:     else                rddir();
 122:     getfiles();
 123:     update();
 124:     check();
 125: }
 126: 
 127: cmt()
 128: {
 129:     extern taboc();
 130: 
 131:     if (flags & (flc|flw))  useerr();
 132:     rddir();
 133:     if (flags & flv)
 134:         printf("   mode    uid gid tapa    size   date    time name\n");
 135:     gettape(taboc);
 136:     check();
 137: }
 138: 
 139: cmx()
 140: {
 141:     extern extract();
 142: 
 143:     if (flags & (flc))      useerr();
 144:     rddir();
 145:     gettape(extract);
 146:     done();
 147: }
 148: 
 149: check()
 150: {
 151:     usage();
 152:     done();
 153: }
 154: 
 155: done()
 156: {
 157:     printf("End\n");
 158:     exit(0);
 159: }
 160: 
 161: encode(pname,dptr)  /* pname points to the pathname
 162: 			 * nptr points to next location in nameblk
 163: 			 * dptr points to the dir entry		   */
 164: char    *pname;
 165: struct  dent *dptr;
 166: {
 167:     register  char *np;
 168:     register n;
 169: 
 170:     dptr->d_namep = np = nptr;
 171:     if (np > top - NAMELEN)  {
 172:         if(sbrk(BRKINCR) == (char *)-1) {
 173:             printf("Out of core\n");
 174:             done();
 175:         } else
 176:             top += BRKINCR;
 177:     }
 178:     if((n=strlen(pname)) > NAMELEN) {
 179:         printf("Pathname too long - %s\nFile ignored\n",pname);
 180:         clrent(dptr);
 181:     }
 182:     else {
 183:         nptr += n+1;
 184:         strcpy(np, pname);
 185:     }
 186: }
 187: 
 188: decode(pname,dptr)  /* dptr points to the dir entry
 189: 			 * name is placed in pname[] */
 190: char    *pname;
 191: struct  dent *dptr;
 192: {
 193: 
 194:     strcpy(pname, dptr->d_namep);
 195: }

Defined functions

check defined in line 149; used 3 times
cmd defined in line 106; used 2 times
  • in line 7, 35
cmr defined in line 118; used 8 times
cmt defined in line 127; used 2 times
  • in line 7, 47
cmx defined in line 139; used 2 times
  • in line 7, 55
decode defined in line 188; used 4 times
done defined in line 155; used 14 times
encode defined in line 161; used 2 times
main defined in line 3; never used
optap defined in line 65; used 1 times
  • in line 60
setcom defined in line 89; used 5 times
useerr defined in line 98; used 6 times
Last modified: 1981-07-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1003
Valid CSS Valid XHTML 1.0 Strict