1 /* 2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 3 * Use is subject to license terms. 4 */ 5 #pragma ident "%Z%%M% %I% %E% SMI" 6 7 /* 8 * util/et/error_message.c 9 * 10 * Copyright 1987 by the Student Information Processing Board 11 * of the Massachusetts Institute of Technology 12 * 13 * For copyright info, see "mit-sipb-copyright.h". 14 */ 15 16 #include <stdio.h> 17 #ifdef HAVE_STDLIB_H 18 #include <stdlib.h> 19 #endif 20 #include <string.h> 21 #include <libintl.h> 22 #include "com_err.h" 23 #include "mit-sipb-copyright.h" 24 #include "internal.h" 25 #include "error_message.h" 26 27 static char buffer[25]; 28 29 struct et_list * _et_list = (struct et_list *) NULL; 30 error_message(code)31const char * KRB5_CALLCONV error_message (code) 32 long code; 33 { 34 int offset; 35 long l_offset; 36 long table_num; 37 int started = 0; 38 char *cp; 39 40 l_offset = code & ((1<<ERRCODE_RANGE)-1); 41 offset = (int) l_offset; 42 table_num = code - l_offset; 43 if (!table_num) { 44 #ifdef HAVE_STRERROR 45 cp = strerror(offset); 46 if (cp) 47 return cp; 48 goto oops; 49 #else 50 #ifdef HAVE_SYS_ERRLIST 51 if (offset < sys_nerr) 52 return(sys_errlist[offset]); 53 else 54 goto oops; 55 #else 56 goto oops; 57 #endif /* HAVE_SYS_ERRLIST */ 58 #endif /* HAVE_STRERROR */ 59 } 60 switch (table_num) { 61 case -2045022976L: 62 return(ggss_error_table(offset)); 63 case -1783126272L: 64 return(kadm_error_table(offset)); 65 case -1780008448L: 66 return(kdb5_error_table(offset)); 67 case -1779992064L: 68 return(kdc5_error_table(offset)); 69 case -1767084800L: 70 return(kpws_error_table(offset)); 71 case -1765328384L: 72 return(krb5_error_table(offset)); 73 case -1760647424L: 74 return(kv5m_error_table(offset)); 75 case -1492553984L: 76 return(ovku_error_table(offset)); 77 case -1429577728L: 78 return(prof_error_table(offset)); 79 case 748800L: 80 return(ss_error_table(offset)); 81 case 28810240L: 82 return(adb_error_table(offset)); 83 case 1859794432L: 84 return(asn1_error_table(offset)); 85 case 37349888L: 86 return(imp_error_table(offset)); 87 case 39756032L: 88 return(k5g_error_table(offset)); 89 case 43787520L: 90 return(ovk_error_table(offset)); 91 case 44806912L: 92 return(pty_error_table(offset)); 93 } 94 oops: 95 strlcpy (buffer, dgettext(TEXT_DOMAIN, "Unknown code "), sizeof (buffer)); 96 for (cp = buffer; *cp; cp++) 97 ; 98 if (offset >= 100) { 99 *cp++ = '0' + offset / 100; 100 offset %= 100; 101 started++; 102 } 103 if (started || offset >= 10) { 104 *cp++ = '0' + offset / 10; 105 offset %= 10; 106 } 107 *cp++ = '0' + offset; 108 *cp = '\0'; 109 return(buffer); 110 } 111 com_err_finish_init()112int com_err_finish_init() 113 { 114 /* 115 * SUNW14resync 116 * Since the original SEAM (Solaris Kerberos) error_message() 117 * has deviated substantially from MIT let's disable 118 * com_err_initialize for now and revisit if necessary. 119 */ 120 /* return CALL_INIT_FUNCTION(com_err_initialize); */ 121 return 0; 122 } 123