Rearrange error codes to support exit codes
This commit is contained in:
parent
75ed1fe903
commit
ff984c1551
|
@ -6,12 +6,14 @@
|
|||
#include <stdarg.h>
|
||||
|
||||
typedef enum hbe_errcode {
|
||||
HBE_IO_FOPEN_FAIL = 129,
|
||||
HBE_INTERR_PEEK_OFFSET_GEQ_ZERO = 1,
|
||||
|
||||
HBE_IO_FOPEN_FAIL = 33,
|
||||
HBE_IO_FCLOSE_FAIL,
|
||||
HBE_IO_FREAD_FAIL,
|
||||
HBE_IO_FWRITE_FAIL,
|
||||
|
||||
HBE_PARSE_INVALID_ENTITY = 257,
|
||||
HBE_PARSE_INVALID_ENTITY = 65,
|
||||
HBE_PARSE_NONSTANDARD_TAG,
|
||||
HBE_PARSE_UCASE_TAG,
|
||||
HBE_PARSE_UCASE_ATTR,
|
||||
|
@ -19,10 +21,8 @@ typedef enum hbe_errcode {
|
|||
HBE_PARSE_ILLEGAL_CHILD,
|
||||
HBE_PARSE_UNCLOSED_TAG,
|
||||
|
||||
HBE_PARSE_UNEXPECTED_END = 513,
|
||||
HBE_PARSE_UNEXPECTED_END,
|
||||
HBE_PARSE_EXPECTED_NOT_FOUND,
|
||||
|
||||
HBE_INTERR_PEEK_OFFSET_GEQ_ZERO = 8193,
|
||||
} hbe_errcode_t;
|
||||
|
||||
void hbe_fatal(hbe_errcode_t errcode, char *fmt, ...) {
|
||||
|
@ -32,7 +32,8 @@ void hbe_fatal(hbe_errcode_t errcode, char *fmt, ...) {
|
|||
vfprintf(stderr, fmt, args);
|
||||
fprintf(stderr, "\n");
|
||||
va_end(args);
|
||||
exit(EXIT_FAILURE);
|
||||
// NOTE: $errcode must be less than 256 (see man exit(3))
|
||||
exit(errcode);
|
||||
}
|
||||
|
||||
// TODO errcode enum used as exit statuses
|
||||
|
|
Loading…
Reference in New Issue