Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site greipa.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!ihnp4!pesnta!twg!greipa!paul From: paul@greipa.UUCP (Paul A. Vixie) Newsgroups: net.sources Subject: mkact.c - rebuild your usenet active file Message-ID: <198@greipa.UUCP> Date: Tue, 14-May-85 03:04:28 EDT Article-I.D.: greipa.198 Posted: Tue May 14 03:04:28 1985 Date-Received: Wed, 15-May-85 00:47:42 EDT Distribution: net Organization: Genstar Rental Electronics, Palo Alto, Ca. Lines: 86 This utility was written when our news active file was accidentally wiped out. Because the active file is so sensitive, it does not operate on it directly, but instead operates as a filter. To make use of it, you must have an active file in proper format containing all newsgroups you wish to recover (this was our case; the file just suddenly became two weeks out of date)... There is nothing at the end of this article... --------------------------hack here-------------------------------------- /* mkact - remake news active file for 2.10.2 * vix 13may85 [written] * * usage: $0 newactivefile */ #include #include #include #define TRUE 1 #define FALSE 0 #define MAXSTR 128 #define BASE "/usr/spool/news/" #define COMM "ls -1F %s | sort -n" main() { char line[MAXSTR], ng[MAXSTR], can[2], dir[MAXSTR], command[MAXSTR]; long maxart, minart; int x, l; FILE *sort, *popen(); while (4 == fscanf(stdin, "%s %ld %ld %1s", ng, &maxart, &minart, can)) { makedir(dir, ng); if (present(dir)) { sprintf(command, COMM, dir); if (!(sort = popen(command, "r"))) perror(command); else { for (l = 0; fgets(line, MAXSTR-1, sort); l++) { if (0 != (x = atoi(line))) { if (line[strlen(line)-2] != '/') { if (1 == l) minart = x; maxart = x; } } } } pclose(sort); } printf("%s %05d %05d %s\n", ng, maxart, minart, can); } } static makedir(dir, ng) char *dir, *ng; { strcpy(dir, BASE); dir += strlen(BASE); while (*ng) { if (*ng == '.') *dir = '/'; else *dir = *ng; dir++; ng++; } *dir = '\0'; } static present(name) char *name; { int file; if (-1 == (file = open(name, O_RDONLY, 0))) return (FALSE); close(file); return (TRUE); }