1 /* 2 * libwbxml, the WBXML Library. 3 * Copyright (C) 2002-2008 Aymerick Jehanne <aymerick@jehanne.org> 4 * Copyright (C) 2009-2011 Michael Bell <michael.bell@opensync.org> 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library 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 GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 * 20 * LGPL v2.1: http://www.gnu.org/copyleft/lesser.txt 21 * 22 * Contact: aymerick@jehanne.org 23 * Home: http://libwbxml.aymerick.com 24 */ 25 26 /** 27 * @file wbxml_tables.h 28 * @ingroup wbxml_tables 29 * 30 * @author Aymerick Jehanne <aymerick@jehanne.org> 31 * @date 02/03/17 32 * 33 * @brief WBXML Tables 34 */ 35 36 #ifndef WBXML_TABLES_H 37 #define WBXML_TABLES_H 38 39 #include "wbxml.h" 40 41 #ifdef __cplusplus 42 extern "C" { 43 #endif /* __cplusplus */ 44 45 /** @addtogroup wbxml_tables 46 * @{ 47 */ 48 49 /**************************************************** 50 * WBXML Public IDs (http://www.wapforum.org/wina) 51 */ 52 53 #define WBXML_PUBLIC_ID_UNKNOWN 0x01 54 55 /* WAP */ 56 #define WBXML_PUBLIC_ID_WML10 0x02 57 #define WBXML_PUBLIC_ID_WTA10 0x03 58 #define WBXML_PUBLIC_ID_WML11 0x04 59 #define WBXML_PUBLIC_ID_SI10 0x05 60 #define WBXML_PUBLIC_ID_SL10 0x06 61 #define WBXML_PUBLIC_ID_CO10 0x07 62 #define WBXML_PUBLIC_ID_CHANNEL11 0x08 63 #define WBXML_PUBLIC_ID_WML12 0x09 64 #define WBXML_PUBLIC_ID_WML13 0x0A 65 #define WBXML_PUBLIC_ID_PROV10 0x0B 66 #define WBXML_PUBLIC_ID_WTAWML12 0x0C 67 #define WBXML_PUBLIC_ID_CHANNEL12 WBXML_PUBLIC_ID_UNKNOWN /**< I don't understand what is the Channel1.2 WBXML Public ID */ 68 #define WBXML_PUBLIC_ID_EMN10 0x0D 69 #define WBXML_PUBLIC_ID_DRMREL10 0x0E 70 71 #define XML_PUBLIC_ID_WML10 "-//WAPFORUM//DTD WML 1.0//EN" 72 #define XML_PUBLIC_ID_WTA10 "-//WAPFORUM//DTD WTA 1.0//EN" 73 #define XML_PUBLIC_ID_WML11 "-//WAPFORUM//DTD WML 1.1//EN" 74 #define XML_PUBLIC_ID_SI10 "-//WAPFORUM//DTD SI 1.0//EN" 75 #define XML_PUBLIC_ID_SL10 "-//WAPFORUM//DTD SL 1.0//EN" 76 #define XML_PUBLIC_ID_CO10 "-//WAPFORUM//DTD CO 1.0//EN" 77 #define XML_PUBLIC_ID_CHANNEL11 "-//WAPFORUM//DTD CHANNEL 1.1//EN" 78 #define XML_PUBLIC_ID_WML12 "-//WAPFORUM//DTD WML 1.2//EN" 79 #define XML_PUBLIC_ID_WML13 "-//WAPFORUM//DTD WML 1.3//EN" 80 #define XML_PUBLIC_ID_PROV10 "-//WAPFORUM//DTD PROV 1.0//EN" 81 #define XML_PUBLIC_ID_WTAWML12 "-//WAPFORUM//DTD WTA-WML 1.2//EN" 82 #define XML_PUBLIC_ID_CHANNEL12 "-//WAPFORUM//DTD CHANNEL 1.2//EN" 83 #define XML_PUBLIC_ID_EMN10 "-//WAPFORUM//DTD EMN 1.0//EN" 84 #define XML_PUBLIC_ID_DRMREL10 "-//OMA//DTD DRMREL 1.0//EN" 85 86 /* Ericsson/Nokia OTA Settings v7.0 */ 87 #define WBXML_PUBLIC_ID_OTA_SETTINGS WBXML_PUBLIC_ID_UNKNOWN 88 #define XML_PUBLIC_ID_OTA_SETTINGS NULL /* No XML Public ID defined */ 89 90 /* SyncML 1.0 */ 91 #define WBXML_PUBLIC_ID_SYNCML_SYNCML10 0x0FD1 92 #define WBXML_PUBLIC_ID_SYNCML_DEVINF10 0x0FD2 93 #define WBXML_PUBLIC_ID_SYNCML_METINF10 WBXML_PUBLIC_ID_UNKNOWN /* No WBXML PublicID defined for SyncML Meta Info */ 94 95 #define XML_PUBLIC_ID_SYNCML_SYNCML10 "-//SYNCML//DTD SyncML 1.0//EN" 96 #define XML_PUBLIC_ID_SYNCML_DEVINF10 "-//SYNCML//DTD DevInf 1.0//EN" 97 #define XML_PUBLIC_ID_SYNCML_METINF10 "-//SYNCML//DTD MetInf 1.0//EN" 98 99 /* SyncML 1.1 */ 100 #define WBXML_PUBLIC_ID_SYNCML_SYNCML11 0x0FD3 101 #define WBXML_PUBLIC_ID_SYNCML_DEVINF11 0x0FD4 102 #define WBXML_PUBLIC_ID_SYNCML_METINF11 WBXML_PUBLIC_ID_UNKNOWN /* No WBXML PublicID defined for SyncML Meta Info */ 103 104 #define XML_PUBLIC_ID_SYNCML_SYNCML11 "-//SYNCML//DTD SyncML 1.1//EN" 105 #define XML_PUBLIC_ID_SYNCML_DEVINF11 "-//SYNCML//DTD DevInf 1.1//EN" 106 #define XML_PUBLIC_ID_SYNCML_METINF11 "-//SYNCML//DTD MetInf 1.1//EN" 107 108 /* SyncML 1.2 */ 109 #define WBXML_PUBLIC_ID_SYNCML_SYNCML12 0x1201 110 #define WBXML_PUBLIC_ID_SYNCML_METINF12 0x1202 111 #define WBXML_PUBLIC_ID_SYNCML_DEVINF12 0x1203 112 #define WBXML_PUBLIC_ID_SYNCML_DMDDF12 WBXML_PUBLIC_ID_UNKNOWN /* No WBXML PublicID defined for OMA DM DDF */ 113 114 #define XML_PUBLIC_ID_SYNCML_SYNCML12 "-//SYNCML//DTD SyncML 1.2//EN" 115 #define XML_PUBLIC_ID_SYNCML_DEVINF12 "-//SYNCML//DTD DevInf 1.2//EN" 116 #define XML_PUBLIC_ID_SYNCML_METINF12 "-//SYNCML//DTD MetInf 1.2//EN" 117 #define XML_PUBLIC_ID_SYNCML_DMDDF12 "-//OMA//DTD-DM-DDF 1.2//EN" 118 119 /* OMA Wireless Village CSP 1.1 / 1.2 - @todo Check for CSP 1.0 */ 120 #define WBXML_PUBLIC_ID_WV_CSP11 0x10 121 #define WBXML_PUBLIC_ID_WV_CSP12 WBXML_PUBLIC_ID_UNKNOWN 122 123 #define XML_PUBLIC_ID_WV_CSP11 "-//OMA//DTD WV-CSP 1.1//EN" /**< @todo Also defined as "-//WIRELESSVILLAGE//DTD CSP 1.1//EN" (so choose one) */ 124 #define XML_PUBLIC_ID_WV_CSP12 "-//OMA//DTD WV-CSP 1.2//EN" 125 126 /* Microsoft AirSync */ 127 #define WBXML_PUBLIC_ID_AIRSYNC WBXML_PUBLIC_ID_UNKNOWN 128 #define XML_PUBLIC_ID_AIRSYNC "-//AIRSYNC//DTD AirSync//EN" 129 130 #define WBXML_PUBLIC_ID_ACTIVESYNC WBXML_PUBLIC_ID_UNKNOWN 131 #define XML_PUBLIC_ID_ACTIVESYNC "-//MICROSOFT//DTD ActiveSync//EN" 132 133 /* Nokia ConML */ 134 #define WBXML_PUBLIC_ID_CONML 0x8F 135 #define XML_PUBLIC_ID_CONML "-//CONML//DTD ConML//EN" 136 137 /**************************************************** 138 * WBXML Encoding options 139 */ 140 141 #define WBXML_TAG_OPTION_UNKNOWN 0x0 142 #define WBXML_TAG_OPTION_BINARY 0x1 143 #define WBXML_TAG_OPTION_OPAQUE 0x2 144 #define WBXML_TAG_OPTION_CDATA 0x4 145 146 /* Example: CDATA|OPAQUE 147 * => XML: <![CDATA ... ]]> 148 * => WBXML: create opaque encoding 149 */ 150 151 /**************************************************** 152 * WBXML Tables Structures 153 */ 154 155 /** 156 * @brief WBXML Public ID structure 157 */ 158 typedef struct WBXMLPublicIDEntry_s 159 { 160 WB_ULONG wbxmlPublicID; /**< WBXML Public ID */ 161 const WB_TINY *xmlPublicID; /**< XML Public ID */ 162 const WB_TINY *xmlRootElt; /**< XML Root Element */ 163 const WB_TINY *xmlDTD; /**< XML DTD */ 164 165 } WBXMLPublicIDEntry; 166 167 168 /** 169 * @brief WBXML Application Token structure: Tag token 170 * The options are used to optionally define the 171 * handling of content. 172 */ 173 typedef struct WBXMLTagEntry_s 174 { 175 const WB_TINY *xmlName; /**< XML Tag Name */ 176 WB_UTINY wbxmlCodePage; /**< WBXML Code Page */ 177 WB_UTINY wbxmlToken; /**< WBXML Tag Token */ 178 WB_ULONG options; /**< (WB)XML (Encoding) Options (optional bit mask)*/ 179 } WBXMLTagEntry; 180 181 182 /** 183 * @brief Name Space 184 * @note For SyncML, where a WBXML Code Page is associated to an XML Name Space 185 */ 186 typedef struct WBXMLNameSpaceEntry_s 187 { 188 const WB_TINY *xmlNameSpace; /**< XML Name Space */ 189 WB_UTINY wbxmlCodePage; /**< WBXML Code Page */ 190 } WBXMLNameSpaceEntry; 191 192 193 /** 194 * @brief WBXML Application Token structure: Attribute token 195 */ 196 typedef struct WBXMLAttrEntry_s 197 { 198 const WB_TINY *xmlName; /**< XML Attribute Name */ 199 const WB_TINY *xmlValue; /**< XML Attribute Value (may be NULL) */ 200 WB_UTINY wbxmlCodePage; /**< WBXML Code Page */ 201 WB_UTINY wbxmlToken; /**< WBXML Attribute Token */ 202 } WBXMLAttrEntry; 203 204 205 /** 206 * @brief WBXML Application Token structure: Attribute Value token 207 */ 208 typedef struct WBXMLAttrValueEntry_s 209 { 210 const WB_TINY *xmlName; /**< XML Attribute Value */ 211 WB_UTINY wbxmlCodePage; /**< WBXML Code Page */ 212 WB_UTINY wbxmlToken; /**< WBXML Attribute Value Token */ 213 } WBXMLAttrValueEntry; 214 215 216 /** 217 * @brief WBXML Application Token structure: Extension Value token 218 * @note For Wireless-Village, the content can be tokenized with Extension Tokens 219 */ 220 typedef struct WBXMLExtValueEntry_s 221 { 222 const WB_TINY *xmlName; /**< XML Extension Value */ 223 WB_UTINY wbxmlToken; /**< WBXML Extension Value Token */ 224 } WBXMLExtValueEntry; 225 226 227 /** 228 * @brief Language structure 229 */ 230 typedef struct WBXMLLangEntry_s 231 { 232 WBXMLLanguage langID; /**< Language ID */ 233 const WBXMLPublicIDEntry *publicID; /**< Public ID */ 234 const WBXMLTagEntry *tagTable; /**< Tags Table */ 235 const WBXMLNameSpaceEntry *nsTable; /**< NameSpaces Table */ 236 const WBXMLAttrEntry *attrTable; /**< Attributes Table*/ 237 const WBXMLAttrValueEntry *attrValueTable; /**< Attributes Values Table */ 238 const WBXMLExtValueEntry *extValueTable; /**< Extensions Values Table */ 239 } WBXMLLangEntry; 240 241 242 /** 243 * @brief Get Main Table 244 * @return The main array of WBXML Language Tables 245 */ 246 WBXML_DECLARE(const WBXMLLangEntry *) wbxml_tables_get_main(void); 247 248 /** 249 * @brief Get a Language Table 250 * @param lang Language to get 251 * @return The Language Table, or NULL if unknown Language 252 */ 253 WBXML_DECLARE(const WBXMLLangEntry *) wbxml_tables_get_table(WBXMLLanguage lang); 254 255 /** 256 * @brief Search for a Language Table 257 * @param main_table Main Table Array to search in 258 * @param public_id The Public ID to search [can be NULL] 259 * @param system_id The System ID to search [can be NULL] 260 * @param root The Root Element to search [can be NULL] 261 * @return The Language Table found, or NULL if none found 262 * @note This function try to find the correct Language Table thanks to the XML Public ID, then (if not found) by 263 * the XML System ID, and finally (if not found) by the Root XML Element 264 */ 265 WBXML_DECLARE(const WBXMLLangEntry *) wbxml_tables_search_table(const WBXMLLangEntry *main_table, 266 const WB_UTINY *public_id, 267 const WB_UTINY *system_id, 268 const WB_UTINY *root); 269 270 /** 271 * @brief Get the WBXML Public ID corresponding to given WBXML Language 272 * @param main_table The Main Languages Table to search in 273 * @param lang_id The Language ID 274 * @return The WBXML Public ID (can be WBXML_PUBLIC_ID_UNKNOWN if Language doesn't have one, or if Language not found) 275 */ 276 WBXML_DECLARE(WB_ULONG) wbxml_tables_get_wbxml_publicid(const WBXMLLangEntry *main_table, 277 WBXMLLanguage lang_id); 278 279 /** 280 * @brief Search for a Tag Entry in Language Table, given the XML Name of the Tag 281 * @param lang_table The Language Table to search in 282 * @param cur_code_page The current code page so that it can be searched first, or -1 to start from the first one. 283 * @param xml_name The XML Name of the Tag to search 284 * @return The Tag Entry of this XML Name in Language Table, or NULL if not found 285 */ 286 WBXML_DECLARE(const WBXMLTagEntry *) wbxml_tables_get_tag_from_xml(const WBXMLLangEntry *lang_table, 287 const int cur_code_page, 288 const WB_UTINY *xml_name); 289 290 /** 291 * @brief Search for an Attribute Entry in Language Table, given the XML Name and Value of the Attribute 292 * @param lang_table The Language Table to search in 293 * @param xml_name The XML Name of the Attribute to search 294 * @param xml_value The XML Value of the Attribute to search 295 * @param value_left Is the WBXMLAttrEntry returned EXACTLY the Attribute we are searching ? (ie: is the Attribute Value 296 * found matching the one we were looking for ?). If Yes, then this is NULL. If not, then this is the 297 * attribute value part that we still have to encode. 298 * @return The Attribute Entry of this XML Attribute Name in Language Table, or NULL if not found 299 * @note Has the Attribut Value can be expressed in many ways in WBXML, this function is focused on 300 * searching for the ATTRIBUTE NAME ! 301 * Thus, when Attribute Name is found in Table, we search for an Entry with the same Attribute Name / Attribute Value 302 * pair. If found the 'value_left' parameter is set to NULL. If not, we still return an Entry matching the Attribute Name, 303 * but the 'value_left' parameter is the Attribute Value part that is not included in the Attrbute Token. 304 */ 305 WBXML_DECLARE(const WBXMLAttrEntry *) wbxml_tables_get_attr_from_xml(const WBXMLLangEntry *lang_table, 306 WB_UTINY *xml_name, 307 WB_UTINY *xml_value, 308 WB_UTINY **value_left); 309 310 /** 311 * @brief Search for an Extension Token Entry in Language Table, given the XML Value of the Extension 312 * @param lang_table The Language Table to search in 313 * @param xml_value The XML Value of the Extension to search 314 * @return The Extension Token Entry of this XML Value in Language Table, or NULL if not found 315 */ 316 WBXML_DECLARE(const WBXMLExtValueEntry *) wbxml_tables_get_ext_from_xml(const WBXMLLangEntry *lang_table, 317 WB_UTINY *xml_value); 318 319 /** 320 * @brief Check if an XML Attribute Value contains at least one Attribute Value defined in Language Attribute Values Table 321 * @param lang_table The Language Table to search in 322 * @param xml_value The XML Attribute Value to check 323 * @return TRUE if this value contains an Attribute Value, FALSE otherwise 324 */ 325 WBXML_DECLARE(WB_BOOL) wbxml_tables_contains_attr_value_from_xml(const WBXMLLangEntry *lang_table, 326 WB_UTINY *xml_value); 327 328 /** 329 * @brief Get an XML NameSpace, given a WBXML Code Page 330 * @param ns_table The NameSpace Table 331 * @param code_page The WBXML Code Page 332 * @return The XML NameSpace, or NULL if not found 333 */ 334 WBXML_DECLARE(const WB_TINY *) wbxml_tables_get_xmlns(const WBXMLNameSpaceEntry *ns_table, 335 WB_UTINY code_page); 336 337 WBXML_DECLARE(WB_UTINY) wbxml_tables_get_code_page(const WBXMLNameSpaceEntry *ns_table, 338 const WB_TINY* xmlns); 339 340 /** @} */ 341 342 #ifdef __cplusplus 343 } 344 #endif /* __cplusplus */ 345 346 #endif /* WBXML_TABLES_H */ 347