home *** CD-ROM | disk | FTP | other *** search
- #define HELP 10 /* Display help screen */
- #define OPEN 20 /* Error opening file */
- #define CLOSE 30 /* Error closing file */
- #define READ 40 /* Error reading file */
- #define WRITE 50 /* Error writing file */
- #define SEEK 60 /* Error seeking in file */
- #define MEMORY 70 /* Error allocating memory */
-
- #define USAGE " Usage: SYSCALLS calls [\"username\"]\n"\
- "Examples: SYSCALLS 2500, "\
- "SYSCALLS 71209 \"John Kristoff\", "\
- "SYSCALLS 0 \"SysOp\"\n"\
- "\n"\
- "calls range is 0 to %ld\n"\
- "username optional last caller username in quotes\n",\
- LONG_MAX
-
- /*
- ** Function: Error
- **
- ** Desc: Error handling function exits with message and error code.
- **
- ** Params: int Errorlevel - exit code
- ** int Line - line number where error occurred
- ** char * File - file where i/o error occured or NULL
- **
- ** Return: void
- */
-
- void
- Error( int ErrorLevel, int Line, char * File )
- {
- switch( ErrorLevel )
- {
- case HELP: fprintf( stderr, USAGE );
- break;
-
- case OPEN: fprintf( stderr, "ERROR (%d): Cannot open: %s\n",
- Line, File );
- break;
-
- case CLOSE: fprintf( stderr, "ERROR (%d): Cannot close %s\n",
- Line, File );
- break;
-
- case READ: fprintf( stderr, "ERROR (%d): Cannot read %s\n",
- Line, File );
- break;
-
- case WRITE: fprintf( stderr, "ERROR (%d): Cannot write %s\n",
- Line, File );
- break;
-
- case SEEK: fprintf( stderr, "ERROR (%d): seek error in %s\n",
- Line, File );
- break;
-
- case MEMORY: fprintf( stderr, "ERROR (%d): Cannot allocate memory\n",
- Line );
- break;
-
- default: fprintf( stderr, "ERROR (%d): Invalid instruction\n",
- Line );
- }
- exit( ErrorLevel );
- }
-