error.c

00001 /***************************************************************************
00002             error.c  -  Methods for error manipulation
00003                              -------------------
00004     begin                : Mon Mar 20 2006
00005     copyright            : (C) 2006 by Avi Alkalay
00006     email                : avi@unix.sh
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the BSD License (revised).                      *
00013  *                                                                         *
00014  ***************************************************************************/
00015 
00016 
00017 
00018 
00019 /* Subversion stuff
00020 
00021 $Id: error.c 801 2006-06-16 08:01:27Z mraab $
00022 
00023 */
00024 
00025 #include <string.h>
00026 #include <stdio.h>
00027 #include <errno.h>
00028 
00029 #include "kdb.h"
00030 
00031 
00038 char *kdbStrError(int errnum) {
00039     switch (errnum) {
00040         case KDB_RET_INVALIDKEY:
00041             return "Invalid Key";
00042         case KDB_RET_NOKEY:
00043             return "Key has no name";
00044         case KDB_RET_NODATA:
00045             return "Key has no value";
00046         case KDB_RET_NODESC:
00047             return "Key has no comment/description";
00048         case KDB_RET_NODOMAIN:
00049             return "Key has no user domain";
00050         case KDB_RET_NOGROUP:
00051             return "Key has no group";
00052         case KDB_RET_NOTIME:
00053             return "Key has no access time";
00054         case KDB_RET_TYPEMISMATCH:
00055             return "Operation incompatible with key value type";
00056         case KDB_RET_NOSYS:
00057             return "Backend method not implemented";
00058         case KDB_RET_EBACKEND:
00059             return "Error opening backend";
00060         default:
00061             return strerror(errnum);
00062     }
00063 }
00064 
00071 int kdbPrintError(const char * msg) {
00072     fprintf (stderr, "%s: %s\n", msg, kdbStrError(errno));
00073     return 0;
00074 }

Generated on Sun Mar 25 21:55:36 2007 for Elektra Project by  doxygen 1.5.1