home *** CD-ROM | disk | FTP | other *** search
- /*********************************************************************
- ** FILENAME: malist.c VERSION: 1.00
- **
- ** DESCRIPTION: Sample code to display RemoteAccess message areas
- **
- ** NOTES: Tested with RemoteAccess v2.01 MESSAGES.RA file
- **
- ** AUTHOR: John Kristoff START DATE: 04/25/94
- ** Internet: jkristof@xroads.chigate.com
- ** jkristof@mica.meddean.luc.edu
- ** FidoNet: 1:115/743
- ** Compuserve: 74111,3652
- **
- ** VERSION DATE WHO DETAIL
- ** 1.00 05Jun94 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 */
-
- #define VERS "1.00" /* Program version */
-
- int main( void ); /* If you don't know, YUSC */
-
- int
- main( void )
- {
- int AreaNum = 0; /* Area # we're at */
- struct MESSAGE Msgs; /* Defined in ra.h */
- FILE * fp = NULL; /* Pointer to MESSAGES.RA */
-
- printf( "\n"
- "MALIST v" VERS ", " __DATE__ ".\n"
- "Sample code to display RemoteAccess message areas\n"
- "Copyright John Kristoff, 1994. All rights reserved.\n"
- "\n" );
-
- fp = fopen( "MESSAGES.RA", "rb" );
- if( fp == NULL )
- {
- printf( "ERROR (%d): Cannot open MESSAGES.RA\n", __LINE__ );
- exit( EXIT_FAILURE );
- }
-
- if( fread(&Msgs, sizeof(struct MESSAGE), 1, fp) == NULL )
- {
- printf( "ERROR (%d): Cannot read MESSAGES.RA\n", __LINE__ );
- exit( EXIT_FAILURE );
- }
-
- while( !feof(fp) )
- {
- char Area[41] = ""; /* Blank area name string */
-
- if( Msgs.NameSize < 1 )
- {
- strcpy( Area, "[Unused]" );
- }
- else
- {
- strncpy( Area, Msgs.Name, Msgs.NameSize );
- Area[Msgs.NameSize + 1] = '\0';
- }
-
- printf( "Area %d: %s\n", ++AreaNum, Area );
-
- fread(&Msgs, sizeof(struct MESSAGE), 1, fp);
- }
-
- fclose( fp );
- if( ferror(fp) )
- {
- printf( "ERROR (%d): Cannot close MESSAGES.RA\n", __LINE__ );
- exit( EXIT_FAILURE );
- }
-
- return( EXIT_SUCCESS );
- }
-