00001 /* src/port/strerror.c */ 00002 00003 /* 00004 * strerror - map error number to descriptive string 00005 * 00006 * This version is obviously somewhat Unix-specific. 00007 * 00008 * based on code by Henry Spencer 00009 * modified for ANSI by D'Arcy J.M. Cain 00010 */ 00011 00012 #include "c.h" 00013 00014 00015 extern const char *const sys_errlist[]; 00016 extern int sys_nerr; 00017 00018 const char * 00019 strerror(int errnum) 00020 { 00021 static char buf[24]; 00022 00023 if (errnum < 0 || errnum > sys_nerr) 00024 { 00025 sprintf(buf, _("unrecognized error %d"), errnum); 00026 return buf; 00027 } 00028 00029 return sys_errlist[errnum]; 00030 }