Annotation of 40BSD/cmd/make/gcos.c, revision 1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.