Main Page   Modules   Compound List   File List   Compound Members   File Members   Related Pages  

wbxml_errors.c

Go to the documentation of this file.
00001 /*
00002  * WBXML Lib, the WBXML Library.
00003  * Copyright (C) 2002-2003  Aymerick Jéhanne
00004  * 
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License (version 2.1) as published by the Free Software Foundation.
00008  * 
00009  * This library 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 GNU
00012  * Lesser General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  *
00018  * LGPL v2.1: http://www.gnu.org/licenses/lgpl.txt
00019  *
00020  * Author Contact: libwbxml@jehanne.org
00021  * WBXML Lib home: http://libwbxml.jehanne.org
00022  */
00023  
00034 #include <stdlib.h>
00035 #include <string.h>
00036 
00037 #include "wbxml.h"
00038 
00039 
00043 typedef struct WBXMLErrorCodeItem_s {
00044     WBXMLError     code;    
00045     const WB_TINY *string;  
00046 } WBXMLErrorCodeItem;
00047 
00048 
00052 static const WBXMLErrorCodeItem error_table [] = {
00053     /* Generic Errors */
00054     { WBXML_OK,                                 "No Error" },
00055     { WBXML_NOT_ENCODED,                        "Not Encoded" },
00056     { WBXML_ERROR_ATTR_TABLE_UNDEFINED,         "Attribute Table Undefined" },
00057     { WBXML_ERROR_BAD_DATETIME,                 "Bad %Datetime Format" },
00058     { WBXML_ERROR_BAD_PARAMETER,                "Bad Parameter" },
00059     { WBXML_ERROR_INTERNAL,                     "Internal Error" },
00060     { WBXML_ERROR_LANG_TABLE_UNDEFINED,         "Languages Table Undefined" },
00061     { WBXML_ERROR_NOT_ENOUGH_MEMORY,            "Not Enough Memory" },
00062     { WBXML_ERROR_NOT_IMPLEMENTED,              "Not Implemented" },
00063     { WBXML_ERROR_TAG_TABLE_UNDEFINED,          "Tag Table Undefined" },
00064     { WBXML_ERROR_B64_ENC,                      "Failed to encode Base64" },
00065 #if defined( WBXML_SUPPORT_WV )
00066     { WBXML_ERROR_WV_DATETIME_FORMAT,           "Bad Wireless-Village Date and Time Format" },
00067 #endif /* WBXML_SUPPORT_WV */
00068     /* WBXML Parser Errors */
00069     { WBXML_ERROR_ATTR_VALUE_TABLE_UNDEFINED,   "Attribute Value Table Undefined" },
00070     { WBXML_ERROR_BAD_LITERAL_INDEX,            "Bad Literal Index" },
00071     { WBXML_ERROR_BAD_NULL_TERMINATED_STRING_IN_STRING_TABLE,    "Not NULL Terminated String in String Table" },
00072     { WBXML_ERROR_BAD_OPAQUE_LENGTH,            "Bad Opaque Length" },
00073     { WBXML_ERROR_EMPTY_WBXML,                  "Empty WBXML" },    
00074     { WBXML_ERROR_END_OF_BUFFER,                "Unexpected End Of WBXML Buffer" },
00075     { WBXML_ERROR_ENTITY_CODE_OVERFLOW,         "Entity Code Overflow" },
00076     { WBXML_ERROR_EXT_VALUE_TABLE_UNDEFINED,    "Extension Value Table Undefined" },
00077     { WBXML_ERROR_INVALID_STRTBL_INDEX,         "Invalid String Table Index" },
00078     { WBXML_ERROR_LITERAL_NOT_NULL_TERMINATED_IN_STRING_TABLE,    "Literal Not NULL Terminated in String Table" },
00079     { WBXML_ERROR_NOT_NULL_TERMINATED_INLINE_STRING,             "Not NULL Terminated Inline String" },
00080     { WBXML_ERROR_NULL_PARSER,                  "Null Parser" },
00081     { WBXML_ERROR_NULL_STRING_TABLE,            "No String Table In Document" },
00082     { WBXML_ERROR_STRING_EXPECTED,              "String Expected" },
00083     { WBXML_ERROR_STRTBL_LENGTH,                "Bad String Table Length" },
00084     { WBXML_ERROR_UNKNOWN_ATTR,                 "Unknown Attribute" },
00085     { WBXML_ERROR_UNKNOWN_ATTR_VALUE,           "Unknown Attribute Value" },
00086     { WBXML_ERROR_UNKNOWN_EXTENSION_TOKEN,      "Unknown Extension Token" },
00087     { WBXML_ERROR_UNKNOWN_EXTENSION_VALUE,      "Unknown Extension Value token" },
00088     { WBXML_ERROR_UNKNOWN_PUBLIC_ID,            "Unknown Public ID" },    
00089     { WBXML_ERROR_UNKNOWN_TAG,                  "Unknown Tag" },
00090     { WBXML_ERROR_UNVALID_MBUINT32,             "Unvalid MultiByte UINT32" },
00091 #if defined( WBXML_SUPPORT_WV )
00092     { WBXML_ERROR_WV_INTEGER_OVERFLOW,          "Wireless-Village Integer Overflow" },
00093 #endif /* WBXML_SUPPORT_WV */
00094     /* WBXML Encoder Errors */
00095     { WBXML_ERROR_ENCODER_APPEND_DATA,          "Can't append data to output buffer" },
00096     { WBXML_ERROR_STRTBL_DISABLED,              "String Table generation disabled: can't encode Literal" },
00097     { WBXML_ERROR_XML_NODE_NOT_ALLOWED,         "XML Node Type not allowed" },
00098     { WBXML_ERROR_XML_NULL_ATTR_NAME,           "NULL XML Attribute Name" },
00099     { WBXML_ERROR_XML_PARSING_FAILED,           "Parsing of XML Document Failed" },
00100 #if defined( WBXML_SUPPORT_SYNCML )
00101     { WBXML_ERROR_XML_DEVINF_CONV_FAILED,       "Convertion of XML DevInf document Failed" },
00102 #endif /* WBXML_SUPPORT_WV */
00103     { WBXML_ERROR_NO_XMLPARSER,                 "Can't parse XML (Compiled without Expat): XML to WBXML conversion not possible" }
00104 };
00105 
00106 #define ERROR_TABLE_SIZE ((WB_ULONG) (sizeof(error_table) / sizeof(error_table[0])))
00107 
00108 
00109 /***************************************************
00110  *    Public Functions
00111  */
00112 
00113 WBXML_DECLARE(const WB_UTINY *) wbxml_errors_string(WBXMLError error_code)
00114 {
00115     WB_ULONG i;
00116 
00117     for (i=0; i < ERROR_TABLE_SIZE; i++) {
00118         if (error_table[i].code == error_code)
00119             return (const WB_UTINY *)error_table[i].string;
00120     }
00121 
00122     return (const WB_UTINY *)"Unknown Error Code";
00123 }

Generated on Mon Nov 24 20:09:42 2003 for WBXML Library by doxygen1.3-rc1