diff options
author | Michael Brown <mcb30@etherboot.org> | 2005-05-17 18:26:41 +0000 |
---|---|---|
committer | Michael Brown <mcb30@etherboot.org> | 2005-05-17 18:26:41 +0000 |
commit | ff9104e0296e9b01733e04193130c60fcc5f5212 (patch) | |
tree | 61ef1dda1aa392621b169d7c03c0b9ab7c53bcd7 /src/core/errno.c | |
parent | df207719e301a0c57bddf6e0dd8a210c007e709c (diff) | |
download | ipxe-ff9104e0296e9b01733e04193130c60fcc5f5212.tar.gz |
Added errno, strerror and the "%m" printf metacharacter. These will allow
us to return proper PXE status codes, while simultaneously allowing for
more consistent error reporting (complete with verbose error messages as a
build-time option).
Diffstat (limited to 'src/core/errno.c')
-rw-r--r-- | src/core/errno.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/core/errno.c b/src/core/errno.c new file mode 100644 index 00000000..f0cf5a62 --- /dev/null +++ b/src/core/errno.c @@ -0,0 +1,29 @@ +#include "errno.h" +#include "vsprintf.h" + +/* Global "last error" number */ +int errno; + +static struct errortab errortab_start[0] __table_start(errortab); +static struct errortab errortab_end[0] __table_end(errortab); + +/* + * Retrieve string representation of error number. + * + * If error not found in the error table, generate a generic "Error + * 0x0000" message. + * + */ +const char * strerror ( int errno ) { + static char *generic_message = "Error 0x0000"; + struct errortab *errortab; + + for ( errortab = errortab_start ; errortab < errortab_end ; + errortab++ ) { + if ( errortab->errno == errno ) + return errortab->text; + } + + sprintf ( generic_message + 8, "%hx", errno ); + return generic_message; +} |