home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-386-Vol-2of3.iso / c / clinfo12.zip / CALLINFO.C next >
Text File  |  1992-01-19  |  7KB  |  224 lines

  1. /* USERINFO   -> Waffle BBS Traffic Monitor
  2.    Copyright 1991,1992 Greg Argendeli
  3.    Version 1.2
  4.    January 18, 1992
  5.    Waffle is Copyright Darkside Inc.
  6.  
  7.    When compiled under Turbo C (Copyright Borland Int'l) under the TINY
  8.    memory model, this software will show a list of the top 10 callers, and
  9.    the number of calls each, as well as a breakdown of baud rates.
  10.    The data is from the CALLERS data file, normally found in \waffle\admin\
  11.    CALLERS.   The program does NOT include uucp connections in it's output.
  12.  
  13.    For use in WAFFLE, this program should be compiled under Borland's TURBO C
  14.    (TINY model), and then converted to a .com file via exe2bin.  Please see
  15.    the Waffle BBS documentation on how to provide your users access to this
  16.    package.
  17.  
  18.    This piece of code is Copyright 1991 Greg Argendeli.  The author retains
  19.    all rights to this program.  The source code is distributed for the purpose
  20.    of allowing system operators the option of modifying it for their individual
  21.    systems.
  22.  
  23.    This code may be distributed under the following conditions:
  24.  
  25.     1) This Copyright block MUST remain intact
  26.     2) No charge is made for access, copying, or other packaging.  This
  27.        software may NOT be packaged with any other software without the
  28.        expressed, written consent of the author.  Any system
  29.        distributing this code MUST NOT CHARGE FOR ACCESS IN ANY WAY.
  30.     3) You do not claim authorship.
  31.     4) When modifying this code, please increment the VERSION_MINOR number
  32.        ONLY.  Your changes should be 1.XXXX where XXXX is VERSION_MINOR.
  33.     5) This code may only be distributed in an un-modified form.  If you
  34.        have changed it,you may make your changes available, but they must
  35.        be in a sepparate file, and this source code must be included.
  36.     6) This code was a hack.  if you have any suggestions, please send
  37.        them to me.  Either use the number listed below, or send mail to
  38.        arg@arghouse.uucp.
  39.  
  40.    While I do not plan to get rich on this software, I won't turn down any
  41.    money sent, as a token of appreciation, say $2 US :)
  42.  
  43.    The Listening Post BBS
  44.    BBS: 619-563-1084
  45.  
  46.    Thank you for respecting these conditions. */
  47.  
  48. #include <stdio.h>
  49. #include <stdlib.h>
  50. #include <string.h>
  51.  
  52.  
  53. /* The following includes are standards that I put in all my code... -arg*/
  54. /* Location of the WAFFLE 1.64 Files */
  55.  
  56. #define TRAFFIC_FILE "/waffle/admin/traffic"
  57. #define CALLERS_FILE "/waffle/admin/callers"
  58. #define MAIL_FILE "/waffle/admin/mail"
  59. #define VERSION_NAME "Userinfo"
  60. #define VERSION_MAJOR 1
  61. #define VERSION_MINOR 21
  62. #define DATE_RELEASED "January 19, 1992"
  63. /* Name of your organization.  (MUST be 22 characters in length) */
  64. #define WAFFLENAME "The Usenet Community  "
  65. /* If you modify the code, please increment the 0001 portion of the next def*/
  66. #define REGISTRATION "92NET"
  67.  
  68. /* If you change the spacing and/or length of system names, you will
  69.    probably have to change them in the lower portion of the program.. */
  70.  
  71.  
  72.  
  73. struct alpha
  74. {
  75.     char username[9];
  76.     int calls;
  77. } users[400];
  78.  
  79.  
  80. header()
  81. {
  82.     printf("\n\n\n\n\n\n");
  83.     printf("%s [%d.%d] {%s}\n",VERSION_NAME,VERSION_MAJOR,VERSION_MINOR,DATE_RELEASED);
  84.     printf("Copyright 1991, 1992 arg@arghouse.uucp\n");
  85. #ifdef REGISTRATION
  86.     printf("Registered to: %s [%s]\n",WAFFLENAME,REGISTRATION);
  87. #endif
  88. #ifndef REGISTRATION
  89.     printf("%s\n",WAFFLENAME);
  90. #endif
  91.     printf("----------------------------------------------\n");
  92. }
  93.  
  94.  
  95. main()
  96. {
  97.    FILE * fptr;
  98.    int baud_300=0,
  99.        swap,
  100.        baud_1200=0,
  101.        baud_450=0,
  102.        baud_1600=0,
  103.        baud_2400=0,
  104.        baud_4800=0,
  105.        count=0,
  106.        user_count=0,
  107.        ii=0,
  108.        i=0,
  109.        AA=0,
  110.        high_call=0,
  111.        baud_9600=0,
  112.        old_high=0,
  113.        baud_19200=0,
  114.        baud_38400=0,
  115.        call_count=0,
  116.        average=0,
  117.        match=0,
  118.        turn_count=0;
  119.    char dummy[99],
  120.     user[9],
  121.     baud[12],
  122.     turns[4];
  123.    int temp_calls;
  124.  
  125. struct x
  126. {
  127.   char  user[9];
  128.   int call;
  129. } high_user;
  130.         header();
  131.         printf("Reading Caller: ");
  132.         fptr=fopen(CALLERS_FILE,"r");
  133.         if (fptr==NULL)
  134.          {
  135.             printf("OOPS, CANNOT OPEN DATA FILE\n");
  136.             exit(86);
  137.          }
  138.  
  139.         while (!feof(fptr))
  140.          {
  141.          count++;
  142.          if (count==25) printf("25 ");
  143.          if (count==100) printf("100 ");
  144.          if (count==150) printf("150 ");
  145.          if (count==220) printf("220 ");
  146.          if (count==310) printf("310 ");
  147.          if (count==400) printf("400 ");
  148.          if (count==1000) printf("1000 ");
  149.          if (count==1600) printf("1600 ");
  150.          if (count==2000) printf("2000 ");
  151.          if (count==3000) printf("3000 ");
  152.  
  153.  
  154.          fscanf(fptr,"%s %s",dummy,baud);
  155.          fread(dummy,57,1,fptr);
  156.          strncpy(user,dummy,8);
  157.          user[8]=NULL;
  158.          fscanf(fptr,"%s %s",turns,dummy);
  159.             if (strcmp(baud,"300b")==0) baud_300++;
  160.             if (strcmp(baud,"450b")==0) baud_450++;
  161.             if (strcmp(baud,"1200b")==0) baud_1200++;
  162.             if (strcmp(baud,"2400b")==0) baud_2400++;
  163.             if (strcmp(baud,"4800b")==0) baud_4800++;
  164.             if (strcmp(baud,"9600b")==0) baud_9600++;
  165.             if (strcmp(baud,"19200")==0) baud_19200++;
  166.  
  167.             match=0;
  168.             for (i=1;i<=user_count;i++)
  169.                {
  170.                 if (strcmp(user,users[i].username)==0)
  171.                   {
  172.                      users[i].calls++;
  173.                      match=1;
  174.                   }
  175.                }
  176.                if (!match)
  177.               {
  178.                 user_count++;
  179.                 strcpy(users[user_count].username,user);
  180.                 users[i].calls++;
  181.                }
  182.             match=0;
  183.          }
  184.          printf("%d\n",count);
  185.          strcpy(user,NULL);
  186.          temp_calls=0;
  187.          high_call=0;
  188.          printf("\n    Top 10 Callers (excluding UUCP)\n");
  189.          printf("\tRank\t User\t\tCalls\n");
  190.          printf("+-----------------------------------\n");
  191.          for (i=1;i<=10;i++)
  192.             {
  193.             high_call=0;
  194.               printf("|\t(%d)\t",i);
  195.  
  196.               for (AA=1;AA<=user_count;AA++)
  197.              {
  198.                if (users[AA].call > high_call)
  199.                   {
  200.                 /*printf("%d\n",AA); */
  201.                 high_call=users[AA].call;
  202.                 strcpy(user,users[AA].username);
  203.                 users[AA].call=0;
  204.                   }
  205.              }
  206.               printf("%s\t[%d]",user,high_call);
  207.               if (i==1) printf("\t Speed Breakdown");
  208.               if (i==2) printf("\t-BAUD----Calls---");
  209.               if (i==3) printf("\t  300     %d",baud_300);
  210.               if (i==4) printf("\t  450     %d",baud_450 );
  211.               if (i==5) printf("\t 1200     %d",baud_1200);
  212.               if (i==6) printf("\t 2400     %d",baud_2400);
  213.               if (i==7) printf("\t 4800     %d",baud_4800);
  214.               if (i==8) printf("\t 9600     %d",baud_9600);
  215.               if (i==9) printf("\t19200     %d",baud_19200);
  216.               if (i==10) printf("\tUnique Ids:   %d",user_count);
  217.               printf("\n");
  218.             }
  219.  
  220.             printf("+-----------------------------------\n");
  221.  
  222. }
  223.  
  224.