|
|
1.1 root 1: 0707070035330205021006640000510000040000010144070423770206100001100000001163Makefile # docgen defaults to coversheet script mcsdata
2: # timestamp is used by tmac.cs to compute timestamp for itds
3: # cstrans is used by tmac.cs to package & ship coversheet
4: # to itds database
5: all: cstrans timestamp docgen
6: docgen: docgen.c
7: cstrans: header.h trans.l getstamp.o
8: lex trans.l
9: cc lex.yy.c getstamp.o -ll -o cstrans
10: timestamp: timestamp.o getstamp.o
11: cc timestamp.o getstamp.o -o timestamp
12: install: cstrans timestamp docgen
13: cp docgen /usr/bin
14: cp mcsdata /usr/lib/docgen
15: cp cstrans /usr/lib/tmac
16: cp timestamp /usr/lib/tmac
17: cp name.sed /usr/lib/tmac
18: cp sendcover.sh /usr/lib/tmac/sendcover
19: clean:
20: rm cstrans lex.yy.c
21: 0707070035330025251006640000510000040000010073170412351073100001100000043541docgen.c /**********
22: docgen.c
23:
24: (091984 version: from llc 080284; minor changes by vbt)
25:
26: modify *mmfile, *msfile, and *mcfile strings as needed to supply
27: full pathnames for mmdata, msdata, and mcsdata files;
28:
29: **********/
30: #include <stdio.h>
31: #include <signal.h>
32: char *mmfile="/usr/lib/docgen/mmdata";
33: char *msfile="/usr/lib/docgen/msdata";
34: char *mcfile="/usr/lib/docgen/mcsdata";
35: char *wr = "/usr/lib/docgen/wr";
36: #define eatblanks(a) while((c=getc(a)) == ' '|| c == '\t')
37: #define MAX 100
38: #define CMAX 7500
39: #define LMAX 200
40: #define QMAX 100
41: #define NPATH 10
42: #define NENT 200
43: #define BUFS 512
44: #define LABMAX 20
45: #define STACK 10
46: #define NEST 10
47:
48: int inap;
49: int debug = 0;
50: int sdebug = 0;
51: int verbose = 0;
52: #define ARGS 1
53: #define ONELINE 2
54: #define MANY 4
55: #define OUT 8
56: #define PRINT 16
57: #define SKIP 32
58: #define BLOOP 128
59: #define PATH 256
60: #define QUEST 512
61: #define STUFF 1024
62: #define NAME 2048
63: #define SUM 4096
64: #define PAR 8192
65: #define FLOOP 16384
66: #define SEVERAL 32768
67: #define QSTUFF 65536
68:
69: struct q_a {
70: char *qtext;
71: char *text;
72: char *macro;
73: unsigned long type;
74: struct qa *argq;
75: } s[MAX];
76: struct q_a *p = s;
77:
78: unsigned long gettype();
79: int sig_in_ed();
80: char buf[CMAX];
81: char *ptr = buf;
82: char obuf[BUFS];
83: char *optr = obuf;
84: FILE *outp;
85: char *ofile;
86: char line[LMAX];
87: char sline[LMAX];
88: char *first;
89: int lineno = 1;
90:
91: struct qa {
92: char *text;
93: struct qa *nexta;
94: } ques[QMAX];
95: struct qa *qp = ques;
96:
97: struct pa {
98: char *name;
99: struct list *root;
100: } paths[NPATH];
101: struct pa *pp = paths;
102:
103: struct list {
104: struct q_a *entry;
105: struct list *next;
106: struct list *loop;
107: char *quest;
108: struct list *floop;
109: } list[NENT];
110: struct list *lp = list;
111: struct list *stack[STACK];
112: struct list **st = stack;
113:
114: struct pa *findpath();
115: struct lab {
116: struct list *path;
117: struct list *place;
118: } save[LABMAX], *sav=save;
119: struct lab *savp;
120: struct lab *savc[10];
121: unsigned stype[10];
122: int curly = 0;
123: char *onepath;
124: char *qfile;
125: char *namesf="tagfile";
126: char nname[50];
127: FILE *popen(), *edp;
128:
129: main(argc,argv)
130: int argc;
131: char *argv[];
132: {
133:
134: qfile = mcfile;
135: while(argc > 1 && *argv[1] == '-'){
136: switch(argv[1][1]){
137: case 'f':
138: if(argc > 2)qfile=argv[2];
139: argc--;
140: argv++;
141: break;
142: case 'm':
143: if(argv[1][2] == 's')qfile=msfile;
144: else if(argv[1][2] == 'c')qfile=mcfile;
145: else if(argv[1][2] == 'm')qfile=mmfile;
146: else {
147: fprintf("unknown macro package %s\n",argv);
148: exit(0);
149: }
150: break;
151: case 'w':
152: qfile = wr;
153: break;
154: case 'd':
155: sdebug=1;
156: break;
157: case 'p':
158: debug=1;
159: break;
160: case 'v':
161: verbose=1;
162: break;
163: default:
164: fprintf(stderr,"unknown flag %c\n",argv[1][1]);
165: exit(0);
166: }
167: argc--; argv++;
168: }
169: if(argc > 1)ofile=argv[1];
170: init(qfile);
171: if(onepath != 0){
172: pp=findpath(onepath);
173: lp=pp->root;
174: process(1);
175: }
176: else process(0);
177: done();
178: }
179: init(file)
180: char *file;
181: {
182: FILE *inp;
183: int c;
184: int i;
185: int printall=0;
186: char command[50];
187: FILE *dumb;
188:
189: if(ofile == 0){
190: if(file == wr){
191: printf("Tags going to file tagfile\n");
192: ofile = namesf;
193: }
194: else if(file == mcfile){
195: printf("Output going to file temp.cover\n");
196: ofile = "temp.cover";
197: }
198: else {
199: printf("Output going to file temp\n");
200: ofile = "temp";
201: }
202: }
203: if((inp=fopen(file,"r"))==NULL){
204: fprintf(stderr,"can't open script file %s\n",file);
205: exit(0);
206: }
207: pp->name = onepath = ptr;
208: i=0;
209: while((c=getc(inp)) != '\n'){
210: if(c == ','){
211: *ptr++ = '\0';
212: (++pp)->name = ptr;
213: i++;
214: if(pp > &paths[NPATH-1])
215: error("more than 10 paths-NPATH");
216: }
217: else if(c != ' ' && c != '\t')
218: *ptr++ = c;
219: }
220: *ptr++ = '\0';
221: if(i > 0)onepath=0;
222: lineno++;
223: first = ptr;
224: if(getstr(inp)== 0)
225: if(onepath == 0)
226: error("text string expected");
227: while(getentry(inp) != 0){
228: if(p++ >= &s[MAX-1])
229: error("number of instructions exceeded-MAX");
230: }
231: if(debug)printf("\n");
232: if((dumb = fopen(ofile,"r")) != NULL){
233: if(file == wr){
234: printf("File %s already exists; Tags will be appended\n",ofile);
235: printall++;
236: }
237: else {
238: printf("File %s already exists; Text will be appended\n",ofile);
239: }
240: fclose(dumb);
241: }
242: if((dumb = fopen(ofile,"a")) == NULL){
243: fprintf(stderr,"can't open %s\n",ofile);
244: exit(1);
245: }
246: fclose(dumb);
247: sprintf(command,"ed - %s\n",ofile);
248: signal(SIGINT,sig_in_ed);
249: if((edp = popen(command,"w")) == NULL){
250: printf("can't involk ed\n");
251: exit(0);
252: }
253: setbuf(edp,NULL);
254: if(printall){
255: printf("The following tags are already defined:\n");
256: fputs("1,$p\n",edp);
257: fflush(edp);
258: sleep(8);
259: printf("\n");
260: }
261: fputs("a\n",edp);
262: inap = 1;
263: }
264:
265: getentry(inp)
266: FILE *inp;
267: {
268: char *l;
269: int c;
270: int comment = 0;
271:
272: if(debug)printf("\n place %o ",p);
273: savp = sav;
274: l = line;
275: while((*l = c = getc(inp)) != ':'){
276: if(c == EOF)return(0);
277: if(c == '*'){
278: if(comment){
279: comment=0;
280: continue;
281: }
282: else {
283: comment=1;
284: continue;
285: }
286: }
287: if(comment){
288: if(c == '\n')lineno++;
289: continue;
290: }
291: if(c == '\\'){
292: *l = getc(inp);
293: if(++l >= &line[LMAX-1])
294: error("line length exceeded-LMAX");
295: continue;
296: }
297: if(c == '}'){
298: if(debug)printf("found }\n");
299: l=ptr;
300: getstr(inp);
301: addloop(--curly,l);
302: eatline(inp);
303: sav = savc[curly];
304: p->type = BLOOP;
305: return(1);
306: }
307: if(c == ','){
308: *l = '\0';
309: addentry(line,p);
310: l=line;
311: }
312: else if(c == '\n'){
313: l=line;
314: lineno++;
315: }
316: else if(c != ' ' && c != '\t'){
317: if(l++ >= &line[LMAX-1])
318: error("line length exceeded-LMAX");
319: }
320: }
321: *l = '\0';
322: addentry(line,p);
323: p->macro = ptr;
324: while((*ptr = c = getc(inp))!= ':'){
325: if(c == '\\'){
326: *ptr = getc(inp);
327: if(++ptr >= &buf[CMAX-1])
328: error("string buffer exceeded-CMAX");
329: }
330: else if(c == ' ' && ptr == p->macro);
331: else if(c == '{' && ptr == p->macro){
332: if(debug)printf("in { savp %o\n",savp);
333: (sav++)->path = 0;
334: stype[curly] = BLOOP;
335: savc[curly++] = savp;
336: if(curly >= NEST)
337: error("nesting depth exceeded-NEST");
338: if((c = getc(inp)) == ' '|| c == '\t')
339: eatblanks(inp);
340: if(c == '\n'){
341: lineno++;
342: if((c = getc(inp)) == ' '|| c == '\t')
343: eatblanks(inp);
344: }
345: if(c == '"'){
346: p->type = FLOOP;
347: ungetc(c,inp);
348: l=ptr;
349: getstr(inp);
350: p->qtext = l;
351: stype[curly-1] = FLOOP;
352: }
353: else {
354: ungetc(c,inp);
355: p->type = BLOOP;
356: }
357: return(1);
358: }
359: else if(ptr++ >= &buf[CMAX-1])
360: error("string buffer exceeded-CMAX");
361: }
362: if(p->macro == ptr)p->macro=0;
363: else *ptr++ = '\0';
364: p->type = gettype(inp);
365: if(p->type&QUEST){
366: p->qtext = ptr;
367: if(getstr(inp) == 0)
368: error("text string expected");
369: }
370: else p->qtext = 0;
371: p->text = ptr;
372: if(p->type&(ONELINE|SEVERAL|PRINT|MANY|PATH))
373: if(getstr(inp)== 0)
374: error("text string expected");
375: if(p->text == ptr)p->text = 0;
376: if(debug)printf(" macro %s type %d text %s ",p->macro,p->type,p->text);
377: if(sdebug)db(p);
378: if(p->type & (ARGS |SKIP)){
379: p->argq = qp;
380: qp->text = ptr;
381: while(getstr(inp) != 0){
382: qp->nexta = (qp+1);
383: if(debug||sdebug)printf("\n arg question= %s",qp->text);
384: if(debug)printf(" next %o",qp->nexta);
385: if(qp++ >= &ques[QMAX-1])
386: error("number of questions exceeded-QMAX");
387: qp->text = ptr;
388: }
389: (qp-1)->nexta = 0;
390: if(debug)printf("\n last %s next %o",(qp-1)->text,(qp-1)->nexta);
391: if(sdebug)printf("\n");
392: }
393: sav = savp;
394: return(1);
395: }
396: getstr(inp)
397: FILE *inp;
398: {
399: int c;
400: while((c=getc(inp)) == ' ' || c == '\t' || c == '\n')if(c == '\n')lineno++;
401: if(c != '\"'){
402: ungetc(c,inp);
403: return(0);
404: }
405: while((*ptr=c=getc(inp)) != '\"'){
406: if(ptr++ >= &buf[CMAX])
407: error("string buffer exceeded-CMAX");
408: if(c == '\n')lineno++;
409: }
410: *ptr++ = '\0';
411: return(1);
412: }
413: addentry(ch,p)
414: char *ch;
415: struct q_a *p;
416: {
417: struct list *ll;
418: if(debug || sdebug)printf("path= %s, ",ch);
419:
420: for(pp=paths;pp->name != 0 && pp < &paths[NPATH];pp++){
421: if(match(ch,pp->name)){
422: if(pp->root == 0){
423: pp->root = lp;
424: }
425: else {
426: ll=pp->root;
427: while(ll->next != 0)ll=ll->next;
428: ll->next = lp;
429: }
430: if(debug)printf("entry %o path %o\n",lp,pp);
431: sav->path = (struct list *)pp;
432: sav->place = lp;
433: lp->entry = p;
434: if(lp++ >= &list[NENT-1])
435: error("tree exceeded-NENT");
436: if(sav++ >= &save[LABMAX-1])
437: error("saved paths exceeded-LABMAX");
438: return;
439: }
440: }
441: printf("no path to %s\n",ch);
442: exit(0);
443: }
444:
445: addloop(in,cp)
446: char *cp;
447: {
448: struct lab *sp;
449: struct list *ll;
450:
451: sp = savc[in];
452: while((ll = sp->path) != 0){
453: if(debug)printf("addloop sp %o path %o",sp,sp->path);
454: while(ll->next != 0){
455: ll=ll->next;
456: }
457: if(debug)printf("ll %o place %o\n",ll,sp->place);
458: if(ll->loop != 0){
459: ll->next = lp;
460: lp->loop = sp->place;
461: lp->quest = cp;
462: lp->entry = p;
463: if(lp++ >= &list[NENT-1])
464: error("tree exceeded - NENT");
465: }
466: else {
467: ll->loop = sp->place;
468: ll->quest = cp;
469: }
470: if(stype[in] == FLOOP){
471: sp->place->floop = lp;
472: lp->entry = p;
473: if(lp++ >= &list[NENT-1])
474: error("tree exceeded - NENT");
475: }
476: sp++;
477: }
478: }
479: unsigned long
480: gettype(inp)
481: FILE *inp;
482: {
483: int c;
484: unsigned long i;
485: i=0;
486: another:
487: while((c=getc(inp)) == ' ' || c == '\t');
488: switch(c){
489: case 'A':
490: i |= ARGS;
491: break;
492: case 'M':
493: i |= MANY;
494: break;
495: case 'O':
496: if((c=getc(inp)) == 'U')
497: i |= OUT;
498: else if(c == 'N')
499: i|= ONELINE;
500: else error("unknown action");
501: break;
502: case 'P':
503: if((c=getc(inp)) == 'R')
504: i |= PRINT;
505: else if(c == 'A'){
506: if((c=getc(inp)) == 'T')
507: i |= PATH;
508: else if(c == 'R')
509: i |= PAR|MANY;
510: else error("unknown action");
511: }
512: else error("unknown action");
513: break;
514: case 'S':
515: if((c=getc(inp)) == 'T')
516: i |= STUFF|ARGS;
517: else if(c == 'K')
518: i |= SKIP;
519: else if(c == 'U')
520: i |= SUM|MANY;
521: else if(c == 'E')
522: i |= SEVERAL;
523: else error("unknown action");
524: break;
525: case 'Q':
526: if((c=getc(inp)) == 'U')
527: i |= QUEST;
528: else if(c == 'S')
529: i |= QSTUFF|ARGS;
530: else error("unknown action");
531: break;
532: case 'N':
533: i |= NAME|ONELINE;
534: break;
535: default:
536: error("unknown action");
537: }
538: while((c=getc(inp))!= '\n')
539: if(c == '&')goto another;
540: lineno++;
541: if(i&OUT)
542: if(i & ~OUT){
543: if(i & ~(OUT|QUEST))
544: error("action error - OUT not alone");
545: }
546: if(i & PRINT)
547: if(i & ~PRINT){
548: if(i & ~(PRINT|QUEST))
549: error("action error - PRINT not alone");
550: }
551: if(i & PATH)
552: if(i & ~PATH)error("action error - PATH not alone");
553: if((i&(MANY|ONELINE))==(MANY|ONELINE))
554: error("contridictory actions - MANY & ONELINE");
555: return(i);
556: }
557:
558: process(start)
559: int start;
560: {
561: if(start == 0){
562: printf("%s\n",first);
563: getl(stdin,line);
564: pp=findpath(line);
565: lp = pp->root;
566: }
567: more:
568: while(lp){
569: if(question(lp->entry)== 1)
570: continue;
571: if(lp->loop != 0){
572: printf("%s\n",lp->quest);
573: getl(stdin,line);
574: if(line[0] == 'y'|| line[0] == 'Y')
575: lp=lp->loop;
576: else{
577: if(lp->loop->entry->type & 1){
578: lp->loop->entry->type &= 0177776;
579: }
580: if(line[0] == 'q')done();
581: else lp=lp->next;
582: }
583: }
584: else
585: lp = lp->next;
586: }
587: if(*st != 0){
588: lp = *st--;
589: if(lp->loop != 0){
590: printf("%s\n",lp->quest);
591: getl(stdin,line);
592: if(line[0] == 'y' || line[0] == 'Y')
593: lp=lp->loop;
594: else{
595: if(lp->loop->entry->type & 1)
596: lp->loop->entry->type &= 0177776;
597: if(line[0] == 'q')done();
598: else lp=lp->next;
599: }
600: }
601: else lp=lp->next;
602: goto more;
603: }
604: }
605:
606: question(rp)
607: struct q_a *rp;
608: {
609: int blanks;
610: char *ch, *sv;
611:
612: rest:
613: if(debug)printf("in question %o\n",rp);
614: if(rp->type & BLOOP)
615: return(0);
616: if(rp->type & FLOOP){
617: if(rp->type & 1)return(0);
618: printf("%s\n",rp->qtext);
619: getl(stdin,line);
620: if(line[0] == 'y' || line[0] == 'Y'){
621: lp = lp->next;
622: rp->type |= 1;
623: }
624: else if(line[0] == 'q')done();
625: else lp= lp->floop;
626: return(1);
627: }
628: if(rp->type & PATH){
629: *(++st) = lp;
630: if(st >= &stack[STACK-1])
631: error("stack depth exceeded-STACK");
632: printf("%s\n",rp->text);
633: getl(stdin,line);
634: if(line[0] == '\0'){
635: st--;
636: return(0);
637: }
638: pp=findpath(line);
639: lp = pp->root;
640: return(1);
641: }
642: if(rp->type&QUEST){
643: printf("%s\n",rp->qtext);
644: getl(stdin,line);
645: if(line[0] != 'Y' && line[0] != 'y')return(0);
646: }
647: if(rp->text != 0)
648: if((rp->type&MANY) == 0)printf("%s\n",rp->text);
649: if(rp->type&(ONELINE|SEVERAL))
650: getl(stdin,sline);
651: if(rp->type&NAME){
652: return(newname(sline));
653: }
654: if(rp->type&SUM){
655: summary();
656: }
657: if(rp->type&PAR){
658: par();
659: }
660: if(rp->type&(STUFF|QSTUFF)){
661: sv = ch = rp->macro;
662: qp = rp->argq;
663: do{
664: while(*ch != '$'){
665: if(*ch == '\\')ch++;
666: if(*ch == '\0')break;
667: ch++;
668: }
669: if(*ch == '$'){
670: *ch = '\0';
671: out(sv);
672: *ch++ = '$';
673: sv = ch;
674: }
675: printf("%s\n",qp->text);
676: getl(stdin,line);
677: if(rp->type&QSTUFF)
678: if(line[0] == '\0')break;
679: if(*(ch-1) == '$')
680: out(line);
681: qp = qp->nexta;
682: } while(qp != 0);
683: if(rp->type&STUFF)
684: out(sv);
685: else if(*sv == '"')out("\"");
686: out("\n");
687: }
688: else if(rp->type&(ARGS | SKIP)){
689: if((rp->type&SKIP) == 0 && rp->macro != 0)
690: out(rp->macro);
691: qp = rp->argq;
692: do{
693: printf("%s\n",qp->text);
694: blanks = getl(stdin,line);
695: if(rp->type&SKIP){
696: if(line[0] == '\0')
697: return(0);
698: else out(rp->macro);
699: }
700: out(" ");
701: if(line[0] == '\0')blanks++;
702: if(blanks)out("\"");
703: out(line);
704: if(blanks)out("\"");
705: qp=qp->nexta;
706: } while(qp != 0);
707: out("\n");
708: }
709: else if((rp->type&(OUT|ONELINE|MANY))&& rp->macro != 0){
710: out(rp->macro);
711: out("\n");
712: }
713: if(rp->type&SEVERAL){
714: out(rp->macro);
715: out(" ");
716: out(sline);
717: out("\n");
718: }
719: if(rp->type&ONELINE){
720: out(sline);
721: out("\n");
722: }
723: if(rp->type&MANY){
724: if(rp->type&(SUM))
725: printf("%s named %s.sum\n",rp->text,nname);
726: else if(rp->type&PAR)
727: printf("%s named %s.par\n",rp->text,nname);
728: else printf("%s\n",rp->text);
729: printf(" end with : alone on a line (or read a file with :r filename)\n");
730: getl(stdin,line);
731: if(line[0] == ':' && line[1] == 'r'){
732: ch = &line[2];
733: more:
734: readfiles(ch);
735: printf("Type other file names or return\n");
736: getl(stdin,line);
737: if(line[0] == '\0')return(0);
738: ch = line;
739: goto more;
740: }
741: toed();
742: }
743: return(0);
744: }
745: sig_in_ed(){
746: inap = 0;
747: printf("type q to quit ");
748: getl(stdin,line);
749: if(line[0] == 'q')done();
750: fputs("a\n",edp);
751: optr = obuf;
752: inap=1;
753: signal(SIGINT,sig_in_ed);
754: process(1);
755: done();
756: }
757:
758: getl(inp,l)
759: char *l;
760: FILE *inp;
761: {
762: int c;
763: int blanks;
764:
765: blanks=0;
766: while((*l = c = getc(inp)) != '\n'){
767: l++;
768: if(c == ' ' || c == '\t')blanks++;
769: }
770: *l++ = 0;
771: return(blanks);
772: }
773:
774: out(ch)
775: char *ch;
776: {
777: char c;
778:
779: while(*ch != '\0'){
780: if(*ch == '\n'){
781: *optr++ = *ch++;
782: *optr = '\0';
783: fputs(obuf,edp);
784: optr=obuf;
785: if(verbose)printf("%s",obuf);
786: }
787: else *optr++ = *ch++;
788: if(optr >= &obuf[BUFS-1]){
789: *optr = '\0';
790: fputs(obuf,edp);
791: optr = obuf;
792: }
793: }
794: }
795: ofl()
796: {
797: if(optr != obuf){
798: *optr='\0';
799: fputs(obuf,edp);
800: optr=obuf;
801: }
802: if(inap)
803: fputs(".\nw\na\n",edp);
804: else {
805: fputs("w\na\n",edp);
806: inap=1;
807: }
808: }
809: done(){
810: ofl();
811: fputs(".\nq\n",edp);
812: exit(0);
813: }
814:
815: match(ch,hh)
816: char *ch, *hh;
817: {
818: while(*ch == *hh){
819: if(*ch == '\0')return(1);
820: ch++;
821: hh++;
822: }
823: return(0);
824: }
825:
826: struct pa *
827: findpath(ch)
828: char *ch;
829: {
830: for(pp=paths;pp->name != 0;pp++){
831: if(match(ch,pp->name))
832: return(pp);
833: }
834: printf("can't find path for %s\n",ch);
835: exit(0);
836: }
837: eatline(inp)
838: FILE *inp;
839: {
840: while(getc(inp) != '\n');
841: lineno++;
842: }
843: readfiles(ptr)
844: char *ptr;
845: {
846: FILE *io;
847: int nomore;
848: char *bp;
849: char fname[50];
850:
851: ofl();
852: fputs(".\n",edp);
853: nomore = 0;
854: while(1){
855: while(*ptr == ' ')ptr++;
856: bp = ptr;
857: while(*ptr != ' ' && *ptr != '\0')ptr++;
858: if(*ptr == '\0')nomore++;
859: else *ptr++ = '\0';
860: sprintf(fname,"$r %s\n",bp);
861: fputs(fname,edp);
862: if(nomore != 0)break;
863: }
864: fputs("a\n",edp);
865: }
866: error(sp)
867: char *sp;
868: {
869: fprintf(stderr,"%s at line %d file %s\n",sp,lineno,qfile);
870: exit(1);
871: }
872: db(dbp)
873: struct q_a *dbp;
874: {
875: printf(" macro= %s type=",dbp->macro);
876: if(dbp->type&ARGS)printf(" ARGS");
877: if(dbp->type&SKIP)printf(" SKIP");
878: if(dbp->type&OUT)printf(" OUT");
879: if(dbp->type&PRINT)printf(" PRINT");
880: if(dbp->type&ONELINE)printf(" ONELINE");
881: if(dbp->type&SEVERAL)printf(" SEVERAL");
882: if(dbp->type&MANY)printf(" MANY");
883: if(dbp->type&PATH)printf(" PATH");
884: if(dbp->text != 0)printf("\nmain text= %s\n",dbp->text);
885: else printf("\n");
886: }
887: newname(s)
888: char *s;
889: {
890: int i;
891: char *name1, *name2;
892: int pid, rpid, retcode;
893: char *sp,spac[10];
894: restart:
895: sp = spac;
896: *sp = '\0';
897: if(*s == ' ' || *s == '\t')
898: while(*s== ' ' || *s == '\t')*sp++ = *s++;
899: *sp = '\0';
900: for(i=0;*s != '\0';i++)
901: nname[i] = *s++;
902: if(nname[0] == ':'){
903: switch(nname[1]){
904: case 'p':
905: sprintf(line,".\nw\ne %s\n1,$p\na\n",ofile);
906: fputs(line,edp);
907: sleep(8);
908: return(1);
909: case 'r':
910: sprintf(line,".\nw\ne %s\na\n",&nname[3]);
911: printf("Type text to append to file %s\n",&nname[3]);
912: fputs(line,edp);
913: getl(stdin,line);
914: toed();
915: return(1);
916: case 'j':
917: name1=0;
918: name2 = nname;
919: nextn:
920: for(; *name2 != ' ';name2++)
921: if(*name2 == '\0'){
922: printf("error in command line: %s\nplease retype\n",nname);
923: getl(stdin,sline);
924: s=sline;
925: goto restart;
926: }
927: *name2++ = '\0';
928: while(*name2 == ' ')name2++;
929: if(name1 == 0){
930: name1 = name2;
931: goto nextn;
932: }
933: sprintf(line,".\nw\ne %s.sum\n$r %s.sum\nw\n",name1,name2);
934: fputs(line,edp);
935: sprintf(line,"e %s.par\n$r %s.par\nw\n",name1,name2);
936: fputs(line,edp);
937: sprintf(line,"e %s\n/%s/d\nw\na\n",ofile);
938: fputs(line,edp);
939: return(1);
940: default:
941: printf("unknown command %s\n",nname);
942: printf("please retype\n");
943: goto restart;
944: }
945: }
946: if(nname[0] == '!'){
947: if((pid = fork()) == 0){
948: execl("/bin/sh","sh","-c",&nname[1],0);
949: exit(0);
950: }
951: while((rpid=wait(&retcode))!=pid&& rpid != -1);
952: printf("!\n");
953: return(1);
954: }
955: if(i > 10){
956: printf("tag too long - please type new tag ");
957: getl(stdin,sline);
958: s=sline;
959: goto restart;
960: }
961: nname[i] = '\0';
962: sprintf(line, ".\nw\ne %s\na\n%s%s\n",ofile,spac,nname);
963: fputs(line,edp);
964: return(0);
965: }
966: summary(){
967: FILE *ff;
968: sprintf(line,"%s.sum",nname);
969: if((ff = fopen(line,"a")) == NULL){
970: printf("can't open %s\n",line);
971: }
972: sprintf(line,".\nw\ne %s.sum\na\n",nname);
973: fputs(line,edp);
974: fclose(ff);
975: }
976: par(){
977: FILE *ff;
978: sprintf(line,"%s.par",nname);
979: if((ff=fopen(line,"a")) == NULL){
980: printf("can't open %s\n",line);
981: exit(1);
982: }
983: sprintf(line,".\nw\ne %s.par\na\n",nname);
984: fputs(line,edp);
985: fclose(ff);
986: }
987: toed(){
988: while(1){
989: if(line[1] == '\0'){
990: switch(line[0]){
991: case 'i':
992: case 'a':
993: case 'c':
994: inap++;
995: break;
996: case '.':
997: inap = 0;
998: break;
999: case 'q':
1000: if(inap != 0)break;
1001: case ':':
1002: if(inap == 0){fputs("a\n",edp);
1003: inap++;
1004: }
1005: return(0);
1006: }
1007: }
1008: fputs(line,edp);
1009: fputs("\n",edp);
1010: getl(stdin,line);
1011: }
1012: }
1013: 0707070035330205151006640000510000040000010235620412351407300001300000000414getstamp.c #include <sys/types.h>
1014: #include <sys/stat.h>
1015: #include <time.h>
1016: long
1017: getstamp(filename)
1018: char *filename;
1019: {
1020: long mtime;
1021: struct stat fbuf, *fp = &fbuf;
1022: struct tm t, *tp = &t;
1023: stat(filename, fp);
1024: t = *localtime(&fp->st_mtime);
1025: mtime = fp->st_mtime;
1026: return(mtime);
1027: }
1028: 0707070035330205051006640000510000040000010235640412351413100001100000001552header.h /********** docsend.h - 092884 **********/
1029:
1030: #define HEADSIZE 160
1031: #define UJN 0 /* unique job name - 14 bytes */
1032: #define ULOG 15 /* user login - 8 bytes */
1033: #define CO 24 /* company code - 2 bytes */
1034: #define DOCNUM 28 /* first document number (cover sheet only) - 18 bytes */
1035: #define TIMESTAMP 53 /* docsend timestamp - 9 bytes */
1036: #define DEVICE 64 /* device: aps (APS-5), i10 (imagen), X97 (troff xerox), X (nroff xerox), 450 (nroff terminal), a.i (imagen with APS-5 simulation) - 3 bytes */
1037: #define NETWORK 68 /* network - nusend (1), usend (2), others (0) - 1 byte */
1038: #define TODSEND 70 /* TOD of docsend - 10 bytes */
1039: #define DEST 81 /* JES remote station - 5 bytes */
1040: #define BIN 87 /* bin or mail info - 34 bytes */
1041: #define PAGES 90 /* TP%d total pages */
1042: #define DUMMY 122 /* position for next field */
1043: #define VERSION 152 /* docsend version (vbt) - 6 bytes */
1044:
1045: 0707070035330155531007750000510000040000010311640423770172700001500000000155sendcover.sh trap 'rm -f /tmp/cs$$; trap 0; exit' 0 1 2 3 15
1046: L=/usr/lib/tmac
1047: T=/tmp/cs$$
1048: $L/cstrans $T $1 $2
1049: sh $T
1050: rm $T
1051: 0707070035330205071006640000510000040000010235610412351405300001400000000261timestamp.c #include <stdio.h>
1052: main(argc, argv)
1053: char *argv[];
1054: {
1055: long mtime, getstamp();
1056: char *filename;
1057: filename = argv[1];
1058: mtime = getstamp(filename);
1059: printf(".ds s) %ld\n",mtime);
1060: }
1061: 0707070035330165711006640021230000040000010214560421531217500001000000012541trans.l %{
1062: #include <sys/types.h>
1063: #include <pwd.h>
1064: #include <sys/stat.h>
1065: #include <time.h>
1066: #include <libc.h>
1067: #include "header.h"
1068:
1069: #define DATE DOCNUM+6
1070: #define SEQNUM DOCNUM+13
1071: #define TYPE DOCNUM+15
1072: #define SOFT DOCNUM+17
1073: struct passwd *getpwuid(), *ps;
1074: int soft;
1075: char *p, *s1, *s2;
1076: int type, ci=0, pm=0, rl=0;
1077: char buf[HEADSIZE];
1078: char *co = &buf[CO];
1079: char *dept = &buf[DOCNUM], *date = &buf[DATE], *seqnum = &buf[SEQNUM];
1080: char *stype = &buf[TYPE], *ssoft = &buf[SOFT];
1081: char *machine = buf;
1082: char *login = &buf[ULOG], *timestamp = &buf[TIMESTAMP];
1083: char *version = &buf[VERSION];
1084: char *pages = &buf[PAGES];
1085: int more = 1;
1086: %}
1087: %%
1088: ^".so".* ;
1089: ^".TI" {
1090: printf(".TL\n");
1091: }
1092: ^".DT".* ;
1093: ^".AH".* {
1094: yytext[yyleng] = '\0';
1095: p = strtok(&yytext[3], " \n");
1096: printf(".AU %s", p);
1097: if (*p == '"') {
1098: p = strtok((char *)0, "\"");
1099: printf(" %s", p);
1100: }
1101: p = strtok((char *)0, "\n");
1102: printf(" \"\"%s\n", p);
1103: }
1104: ^".AP".* {
1105: yytext[yyleng] = '\0';
1106: printf(".rP %s\n",&yytext[3]);
1107: }
1108: ^".SA" {
1109: printf(".AS\n");
1110: }
1111: ^".SE" {
1112: printf(".AE\n");
1113: }
1114: ^".KW".* {
1115: printf(".OK %s\n",&yytext[3]);
1116: }
1117: ^".TY".* {
1118: for(p = &yytext[3]; *p == ' ';p++);
1119: if(*p == 'I')type=2;
1120: else if(*(p+1) == 'M')type=1;
1121: else type=3;
1122: *stype = *p;
1123: *(stype+1) = *(p+1);
1124: while(*p != ' '){
1125: if(*p == '\n'){
1126: soft=0;
1127: break;
1128: }
1129: p++;
1130: }
1131: if(*p == ' ')
1132: if(*++p == 'y')
1133: soft=1;
1134: printf(".MT %d\n",type);
1135: if(soft){
1136: *ssoft = 'S';
1137: printf(".sF\n");
1138: }
1139: }
1140: ^".MT".* {
1141: for(p = &yytext[3]; *p == ' ';p++);
1142: if(*p == '1') {
1143: type=1;
1144: *stype = 'T';
1145: *(stype+1) = 'M';
1146: } else if(*p == '2') {
1147: type=2;
1148: *stype = 'I';
1149: *(stype+1) = 'M';
1150: } else type=3;
1151: printf(".MT %d\n",type);
1152: }
1153: ^".sF".* {
1154: soft = 1;
1155: *ssoft = 'S';
1156: printf(".sF\n");
1157: }
1158: ^(".NU"|".dN").* {
1159: p = strtok(&yytext[3], "- \n\"");
1160: if(p != 0){
1161: sprintf(dept,"%s-",p);
1162: printf(".dN %s-",p);
1163: type = 1;
1164: }
1165: p = strtok((char *)0, "- \n\"");
1166: if(p != 0){
1167: sprintf(date,"%s-",p);
1168: printf("%s-",p);
1169: }
1170: p = strtok((char *)0, "- \n\"");
1171: if(p != 0){
1172: *seqnum = *p;
1173: *(seqnum+1) = *(p+1);
1174: printf("%s\n",p);
1175: }
1176: else if(type) printf("\n");
1177: p = strtok((char *)0, " \n\"");
1178: if(p != 0)
1179: printf(".fC %s\n",p);
1180: p = strtok((char *)0, " \n\"");
1181: if(p != 0)
1182: printf(".wP %s\n",p);
1183: }
1184: ^".MY".* {
1185: printf(".mE %s\n",&yytext[3]);
1186: }
1187: ^".ED".* {
1188: printf(".eD %s'n",&yytext[3]);
1189: }
1190: ^".PR".* {
1191: pm=1;
1192: printf(".PM %s\n",&yytext[3]);
1193: }
1194: ^".RL".* {
1195: rl=1;
1196: if(yyleng>3){
1197: p=&yytext[3];
1198: while(*p == ' ')p++;
1199: if(*p == '\"')p++;
1200: if(*p == 'n')printf(".fA n\n");
1201: else printf(".fA y\n");
1202: }
1203: else printf(".fA y\n");
1204: }
1205: ^".GS" {
1206: printf(".gS\n");
1207: }
1208: ^".CI".* {
1209: /* ci = 1; gone away
1210: if(yyleng == 3)
1211: printf(".cI n\n");
1212: else {
1213: p = &yytext[3];
1214: while(*p == ' ')p++;
1215: if(*p == '\n' || *p == 'n')
1216: printf(".cI n\n");
1217: else if(*p == '\"')p++;
1218: if(*p == 'y')
1219: printf(".cI y\n");
1220: else if(*p == '\"' || *p == 'n')
1221: printf(".cI n\n");
1222: else fprintf(stderr,".CI unknown argument %c\n",*p);
1223: }*/
1224: }
1225: ^".CO".* {
1226: /* if(!ci){
1227: printf(".cI n\n");
1228: ci = 1;
1229: }*/
1230: if(!rl){
1231: printf(".fA y\n");
1232: rl = 1;
1233: }
1234: printf(".cC\n");
1235: }
1236: ^".CE" {
1237: printf(".cE\n");
1238: }
1239: ^".CV".* {
1240: /* if(!ci){
1241: printf(".cI n\n");
1242: ci = 1;
1243: }*/
1244: if(!rl){
1245: printf(".fA y\n");
1246: rl = 1;
1247: }
1248: printf(".cS\n");
1249: }
1250: ^".CS".* {
1251: ECHO;
1252: printf("\n");
1253: return(0);
1254: }
1255: ^".SC".* {
1256: /* if(!ci){
1257: printf(".cI n\n");
1258: ci = 1;
1259: }*/
1260: if(!rl){
1261: printf(".fA y\n");
1262: rl = 1;
1263: }
1264: p = s1 = &yytext[3];
1265: while(*s1 == ' ')s1++;
1266: while(*s1 != ' ')s1++;
1267: while(*s1 == ' ')s1++;
1268: while(*s1 != ' ')s1++;
1269: *s1 = '\0';
1270: s1++;
1271: printf(".CS %s \"\" %s\n", p, s1);
1272: return(0);
1273: }
1274: .* {
1275: ECHO;
1276: printf("\n");
1277: }
1278: \n ;
1279: %%
1280: char *header="/tmp/ ";
1281: char *dest = "mhuxd!/usr/spool/uucppublic/doc.mcs";
1282: char *dco = "BL";
1283: main(argc, argv)
1284: char *argv[];
1285: {
1286: FILE *inp;
1287: char *filename, *name, *cover, *pid;
1288: int nuchars, npid, uid, days;
1289: long mtime;
1290: if(argc < 3){
1291: fprintf(stderr,"file name must be supplied to sendcover\n");
1292: exit(1);
1293: }
1294: if((inp=fopen("/etc/whoami","r")) == NULL){
1295: fprintf(stderr,"can't open /etc/whoami\n");
1296: exit(1);
1297: }
1298: nuchars = fread(machine, sizeof(char), 10, inp);
1299: nuchars -= 1;
1300: if(nuchars < 5)pid = machine + nuchars +1;
1301: else pid = machine + 6;
1302: cover = pid + 5;
1303: fclose(inp);
1304: *(pid-1) = '.';
1305: npid = getpid();
1306: sprintf(pid,"%05d",npid);
1307: *cover = 'c';
1308: sprintf(&header[5],"%s",machine);
1309: uid = getuid();
1310: if ((ps = getpwuid(uid)) == NULL){
1311: fprintf(stderr, "login not found");
1312: exit(1);
1313: }
1314: strcpy (login,ps->pw_name);
1315: sprintf(version,"030388L"); /*version*/
1316: strcpy(co, dco); /*company name=BL*/
1317: name = argv[1];
1318: argc--; argv++;
1319: if(freopen(argv[1],"r",stdin)==NULL) {
1320: fprintf(stderr,"%s: cannot open\n", argv[1]);
1321: exit(1);
1322: }
1323: if(freopen(header,"w",stdout)== NULL){
1324: fprintf(stderr,"%s: cannot open\n",header);
1325: exit(1);
1326: }
1327: if((nuchars = fwrite(buf,sizeof(char),HEADSIZE,stdout)) != HEADSIZE){
1328: fprintf(stderr,"wrong number of characters written %d\n",nuchars);
1329: exit(1);
1330: }
1331: filename = argv[1];
1332: mtime = getstamp(filename);
1333: sprintf(timestamp,"%ld",mtime);
1334: argv++;
1335: sprintf(pages,"TP%s",argv[1]);
1336: yylex();
1337: rewind(stdout);
1338: for(p=buf; p < &buf[HEADSIZE-1]; p++)
1339: if(*p == '\0')*p = ' ';
1340: *p = '\n';
1341: if((nuchars = fwrite(buf,sizeof(char),HEADSIZE,stdout)) != HEADSIZE){
1342: fprintf(stderr,"wrong number of characters written %d\n",nuchars);
1343: exit(1);
1344: }
1345: *(cover+1) = '\0';
1346: if((inp=fopen(name,"a")) == NULL){
1347: fprintf(stderr,"can't open tmp file %s\n",name);
1348: exit(1);
1349: }
1350: fprintf(inp,"cd /tmp; uucp -m -C %s %s; rm %s\n",machine,dest,machine);
1351: fclose(inp);
1352: }
1353: 0707070035330165711006640021230000040000010214560421531217500001300000000000TRAILER!!! printf(stderr,"wrong number of characters written %d\n",nuchars);
1354: exit(1);
1355: }
1356: *(cover+1) = '\0';
1357: if((inp=fopen(name,"a")) == NUL
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.