dnxError.c

Go to the documentation of this file.
00001 /*--------------------------------------------------------------------------
00002  
00003    Copyright (c) 2006-2007, Intellectual Reserve, Inc. All rights reserved.
00004  
00005    This program is free software; you can redistribute it and/or modify
00006    it under the terms of the GNU General Public License version 2 as 
00007    published by the Free Software Foundation.
00008  
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012    GNU General Public License for more details.
00013  
00014    You should have received a copy of the GNU General Public License
00015    along with this program; if not, write to the Free Software
00016    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  
00018   --------------------------------------------------------------------------*/
00019 
00032 #include "dnxError.h"
00033 
00034 #include <errno.h>
00035 #include <string.h>
00036 
00037 #define elemcount(x) (sizeof(x)/sizeof(*(x)))
00038 
00039 static dnxError gLastError = DNX_OK;      
00043 /*--------------------------------------------------------------------------
00044                                  INTERFACE
00045   --------------------------------------------------------------------------*/
00046 
00047 dnxError dnxGetLastError(void) { return gLastError; }
00048 
00049 //----------------------------------------------------------------------------
00050 
00051 void dnxSetLastError(dnxError eno) { gLastError = eno; }
00052 
00053 //----------------------------------------------------------------------------
00054 
00055 char * dnxErrorString(dnxError eno)
00056 {
00057    static char * errCatalog[] = 
00058    {
00059       "A-OK, Okey-Dokey, Rock-On",
00060       "Invalid value",
00061       "Resource is exhausted",
00062       "Invalid or malformed URL",
00063       "Resource is already initialized/deinitialized",
00064       "Resource already exists",
00065       "Unsupported operation",
00066       "Out of memory",
00067       "Channel open error",
00068       "Message size is out of bounds",
00069       "Message transmission failure",
00070       "Message reception failure",
00071       "Invalid communications address",
00072       "Resource was not found",
00073       "Incorrect or invalid text",
00074       "Threading error",
00075       "Timeout error",
00076       "Resource is busy",
00077       "Access denied",
00078    };
00079 
00080    // check for system error first - return system error string
00081    if (eno < DNX_ERR_BASE)
00082       return strerror(eno);
00083 
00084    // adjust for dnx error base - return dnx error string
00085    eno -= DNX_ERR_BASE;
00086    return (char *)((eno < 0 || eno >= elemcount(errCatalog)) ? 
00087          "Unknown error code" : errCatalog[eno]);
00088 }
00089 
00090 /*--------------------------------------------------------------------------*/
00091 

Generated on Tue Apr 13 15:48:07 2010 for DNX by  doxygen 1.5.6