17c478bd9Sstevel@tonic-gate /* 2*505d05c7Sgtb * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 3*505d05c7Sgtb * Use is subject to license terms. 47c478bd9Sstevel@tonic-gate */ 57c478bd9Sstevel@tonic-gate 67c478bd9Sstevel@tonic-gate /* 77c478bd9Sstevel@tonic-gate * util/et/error_message.c 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * Copyright 1987 by the Student Information Processing Board 107c478bd9Sstevel@tonic-gate * of the Massachusetts Institute of Technology 117c478bd9Sstevel@tonic-gate * 127c478bd9Sstevel@tonic-gate * For copyright info, see "mit-sipb-copyright.h". 137c478bd9Sstevel@tonic-gate */ 147c478bd9Sstevel@tonic-gate 157c478bd9Sstevel@tonic-gate #include <stdio.h> 167c478bd9Sstevel@tonic-gate #ifdef HAVE_STDLIB_H 177c478bd9Sstevel@tonic-gate #include <stdlib.h> 187c478bd9Sstevel@tonic-gate #endif 197c478bd9Sstevel@tonic-gate #include <string.h> 207c478bd9Sstevel@tonic-gate #include <libintl.h> 217c478bd9Sstevel@tonic-gate #include "com_err.h" 227c478bd9Sstevel@tonic-gate #include "mit-sipb-copyright.h" 237c478bd9Sstevel@tonic-gate #include "internal.h" 247c478bd9Sstevel@tonic-gate #include "error_message.h" 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate static char buffer[25]; 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate struct et_list * _et_list = (struct et_list *) NULL; 297c478bd9Sstevel@tonic-gate error_message(code)30*505d05c7Sgtbconst char * KRB5_CALLCONV error_message (code) 317c478bd9Sstevel@tonic-gate long code; 327c478bd9Sstevel@tonic-gate { 337c478bd9Sstevel@tonic-gate int offset; 347c478bd9Sstevel@tonic-gate long l_offset; 357c478bd9Sstevel@tonic-gate long table_num; 367c478bd9Sstevel@tonic-gate int started = 0; 377c478bd9Sstevel@tonic-gate char *cp; 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate l_offset = code & ((1<<ERRCODE_RANGE)-1); 407c478bd9Sstevel@tonic-gate offset = (int) l_offset; 417c478bd9Sstevel@tonic-gate table_num = code - l_offset; 427c478bd9Sstevel@tonic-gate if (!table_num) { 437c478bd9Sstevel@tonic-gate #ifdef HAVE_STRERROR 447c478bd9Sstevel@tonic-gate cp = strerror(offset); 457c478bd9Sstevel@tonic-gate if (cp) 467c478bd9Sstevel@tonic-gate return cp; 477c478bd9Sstevel@tonic-gate goto oops; 487c478bd9Sstevel@tonic-gate #else 497c478bd9Sstevel@tonic-gate #ifdef HAVE_SYS_ERRLIST 507c478bd9Sstevel@tonic-gate if (offset < sys_nerr) 517c478bd9Sstevel@tonic-gate return(sys_errlist[offset]); 527c478bd9Sstevel@tonic-gate else 537c478bd9Sstevel@tonic-gate goto oops; 547c478bd9Sstevel@tonic-gate #else 557c478bd9Sstevel@tonic-gate goto oops; 567c478bd9Sstevel@tonic-gate #endif /* HAVE_SYS_ERRLIST */ 577c478bd9Sstevel@tonic-gate #endif /* HAVE_STRERROR */ 587c478bd9Sstevel@tonic-gate } 597c478bd9Sstevel@tonic-gate switch (table_num) { 607c478bd9Sstevel@tonic-gate case -2045022976L: 617c478bd9Sstevel@tonic-gate return(ggss_error_table(offset)); 627c478bd9Sstevel@tonic-gate case -1783126272L: 637c478bd9Sstevel@tonic-gate return(kadm_error_table(offset)); 647c478bd9Sstevel@tonic-gate case -1780008448L: 657c478bd9Sstevel@tonic-gate return(kdb5_error_table(offset)); 667c478bd9Sstevel@tonic-gate case -1779992064L: 677c478bd9Sstevel@tonic-gate return(kdc5_error_table(offset)); 687c478bd9Sstevel@tonic-gate case -1767084800L: 697c478bd9Sstevel@tonic-gate return(kpws_error_table(offset)); 707c478bd9Sstevel@tonic-gate case -1765328384L: 717c478bd9Sstevel@tonic-gate return(krb5_error_table(offset)); 727c478bd9Sstevel@tonic-gate case -1760647424L: 737c478bd9Sstevel@tonic-gate return(kv5m_error_table(offset)); 747c478bd9Sstevel@tonic-gate case -1492553984L: 757c478bd9Sstevel@tonic-gate return(ovku_error_table(offset)); 767c478bd9Sstevel@tonic-gate case -1429577728L: 777c478bd9Sstevel@tonic-gate return(prof_error_table(offset)); 787c478bd9Sstevel@tonic-gate case 748800L: 797c478bd9Sstevel@tonic-gate return(ss_error_table(offset)); 807c478bd9Sstevel@tonic-gate case 28810240L: 817c478bd9Sstevel@tonic-gate return(adb_error_table(offset)); 827c478bd9Sstevel@tonic-gate case 1859794432L: 837c478bd9Sstevel@tonic-gate return(asn1_error_table(offset)); 847c478bd9Sstevel@tonic-gate case 37349888L: 857c478bd9Sstevel@tonic-gate return(imp_error_table(offset)); 867c478bd9Sstevel@tonic-gate case 39756032L: 877c478bd9Sstevel@tonic-gate return(k5g_error_table(offset)); 887c478bd9Sstevel@tonic-gate case 43787520L: 897c478bd9Sstevel@tonic-gate return(ovk_error_table(offset)); 907c478bd9Sstevel@tonic-gate case 44806912L: 917c478bd9Sstevel@tonic-gate return(pty_error_table(offset)); 927c478bd9Sstevel@tonic-gate } 937c478bd9Sstevel@tonic-gate oops: 947c478bd9Sstevel@tonic-gate strlcpy (buffer, dgettext(TEXT_DOMAIN, "Unknown code "), sizeof (buffer)); 957c478bd9Sstevel@tonic-gate for (cp = buffer; *cp; cp++) 967c478bd9Sstevel@tonic-gate ; 977c478bd9Sstevel@tonic-gate if (offset >= 100) { 987c478bd9Sstevel@tonic-gate *cp++ = '0' + offset / 100; 997c478bd9Sstevel@tonic-gate offset %= 100; 1007c478bd9Sstevel@tonic-gate started++; 1017c478bd9Sstevel@tonic-gate } 1027c478bd9Sstevel@tonic-gate if (started || offset >= 10) { 1037c478bd9Sstevel@tonic-gate *cp++ = '0' + offset / 10; 1047c478bd9Sstevel@tonic-gate offset %= 10; 1057c478bd9Sstevel@tonic-gate } 1067c478bd9Sstevel@tonic-gate *cp++ = '0' + offset; 1077c478bd9Sstevel@tonic-gate *cp = '\0'; 1087c478bd9Sstevel@tonic-gate return(buffer); 1097c478bd9Sstevel@tonic-gate } 110*505d05c7Sgtb com_err_finish_init()111*505d05c7Sgtbint com_err_finish_init() 112*505d05c7Sgtb { 113*505d05c7Sgtb /* 114*505d05c7Sgtb * SUNW14resync 115*505d05c7Sgtb * Since the original SEAM (Solaris Kerberos) error_message() 116*505d05c7Sgtb * has deviated substantially from MIT let's disable 117*505d05c7Sgtb * com_err_initialize for now and revisit if necessary. 118*505d05c7Sgtb */ 119*505d05c7Sgtb /* return CALL_INIT_FUNCTION(com_err_initialize); */ 120*505d05c7Sgtb return 0; 121*505d05c7Sgtb } 122