mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-11 13:50:00 -04:00
add result
This commit is contained in:
parent
18cc70d001
commit
fda0ab6a96
2 changed files with 33 additions and 0 deletions
15
lib/isc/include/isc/result.h
Normal file
15
lib/isc/include/isc/result.h
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
#ifndef ISC_RESULT_H
|
||||
#define ISC_RESULT_H 1
|
||||
|
||||
typedef unsigned int isc_result;
|
||||
|
||||
#define ISC_R_SUCCESS 0
|
||||
#define ISC_R_NOMEMORY 1
|
||||
#define ISC_R_UNEXPECTED 0xFFFFFFFFL
|
||||
|
||||
#define isc_result_to_text __isc_result_to_text
|
||||
|
||||
char * isc_result_to_text(isc_result);
|
||||
|
||||
#endif /* ISC_RESULT_H */
|
||||
18
lib/isc/result.c
Normal file
18
lib/isc/result.c
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
#include <isc/result.h>
|
||||
|
||||
#define LAST_ENTRY ISC_R_NOMEMORY
|
||||
|
||||
static char *text_table[LAST_ENTRY+1] = {
|
||||
"success",
|
||||
"out of memory"
|
||||
};
|
||||
|
||||
char *
|
||||
isc_result_to_text(isc_result result) {
|
||||
if (result == ISC_R_UNEXPECTED)
|
||||
return ("unexpected error");
|
||||
if (result > LAST_ENTRY)
|
||||
return ("unknown result code");
|
||||
return (text_table[result]);
|
||||
}
|
||||
Loading…
Reference in a new issue