home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume28 / inpdos / part01 < prev    next >
Encoding:
Text File  |  1992-03-14  |  21.1 KB  |  655 lines

  1. Newsgroups: comp.sources.misc
  2. From: Christophe.Wolfhugel@grasp1.univ-lyon1.fr (Christophe Wolfhugel)
  3. Subject:  v28i103:  inpdos - inpaths for MS-DOS/unix, Part01/01
  4. Message-ID: <1992Mar14.224927.5633@sparky.imd.sterling.com>
  5. X-Md4-Signature: 5745bc3acbc7f610b2947e395c140fed
  6. Date: Sat, 14 Mar 1992 22:49:27 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: Christophe.Wolfhugel@grasp1.univ-lyon1.fr (Christophe Wolfhugel)
  10. Posting-number: Volume 28, Issue 103
  11. Archive-name: inpdos/part01
  12. Environment: UNIX, MS-DOS, TurboC
  13.  
  14. Here is the shar archive with the ms-dos/unix version of Brian Reid's 
  15. original inpaths statistical program.  I have named it 'inpdos' in 
  16. order to differentiate it from Brian's release.
  17.  
  18. Default defines are set for MS-DOS. See the README and header of the
  19. C source code for more complete information.
  20.  
  21. Chris
  22. ----------snip----------snip----------snip----------snip----------snip--------
  23. #! /bin/sh
  24. # This is a shell archive.  Remove anything before this line, then feed it
  25. # into a shell via "sh file" or similar.  To overwrite existing files,
  26. # type "sh file -c".
  27. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  28. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  29. # Contents:  README inpdos.c
  30. # Wrapped by kent@sparky on Sat Mar 14 16:44:32 1992
  31. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  32. echo If this archive is complete, you will see the following message:
  33. echo '          "shar: End of archive 1 (of 1)."'
  34. if test -f 'README' -a "${1}" != "-c" ; then 
  35.   echo shar: Will not clobber existing file \"'README'\"
  36. else
  37.   echo shar: Extracting \"'README'\" \(1558 characters\)
  38.   sed "s/^X//" >'README' <<'END_OF_FILE'
  39. XThis source code is the MS-DOS version of Brian Reid's inpaths program.
  40. XIt also works perfectly under Unix with the appropriate defines
  41. X(see the source code).
  42. X
  43. XThe name has been changed from inpaths to inpdos in order to avoid any
  44. Xconfusion with Brian Reid's official releases of the package.
  45. X
  46. XIn order to use this inpaths your newsspool must be a tree with one
  47. Xone numeric file per article (as it is stored by b/cnews on Unix boxes).
  48. X
  49. XThere already is a version of inpaths for some other Dos structures
  50. Xsuch as 'snews' which uses databases instead of on file per article.
  51. X
  52. XThe source code, patches if any, and future releases will very
  53. Xprobably be available in the anonymous ftp directory of host
  54. Xgrasp1.univ-lyon1.fr [134.214.100.25] in /pub/msdos/news.
  55. X
  56. XIf you have any questions, suggestions, remarks, feel free to contact
  57. Xme.
  58. X
  59. X        Christophe.Wolfhugel@grasp1.univ-lyon1.fr
  60. X
  61. X-------------------------------------------------------------------------
  62. X
  63. Xznews - request for co-developer
  64. X
  65. XThis is an announcement... I'm seeking for an MS-DOS (TC 2.0) developer
  66. Xwho would be interested to develop a newsreader using already made
  67. Xlow level interfaces for the newsspool and active, newsrc management.
  68. X
  69. XThe news database is in fact a virtual paging space of any space coupled
  70. Xwith an in core memory manager. Most low-level stuff is already ready
  71. Xand I also started a little bit a newsreader, but I'm too lazy
  72. X(and not really interested) to do a high level interface.
  73. X
  74. XSomeone volunteers?
  75. X
  76. XThe entire package will be distributed under the GNU Copyleft.
  77. X
  78. XChris
  79. END_OF_FILE
  80.   if test 1558 -ne `wc -c <'README'`; then
  81.     echo shar: \"'README'\" unpacked with wrong size!
  82.   fi
  83.   # end of 'README'
  84. fi
  85. if test -f 'inpdos.c' -a "${1}" != "-c" ; then 
  86.   echo shar: Will not clobber existing file \"'inpdos.c'\"
  87. else
  88.   echo shar: Extracting \"'inpdos.c'\" \(16915 characters\)
  89.   sed "s/^X//" >'inpdos.c' <<'END_OF_FILE'
  90. X/* inpaths.c -- track the paths of incoming news articles and prepare
  91. X *            in a format suitable for decwrl pathsurveys
  92. X *
  93. X *
  94. X * This program inputs a list of filenames of news articles, and outputs a
  95. X * data report which should be mailed to the decwrl Network Monitoring
  96. X * Project at address "pathsurvey@decwrl.dec.com". Please run it once a month
  97. X * if you can, in time so that the results arrive at decwrl by the 1st
  98. X * day of the month.
  99. X *
  100. X *
  101. X * Run it like this (Unix boxes):
  102. X *
  103. X *  cd /usr/spool/news
  104. X *  find . -type f -print | inpaths "yourhost" | mail pathsurvey@decwrl.dec.com
  105. X *
  106. X *  where "yourhost" is the host name of your computer, e.g. "decwrl".
  107. X *
  108. X * If running under MS-DOS (find is included):
  109. X *
  110. X *  cd c:\usr\spool\news
  111. X *  inpaths yourhost | mail pathsurvey@decwrl.dec.com
  112. X *
  113. X *  or redirect the output to a file and then mail it to the given address.
  114. X *
  115. X * The input to "inpaths" must be a list of the file names of news articles,
  116. X * relative to the spooling directory. "./news/config/2771" and
  117. X * "news/config/2771" are both legal inputs, but "/usr/spool/news/config/2771"
  118. X * is not.  * If you have some other way of generating a list of news file
  119. X * names, such as running a script over the history file, you can use that
  120. X * instead. Inpaths handles crossposting regardless of which technique
  121. X * you use.
  122. X *
  123. X * If you get an error message "no traffic found. Check $CWD", then the
  124. X * problem is most likely that the path names you are giving it are not
  125. X * relative to the spooling directory, e.g. you are feeding it lines like
  126. X * "/usr/spool/news/news/config/2771" instead of "./news/config/2771"
  127. X *
  128. X * There are 3 options: -s, -m, and -l for short, medium, and long report.
  129. X * The default is to produce a long report. If you are worried about mail
  130. X * expenses you can send a shorter report. The long report is typically
  131. X * about 50K bytes for a major site, and perhaps 25K bytes for a smaller
  132. X * site.
  133. X *
  134. X * Brian Reid
  135. X *      V1       Sep 1986
  136. X *      V2.4     May 1989
  137. X *      V2.4.1   Jan 1992
  138. X *
  139. X * Christophe Wolfhugel <wolf@grasp1.univ-lyon1.fr>
  140. X *      V2.4-DOS   Oct 1991
  141. X *      V2.4.1-DOS Feb 1992
  142. X *
  143. X * IMPORTANT, MS-DOS Users: when compiling use a compilation model with
  144. X * 32 bits data handling (medium is ok). Otherwise you will very probably
  145. X * get an out of memory error message. Floating point should be enabled.
  146. X * This DOS version seems to be able to handle about 10000 articles, I
  147. X * myself never tested on more that 3000.
  148. X *
  149. X * Special thanks to Mel Pleasant and Bob Thrush for significant help with
  150. X * portability bugs.
  151. X *
  152. X */
  153. X
  154. X/* if you are compiling on a USG machine (SysV, etc),
  155. X   please uncomment the following line: */
  156. X
  157. X/* #define SYSV         */
  158. X
  159. X/* if you are compiling on a MS-DOS machine (tested under Turbo C 2.0),
  160. X   please uncomment the following line: */
  161. X
  162. X#define MSDOS           /* */
  163. X
  164. X/* define if you wish to use the fast malloc() routine. This does not
  165. X   improve much performance on Unix boxes but is *highly* recommended
  166. X   under MS-DOS as it allows to handle much more articles with the
  167. X   savings done with this method. */
  168. X
  169. X#define FAST_MALLOC     /* */
  170. X
  171. X#ifdef MSDOS
  172. X# define VERSION "2.4-DOS"
  173. X# define VERBOSE                /* Verbose fast malloc on MS-DOS */
  174. X#else
  175. X# define VERSION "2.4"
  176. X#endif
  177. X#ifdef FAST_MALLOC
  178. X# define BLK_SIZE       (16*1024)
  179. X#else
  180. X# define mymalloc(s) malloc(s)
  181. X#endif
  182. X#include <stdio.h>
  183. X#include <fcntl.h>
  184. X#include <ctype.h>
  185. X#include <sys/types.h>
  186. X#include <sys/stat.h>
  187. X#ifdef MSDOS
  188. X# include <dir.h>
  189. X# include <dos.h>
  190. X# include <string.h>
  191. X#endif
  192. X
  193. X#define HEADBYTES 1024
  194. X
  195. X#ifdef SYSV
  196. X    long time();
  197. X#else
  198. X    time_t time();
  199. X#endif
  200. X
  201. Xextern int exit();
  202. Xextern long coreleft();
  203. Xextern char *malloc();
  204. Xextern char *strcpy();
  205. X
  206. X#ifdef MSDOS
  207. Xextern unsigned _stklen=3*4096;         /* 4 Kb isn't enough */
  208. X
  209. Xchar tmpf[]="inXXXXXX";                 /* Both are used for the */
  210. XFILE *f;                                /* built-in find */
  211. X#endif
  212. X
  213. X#ifdef FAST_MALLOC
  214. X
  215. Xchar *mymalloc(long s)
  216. X{
  217. X   static char *ptr=NULL,*c;
  218. X   static long lg=0,i=0;
  219. X
  220. X   if (ptr==NULL || (lg+s)>(BLK_SIZE-1)) {
  221. X      ptr=malloc(BLK_SIZE); lg=0;
  222. X      if (ptr==NULL) {
  223. X         fprintf(stderr,"Not enough memory to process your newsspool.\n");
  224. X         fprintf(stderr,"That's really too bad, as you seem to be an\n");
  225. X         fprintf(stderr,"important site with valuable data :-).\n");
  226. X         exit(1);
  227. X      } /* endif */
  228. X   } /* endif */
  229. X   lg+=s; c=ptr; ptr+=s;
  230. X#ifdef VERBOSE
  231. X   fprintf(stderr,"#%04ld - lg %3ld - fr %6ld\n",++i,lg,coreleft()+BLK_SIZE-lg);
  232. X#endif
  233. X   return(c);
  234. X}
  235. X
  236. X#endif  /* FAST_MALLOC */
  237. X
  238. X#ifdef MSDOS
  239. X
  240. Xvoid reduce(char *s)
  241. X{
  242. X   char *cp;
  243. X   int i;
  244. X
  245. X   cp=s; s=strtok(s,".");
  246. X   while (s!=NULL) {
  247. X      for (i=0; i<8 && s[i]!=0; i++) {
  248. X         *cp++ = s[i];
  249. X      } /* endfor */
  250. X      if ((s=strtok(NULL,"."))!=NULL) *cp++ = '.';
  251. X   } /* endwhile */
  252. X   *cp = 0;
  253. X}
  254. X
  255. Xvoid recurse(char *s,char *t)
  256. X{
  257. X   struct ffblk ff;
  258. X   char cdir[96];
  259. X
  260. X   if (t!=NULL) sprintf(cdir,"%s/%s",s,t); else strcpy(cdir,s);
  261. X   if (findfirst("*",&ff,FA_DIREC)==-1) exit(0);
  262. X   do {
  263. X      if (ff.ff_name[0]!='.') {
  264. X         if (ff.ff_attrib==FA_DIREC) {
  265. X            chdir(ff.ff_name);
  266. X            recurse(cdir,ff.ff_name);
  267. X            chdir("..");
  268. X         } else {
  269. X            strlwr(cdir); strlwr(ff.ff_name);
  270. X            fprintf(f,"%s/%s\n",cdir,ff.ff_name);
  271. X         } /* endif */
  272. X      } /* endif */
  273. X   } while (findnext(&ff)==0);
  274. X}
  275. X
  276. Xvoid artList()
  277. X{
  278. X   mktemp(tmpf); f=fopen(tmpf,"w");
  279. X   recurse(".",NULL);
  280. X   fclose(f); freopen(tmpf,"r",stdin);
  281. X}
  282. X
  283. X#endif  /* MSDOS */
  284. X
  285. X/* this is index() or strchr() included here for portability */
  286. X
  287. Xchar *index(ptr,chr)
  288. Xchar *ptr,chr;
  289. X {
  290. X    do {if (*ptr==chr) return(ptr);} while (*ptr++);
  291. X    return ( (char *) NULL);
  292. X }
  293. X
  294. Xmain (argc,argv)
  295. X  int argc;
  296. X  char **argv;
  297. X {
  298. X    char linebuf[1024], jc, *lptr, *cp, *cp1, *cp2;
  299. X    char rightdelim;
  300. X    char *pathfield, *groupsfield;
  301. X    int crossposted;
  302. X    char artbuf[HEADBYTES], ngfilename[256];
  303. X    struct stat statbuf, *sbptr;
  304. X    char *scanlimit;
  305. X    char *hostname;
  306. X    char hostString[128];
  307. X    int needHost;
  308. X    static int passChar[256];
  309. X    int isopen,columns,verbose,totalTraffic;
  310. X    long nowtime,age,agesum;
  311. X    float avgAge;
  312. X
  313. X#ifndef MSDOS
  314. X        /* definitions for getopt */
  315. X    extern int optind;
  316. X    extern char *optarg;
  317. X#endif
  318. X
  319. X /* structure used to tally the traffic between two hosts */
  320. X    struct trec {
  321. X        struct trec *rlink;
  322. X        struct nrec *linkid;
  323. X        int tally;
  324. X    } ;
  325. X
  326. X /* structure to hold the information about a host */
  327. X    struct nrec {
  328. X        struct nrec *link;
  329. X        struct trec *rlink;
  330. X        char *id;
  331. X        long sentto; /* tally of articles sent to somebody from here */
  332. X    } ;
  333. X    struct nrec *hosthash[128], *hnptr, *list, *relay;
  334. X    struct trec *rlist;
  335. X    int i, article, gotbytes, c;
  336. X
  337. X    hostname = "unknown";
  338. X    verbose = 2;
  339. X#ifdef MSDOS
  340. X    for (i=1; i<argc; i++) {
  341. X       if (argv[i][0]!='-') break;
  342. X       switch (argv[i][1]) {
  343. X#else
  344. X    while (( c=getopt(argc, argv, "sml" )) != EOF)
  345. X       switch (c) {
  346. X#endif
  347. X          case 's': verbose=0; break;
  348. X          case 'm': verbose=1; break;
  349. X          case 'l': verbose=2; break;
  350. X          case '?': fprintf(stderr,
  351. X                    "usage: %s [-s] [-m] [-l] hostname\n",argv[0]);
  352. X                    exit(1);
  353. X       } /* endswitch */
  354. X#ifdef MSDOS
  355. X    } /* endfor */
  356. X    if (i<argc) {
  357. X        hostname = argv[i];
  358. X#else
  359. X    if (optind < argc) {
  360. X        hostname = argv[optind];
  361. X#endif
  362. X    } else {
  363. X        fprintf(stderr,"usage: %s [-s] [-m] [-l] `hostname`\n",argv[0]);
  364. X        exit(1);
  365. X    }
  366. X
  367. X    if (isatty(fileno(stderr))) {
  368. X        fprintf(stderr,"computing %s inpaths for host %s\n",
  369. X            verbose==0 ? "short" : (verbose==1 ? "medium" : "long"),hostname);
  370. X    }
  371. X
  372. X#ifdef MSDOS
  373. X    artList();          /* Find all articles */
  374. X#endif
  375. X
  376. X    for (i = 0; i<128; i++) hosthash[i] = (struct nrec *) NULL;
  377. X
  378. X/* precompute character types to speed up scan */
  379. X    for (i = 0; i<=255; i++) {
  380. X        passChar[i] = 0;
  381. X        if (isalpha(i) || isdigit(i)) passChar[i] = 1;
  382. X        if (i == '-' || i == '.' || i == '_') passChar[i] = 1;
  383. X    }
  384. X    totalTraffic = 0;
  385. X    nowtime = (long) time(0L);
  386. X    agesum = 0;
  387. X
  388. X    while (gets(linebuf) != (char *) NULL) {
  389. X        lptr = linebuf;
  390. X        isopen = 0;
  391. X
  392. X/* Skip blank lines */
  393. X        if (linebuf[0] == '\0') goto bypass;
  394. X
  395. X/* Skip files that do not have pure numeric names */
  396. X        i = strlen(lptr)-1;
  397. X        do {
  398. X            if (!isdigit(linebuf[i])) {
  399. X                if (linebuf[i]=='/') break;
  400. X                goto bypass;
  401. X            }
  402. X            i--;
  403. X        } while (i>=0);
  404. X
  405. X/* Open the file for reading */
  406. X        article = open(lptr, O_RDONLY);
  407. X        isopen = (article > 0);
  408. X        if (!isopen) goto bypass;
  409. X        sbptr = &statbuf;
  410. X        if (fstat(article, sbptr) == 0) {
  411. X
  412. X/* Record age of file in hours */
  413. X            age = (nowtime - statbuf.st_mtime) / 3600;
  414. X            agesum += age;
  415. X/* Reject names that are not ordinary files             */
  416. X#if defined(_POSIX_SOURCE) && defined(SYSV)
  417. X            if (! S_ISREG(statbuf.st_mode)) goto bypass;
  418. X#else
  419. X            if ((statbuf.st_mode & S_IFREG) == 0) goto bypass;
  420. X#endif
  421. X/* Pick the file name apart into an equivalent newsgroup name */
  422. X            if (*lptr == '.') {
  423. X                lptr++;
  424. X                if (*lptr == '/') lptr++;
  425. X            }
  426. X            cp = ngfilename;
  427. X            while (*lptr != 0) {
  428. X                if (*lptr == '/') *cp++ = '.';
  429. X                else *cp++ = *lptr;
  430. X                lptr++;
  431. X            }
  432. X            cp--; while (isdigit(*cp)) *cp-- = NULL;
  433. X            if (*cp == '.') *cp = NULL;
  434. X        } else goto bypass;
  435. X
  436. X/* Read in the first few bytes of the article; find the end of the header */
  437. X        gotbytes = read(article, artbuf, HEADBYTES);
  438. X        if (gotbytes < 10) goto bypass;
  439. X
  440. X/* Find "Path:" header field */
  441. X        pathfield = (char *) 0;
  442. X            groupsfield = (char *) 0;
  443. X        scanlimit = &artbuf[gotbytes];
  444. X        for (cp=artbuf; cp <= scanlimit; cp++) {
  445. X            if (*cp == '\n') break;
  446. X            if (pathfield && groupsfield) goto gotpath;
  447. X            if (strncmp(cp, "Path: ", 6) == 0) {
  448. X                pathfield = cp; goto nextgr;
  449. X            }
  450. X            if (strncmp(cp, "Newsgroups: ", 12) == 0) {
  451. X                groupsfield = cp; goto nextgr;
  452. X            }
  453. X   nextgr:
  454. X            while (*cp != '\n' && cp <= scanlimit) cp++;
  455. X        }
  456. X        if (groupsfield == (char *) 0 || (pathfield == (char *) 0))
  457. X            goto bypass;
  458. X
  459. Xgotpath: ;
  460. X
  461. X/* Determine the name of the newsgroup to which this is charged. It is not
  462. X   necessarily the name of the file in which we found it; rather, use the
  463. X   "Newsgroups:" field.                                                  */
  464. X
  465. X        crossposted = 0;
  466. X        groupsfield += 12;      /* skip 'Newsgroups: ' */
  467. X        while (*groupsfield == ' ') groupsfield++;
  468. X        cp= (char *) index(groupsfield,'\n');
  469. X        if (cp) {
  470. X            *cp = 0;
  471. X        } else {
  472. X  /* if this field is malformed, there is no point trying to process the
  473. X     entire message.
  474. X   */
  475. X           goto bypass;
  476. X        }
  477. X        cp=(char *) index(groupsfield,',');
  478. X        if (cp) {
  479. X            crossposted++;
  480. X            *cp = 0;
  481. X        }
  482. X
  483. X/* To avoid double-billing, only charge the newsgroup if the pathname matches
  484. X   the contents of the Newsgroups: field. This will also prevent picking up
  485. X   junk and control messages.
  486. X */
  487. X#ifdef MSDOS
  488. X        reduce(groupsfield);
  489. X#endif
  490. X        if (strcmp(ngfilename,groupsfield)) goto bypass;
  491. X
  492. X/* Extract all of the host names from the "Path:" field and put them in our
  493. Xhost table.                                                              */
  494. X        cp = pathfield;
  495. X        while (*cp != NULL && *cp != '\n') cp++;
  496. X        if (cp == NULL) {
  497. X            fprintf(stderr,"%s: end of Path line not in buffer.\n",lptr);
  498. X            goto bypass;
  499. X        }
  500. X
  501. X        totalTraffic++;
  502. X        *cp = 0;
  503. X        pathfield += 5; /* skip 'Path:' */
  504. X        cp1 = pathfield;
  505. X        relay = (struct nrec *) NULL;
  506. X        rightdelim = '!';
  507. X        while (cp1 < cp) {
  508. X            /* get next field */
  509. X            while (*cp1=='!') cp1++;
  510. X            cp2 = ++cp1;
  511. X            while (passChar[(int) (*cp2)]) cp2++;
  512. X
  513. X            rightdelim = *cp2; *cp2 = 0;
  514. X            if (rightdelim=='!' && *cp1 != (char) NULL) {
  515. X            /* see if already in the table */
  516. X                list = hosthash[*cp1];
  517. X                while (list != NULL) {
  518. X                    /*
  519. X                     * Attempt to speed things up here a bit.  Since we hash
  520. X                     * on the first char, we see if the second char is a match
  521. X                     * before calling strcmp()
  522. X                     */
  523. X                    if (list->id[1] == cp1[1] && !strcmp(list->id, cp1)) {
  524. X                        hnptr = list;
  525. X                        break;          /* I hate unnecessary goto's */
  526. X                    }
  527. X                    list = list->link;
  528. X                }
  529. X                if(list == NULL) {
  530. X                        /* get storage and splice in a new one */
  531. X                        hnptr = (struct nrec *) mymalloc(sizeof (struct nrec));
  532. X                        hnptr->id = (char *) strcpy(mymalloc(1+strlen(cp1)),cp1);
  533. X                        hnptr->link = hosthash[*cp1];
  534. X                        hnptr->rlink = (struct trec *) NULL;
  535. X                        hnptr->sentto = (long) 0;
  536. X                        hosthash[*cp1] = hnptr;
  537. X                }
  538. X            }
  539. X/*
  540. XAt this point "hnptr" points to the host record of the current host. If
  541. Xthere was a relay host, then "relay" points to its host record (the relay
  542. Xhost is just the previous host on the Path: line. Since this Path means
  543. Xthat news has flowed from host "hnptr" to host "relay", we want to tally
  544. Xone message in a data structure corresponding to that link. We will
  545. Xincrement the tally record that is attached to the source host "hnptr".
  546. X*/
  547. X
  548. X            if (relay != NULL && relay != hnptr) {
  549. X                rlist = relay->rlink;
  550. X                while (rlist != NULL) {
  551. X                    if (rlist->linkid == hnptr) goto have2;
  552. X                    rlist = rlist->rlink;
  553. X                }
  554. X                rlist = (struct trec *) mymalloc(sizeof (struct trec));
  555. X                rlist->rlink = relay->rlink;
  556. X                relay->rlink = rlist;
  557. X                rlist->linkid = hnptr;
  558. X                rlist->tally = 0;
  559. X
  560. X    have2:      rlist->tally++;
  561. X                hnptr->sentto++;
  562. X            }
  563. X
  564. X            cp1 = cp2;
  565. X            relay = hnptr;
  566. X            if (rightdelim == ' ' || rightdelim == '(') break;
  567. X        }
  568. Xbypass: if (isopen) close(article) ;
  569. X    }
  570. X/* Now dump the host table */
  571. X    if (!totalTraffic) {
  572. X        fprintf(stderr,"%s: error--no traffic found. Check $CWD.\n",argv[0]);
  573. X        exit(1);
  574. X    }
  575. X
  576. X    avgAge = ((double) agesum) / (24.0*(double) totalTraffic);
  577. X    printf("ZCZC begin inhosts %s %s %d %d %3.1f\n",
  578. X        VERSION,hostname,verbose,totalTraffic,avgAge);
  579. X    for (jc=0; jc<127; jc++) {
  580. X        list = hosthash[jc];
  581. X        while (list != NULL) {
  582. X            if (list->rlink != NULL) {
  583. X                if (verbose > 0 || (100*list->sentto > totalTraffic))
  584. X                    printf("%ld\t%s\n",list->sentto, list->id);
  585. X            }
  586. X            list = list->link;
  587. X        }
  588. X    }
  589. X    printf("ZCZC end inhosts %s\n",hostname);
  590. X
  591. X    printf("ZCZC begin inpaths %s %s %d %d %3.1f\n",
  592. X        VERSION,hostname,verbose,totalTraffic,avgAge);
  593. X    for (jc=0; jc<127; jc++) {
  594. X        list = hosthash[jc];
  595. X        while (list != NULL) {
  596. X            if (verbose > 1 || (100*list->sentto > totalTraffic)) {
  597. X                if (list->rlink != NULL) {
  598. X                    columns = 3+strlen(list->id);
  599. X                    sprintf(hostString,"%s H ",list->id);
  600. X                    needHost = 1;
  601. X                    rlist = list->rlink;
  602. X                    while (rlist != NULL) {
  603. X                        if (
  604. X                             (100*rlist->tally > totalTraffic)
  605. X                          || ((verbose > 1)&&(5000*rlist->tally>totalTraffic))
  606. X                           ) {
  607. X                            if (needHost) printf("%s",hostString);
  608. X                            needHost = 0;
  609. X                            relay = rlist->linkid;
  610. X                            if (columns > 70) {
  611. X                                printf("\n%s",hostString);
  612. X                                columns = 3+strlen(list->id);
  613. X                            }
  614. X                            printf("%d Z %s U ", rlist->tally, relay->id);
  615. X                            columns += 9+strlen(relay->id);
  616. X                        }
  617. X                        rlist = rlist->rlink;
  618. X                    }
  619. X                    if (!needHost) printf("\n");
  620. X                }
  621. X            }
  622. X            list = list->link;
  623. X        }
  624. X    }
  625. X    printf("ZCZC end inpaths %s\n",hostname);
  626. X    fclose(stdout);
  627. X#ifdef MSDOS
  628. X    unlink(tmpf);
  629. X#endif
  630. X    exit(0);
  631. X}
  632. END_OF_FILE
  633.   if test 16915 -ne `wc -c <'inpdos.c'`; then
  634.     echo shar: \"'inpdos.c'\" unpacked with wrong size!
  635.   fi
  636.   # end of 'inpdos.c'
  637. fi
  638. echo shar: End of archive 1 \(of 1\).
  639. cp /dev/null ark1isdone
  640. MISSING=""
  641. for I in 1 ; do
  642.     if test ! -f ark${I}isdone ; then
  643.     MISSING="${MISSING} ${I}"
  644.     fi
  645. done
  646. if test "${MISSING}" = "" ; then
  647.     echo You have the archive.
  648.     rm -f ark[1-9]isdone
  649. else
  650.     echo You still must unpack the following archives:
  651.     echo "        " ${MISSING}
  652. fi
  653. exit 0
  654. exit 0 # Just in case...
  655.