|
|
1.1 root 1: static char *sccsid = "@(#)gcos.c 4.1 (Berkeley) 81/02/28";
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( cp ) char *cp; {
141: char *s, name[13];
142: int i, *p, bcd[2];
143:
144: /*
145: cheat about names with slashes -- try opening;
146: if it is openable, it exists, and assume it was made
147: at t=1 (long time ago); otherwise, assume it
148: does not exist
149: */
150:
151: for(s=cp ; *s ; ++s)
152: if(*s == '/')
153: if(i = copen(cp,'r') < 0)
154: return(0);
155: else {
156: cclose(i);
157: return(1);
158: }
159:
160: if(gtcalled == 0) getcat();
161:
162: p = name;
163: for( i=0; *cp; ++i ) name[i] = *cp++;
164: while( i<12 ) name[i++] = ' ';
165: f9to6( *p, bcd[0], 12 );
166: for ( i=0; i<catsiz; ++i ){
167: if( fbb[i].fn1 == bcd[0] && fbb[i].fn2 == bcd[1] )
168: return( fbb[i].ftm );
169: }
170: return( 0 );
171: }
172:
173:
174: #include "defs"
175:
176: static char n13[13];
177: static char *n13end &n13[12];
178:
179:
180:
181: struct depblock *srchdir(pat, mkchain, nextdbl)
182:
183: char *pat; /* pattern to be matched in directory */
184: int mkchain; /* nonzero if results to be remembered */
185: struct depblock *nextdbl; /* final value for chain */
186: {
187: int dirf;
188: int i, nread;
189: char *dirname, *dirpref, *endir, *filepat, *p, temp[100];
190: char fullname[100], *p1, *p2, *copys();
191: struct nameblock *q;
192: struct depblock *thisdbl;
193: struct pattern *patp;
194: int *intp1, *intp2;
195:
196: if(gtcalled == 0) getcat();
197: thisdbl=0;
198:
199: if(mkchain == 0)
200: for(patp=firstpat ; patp!=0 ; patp = patp->nxtpattern)
201: if(! unequal(pat, patp->patval)) return(0);
202:
203: patp = ALLOC(pattern);
204: patp->nxtpattern = firstpat;
205: firstpat = patp;
206: patp->patval = copys(pat);
207:
208: endir = 0;
209:
210: for(p=pat; *p!='\0'; ++p)
211: if(*p=='/') endir = p;
212:
213: if(endir==0)
214: {
215: dirname = "";
216: dirpref = "";
217: filepat = pat;
218: }
219: else {
220: fatal("File name has an embedded slash");
221: dirname = pat;
222: *endir = '\0';
223: dirpref = concat(dirname, "/", temp);
224: filepat = endir+1;
225: }
226:
227: for(i=0;i<catsiz;++i)
228: {
229: intp1 = &fbb[i].fn1;
230: intp2 = n13;
231: f6to9(*intp1, *intp2, 12);
232: for(p1=n13; p1<n13end && *p1!=' ' ; ++p1)
233: if('A'<=*p1 && *p1<='Z') *p1 =+ ('a'-'A');
234: *p1 = '\0';
235:
236: if( amatch(n13,filepat) )
237: {
238: concat(dirpref,n13,fullname);
239: if( (q=srchname(fullname)) ==0)
240: q = makename(copys(fullname));
241: if(mkchain)
242: {
243: thisdbl = ALLOC(depblock);
244: thisdbl->nextp = nextdbl;
245: thisdbl->depname = q;
246: nextdbl = thisdbl;
247: }
248: }
249: }
250:
251: if(endir != 0) *endir = '/';
252:
253: return(thisdbl);
254: }
255:
256: /* stolen from glob through find */
257:
258: amatch(s, p)
259: char *s, *p;
260: {
261: register int cc, scc, k;
262: int c, lc;
263:
264: scc = *s;
265: lc = 077777;
266: switch (c = *p) {
267:
268: case '[':
269: k = 0;
270: while (cc = *++p) {
271: switch (cc) {
272:
273: case ']':
274: if (k)
275: return(amatch(++s, ++p));
276: else
277: return(0);
278:
279: case '-':
280: k =| lc <= scc & scc <= (cc=p[1]);
281: }
282: if (scc==(lc=cc)) k++;
283: }
284: return(0);
285:
286: case '?':
287: caseq:
288: if(scc) return(amatch(++s, ++p));
289: return(0);
290: case '*':
291: return(umatch(s, ++p));
292: case 0:
293: return(!scc);
294: }
295: if (c==scc) goto caseq;
296: return(0);
297: }
298:
299: umatch(s, p)
300: char *s, *p;
301: {
302: if(*p==0) return(1);
303: while(*s)
304: if (amatch(s++,p)) return(1);
305: return(0);
306: }
307:
308:
309:
310: dosys(comstring,nohalt)
311: char *comstring;
312: int nohalt;
313: {
314: char *p;
315:
316: for(p=comstring ; *p!='\0' ; ++p);
317: if( p-comstring > 80)
318: fatal("Command string longer than 80 characters");
319:
320: system(comstring);
321:
322: return(0);
323: }
324:
325:
326: touch(s)
327: char *s;
328: {
329: fprintf(stderr, "touch not yet implemented on GCOS\n");
330: cexit(2);
331: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.