/**********************************************************************/ /* /* $Date: 91/10/25 23:33:28 $ /* $Revision: 1.7.33.1 $ /* /**********************************************************************/ #include #include #include #include #define CGETS(x,y) UxCatGets(MC_MISC1,(x),(y)) #define CGETS_SYS(x,y) UxCatGets(MC_SYSTEM_NAME,(x),(y)) extern char *UxCopyString(); static char *msg_prefix = ""; /*************************************************************************** NAME: UxInternalError (va_alist) INPUT: see description OUTPUT: --- RETURN: void DESCRIPTION: This function is to be used to print error messages to stderr. It should be called with at least 3 arguments. The first argument should be the name of the file where the error occurred. The second argument should be the line number within that file where the error occurred. Usually these would be __FILE__ and __LINE__ which are supplied by the preprocessor. The third argument should be a format string of the form that would be passed to printf. The remaining arguments (if any) should be the values to be printed. For example: UxInternalError("my_file", 23, "hello\n") would print "ERROR: my_file(23) hello" UxInternalError("my_file", 23, "Arg %d is wrong\n", cnt) would print something like "ERROR: my_file(23) Arg 13 is wrong" EXT REFERENCES: --- EXT EFFECTS: --- CREATION: Apr 10/90 REVISIONS: Sep 6/90 Added NLS support. This function can be called with a string which was received directly from the message catalog. It is copied before accessing the catalog again. But any argument to the format has to be preserved (through UxCopyString) by the caller. ---------------------------------------------------------------------------*/ void UxInternalError (va_alist) va_dcl { va_list args; char *file_name, *format_str; int line_num; va_start (args); /* The first two args are the file name and the line number */ file_name = va_arg (args, char*); line_num = va_arg (args, int); format_str = UxCopyString(va_arg (args, char*)); (void) fprintf (stderr, msg_prefix); (void) fprintf (stderr, CGETS(MS_MISC_INTERNALERRORFORMAT, DS_MS_MISC_INTERNALERRORFORMAT), file_name, line_num); /* The remaining arguments are to be passed to vfprintf() */ (void) vfprintf (stderr, format_str, args); UxFree(format_str); va_end (args); } /*************************************************************************** NAME: UxStandardError (va_alist) INPUT: see description OUTPUT: --- RETURN: void CREATION: Sep 20/90 DESCRIPTION: This function is to be used to print error messages to stderr. It imitates fprintf(stderr,...) except it prefixes the string to be printed with the product name. ****************************************************************************/ void UxStandardError (va_alist) va_dcl { va_list args; char *format_str; va_start (args); format_str = va_arg (args, char*); (void) fprintf (stderr, msg_prefix); (void) vfprintf (stderr, format_str, args); va_end (args); } /***************************************************************************** NAME: void UxInitInternalError() INPUT: None CREATION: 15/09/90 REVISIONS: -- -----------------------------------------------------------------------------*/ void UxInitInternalError() { msg_prefix = UxCopyString(CGETS_SYS(MS_SYS_PREFIX,DS_MS_SYS_PREFIX)); }