home *** CD-ROM | disk | FTP | other *** search
- /*********************************************************************
- ** FILENAME: ureport.c VERSION: 1.00
- **
- ** DESCRIPTION: Create a text output of a RemoteAccess user list
- **
- ** AUTHOR: John Kristoff START DATE: 11/06/94
- ** FidoNet: 1:115/743
- ** Internet: jkristof@xroads.chigate.com
- ** jkristof@bsd.meddean.luc.edu
- ** Compu$erve: 74111,3652
- **
- ** VERSION DATE WHO DETAIL
- ** 1.00 06Sep94 JK Initial design and coding
- **
- ** Copyright John Kristoff, 1994. All rights reserved.
- ** You may use this program or any part there-of as desired
- ** without restriction.
- */
-
- #include <stdio.h> /* Standard i/o */
- #include <stdlib.h> /* Standard library */
- #include "ra.h" /* RemoteAccess structures */
- #include "error.h" /* Error handling function */
-
- #define VERSION "1.00" /* Program version */
- #define SOURCE_FILE "USERS.BBS" /* Userlist data file */
- #define OUTPUT_FILE "UREPORT.ASC" /* Userlist text file */
-
- typedef struct
- {
- char Username[36]; /* User name */
- char Location[26]; /* User's location */
- char Address1[51]; /* Address line #1 */
- char Address2[51]; /* Address line #2 */
- char Address3[51]; /* Address line #3 */
- char Handle[36]; /* User's alias/handle */
- char Comment[81]; /* SysOp comment */
- char VoicePhone[16]; /* User's voice phone # */
-
- } OUTPUT_DATA; /* Output data structure */
-
-
- int main( void ); /* If you don't know, YUSC */
-
- int
- main( void )
- {
- FILE * fpSource; /* File pointer to data file */
- FILE * fpOutput; /* File pointer to text file */
-
- USERS Userlist; /* RA userlist structure */
- OUTPUT_DATA OutputData; /* Ouput data structure */
-
- long int TotalUsers = 0; /* Total user count */
-
- printf( "\n"
- "UREPORT v" VERSION ", " __DATE__ ".\n"
- "RemoteAccess USERS.BBS to text file utility.\n"
- "Copyright John Kristoff, 1994. All rights reserved.\n"
- "\n" );
-
- fpSource = fopen( SOURCE_FILE, "rb" );
- if( fpSource == NULL )
- {
- Error( OPEN, __LINE__, SOURCE_FILE );
- }
-
- fpOutput = fopen( OUTPUT_FILE, "w" );
- if( fpOutput == NULL )
- {
- Error( OPEN, __LINE__, OUTPUT_FILE );
- }
-
- printf( "Working... " );
-
-
- /*****************************************************************/
- /* The backbone of the program */
- /* 1. Read a struct */
- /* 2. Get data into our preferred C format */
- /* 3. Print it to the output file */
- /*****************************************************************/
-
- while( !feof(fpSource) )
- {
- fread( &Userlist, sizeof(USERS), 1, fpSource );
- if( &Userlist == NULL )
- {
- Error( READ, __LINE__, SOURCE_FILE );
- }
-
-
- /* Username and Security Level */
- strncpy( OutputData.Username,
- Userlist.name.string,
- Userlist.name.l1
- );
-
- OutputData.Username[Userlist.name.l1] = '\0';
-
- fprintf( fpOutput,
- "User: %-45sSecurity: %u\n",
- OutputData.Username,
- Userlist.security
- );
-
-
- /* Handle */
- strncpy( OutputData.Handle,
- Userlist.handle,
- Userlist.l6
- );
-
- OutputData.Handle[Userlist.l6] = '\0';
-
- fprintf( fpOutput,
- "Handle: %s\n",
- OutputData.Handle
- );
-
-
- /* Location */
- strncpy( OutputData.Location,
- Userlist.location,
- Userlist.l1
- );
-
- OutputData.Location[Userlist.l1] = '\0';
-
- fprintf( fpOutput,
- "Location: %s\n",
- OutputData.Location
- );
-
-
- /* Address 1 */
- strncpy( OutputData.Address1,
- Userlist.address1,
- Userlist.l3
- );
-
- OutputData.Address1[Userlist.l3] = '\0';
-
- fprintf( fpOutput,
- "Address 1: %s\n",
- OutputData.Address1
- );
-
-
- /* Address 2 */
- strncpy( OutputData.Address2,
- Userlist.address2,
- Userlist.l4
- );
-
- OutputData.Address2[Userlist.l4] = '\0';
-
- fprintf( fpOutput,
- "Address 2: %s\n",
- OutputData.Address2
- );
-
-
- /* Address 3 */
- strncpy( OutputData.Address3,
- Userlist.address3,
- Userlist.l5
- );
-
- OutputData.Address3[Userlist.l5] = '\0';
-
- fprintf( fpOutput,
- "Address 3: %s\n",
- OutputData.Address3
- );
-
-
- /* SysOp Comment */
- strncpy( OutputData.Comment,
- Userlist.comment,
- Userlist.l7
- );
-
- OutputData.Comment[Userlist.l7] = '\0';
-
- fprintf( fpOutput,
- "SysOp Comment: %s\n",
- OutputData.Comment
- );
-
-
- /* Voice Phone # */
- strncpy( OutputData.VoicePhone,
- Userlist.voicephone,
- Userlist.l9
- );
-
- OutputData.VoicePhone[Userlist.l9] = '\0';
-
- fprintf( fpOutput,
- "Voice Phone #: %s\n",
- OutputData.VoicePhone
- );
-
-
- /* Add a couple of blank lines */
- fprintf( fpOutput,
- "\n\n"
- );
-
- TotalUsers++; /* Total user count */
- }
-
-
- /* Let's clean up */
-
- fclose( fpSource );
- if( ferror(fpSource) )
- {
- Error( CLOSE, __LINE__, SOURCE_FILE );
- }
-
- fclose( fpOutput );
- if( ferror(fpOutput) )
- {
- Error( CLOSE, __LINE__, SOURCE_FILE );
- }
-
- printf( "Done! %ld users processed.\n", TotalUsers );
-
- return( EXIT_SUCCESS );
- }
-