/* * @OSF_COPYRIGHT@ * COPYRIGHT NOTICE * Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc. * ALL RIGHTS RESERVED (DCE). See the file named COPYRIGHT.DCE in the * src directory for the full copyright text. * * (c) Copyright 1991, 1992 Siemens-Nixdorf Information Systems * Burlington, MA, USA */ /* * HISTORY * $Log: cma_message.c,v $ * Revision 1.1.4.2 1993/06/24 21:01:45 hinman * [hinman@sni] - Check in SNI merged version (these files have no tainted or private code * [1993/06/17 14:44:09 hinman] * * Revision 1.1.2.6 1993/01/08 22:22:37 tom * Bug 6776 - Do not call setlocale in a library routine. * Locale init should always be done in the application. * [1993/01/08 20:56:43 tom] * * Revision 1.1.2.5 1992/12/15 22:28:52 alan * Insert copyright notices * [1992/12/07 19:39:38 alan] * * Revision 1.1.2.4 1992/09/29 20:15:07 devsrc * [OT 5373] SNI/SVR4 merge. * [1992/09/17 20:49:40 sekhar] * * Revision 1.1.2.3 1992/09/04 20:11:32 bolinger * Fix up log. * [1992/09/04 19:52:51 bolinger] * * Fix OT defect 5317: clean up rules for lookup of message catalog in * default location when NLSPATH lookup fails, and (for AIX 3.2) perform * explicit locale initialization, without which catalog lookup will * always fail. * [1992/09/04 15:06:49 bolinger] * * Revision 1.1.2.2 1992/09/03 14:38:24 bolinger * Replace current source file with equivalent from DEC BL10+ * source base, as originally integrated in the * nosupport/threads_bl10 tree. (See OT defect 5300.) * [1992/09/02 14:04:43 bolinger] * * Revision 1.1.2.2 1992/05/08 23:33:13 bolinger * BL10 CMA sources from DEC. * [1992/05/08 23:32:55 bolinger] * * Revision 1.1 1992/01/19 14:39:12 devrcs * Initial revision * * $EndLog$ */ /* ** Copyright (c) 1991 by ** Hewlett-Packard Company, Palo Alto, Ca. & ** Digital Equipment Corporation, Maynard, Mass. ** ** %a%copyright(,** ) ** ** NAME ** ** cma_message.c ** ** FACILITY: ** ** Distributed Computing Environment (DCE) ** ** ABSTRACT: ** ** Error status management routines. ** ** %a%private_begin ** ** MODIFICATION HISTORY: ** ** 20-Nov-91 butenhof Prototype, extra level of fallback for cat file. ** 19-Nov-91 harrow Create cma version, include default values for thd messages. ** 22-oct-91 mishkin map rad-50 0 to "a" instead of "_". ** 13-jun-91 martin Preface rpcsts.h with dce/; ** remove inclusion of dce_error.h. ** 09-apr-91 janicki change status to an int ** 27-mar-91 mishin remove version number stuff; add support for DFS ** 08-mar-91 janicki Change order. Full status code now ** ** Update dce_error_inq_text() signature. ** 25-jan-91 janicki Add .cat to file name. ** Add second try to open message file. ** 07-jan-91 sudama Fix message not found to return -1 ** Fix logic in message file version mismatch ** 29-nov-90 woodbury Change #include paths for IBM ** 13-nov-90 sudama Original creation. ** ** %a%private_end ** */ #ifdef SNI_SVR4 #include #endif #include /* for catalog routine prototypes */ #include /* standard i/o */ #if _CMA_UNIX_TYPE == _CMA__SVR4 #include #else #include #endif /* _CMA__SVR4 */ #include /* public types for NLS (I18N) routines */ #define FACILITY_CODE_MASK 0xF0000000 #define FACILITY_CODE_SHIFT 28 #define COMPONENT_CODE_MASK 0x0FFFF000 #define COMPONENT_CODE_SHIFT 12 #define STATUS_CODE_MASK 0x00000FFF #define STATUS_CODE_SHIFT 0 #define NO_MESSAGE "THIS IS NOT A MESSAGE" /* * Define the default location for the catalog files. */ #ifdef AIX32 #define DEFAULT_NLSPATH "/usr/lib/nls/msg/En_US/%s" #else #define DEFAULT_NLSPATH "/usr/lib/nls/msg/en_US.88591/%s" #endif #ifdef ADA_PTHREAD #include #endif /* **++ ** ** ROUTINE NAME: cma__error_inq_text ** ** SCOPE: PRIVATE ** ** DESCRIPTION: ** ** Returns a text string in a user provided buffer associated with a given ** error status code. In the case of errors a text string will also be ** returned indicating the nature of the error. ** ** INPUTS: ** ** status_to_convert A DCE error status code to be converted to ** text form. ** ** INPUTS/OUTPUTS: None. ** ** OUTPUTS: ** ** error_text A user provided buffer to hold the text ** equivalent of status_to_convert or ** a message indicating what error occurred. ** ** ** status The result of the operation. One of: ** 0 - success ** -1 - failure ** ** IMPLICIT INPUTS: none ** ** IMPLICIT OUTPUTS: none ** ** FUNCTION VALUE: none ** ** SIDE EFFECTS: none ** **-- **/ void cma__error_inq_text #if _CMA_PROTO_ (unsigned long status_to_convert, unsigned char *error_text, int *status) #else (status_to_convert, error_text, status) unsigned long status_to_convert; unsigned char *error_text; int *status; #endif { unsigned short facility_code; unsigned short component_code; unsigned short status_code; unsigned short i; nl_catd catd; char component_name[4]; char *facility_name; char filename_prefix[7]; char nls_filename[11]; char alt_filename[80]; char *message; static char *facility_names[] = { "dce", "dfs" }; /* * set up output status for future error returns */ if (status != NULL) { *status = -1; } /* * check for ok input status */ if (status_to_convert == 0) { if (status != NULL) { *status = 0; } strcpy ((char *)error_text, "successful completion"); return; } /* * extract the component, facility and status codes */ facility_code = (status_to_convert & FACILITY_CODE_MASK) >> FACILITY_CODE_SHIFT; component_code = (status_to_convert & COMPONENT_CODE_MASK) >> COMPONENT_CODE_SHIFT; status_code = (status_to_convert & STATUS_CODE_MASK) >> STATUS_CODE_SHIFT; /* * see if this is a recognized facility */ if (facility_code == 0 || facility_code > sizeof (facility_names) / sizeof (char *)) { # if _CMA_UNIX_TYPE == _CMA__SVR4 cma__int_sprintf ((char *) error_text, "status %08x (unknown facility)", status_to_convert); # else sprintf ((char *) error_text, "status %08x (unknown facility)", status_to_convert); # endif /* _CMA__SVR4 */ return; } facility_name = facility_names[facility_code - 1]; /* * Convert component name from RAD-50 component code. (Mapping is: * 0 => 'a', ..., 25 => 'z', 26 => '{', 27 => '0', ..., 36 => '9'.) */ component_name[3] = 0; component_name[2] = component_code % 40; component_code /= 40; component_name[1] = component_code % 40; component_name[0] = component_code / 40; for (i = 0; i < 3; i++) { component_name[i] += (component_name[i] <= 26) ? 'a' : ('0' - 27); } #if _CMA_UNIX_TYPE == _CMA__SVR4 cma__int_sprintf (filename_prefix, "%3s%3s", facility_name, component_name); #else sprintf (filename_prefix, "%3s%3s", facility_name, component_name); #endif /* * Add ".cat" to prefix to obtain the full message file name */ #if _CMA_UNIX_TYPE != _CMA__SVR4 sprintf (nls_filename, "%s.cat", filename_prefix); #else cma__int_sprintf (nls_filename, "%s", filename_prefix); #endif /* * Open the message file */ catd = (nl_catd) catopen (nls_filename, 0); if (catd == (nl_catd) -1) { /* * If we did not succeed in opening message file using NLSPATH, * try to open the message file in a well-known default area */ # if _CMA_UNIX_TYPE == _CMA__SVR4 cma__int_sprintf (alt_filename, # else sprintf (alt_filename, # endif /* _CMA__SVR4 */ DEFAULT_NLSPATH, nls_filename); catd = (nl_catd) catopen (alt_filename, 0); if (catd == (nl_catd) -1) { char *thd_message = NULL; switch (status_to_convert) { case exc_s_exception : thd_message="Address exception raised";break; case exc_s_exccop : thd_message="Status exception raised";break; case exc_s_uninitexc : thd_message="Uninitialized exception raised";break; case exc_s_illaddr : thd_message="Invalid memory address";break; case exc_s_exquota : thd_message="Operation failed due to insufficient quota";break; case exc_s_insfmem : thd_message="Insufficient virtual memory for requested operation";break; case exc_s_nopriv : thd_message="Insufficent privilege for requested operation";break; case exc_s_normal : thd_message="Normal successful completion";break; case exc_s_illinstr : thd_message="Illegal instruction";break; case exc_s_resaddr : thd_message="Reserved addressing error";break; case exc_s_privinst : thd_message="Privileged instruction error";break; case exc_s_resoper : thd_message="Reserved operand error";break; case exc_s_SIGTRAP : thd_message="Trace or breakpoint trap";break; case exc_s_SIGIOT : thd_message="IOT trap";break; case exc_s_SIGEMT : thd_message="EMT trap";break; case exc_s_aritherr : thd_message="Arithmetic error";break; case exc_s_SIGSYS : thd_message="Bad system call";break; case exc_s_SIGPIPE : thd_message="Broken pipe";break; case exc_s_excpu : thd_message="CPU-time limit exceeded";break; case exc_s_exfilsiz : thd_message="File-size limit exceeded";break; case exc_s_intovf : thd_message="Integer overflow";break; case exc_s_intdiv : thd_message="Integer divide by zero";break; case exc_s_fltovf : thd_message="Floating point overflow";break; case exc_s_fltdiv : thd_message="Floating point/decimal divide by zero";break; case exc_s_fltund : thd_message="Floating point underflow";break; case exc_s_decovf : thd_message="Decimal overflow";break; case exc_s_subrng : thd_message="Subscript out of range";break; case cma_s_alerted : thd_message="Thread has been canceled";break; case cma_s_assertion : thd_message="A thread assertion check has failed";break; case cma_s_badparam : thd_message="Invalid parameter to operation";break; case cma_s_bugcheck : thd_message="Internal error detected in thread library";break; case cma_s_exit_thread : thd_message="Current thread has been requested to exit";break; case cma_s_existence : thd_message="Object referenced does not currently exist";break; case cma_s_in_use : thd_message="Object referenced is already in use";break; case cma_s_use_error : thd_message="Operation inappropriate for specified object";break; case cma_s_wrongmutex : thd_message="Wrong mutex specified in condition wait";break; case cma_s_stackovf : thd_message="Attempted stack overflow was detected";break; case cma_s_nostackmem : thd_message="No space is currently available to create a new stack";break; case cma_s_notcmastack : thd_message="The current stack was not allocated by thread library";break; case cma_s_timed_out : thd_message="Timed condition wait expired";break; case cma_s_unimp : thd_message="Unimplemented feature";break; case cma_s_inialrpro : thd_message="Thread library initialization is already in progress";break; case cma_s_defer_q_full : thd_message="No space currently available to process interrupt request";break; case cma_s_signal_q_full : thd_message="Unable to process condition signal from interrupt level";break; case cma_s_alert_nesting : thd_message="Improper nesting of alert scope";break; case exc_s_unkstatus : thd_message="Unknown status code 0x%1$08X";break; #if _CMA_UNIX_TYPE == _CMA__SVR4 case exc_s_illopc: thd_message="Illegal opcode"; break; case exc_s_illopn: thd_message="Illegal operand"; break; case exc_s_illadr: thd_message="Illegal addressing mode"; break; case exc_s_illtrp: thd_message="Illegal trap"; break; case exc_s_prvopc: thd_message="privileged opcode"; break; case exc_s_prvreg: thd_message="Privileged register"; break; case exc_s_coproc: thd_message=" Co-processor"; break; case exc_s_badstk: thd_message="Bad Stack"; break; case exc_s_brkpt : thd_message="Process breakpoint"; break; case exc_s_trace : thd_message="Process trace"; break; case exc_s_fltinv: thd_message="Invalid floating point operation"; break; case exc_s_maperr: thd_message="Address not mapped to object"; break; case exc_s_accerr: thd_message="Invalid permissions"; break; case exc_s_adraln: thd_message="Invalid address alignment"; break; case exc_s_adrerr: thd_message="Non-existent physical address"; break; case exc_s_objerr: thd_message="Object specific"; break; #endif default: { # if _CMA_UNIX_TYPE == _CMA__SVR4 cma__int_sprintf ( # else sprintf ( # endif /* _CMA__SVR4 */ (char *)error_text, "status %08x (%s / %s)", status_to_convert, facility_name, component_name); *status = 0; } } /* */ if (thd_message != NULL) { # if _CMA_UNIX_TYPE == _CMA__SVR4 cma__int_sprintf ( # else sprintf ( # endif /* _CMA__SVR4 */ (char *)error_text, "%s (%s / %s)", thd_message, facility_name, component_name); *status = 0; } return; } } /* * try to get the specified message from the file */ message = (char *) catgets (catd, 1, status_code, NO_MESSAGE); /* * if everything went well, return the resulting message */ if (strcmp (message, NO_MESSAGE) != 0) { # if _CMA_UNIX_TYPE == _CMA__SVR4 cma__int_sprintf ((char *) error_text, "%s (%s / %s)", # else sprintf ((char *) error_text, "%s (%s / %s)", # endif /* _CMA__SVR4 */ message, facility_name, component_name); if (status != NULL) { *status = 0; } } else { # if _CMA_UNIX_TYPE == _CMA__SVR4 cma__int_sprintf ((char *) error_text, "status %08x (%s / %s)", # else sprintf ((char *) error_text, "status %08x (%s / %s)", # endif /* _CMA__SVR4 */ status_to_convert, facility_name, component_name); } catclose (catd); } /* DEC/CMS REPLACEMENT HISTORY, Element CMA_MESSAGE.C */ /* *6 9-JAN-1992 10:27:22 BUTENHOF "Remove ""Exception: "" from builtin messages" */ /* *5 22-NOV-1991 11:56:28 BUTENHOF "Integrate dce message formatting" */ /* *4 24-SEP-1991 16:27:35 BUTENHOF "Merge CMA5 reverse IBM/HP/Apollo drops" */ /* *3 2-JUL-1991 16:47:17 BUTENHOF "Use normal printf on Tin" */ /* *2 13-JUN-1991 19:33:12 BUTENHOF "fix history" */ /* *1 13-JUN-1991 19:29:11 BUTENHOF "Message catalog support" */ /* DEC/CMS REPLACEMENT HISTORY, Element CMA_MESSAGE.C */