|
|
1.1 ! root 1: #include <stdio.h> ! 2: #include <sys/types.h> ! 3: #include <sys/stat.h> ! 4: ! 5: #define HISTORY "/usr/new/lib/news/history" ! 6: #define SPOOL "/usr/spool/news" ! 7: ! 8: #include <sys/types.h> ! 9: #include <sys/timeb.h> ! 10: #include <ctype.h> ! 11: #include <sys/time.h> ! 12: ! 13: #define NULL 0 ! 14: #define daysec (24L*60L*60L) ! 15: ! 16: main() ! 17: { ! 18: FILE *Hfile, *Afile; ! 19: char buffer[BUFSIZ], datestr[BUFSIZ]; ! 20: char *index(); ! 21: struct stat stbuf; ! 22: struct timeb now; ! 23: long t; ! 24: ! 25: Hfile = fopen(HISTORY, "r"); ! 26: if (Hfile == NULL) { ! 27: perror(HISTORY); ! 28: exit(1); ! 29: } ! 30: ! 31: if (chdir(SPOOL) < 0) { ! 32: perror(SPOOL); ! 33: exit(1); ! 34: } ! 35: ! 36: (void) ftime(&now); ! 37: ! 38: while (fgets(buffer, BUFSIZ, Hfile) != NULL) { ! 39: register char *p, *file; ! 40: ! 41: p = index(buffer, '\t'); ! 42: if (p == NULL) ! 43: continue; ! 44: file = index(p+1, '\t'); ! 45: if (file == NULL || file[1] == '\n') ! 46: continue; ! 47: *file = '\0'; ! 48: t = getdate(p, &now); ! 49: if ( (t+daysec*14L) < now.time) ! 50: continue; ! 51: strcpy(datestr, p); ! 52: p = file; ! 53: while (*++p != ' ' && *p != '\n') ! 54: if (*p == '.') ! 55: *p = '/'; ! 56: *p = '\0'; ! 57: file++; ! 58: if ( strncmp(file, "net", 3) && strncmp(file, "mod", 3) ! 59: && strncmp(file, "comp", 4) && strncmp(file, "sci", 3) ! 60: && strncmp(file, "news", 4) && strncmp(file, "rec", 3) ! 61: && strncmp(file, "talk", 4) && strncmp(file, "misc", 4) ! 62: && strncmp(file, "soc", 3) ! 63: ) ! 64: continue; ! 65: Afile = fopen(file, "r"); ! 66: if (Afile == NULL) ! 67: continue; ! 68: while (fgets(buffer, BUFSIZ, Afile) != NULL && ! 69: buffer[0] != '\n') { ! 70: if (strncmp(buffer, "From: ", 5) == 0) { ! 71: register char *cp = index(buffer, '@'); ! 72: if (cp) ! 73: while (*++cp && *cp != '.' && *cp != ' ') ! 74: if (isupper(*cp)) ! 75: *cp = tolower(*cp); ! 76: cp--; ! 77: while (*++cp && *cp != ' ') ! 78: if (islower(*cp)) ! 79: *cp = toupper(*cp); ! 80: } ! 81: fputs(buffer, stdout); ! 82: } ! 83: fstat(fileno(Afile), &stbuf); ! 84: printf("Date-Received: %s\n", datestr); ! 85: printf("Bytes: %ld\n\n", stbuf.st_size - ftell(Afile)); ! 86: fclose(Afile); ! 87: } ! 88: printf("\n"); ! 89: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.