Blame common/error.c

rpm-build ca8475
 /*
rpm-build ca8475
   Unix SMB/CIFS implementation.
rpm-build ca8475
rpm-build ca8475
   trivial database library
rpm-build ca8475
rpm-build ca8475
   Copyright (C) Andrew Tridgell              1999-2005
rpm-build ca8475
   Copyright (C) Paul `Rusty' Russell		   2000
rpm-build ca8475
   Copyright (C) Jeremy Allison			   2000-2003
rpm-build ca8475
rpm-build ca8475
     ** NOTE! The following LGPL license applies to the tdb
rpm-build ca8475
     ** library. This does NOT imply that all of Samba is released
rpm-build ca8475
     ** under the LGPL
rpm-build ca8475
rpm-build ca8475
   This library is free software; you can redistribute it and/or
rpm-build ca8475
   modify it under the terms of the GNU Lesser General Public
rpm-build ca8475
   License as published by the Free Software Foundation; either
rpm-build ca8475
   version 3 of the License, or (at your option) any later version.
rpm-build ca8475
rpm-build ca8475
   This library is distributed in the hope that it will be useful,
rpm-build ca8475
   but WITHOUT ANY WARRANTY; without even the implied warranty of
rpm-build ca8475
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
rpm-build ca8475
   Lesser General Public License for more details.
rpm-build ca8475
rpm-build ca8475
   You should have received a copy of the GNU Lesser General Public
rpm-build ca8475
   License along with this library; if not, see <http://www.gnu.org/licenses/>.
rpm-build ca8475
*/
rpm-build ca8475
rpm-build ca8475
#include "tdb_private.h"
rpm-build ca8475
rpm-build ca8475
_PUBLIC_ enum TDB_ERROR tdb_error(struct tdb_context *tdb)
rpm-build ca8475
{
rpm-build ca8475
	return tdb->ecode;
rpm-build ca8475
}
rpm-build ca8475
rpm-build ca8475
static struct tdb_errname {
rpm-build ca8475
	enum TDB_ERROR ecode; const char *estring;
rpm-build ca8475
} emap[] = { {TDB_SUCCESS, "Success"},
rpm-build ca8475
	     {TDB_ERR_CORRUPT, "Corrupt database"},
rpm-build ca8475
	     {TDB_ERR_IO, "IO Error"},
rpm-build ca8475
	     {TDB_ERR_LOCK, "Locking error"},
rpm-build ca8475
	     {TDB_ERR_OOM, "Out of memory"},
rpm-build ca8475
	     {TDB_ERR_EXISTS, "Record exists"},
rpm-build ca8475
	     {TDB_ERR_NOLOCK, "Lock exists on other keys"},
rpm-build ca8475
	     {TDB_ERR_EINVAL, "Invalid parameter"},
rpm-build ca8475
	     {TDB_ERR_NOEXIST, "Record does not exist"},
rpm-build ca8475
	     {TDB_ERR_RDONLY, "write not permitted"} };
rpm-build ca8475
rpm-build ca8475
/* Error string for the last tdb error */
rpm-build ca8475
_PUBLIC_ const char *tdb_errorstr(struct tdb_context *tdb)
rpm-build ca8475
{
rpm-build ca8475
	uint32_t i;
rpm-build ca8475
	for (i = 0; i < sizeof(emap) / sizeof(struct tdb_errname); i++)
rpm-build ca8475
		if (tdb->ecode == emap[i].ecode)
rpm-build ca8475
			return emap[i].estring;
rpm-build ca8475
	return "Invalid error code";
rpm-build ca8475
}
rpm-build ca8475