| 1 |
/*--------------------------------------------------------------------- |
| 2 |
* $Date: 2009-08-18 15:23:20 $ $Revision: 1.2 $ |
| 3 |
*--------------------------------------------------------------------- |
| 4 |
* |
| 5 |
* |
| 6 |
* Copyright (c) 1992, Visual Edge Software Ltd. |
| 7 |
* |
| 8 |
* ALL RIGHTS RESERVED. Permission to use, copy, modify, and |
| 9 |
* distribute this software and its documentation for any purpose |
| 10 |
* and without fee is hereby granted, provided that the above |
| 11 |
* copyright notice appear in all copies and that both that |
| 12 |
* copyright notice and this permission notice appear in supporting |
| 13 |
* documentation, and that the name of Visual Edge Software not be |
| 14 |
* used in advertising or publicity pertaining to distribution of |
| 15 |
* the software without specific, written prior permission. The year |
| 16 |
* included in the notice is the year of the creation of the work. |
| 17 |
*-------------------------------------------------------------------*/ |
| 18 |
|
| 19 |
/* |
| 20 |
.VERSION |
| 21 |
090818 last modif |
| 22 |
*/ |
| 23 |
|
| 24 |
|
| 25 |
#include <stdio.h> |
| 26 |
#include <stdarg.h> |
| 27 |
#include "uimx_cat.h" |
| 28 |
#include "misc1_ds.h" |
| 29 |
#define CGETS(x,y) UxCatGets(MC_MISC1,(x),(y)) |
| 30 |
#define CGETS_SYS(x,y) UxCatGets(MC_SYSTEM_NAME,(x),(y)) |
| 31 |
|
| 32 |
extern char *UxCopyString(); |
| 33 |
extern void UxFree(); |
| 34 |
|
| 35 |
|
| 36 |
static char *msg_prefix = ""; |
| 37 |
|
| 38 |
/*************************************************************************** |
| 39 |
NAME: UxInternalError (char *file_name,char *format_str, ...) |
| 40 |
INPUT: see description |
| 41 |
OUTPUT: --- |
| 42 |
RETURN: void |
| 43 |
DESCRIPTION: This function is to be used to print error messages to stderr. |
| 44 |
It should be called with at least 3 arguments. |
| 45 |
The first argument should be the name of the file where the |
| 46 |
error occurred. The second argument should be the line number |
| 47 |
within that file where the error occurred. Usually these would |
| 48 |
be __FILE__ and __LINE__ which are supplied by the preprocessor. |
| 49 |
The third argument should be a format string of the form that |
| 50 |
would be passed to printf. The remaining arguments (if any) |
| 51 |
should be the values to be printed. |
| 52 |
For example: |
| 53 |
UxInternalError("my_file", 23, "hello\n") |
| 54 |
would print "ERROR: my_file(23) hello" |
| 55 |
UxInternalError("my_file", 23, "Arg %d is wrong\n", cnt) |
| 56 |
would print something like "ERROR: my_file(23) Arg 13 is wrong" |
| 57 |
EXT REFERENCES: --- |
| 58 |
EXT EFFECTS: --- |
| 59 |
CREATION: Apr 10/90 |
| 60 |
REVISIONS: Sep 6/90 |
| 61 |
Added NLS support. This function can be called |
| 62 |
with a string which was received directly from |
| 63 |
the message catalog. It is copied before accessing |
| 64 |
the catalog again. But any argument to the format |
| 65 |
has to be preserved (through UxCopyString) by the |
| 66 |
caller. |
| 67 |
|
| 68 |
---------------------------------------------------------------------------*/ |
| 69 |
void UxInternalError (char *file_name, int line_num, ...) |
| 70 |
{ |
| 71 |
va_list args; |
| 72 |
|
| 73 |
char *format_str; |
| 74 |
|
| 75 |
/* The first two args are the file name and the line number */ |
| 76 |
va_start (args,line_num); |
| 77 |
|
| 78 |
format_str = UxCopyString(va_arg (args, char*)); |
| 79 |
|
| 80 |
(void) fprintf (stderr, "%s", msg_prefix); |
| 81 |
(void) fprintf (stderr, CGETS(MS_MISC_INTERNALERRORFORMAT, |
| 82 |
DS_MS_MISC_INTERNALERRORFORMAT), file_name, line_num); |
| 83 |
|
| 84 |
/* The remaining arguments are to be passed to vfprintf() */ |
| 85 |
(void) vfprintf (stderr, format_str, args); |
| 86 |
UxFree(format_str); |
| 87 |
|
| 88 |
va_end (args); |
| 89 |
} |
| 90 |
|
| 91 |
/*************************************************************************** |
| 92 |
NAME: UxStandardError (va_alist) |
| 93 |
INPUT: see description |
| 94 |
OUTPUT: --- |
| 95 |
RETURN: void |
| 96 |
CREATION: Sep 20/90 |
| 97 |
DESCRIPTION: This function is to be used to print error messages to stderr. |
| 98 |
It imitates fprintf(stderr,...) except it prefixes the string |
| 99 |
to be printed with the product name. |
| 100 |
****************************************************************************/ |
| 101 |
void UxStandardError (char *format_str, ...) |
| 102 |
{ |
| 103 |
va_list args; |
| 104 |
|
| 105 |
va_start (args,format_str); |
| 106 |
|
| 107 |
(void) fprintf (stderr, "%s", msg_prefix); |
| 108 |
(void) vfprintf (stderr, format_str, args); |
| 109 |
|
| 110 |
va_end (args); |
| 111 |
} |
| 112 |
|
| 113 |
/***************************************************************************** |
| 114 |
NAME: void UxInitInternalError() |
| 115 |
INPUT: None |
| 116 |
|
| 117 |
CREATION: 15/09/90 |
| 118 |
REVISIONS: -- |
| 119 |
-----------------------------------------------------------------------------*/ |
| 120 |
void UxInitInternalError() |
| 121 |
{ |
| 122 |
msg_prefix = UxCopyString(CGETS_SYS(MS_SYS_PREFIX,DS_MS_SYS_PREFIX)); |
| 123 |
} |