00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <private.h>
00025
00026 #ifndef lint
00027 static const char rcsid[] = "@(#) $Id: errmsg.c,v 1.1.1.1 2005/10/21 19:00:00 marcel Exp $";
00028 #endif
00029
00030 #if HAVE_GETTEXT
00031 # undef HAVE_CATGETS
00032 # include <libintl.h>
00033 #else
00034 # define dgettext(dom, str) str
00035 #endif
00036
00037 #if HAVE_CATGETS
00038 # include <nl_types.h>
00039 static nl_catd _libelf_cat = (nl_catd)0;
00040 #endif
00041
00042 #if HAVE_GETTEXT || HAVE_CATGETS
00043 static const char domain[] = "libelf";
00044 #endif
00045
00046 #if PIC
00047 static const char *_messages[] = {
00048 #else
00049 static const char *const _messages[] = {
00050 #endif
00051 #define __err__(a,b) b,
00052 #include <errors.h>
00053 #undef __err__
00054 };
00055
00056 const char*
00057 elf_errmsg(int err) {
00058 if (err == 0) {
00059 err = _elf_errno;
00060 if (err == 0) {
00061 return NULL;
00062 }
00063 }
00064 else if (err == -1) {
00065 err = _elf_errno;
00066 }
00067
00068 if (err < 0 || err >= ERROR_NUM || _messages[err] == NULL) {
00069 err = ERROR_UNKNOWN;
00070 }
00071
00072 #if HAVE_CATGETS
00073 if (_libelf_cat == (nl_catd)0) {
00074 _libelf_cat = catopen(domain, 0);
00075 }
00076 if (_libelf_cat != (nl_catd)-1) {
00077 return catgets(_libelf_cat, 1, err + 1, _messages[err]);
00078 }
00079 #endif
00080 return dgettext(domain, _messages[err]);
00081 }