~vcs-imports/samba/main

« back to all changes in this revision

Viewing changes to source/tdb/error.c

  • Committer: jerry
  • Date: 2006-07-14 21:48:39 UTC
  • Revision ID: vcs-imports@canonical.com-20060714214839-586d8c489a8fcead
gutting trunk to move to svn:externals

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 /* 
2
 
   Unix SMB/CIFS implementation.
3
 
 
4
 
   trivial database library
5
 
 
6
 
   Copyright (C) Andrew Tridgell              1999-2005
7
 
   Copyright (C) Paul `Rusty' Russell              2000
8
 
   Copyright (C) Jeremy Allison                    2000-2003
9
 
   
10
 
     ** NOTE! The following LGPL license applies to the tdb
11
 
     ** library. This does NOT imply that all of Samba is released
12
 
     ** under the LGPL
13
 
   
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 2 of the License, or (at your option) any later version.
18
 
 
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.
23
 
 
24
 
   You should have received a copy of the GNU Lesser General Public
25
 
   License along with this library; if not, write to the Free Software
26
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27
 
*/
28
 
 
29
 
#include "tdb_private.h"
30
 
 
31
 
enum TDB_ERROR tdb_error(struct tdb_context *tdb)
32
 
{
33
 
        return tdb->ecode;
34
 
}
35
 
 
36
 
static struct tdb_errname {
37
 
        enum TDB_ERROR ecode; const char *estring;
38
 
} emap[] = { {TDB_SUCCESS, "Success"},
39
 
             {TDB_ERR_CORRUPT, "Corrupt database"},
40
 
             {TDB_ERR_IO, "IO Error"},
41
 
             {TDB_ERR_LOCK, "Locking error"},
42
 
             {TDB_ERR_OOM, "Out of memory"},
43
 
             {TDB_ERR_EXISTS, "Record exists"},
44
 
             {TDB_ERR_NOLOCK, "Lock exists on other keys"},
45
 
             {TDB_ERR_EINVAL, "Invalid parameter"},
46
 
             {TDB_ERR_NOEXIST, "Record does not exist"},
47
 
             {TDB_ERR_RDONLY, "write not permitted"} };
48
 
 
49
 
/* Error string for the last tdb error */
50
 
const char *tdb_errorstr(struct tdb_context *tdb)
51
 
{
52
 
        u32 i;
53
 
        for (i = 0; i < sizeof(emap) / sizeof(struct tdb_errname); i++)
54
 
                if (tdb->ecode == emap[i].ecode)
55
 
                        return emap[i].estring;
56
 
        return "Invalid error code";
57
 
}
58