Annotation of researchv10no/games/imp.c, revision 1.1

1.1     ! root        1: #include <stdio.h>
        !             2: FILE *fin;
        !             3: int redir;
        !             4: main(){
        !             5:        char cline[200], fline[200], dline[30], ndline[30], tuid[12], tm[12];
        !             6:        char fid[100], rid[100], rline[113], *gets(), fname[100], buf[200],
        !             7:                *fgets();
        !             8:        FILE *f, *fopen(), *popen();
        !             9: 
        !            10:        f = popen("date", "r");
        !            11:        fgets(dline, 30, f);
        !            12:        dline[28] = '\0';
        !            13:        pclose(f);
        !            14: 
        !            15:        printf("Target uid: ");
        !            16:        gets(tuid);
        !            17:        printf("Target machine: ");
        !            18:        gets(tm);
        !            19:        printf("Sender: ");
        !            20:        gets(fid);
        !            21:        printf("Sending machine: ");
        !            22:        gets(rid);
        !            23: 
        !            24:        strcpy(cline, "uux - ");
        !            25:        strcat(cline, tm);
        !            26:        strcat(cline, "!rmail '(");
        !            27:        strcat(cline, tuid);
        !            28:        strcat(cline, ")'");
        !            29: 
        !            30:        strcpy(fline, "From ");
        !            31:        strcat(fline, fid);
        !            32:        strcat(fline, " ");
        !            33: 
        !            34:        strcpy(dline+16, dline+19);
        !            35: 
        !            36:        *rline = '\0';
        !            37:        if(*rid){
        !            38:           strcpy(rline, " remote from ");
        !            39:           strcat(rline, rid);
        !            40:        }
        !            41: 
        !            42:        printf("%s\n", cline);
        !            43:        printf("%s%s%s\n", fline, dline, rline);
        !            44:        printf("CR or new date stamp: ");
        !            45:        *ndline = '\0';
        !            46:        gets(ndline);
        !            47:        if(*ndline) strcpy(dline, ndline);
        !            48:        strcat(fline, dline);
        !            49:        strcat(fline, rline);
        !            50:        if(*ndline) printf("%s\n", fline);
        !            51: 
        !            52:        puts("Last chance to abort.  Type message or <filename");
        !            53:        redir = getchar();
        !            54:        if(redir == '<'){
        !            55:           gets(fname);
        !            56:           if((fin = fopen(fname, "r")) == NULL){
        !            57:              printf("Can't open %s\n", fname);
        !            58:              exit(1);
        !            59:           }
        !            60:           redir = 1;
        !            61:        }
        !            62:        else{
        !            63:           ungetc(redir, stdin);
        !            64:           redir = 0;
        !            65:        }
        !            66: 
        !            67:        f = popen(cline, "w");
        !            68:        fprintf(f, "%s\n", fline);
        !            69: 
        !            70:        while(next(buf) != EOF) fprintf(f, "%s\n", buf);
        !            71: 
        !            72:        pclose(f);
        !            73: }
        !            74: next(buf)
        !            75: char *buf;
        !            76: {
        !            77:        if(redir){
        !            78:           if(fgets(buf, 200, fin) == NULL) goto quit;
        !            79:           buf[strlen(buf)-1] = '\0';
        !            80:        }
        !            81:        else if(gets(buf) == NULL) goto quit;
        !            82:        if(*buf == '.' && *(buf+1) == '\0') goto quit;
        !            83:        return 0;
        !            84: quit:  return EOF;
        !            85: }

unix.superglobalmegacorp.com

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