add result
This commit is contained in:
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]);
|
||||
}
|
||||
Reference in New Issue
Block a user