home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / UREP100.ZIP / UREPORT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-06  |  6.7 KB  |  233 lines

  1. /*********************************************************************
  2. ** FILENAME: ureport.c                      VERSION: 1.00
  3. **
  4. ** DESCRIPTION: Create a text output of a RemoteAccess user list
  5. **
  6. ** AUTHOR: John Kristoff                START DATE: 11/06/94
  7. **            FidoNet: 1:115/743
  8. **           Internet: jkristof@xroads.chigate.com
  9. **                     jkristof@bsd.meddean.luc.edu
  10. **         Compu$erve: 74111,3652
  11. **
  12. ** VERSION  DATE     WHO  DETAIL
  13. ** 1.00     06Sep94  JK   Initial design and coding
  14. **
  15. **      Copyright John Kristoff, 1994.  All rights reserved.
  16. **      You may use this program or any part there-of as desired
  17. **      without restriction.
  18. */
  19.  
  20. #include <stdio.h>                      /* Standard i/o              */
  21. #include <stdlib.h>                     /* Standard library          */
  22. #include "ra.h"                         /* RemoteAccess structures   */
  23. #include "error.h"                      /* Error handling function   */
  24.  
  25. #define VERSION     "1.00"              /* Program version           */
  26. #define SOURCE_FILE "USERS.BBS"         /* Userlist data file        */
  27. #define OUTPUT_FILE "UREPORT.ASC"       /* Userlist text file        */
  28.  
  29. typedef struct
  30. {
  31.     char Username[36];                  /* User name                 */
  32.     char Location[26];                  /* User's location           */
  33.     char Address1[51];                  /* Address line #1           */
  34.     char Address2[51];                  /* Address line #2           */
  35.     char Address3[51];                  /* Address line #3           */
  36.     char Handle[36];                    /* User's alias/handle       */
  37.     char Comment[81];                   /* SysOp comment             */
  38.     char VoicePhone[16];                /* User's voice phone #      */
  39.  
  40. } OUTPUT_DATA;                          /* Output data structure     */
  41.  
  42.  
  43. int main( void );                       /* If you don't know, YUSC   */
  44.  
  45. int
  46. main( void )
  47. {
  48.     FILE * fpSource;                    /* File pointer to data file */
  49.     FILE * fpOutput;                    /* File pointer to text file */
  50.  
  51.     USERS Userlist;                     /* RA userlist structure     */
  52.     OUTPUT_DATA OutputData;             /* Ouput data structure      */
  53.  
  54.     long int TotalUsers = 0;            /* Total user count          */
  55.  
  56.     printf( "\n"
  57.             "UREPORT v" VERSION ", " __DATE__ ".\n"
  58.             "RemoteAccess USERS.BBS to text file utility.\n"
  59.             "Copyright John Kristoff, 1994.  All rights reserved.\n"
  60.             "\n" );
  61.  
  62.     fpSource = fopen( SOURCE_FILE, "rb" );
  63.     if( fpSource == NULL )
  64.     {
  65.         Error( OPEN, __LINE__, SOURCE_FILE );
  66.     }
  67.  
  68.     fpOutput = fopen( OUTPUT_FILE, "w" );
  69.     if( fpOutput == NULL )
  70.     {
  71.         Error( OPEN, __LINE__, OUTPUT_FILE );
  72.     }
  73.  
  74.     printf( "Working...  " );
  75.  
  76.  
  77.     /*****************************************************************/
  78.     /* The backbone of the program                                   */
  79.     /*    1. Read a struct                                           */
  80.     /*    2. Get data into our preferred C format                    */
  81.     /*    3. Print it to the output file                             */
  82.     /*****************************************************************/
  83.  
  84.     while( !feof(fpSource) )
  85.     {
  86.         fread( &Userlist, sizeof(USERS), 1, fpSource );
  87.         if( &Userlist == NULL )
  88.         {
  89.             Error( READ, __LINE__, SOURCE_FILE );
  90.         }
  91.  
  92.  
  93.         /* Username and Security Level */
  94.         strncpy( OutputData.Username,
  95.                  Userlist.name.string,
  96.                  Userlist.name.l1
  97.                );
  98.  
  99.         OutputData.Username[Userlist.name.l1] = '\0';
  100.  
  101.         fprintf( fpOutput,
  102.                  "User: %-45sSecurity: %u\n",
  103.                  OutputData.Username,
  104.                  Userlist.security
  105.                );
  106.  
  107.  
  108.         /* Handle */
  109.         strncpy( OutputData.Handle,
  110.                  Userlist.handle,
  111.                  Userlist.l6
  112.                );
  113.  
  114.         OutputData.Handle[Userlist.l6] = '\0';
  115.  
  116.         fprintf( fpOutput,
  117.                  "Handle: %s\n",
  118.                  OutputData.Handle
  119.                );
  120.  
  121.  
  122.         /* Location */
  123.         strncpy( OutputData.Location,
  124.                  Userlist.location,
  125.                  Userlist.l1
  126.                );
  127.  
  128.         OutputData.Location[Userlist.l1] = '\0';
  129.  
  130.         fprintf( fpOutput,
  131.                  "Location: %s\n",
  132.                  OutputData.Location
  133.                );
  134.  
  135.  
  136.         /* Address 1 */
  137.         strncpy( OutputData.Address1,
  138.                  Userlist.address1,
  139.                  Userlist.l3
  140.                );
  141.  
  142.         OutputData.Address1[Userlist.l3] = '\0';
  143.  
  144.         fprintf( fpOutput,
  145.                  "Address 1: %s\n",
  146.                  OutputData.Address1
  147.                );
  148.  
  149.  
  150.         /* Address 2 */
  151.         strncpy( OutputData.Address2,
  152.                  Userlist.address2,
  153.                  Userlist.l4
  154.                );
  155.  
  156.         OutputData.Address2[Userlist.l4] = '\0';
  157.  
  158.         fprintf( fpOutput,
  159.                  "Address 2: %s\n",
  160.                  OutputData.Address2
  161.                );
  162.  
  163.  
  164.         /* Address 3 */
  165.         strncpy( OutputData.Address3,
  166.                  Userlist.address3,
  167.                  Userlist.l5
  168.                );
  169.  
  170.         OutputData.Address3[Userlist.l5] = '\0';
  171.  
  172.         fprintf( fpOutput,
  173.                  "Address 3: %s\n",
  174.                  OutputData.Address3
  175.                );
  176.  
  177.  
  178.         /* SysOp Comment */
  179.         strncpy( OutputData.Comment,
  180.                  Userlist.comment,
  181.                  Userlist.l7
  182.                );
  183.  
  184.         OutputData.Comment[Userlist.l7] = '\0';
  185.  
  186.         fprintf( fpOutput,
  187.                  "SysOp Comment: %s\n",
  188.                  OutputData.Comment
  189.                );
  190.  
  191.  
  192.         /* Voice Phone # */
  193.         strncpy( OutputData.VoicePhone,
  194.                  Userlist.voicephone,
  195.                  Userlist.l9
  196.                );
  197.  
  198.         OutputData.VoicePhone[Userlist.l9] = '\0';
  199.  
  200.         fprintf( fpOutput,
  201.                  "Voice Phone #: %s\n",
  202.                  OutputData.VoicePhone
  203.                );
  204.  
  205.  
  206.         /* Add a couple of blank lines */
  207.         fprintf( fpOutput,
  208.                  "\n\n"
  209.                );
  210.  
  211.         TotalUsers++;                   /* Total user count          */
  212.     }
  213.  
  214.  
  215.     /* Let's clean up */
  216.  
  217.     fclose( fpSource );
  218.     if( ferror(fpSource) )
  219.     {
  220.         Error( CLOSE, __LINE__, SOURCE_FILE );
  221.     }
  222.  
  223.     fclose( fpOutput );
  224.     if( ferror(fpOutput) )
  225.     {
  226.         Error( CLOSE, __LINE__, SOURCE_FILE );
  227.     }
  228.  
  229.     printf( "Done!  %ld users processed.\n", TotalUsers );
  230.  
  231.     return( EXIT_SUCCESS );
  232. }
  233.