00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <string.h>
00026 #include <stdio.h>
00027 #include <errno.h>
00028
00029 #include "kdb.h"
00030
00031
00038 char *kdbStrError(int errnum) {
00039 switch (errnum) {
00040 case KDB_RET_INVALIDKEY:
00041 return "Invalid Key";
00042 case KDB_RET_NOKEY:
00043 return "Key has no name";
00044 case KDB_RET_NODATA:
00045 return "Key has no value";
00046 case KDB_RET_NODESC:
00047 return "Key has no comment/description";
00048 case KDB_RET_NODOMAIN:
00049 return "Key has no user domain";
00050 case KDB_RET_NOGROUP:
00051 return "Key has no group";
00052 case KDB_RET_NOTIME:
00053 return "Key has no access time";
00054 case KDB_RET_TYPEMISMATCH:
00055 return "Operation incompatible with key value type";
00056 case KDB_RET_NOSYS:
00057 return "Backend method not implemented";
00058 case KDB_RET_EBACKEND:
00059 return "Error opening backend";
00060 default:
00061 return strerror(errnum);
00062 }
00063 }
00064
00071 int kdbPrintError(const char * msg) {
00072 fprintf (stderr, "%s: %s\n", msg, kdbStrError(errno));
00073 return 0;
00074 }