1/* gdbmerrno.c - convert gdbm errors into english. */ 2 3/* This file is part of GDBM, the GNU data base manager, by Philip A. Nelson. 4 Copyright (C) 1993 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 2, 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; see the file COPYING. If not, write to 18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 19 20 You may contact the original author by: 21 e-mail: phil@cs.wwu.edu 22 us-mail: Philip A. Nelson 23 Computer Science Department 24 Western Washington University 25 Bellingham, WA 98226 26 27 The author of this file is: 28 e-mail: downsj@downsj.com 29 30*************************************************************************/ 31 32 33/* include system configuration before all else. */ 34#include "autoconf.h" 35 36#include "gdbmerrno.h" 37 38/* this is not static so that applications may access the array if they 39 like. it must be in the same order as the error codes! */ 40 41const char * const gdbm_errlist[] = { 42 "No error", "Malloc error", "Block size error", "File open error", 43 "File write error", "File seek error", "File read error", 44 "Bad magic number", "Empty database", "Can't be reader", "Can't be writer", 45 "Reader can't delete", "Reader can't store", "Reader can't reorganize", 46 "Unknown update", "Item not found", "Reorganize failed", "Cannot replace", 47 "Illegal data", "Option already set", "Illegal option" 48}; 49 50#define gdbm_errorcount ((sizeof(gdbm_errlist) / sizeof(gdbm_errlist[0])) - 1) 51 52const char * 53gdbm_strerror(error) 54 gdbm_error error; 55{ 56 if(((int)error < 0) || ((int)error > gdbm_errorcount)) 57 { 58 return("Unknown error"); 59 } 60 else 61 { 62 return(gdbm_errlist[(int)error]); 63 } 64} 65