/***************************************************************************** aapm_status.c **************************************************************************** Description: Utility program required by the AAPM Tape Data Exchange format writing and reading programs error reporting. This routine requires two global variables: - a file pointer (FILE *aapm_log_file) which is the stream pointer for the opened file. If it is NULL, all output is written to stdout. - a character string (char aapm_log_string[180]) to which the messages may be written (to avoid having to have multiple strings defined in each module which calls this routine. Modules Included: aapm_status() Outputs progress messages to a log file and stdout or stderr if need be. ************************ Revision History: $Log: aapm_status.c,v $ * Revision 1.1 2000/01/14 22:49:16 jwm * Remove comments originating in other development trees * * Revision 1.0 2000/01/14 22:42:38 jwm * Initial revision ============================================================================ ***************************************************************************/ static char *RCSid = "$Id: aapm_status.c,v 1.1 2000/01/14 22:49:16 jwm Exp $"; /* DISABLE SOME INCLUSIONS */ #define NOT_MAIN /* Include Files */ #include #include #include #include #include #include #include #include #include "sitedata.h" #include "exchkeys.h" #include "patexchange.h" /***************************************************************************** aapm_status() **************************************************************************** Functional Description: Output a status line to a log file (if one is open) and to stdout for progress messages or stderr for error messages. ***************************************************************************/ int aapm_status ( aapm_status_type aapm_status, /* NATURE OF MESSAGE TYPE eAAPM_INFO | eAAPM_ERROR */ char *status_line /* TEXT STRING DOCUMENTING MESSAGE */ ) { /* SWITCH BASED ON NATURE OF REPORT */ switch( aapm_status ) { case eAAPM_INFO: /* INFORMATIONAL MESSAGE ONLY */ /* PUT IN LOG IF LOG FILE IS OPEN */ if ( aapm_log_file != NULL ) fprintf( aapm_log_file, " INFORM: %s\n", status_line ); else fprintf( stdout, " %s\n", status_line ); break; case eAAPM_STATUS: /* STATUS REPORT MESSAGE */ if ( aapm_log_file != NULL ) fprintf( aapm_log_file, " STATUS: %s\n", status_line ); fprintf( stdout, " %s\n", status_line ); break; case eAAPM_WARN: /* WARNING MESSAGE ABOUT POSSIBLE ERROR */ if ( aapm_log_file != NULL ) fprintf( aapm_log_file, " WARNING: %s\n", status_line ); fprintf( stdout, " WARNING: %s\n", status_line ); break; case eAAPM_ERROR: /* ERROR REPORT MESSAGE */ if ( aapm_log_file != NULL ) fprintf( aapm_log_file, "ERROR!: %s\n", status_line ); fprintf( stdout, "ERROR!: %s\n", status_line ); break; default: /* BAD CALL */ fprintf( stderr, "Invalid status passed to aapm_status()\n" ); break; } /* IF GOING TO A FILE, FLUSH IT */ if ( aapm_log_file != NULL ) fflush( aapm_log_file ); return(0); } /************************** End of aapm_status() *************************/ /************************* End of aapm_status.c ***************************/