2 Unix SMB/CIFS implementation.
4 trivial database library
6 Copyright (C) Andrew Tridgell 1999-2005
7 Copyright (C) Paul `Rusty' Russell 2000
8 Copyright (C) Jeremy Allison 2000-2003
10 ** NOTE! The following LGPL license applies to the tdb
11 ** library. This does NOT imply that all of Samba is released
14 This library is free software; you can redistribute it and/or
15 modify it under the terms of the GNU Lesser General Public
16 License as published by the Free Software Foundation; either
17 version 3 of the License, or (at your option) any later version.
19 This library is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 Lesser General Public License for more details.
24 You should have received a copy of the GNU Lesser General Public
25 License along with this library; if not, see <http://www.gnu.org/licenses/>.
28 #include "tdb1_private.h"
30 _PUBLIC_ enum TDB1_ERROR tdb1_error(struct tdb1_context *tdb)
35 static struct tdb1_errname {
36 enum TDB1_ERROR ecode; const char *estring;
37 } emap[] = { {TDB1_SUCCESS, "Success"},
38 {TDB1_ERR_CORRUPT, "Corrupt database"},
39 {TDB1_ERR_IO, "IO Error"},
40 {TDB1_ERR_LOCK, "Locking error"},
41 {TDB1_ERR_OOM, "Out of memory"},
42 {TDB1_ERR_EXISTS, "Record exists"},
43 {TDB1_ERR_NOLOCK, "Lock exists on other keys"},
44 {TDB1_ERR_EINVAL, "Invalid parameter"},
45 {TDB1_ERR_NOEXIST, "Record does not exist"},
46 {TDB1_ERR_RDONLY, "write not permitted"} };
48 /* Error string for the last tdb error */
49 _PUBLIC_ const char *tdb1_errorstr(struct tdb1_context *tdb)
52 for (i = 0; i < sizeof(emap) / sizeof(struct tdb1_errname); i++)
53 if (tdb->ecode == emap[i].ecode)
54 return emap[i].estring;
55 return "Invalid error code";