|
|
1.1 ! root 1: %{ ! 2: #include <sys/types.h> ! 3: #include <pwd.h> ! 4: #include <sys/stat.h> ! 5: #include <time.h> ! 6: #include <libc.h> ! 7: #include "header.h" ! 8: ! 9: #define DATE DOCNUM+6 ! 10: #define SEQNUM DOCNUM+13 ! 11: #define TYPE DOCNUM+15 ! 12: #define SOFT DOCNUM+17 ! 13: struct passwd *getpwuid(), *ps; ! 14: int soft; ! 15: char *p, *s1, *s2; ! 16: int type, ci=0, pm=0, rl=0; ! 17: char buf[HEADSIZE]; ! 18: char *co = &buf[CO]; ! 19: char *dept = &buf[DOCNUM], *date = &buf[DATE], *seqnum = &buf[SEQNUM]; ! 20: char *stype = &buf[TYPE], *ssoft = &buf[SOFT]; ! 21: char *machine = buf; ! 22: char *login = &buf[ULOG], *timestamp = &buf[TIMESTAMP]; ! 23: char *version = &buf[VERSION]; ! 24: char *pages = &buf[PAGES]; ! 25: int more = 1; ! 26: %} ! 27: %% ! 28: ^".so".* ; ! 29: ^".TI" { ! 30: printf(".TL\n"); ! 31: } ! 32: ^".DT".* ; ! 33: ^".AH".* { ! 34: yytext[yyleng] = '\0'; ! 35: p = strtok(&yytext[3], " \n"); ! 36: printf(".AU %s", p); ! 37: if (*p == '"') { ! 38: p = strtok((char *)0, "\""); ! 39: printf(" %s", p); ! 40: } ! 41: p = strtok((char *)0, "\n"); ! 42: printf(" \"\"%s\n", p); ! 43: } ! 44: ^".AP".* { ! 45: yytext[yyleng] = '\0'; ! 46: printf(".rP %s\n",&yytext[3]); ! 47: } ! 48: ^".SA" { ! 49: printf(".AS\n"); ! 50: } ! 51: ^".SE" { ! 52: printf(".AE\n"); ! 53: } ! 54: ^".KW".* { ! 55: printf(".OK %s\n",&yytext[3]); ! 56: } ! 57: ^".TY".* { ! 58: for(p = &yytext[3]; *p == ' ';p++); ! 59: if(*p == 'I')type=2; ! 60: else if(*(p+1) == 'M')type=1; ! 61: else type=3; ! 62: *stype = *p; ! 63: *(stype+1) = *(p+1); ! 64: while(*p != ' '){ ! 65: if(*p == '\n'){ ! 66: soft=0; ! 67: break; ! 68: } ! 69: p++; ! 70: } ! 71: if(*p == ' ') ! 72: if(*++p == 'y') ! 73: soft=1; ! 74: printf(".MT %d\n",type); ! 75: if(soft){ ! 76: *ssoft = 'S'; ! 77: printf(".sF\n"); ! 78: } ! 79: } ! 80: ^".MT".* { ! 81: for(p = &yytext[3]; *p == ' ';p++); ! 82: if(*p == '1') { ! 83: type=1; ! 84: *stype = 'T'; ! 85: *(stype+1) = 'M'; ! 86: } else if(*p == '2') { ! 87: type=2; ! 88: *stype = 'I'; ! 89: *(stype+1) = 'M'; ! 90: } else type=3; ! 91: printf(".MT %d\n",type); ! 92: } ! 93: ^".sF".* { ! 94: soft = 1; ! 95: *ssoft = 'S'; ! 96: printf(".sF\n"); ! 97: } ! 98: ^(".NU"|".dN").* { ! 99: p = strtok(&yytext[3], "- \n\""); ! 100: if(p != 0){ ! 101: sprintf(dept,"%s-",p); ! 102: printf(".dN %s-",p); ! 103: type = 1; ! 104: } ! 105: p = strtok((char *)0, "- \n\""); ! 106: if(p != 0){ ! 107: sprintf(date,"%s-",p); ! 108: printf("%s-",p); ! 109: } ! 110: p = strtok((char *)0, "- \n\""); ! 111: if(p != 0){ ! 112: *seqnum = *p; ! 113: *(seqnum+1) = *(p+1); ! 114: printf("%s\n",p); ! 115: } ! 116: else if(type) printf("\n"); ! 117: p = strtok((char *)0, " \n\""); ! 118: if(p != 0) ! 119: printf(".fC %s\n",p); ! 120: p = strtok((char *)0, " \n\""); ! 121: if(p != 0) ! 122: printf(".wP %s\n",p); ! 123: } ! 124: ^".MY".* { ! 125: printf(".mE %s\n",&yytext[3]); ! 126: } ! 127: ^".ED".* { ! 128: printf(".eD %s'n",&yytext[3]); ! 129: } ! 130: ^".PR".* { ! 131: pm=1; ! 132: printf(".PM %s\n",&yytext[3]); ! 133: } ! 134: ^".RL".* { ! 135: rl=1; ! 136: if(yyleng>3){ ! 137: p=&yytext[3]; ! 138: while(*p == ' ')p++; ! 139: if(*p == '\"')p++; ! 140: if(*p == 'n')printf(".fA n\n"); ! 141: else printf(".fA y\n"); ! 142: } ! 143: else printf(".fA y\n"); ! 144: } ! 145: ^".GS" { ! 146: printf(".gS\n"); ! 147: } ! 148: ^".CI".* { ! 149: /* ci = 1; gone away ! 150: if(yyleng == 3) ! 151: printf(".cI n\n"); ! 152: else { ! 153: p = &yytext[3]; ! 154: while(*p == ' ')p++; ! 155: if(*p == '\n' || *p == 'n') ! 156: printf(".cI n\n"); ! 157: else if(*p == '\"')p++; ! 158: if(*p == 'y') ! 159: printf(".cI y\n"); ! 160: else if(*p == '\"' || *p == 'n') ! 161: printf(".cI n\n"); ! 162: else fprintf(stderr,".CI unknown argument %c\n",*p); ! 163: }*/ ! 164: } ! 165: ^".CO".* { ! 166: /* if(!ci){ ! 167: printf(".cI n\n"); ! 168: ci = 1; ! 169: }*/ ! 170: if(!rl){ ! 171: printf(".fA y\n"); ! 172: rl = 1; ! 173: } ! 174: printf(".cC\n"); ! 175: } ! 176: ^".CE" { ! 177: printf(".cE\n"); ! 178: } ! 179: ^".CV".* { ! 180: /* if(!ci){ ! 181: printf(".cI n\n"); ! 182: ci = 1; ! 183: }*/ ! 184: if(!rl){ ! 185: printf(".fA y\n"); ! 186: rl = 1; ! 187: } ! 188: printf(".cS\n"); ! 189: } ! 190: ^".CS".* { ! 191: ECHO; ! 192: printf("\n"); ! 193: return(0); ! 194: } ! 195: ^".SC".* { ! 196: /* if(!ci){ ! 197: printf(".cI n\n"); ! 198: ci = 1; ! 199: }*/ ! 200: if(!rl){ ! 201: printf(".fA y\n"); ! 202: rl = 1; ! 203: } ! 204: p = s1 = &yytext[3]; ! 205: while(*s1 == ' ')s1++; ! 206: while(*s1 != ' ')s1++; ! 207: while(*s1 == ' ')s1++; ! 208: while(*s1 != ' ')s1++; ! 209: *s1 = '\0'; ! 210: s1++; ! 211: printf(".CS %s \"\" %s\n", p, s1); ! 212: return(0); ! 213: } ! 214: .* { ! 215: ECHO; ! 216: printf("\n"); ! 217: } ! 218: \n ; ! 219: %% ! 220: char *header="/tmp/ "; ! 221: char *dest = "mhuxd!/usr/spool/uucppublic/doc.mcs"; ! 222: char *dco = "BL"; ! 223: main(argc, argv) ! 224: char *argv[]; ! 225: { ! 226: FILE *inp; ! 227: char *filename, *name, *cover, *pid; ! 228: int nuchars, npid, uid, days; ! 229: long mtime; ! 230: if(argc < 3){ ! 231: fprintf(stderr,"file name must be supplied to sendcover\n"); ! 232: exit(1); ! 233: } ! 234: if((inp=fopen("/etc/whoami","r")) == NULL){ ! 235: fprintf(stderr,"can't open /etc/whoami\n"); ! 236: exit(1); ! 237: } ! 238: nuchars = fread(machine, sizeof(char), 10, inp); ! 239: nuchars -= 1; ! 240: if(nuchars < 5)pid = machine + nuchars +1; ! 241: else pid = machine + 6; ! 242: cover = pid + 5; ! 243: fclose(inp); ! 244: *(pid-1) = '.'; ! 245: npid = getpid(); ! 246: sprintf(pid,"%05d",npid); ! 247: *cover = 'c'; ! 248: sprintf(&header[5],"%s",machine); ! 249: uid = getuid(); ! 250: if ((ps = getpwuid(uid)) == NULL){ ! 251: fprintf(stderr, "login not found"); ! 252: exit(1); ! 253: } ! 254: strcpy (login,ps->pw_name); ! 255: sprintf(version,"030388L"); /*version*/ ! 256: strcpy(co, dco); /*company name=BL*/ ! 257: name = argv[1]; ! 258: argc--; argv++; ! 259: if(freopen(argv[1],"r",stdin)==NULL) { ! 260: fprintf(stderr,"%s: cannot open\n", argv[1]); ! 261: exit(1); ! 262: } ! 263: if(freopen(header,"w",stdout)== NULL){ ! 264: fprintf(stderr,"%s: cannot open\n",header); ! 265: exit(1); ! 266: } ! 267: if((nuchars = fwrite(buf,sizeof(char),HEADSIZE,stdout)) != HEADSIZE){ ! 268: fprintf(stderr,"wrong number of characters written %d\n",nuchars); ! 269: exit(1); ! 270: } ! 271: filename = argv[1]; ! 272: mtime = getstamp(filename); ! 273: sprintf(timestamp,"%ld",mtime); ! 274: argv++; ! 275: sprintf(pages,"TP%s",argv[1]); ! 276: yylex(); ! 277: rewind(stdout); ! 278: for(p=buf; p < &buf[HEADSIZE-1]; p++) ! 279: if(*p == '\0')*p = ' '; ! 280: *p = '\n'; ! 281: if((nuchars = fwrite(buf,sizeof(char),HEADSIZE,stdout)) != HEADSIZE){ ! 282: fprintf(stderr,"wrong number of characters written %d\n",nuchars); ! 283: exit(1); ! 284: } ! 285: *(cover+1) = '\0'; ! 286: if((inp=fopen(name,"a")) == NULL){ ! 287: fprintf(stderr,"can't open tmp file %s\n",name); ! 288: exit(1); ! 289: } ! 290: fprintf(inp,"cd /tmp; uucp -m -C %s %s; rm %s\n",machine,dest,machine); ! 291: fclose(inp); ! 292: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.