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
00026
00027
00028
00029 #include "tdb_private.h"
00030
00031 enum TDB_ERROR tdb_error(struct tdb_context *tdb)
00032 {
00033 return tdb->ecode;
00034 }
00035
00036 static struct tdb_errname {
00037 enum TDB_ERROR ecode; const char *estring;
00038 } emap[] = { {TDB_SUCCESS, "Success"},
00039 {TDB_ERR_CORRUPT, "Corrupt database"},
00040 {TDB_ERR_IO, "IO Error"},
00041 {TDB_ERR_LOCK, "Locking error"},
00042 {TDB_ERR_OOM, "Out of memory"},
00043 {TDB_ERR_EXISTS, "Record exists"},
00044 {TDB_ERR_NOLOCK, "Lock exists on other keys"},
00045 {TDB_ERR_EINVAL, "Invalid parameter"},
00046 {TDB_ERR_NOEXIST, "Record does not exist"},
00047 {TDB_ERR_RDONLY, "write not permitted"} };
00048
00049
00050 const char *tdb_errorstr(struct tdb_context *tdb)
00051 {
00052 u32 i;
00053 for (i = 0; i < sizeof(emap) / sizeof(struct tdb_errname); i++)
00054 if (tdb->ecode == emap[i].ecode)
00055 return emap[i].estring;
00056 return "Invalid error code";
00057 }
00058