add changelog
[platform/upstream/gdbm.git] / src / gdbmerrno.c
1 /* gdbmerrno.c - convert gdbm errors into english. */
2
3 /* This file is part of GDBM, the GNU data base manager.
4    Copyright (C) 1993, 2007, 2011, 2013  Free Software Foundation, Inc.
5
6    GDBM is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3, or (at your option)
9    any later version.
10
11    GDBM is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with GDBM. If not, see <http://www.gnu.org/licenses/>.   */
18
19 /* Include system configuration before all else. */
20 #include "autoconf.h"
21
22 #include "gdbmdefs.h"
23
24 /* The dbm error number is placed in the variable GDBM_ERRNO. */
25 gdbm_error gdbm_errno = GDBM_NO_ERROR;
26
27 /* this is not static so that applications may access the array if they
28    like. it must be in the same order as the error codes! */
29
30 const char * const gdbm_errlist[_GDBM_MAX_ERRNO+1] = {
31   N_("No error"),                /* GDBM_NO_ERROR               */
32   N_("Malloc error"),            /* GDBM_MALLOC_ERROR           */
33   N_("Block size error"),        /* GDBM_BLOCK_SIZE_ERROR       */
34   N_("File open error"),         /* GDBM_FILE_OPEN_ERROR        */
35   N_("File write error"),        /* GDBM_FILE_WRITE_ERROR       */
36   N_("File seek error"),         /* GDBM_FILE_SEEK_ERROR        */
37   N_("File read error"),         /* GDBM_FILE_READ_ERROR        */
38   N_("Bad magic number"),        /* GDBM_BAD_MAGIC_NUMBER       */
39   N_("Empty database"),          /* GDBM_EMPTY_DATABASE         */
40   N_("Can't be reader"),         /* GDBM_CANT_BE_READER         */
41   N_("Can't be writer"),         /* GDBM_CANT_BE_WRITER         */
42   N_("Reader can't delete"),     /* GDBM_READER_CANT_DELETE     */
43   N_("Reader can't store"),      /* GDBM_READER_CANT_STORE      */
44   N_("Reader can't reorganize"), /* GDBM_READER_CANT_REORGANIZE */
45   N_("Unknown update"),          /* GDBM_UNKNOWN_UPDATE         */
46   N_("Item not found"),          /* GDBM_ITEM_NOT_FOUND         */
47   N_("Reorganize failed"),       /* GDBM_REORGANIZE_FAILED      */
48   N_("Cannot replace"),          /* GDBM_CANNOT_REPLACE         */
49   N_("Illegal data"),            /* GDBM_ILLEGAL_DATA           */
50   N_("Option already set"),      /* GDBM_OPT_ALREADY_SET        */
51   N_("Illegal option"),          /* GDBM_OPT_ILLEGAL            */
52   N_("Byte-swapped file"),       /* GDBM_BYTE_SWAPPED           */
53   N_("Wrong file offset"),       /* GDBM_BAD_FILE_OFFSET        */
54   N_("Bad file flags"),          /* GDBM_BAD_OPEN_FLAGS         */
55   N_("Cannot stat file"),        /* GDBM_FILE_STAT_ERROR        */
56   N_("Unexpected end of file"),  /* GDBM_FILE_EOF               */
57   N_("Database name not given"), /* GDBM_NO_DBNAME              */
58   N_("Failed to restore file owner"), /* GDBM_ERR_FILE_OWNER    */
59   N_("Failed to restore file mode"),  /* GDBM_ERR_FILE_MODE     */
60 };
61
62 const char *
63 gdbm_strerror (gdbm_error error)
64 {
65   if (((int)error < _GDBM_MIN_ERRNO) || ((int)error > _GDBM_MAX_ERRNO))
66     {
67       return _("Unknown error");
68     }
69   else
70     {
71       return gettext (gdbm_errlist[(int)error]);
72     }
73 }