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