00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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
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
00068
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
00094
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
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
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 }