1: static  char *sccsid = "@(#)gcos.c	4.3 (Berkeley) 85/08/30";
   2: /* GCOS DEPENDENT PROCEDURES */
   3: 
   4: 
   5: /* DEFAULT RULES FOR GCOS */
   6: 
   7: char *builtin[]
   8:     {
   9:     ".SUFFIXES : .d .c .y .lib",
  10:     ".d.c:",
  11:     "\t./dtgen $<",
  12:     ".y.c:",
  13:     "\t./yacc $<",
  14:     "\tcopy y.tab.c; /$@",
  15:     ".y.lib:",
  16:     "\t./yacc $<",
  17:     "\t./cc y.tab.c r=$@",
  18:     ".c.lib:",
  19:     "\t./cc $< r=$@",
  20:     0 };
  21: 
  22: # define MAXCSIZE 500
  23: # define YZERO 60
  24: 
  25: int gtcalled 0;
  26: 
  27: /* all kinds of static declarations that must be used.. */
  28: 
  29: static double day { 64*1000*60*60*24 };  /* length of day in clock ticks */
  30: 
  31: struct { int lhs:18, rhs:18; };
  32: struct catb {
  33:     int words[6],
  34:     name1, name2,
  35:     passw1, passw2,
  36:     word10, word11,
  37:     datcreat, datmod,  datused,
  38:     stuff[6],
  39:     jjjj:18, tused:18;
  40:     };
  41: struct { int :3, slot:18; };  /* slot where time from cat. block fits */
  42: 
  43: struct catdesc {
  44:     int cat1, cat2, cpass1, cpass2,
  45:         file1, file2, filep1, filep2,
  46:         endmark; };
  47: 
  48: extern int _q_reg, _a_reg;
  49: 
  50: 
  51: # define A10(x,y) 10*x + y
  52: 
  53: /*	interpret the mm/dd/yy format */
  54: 
  55: struct d9 { int :5, m1:4, :5, m2:4, :9,
  56:         :5, d1:4, :5, d2:4, :9,
  57:         :5, y1:4, :5, y2:4  ;};
  58: 
  59: struct d6 { int :2, m61:4, :2, m62:4,
  60:         :2, d61:4, :2, d62:4,
  61:         :2, y61:4, :2, y62:4; };
  62: 
  63: static day6( d6word ){ /* return the day number of a word in bci format */
  64:     int m, y, d;
  65: 
  66:     y = A10( d6word.y61, d6word.y62 );
  67:     m = A10( d6word.m61, d6word.m62 );
  68:     d = A10( d6word.d61, d6word.d62 );
  69: 
  70:     return( d + 31*( m + 12*(y-YZERO) ) );
  71:     }
  72: 
  73: static day9( p ) register int *p; {
  74: 
  75:     int m, y, d;
  76: 
  77:     y = A10( p->y1, p->y2 );
  78:     m = A10( p->m1, p->m2 );
  79:     d = A10( p->d1, p->d2 );
  80: 
  81:     return( d + 31*( m + 12*(y-YZERO) ) );
  82:     }
  83: 
  84: 
  85: static int dfold( dayno, timeno ){
  86:     int kk;
  87:     kk = ( day*dayno + timeno) / 32768.;
  88:     }
  89: 
  90: int prestime(){
  91:     int date[2];
  92:     drldrl( 021, date );
  93:     return( dfold( day9(date), _q_reg ) );
  94:     }
  95: 
  96: 
  97: 
  98: # define DODRL ar[0] = status; ar[1] = &b.cat1; drldrl(30,sp1,sp2); p=ar[0]<<18;
  99: 
 100: static struct { int fn1, fn2;  int ftm; } fbb[MAXCSIZE];
 101: static int catsiz;
 102: 
 103: getcat() {
 104: 
 105:     register i, *p, j;
 106:     int asname[4];
 107:     struct catdesc b;
 108:     int sp1, sp2, temp;
 109:     int ar[2], status[2];
 110:     int filbuf[380];
 111: 
 112:     gtcalled = 1;
 113: 
 114:     sp1 = ar;
 115:     sp1 =>> 18;
 116:     sp2 = filbuf;
 117:     sp2 =>>18;
 118:     sp2.lhs = 19;
 119: 
 120:     b.cat1 = b.cat2 = b.file1 = -1;
 121:     b.cpass1 = b.cpass2 = 0202020202020;
 122: 
 123:     DODRL
 124:     sp2.lhs++;
 125:     for( i=0; p!=0 && i<MAXCSIZE; ++i ){
 126: 
 127:         fbb[i].fn1 = b.file1 = p->name1;
 128:         fbb[i].fn2 = b.file2 = p->name2;
 129:         b.filep1 = p->passw1;
 130:         b.filep2 = p->passw2;
 131:         b.endmark = -1;
 132:         temp = 0;
 133:         temp.slot = p->tused;
 134:         fbb[i].ftm = dfold( day6(p->datmod), temp );
 135:         DODRL
 136:         }
 137:     catsiz = i;
 138:     }
 139: 
 140:  exists( p )
 141:  struct nameblock *p; {
 142:     char *s, *cp, name[13];
 143:     int i, *p, bcd[2];
 144: 
 145: /*
 146:    cheat about names with slashes -- try opening;
 147:    if it is openable, it exists, and assume it was made
 148:    at t=1 (long time ago); otherwise, assume it
 149:    does not exist
 150: */
 151: 
 152: cp = p->namep;
 153: 
 154: for(s=cp ; *s ; ++s)
 155:     if(*s == '/')
 156:         if(i = copen(cp,'r') < 0)
 157:             return(0);
 158:         else    {
 159:             cclose(i);
 160:             return(1);
 161:             }
 162: 
 163: if(gtcalled == 0)  getcat();
 164: 
 165:     p = name;
 166:     for( i=0; *cp; ++i ) name[i] = *cp++;
 167:     while( i<12 ) name[i++] = ' ';
 168:     f9to6( *p, bcd[0], 12 );
 169:     for ( i=0; i<catsiz; ++i ){
 170:         if( fbb[i].fn1 == bcd[0] && fbb[i].fn2 == bcd[1] )
 171:             return( fbb[i].ftm );
 172:         }
 173:     return( 0 );
 174:     }
 175: 
 176: 
 177: #include "defs"
 178: 
 179: static char n13[13];
 180: static char *n13end &n13[12];
 181: 
 182: 
 183: 
 184: struct depblock *srchdir(pat, mkchain, nextdbl)
 185: 
 186: char *pat; /* pattern to be matched in directory */
 187: int mkchain;  /* nonzero if results to be remembered */
 188: struct depblock *nextdbl;  /* final value for chain */
 189: {
 190: int dirf;
 191: int i, nread;
 192: char *dirname, *dirpref, *endir, *filepat, *p, temp[BUFSIZ];
 193: char fullname[BUFSIZ], *p1, *p2, *copys();
 194: struct nameblock *q;
 195: struct depblock *thisdbl;
 196: struct pattern *patp;
 197: int *intp1, *intp2;
 198: 
 199: if(gtcalled == 0)  getcat();
 200: thisdbl=0;
 201: 
 202: if(mkchain == 0)
 203:     for(patp=firstpat ; patp!=0 ; patp = patp->nxtpattern)
 204:         if(! unequal(pat, patp->patval)) return(0);
 205: 
 206: patp = ALLOC(pattern);
 207: patp->nxtpattern = firstpat;
 208: firstpat = patp;
 209: patp->patval = copys(pat);
 210: 
 211: endir = 0;
 212: 
 213: for(p=pat; *p!='\0'; ++p)
 214:     if(*p=='/') endir = p;
 215: 
 216: if(endir==0)
 217:     {
 218:     dirname = "";
 219:     dirpref = "";
 220:     filepat = pat;
 221:     }
 222: else    {
 223: fatal("File name has an embedded slash");
 224:     dirname = pat;
 225:     *endir = '\0';
 226:     dirpref = concat(dirname, "/", temp);
 227:     filepat = endir+1;
 228:     }
 229: 
 230: for(i=0;i<catsiz;++i)
 231:     {
 232:     intp1 = &fbb[i].fn1;
 233:     intp2 = n13;
 234:     f6to9(*intp1, *intp2, 12);
 235:     for(p1=n13; p1<n13end && *p1!=' ' ; ++p1)
 236:         if('A'<=*p1 && *p1<='Z') *p1 =+ ('a'-'A');
 237:         *p1 = '\0';
 238: 
 239:     if( amatch(n13,filepat) )
 240:         {
 241:         concat(dirpref,n13,fullname);
 242:         if( (q=srchname(fullname)) ==0)
 243:             q = makename(copys(fullname));
 244:         if(mkchain)
 245:             {
 246:             thisdbl = ALLOC(depblock);
 247:             thisdbl->nextp = nextdbl;
 248:             thisdbl->depname = q;
 249:             nextdbl = thisdbl;
 250:             }
 251:         }
 252:     }
 253: 
 254: if(endir != 0)  *endir = '/';
 255: 
 256: return(thisdbl);
 257: }
 258: 
 259: /* stolen from glob through find */
 260: 
 261: amatch(s, p)
 262: char *s, *p;
 263: {
 264:     register int cc, scc, k;
 265:     int c, lc;
 266: 
 267:     scc = *s;
 268:     lc = 077777;
 269:     switch (c = *p) {
 270: 
 271:     case '[':
 272:         k = 0;
 273:         while (cc = *++p) {
 274:             switch (cc) {
 275: 
 276:             case ']':
 277:                 if (k)
 278:                     return(amatch(++s, ++p));
 279:                 else
 280:                     return(0);
 281: 
 282:             case '-':
 283:                 k =| lc <= scc & scc <= (cc=p[1]);
 284:             }
 285:             if (scc==(lc=cc)) k++;
 286:         }
 287:         return(0);
 288: 
 289:     case '?':
 290:     caseq:
 291:         if(scc) return(amatch(++s, ++p));
 292:         return(0);
 293:     case '*':
 294:         return(umatch(s, ++p));
 295:     case 0:
 296:         return(!scc);
 297:     }
 298:     if (c==scc) goto caseq;
 299:     return(0);
 300: }
 301: 
 302: umatch(s, p)
 303: char *s, *p;
 304: {
 305:     if(*p==0) return(1);
 306:     while(*s)
 307:         if (amatch(s++,p)) return(1);
 308:     return(0);
 309: }
 310: 
 311: 
 312: 
 313: dosys(comstring,nohalt)
 314: char *comstring;
 315: int nohalt;
 316: {
 317: char *p;
 318: 
 319: for(p=comstring ; *p!='\0' ; ++p);
 320: if( p-comstring > 80)
 321:     fatal("Command string longer than 80 characters");
 322: 
 323: system(comstring);
 324: 
 325: return(0);
 326: }
 327: 
 328: 
 329: touch(s)
 330: char *s;
 331: {
 332: fprintf(stderr, "touch not yet implemented on GCOS\n");
 333: cexit(2);
 334: }

Defined functions

amatch defined in line 261; used 4 times
day6 defined in line 63; used 1 times
day9 defined in line 73; used 1 times
  • in line 93
dfold defined in line 85; used 2 times
dosys defined in line 313; never used
exists defined in line 140; never used
getcat defined in line 103; used 2 times
prestime defined in line 90; never used
srchdir defined in line 184; never used
touch defined in line 329; never used
umatch defined in line 302; used 1 times

Defined variables

builtin defined in line 7; never used
catsiz defined in line 101; used 3 times
day defined in line 29; used 1 times
  • in line 87
fbb defined in line 100; used 7 times
gtcalled defined in line 25; used 3 times
n13 defined in line 180; used 4 times
n13end defined in line 180; used 1 times
sccsid defined in line 1; never used

Defined struct's

catb defined in line 32; never used
catdesc defined in line 43; used 2 times
  • in line 107(2)
d6 defined in line 59; never used
d9 defined in line 55; never used

Defined macros

A10 defined in line 51; used 6 times
DODRL defined in line 98; used 2 times
MAXCSIZE defined in line 22; used 2 times
YZERO defined in line 23; used 2 times
Last modified: 1987-08-07
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3517
Valid CSS Valid XHTML 1.0 Strict