| 1 | /* |
| 2 | * |
| 3 | * XML parser - process Gutenprint XML data with mxml. |
| 4 | * |
| 5 | * Copyright 2002-2003 Roger Leigh ([email protected]) |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License as published by the Free |
| 9 | * Software Foundation; either version 2 of the License, or (at your option) |
| 10 | * any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 15 | * for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | |
| 22 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:409:9`! |
| 23 | #include <config.h>cxx . . $ `<file>/config.h`/ |
| 24 | #endif |
| 25 | #include <gutenprint/gutenprint.h>cxx . . $ `<file>/include/gutenprint/gutenprint.h`/ |
| 26 | #include "gutenprint-internal.h"cxx . . $ `<file>/src/main/gutenprint-internal.h`/ |
| 27 | #include <gutenprint/gutenprint-intl-internal.h>cxx . . $ `<file>/include/gutenprint/gutenprint-intl-internal.h`/ |
| 28 | #include <ctype.h> |
| 29 | #include <stdio.h> |
| 30 | #include <stdlib.h> |
| 31 | #include <string.h> |
| 32 | #include <math.h> |
| 33 | #include <errno.h> |
| 34 | #ifdef HAVE_LIMITS_Hcxx . . $ `../../config.h:94:9`! |
| 35 | #include <limits.h> |
| 36 | #endif |
| 37 | #if defined(HAVE_VARARGS_H) && !defined(HAVE_STDARG_Hcxx . . $ `../../config.h:118:9`!) |
| 38 | #include <varargs.h> |
| 39 | #else |
| 40 | #include <stdarg.h> |
| 41 | #endif |
| 42 | |
| 43 | typedef structcxx . . $ $anonymous_type_e79aca65786bdfcd_0# |
| 44 | { |
| 45 | char *namecxx . . $ $anonymous_type_e79aca65786bdfcd_0#name.; |
| 46 | stp_xml_parse_funccxx . . $ stp_xml_parse_func# parse_funccxx . . $ $anonymous_type_e79aca65786bdfcd_0#parse_func.; |
| 47 | } stpi_xml_parse_registrycxx . . $ stpi_xml_parse_registry#; |
| 48 | |
| 49 | static stp_list_tcxx . . $ stp_list_t# *stpi_xml_registrycxx . . $ stpi_xml_registry.; |
| 50 | |
| 51 | static stp_list_tcxx . . $ stp_list_t# *stpi_xml_preloadscxx . . $ stpi_xml_preloads.; |
| 52 | |
| 53 | static stp_list_tcxx . . $ stp_list_t# *stpi_xml_files_loadedcxx . . $ stpi_xml_files_loaded.; |
| 54 | |
| 55 | static stp_string_list_tcxx . . $ stp_string_list_t# *cached_xml_filescxx . . $ cached_xml_files.; |
| 56 | |
| 57 | static const char * |
| 58 | xml_registry_namefunccxx . . $ xml_registry_namefunc(6271d96ae060557f).(const void *item) |
| 59 | { |
| 60 | const stpi_xml_parse_registrycxx . . $ stpi_xml_parse_registry# *xmlp = (const stpi_xml_parse_registrycxx . . $ stpi_xml_parse_registry# *) item; |
| 61 | return xmlp->namecxx . . $ $anonymous_type_e79aca65786bdfcd_0#name.; |
| 62 | } |
| 63 | |
| 64 | static void |
| 65 | xml_registry_freefunccxx . . $ xml_registry_freefunc(5d22bdacc48458e8).(void *item) |
| 66 | { |
| 67 | stpi_xml_parse_registrycxx . . $ stpi_xml_parse_registry# *xmlp = (stpi_xml_parse_registrycxx . . $ stpi_xml_parse_registry# *) item; |
| 68 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(xmlp->namecxx . . $ $anonymous_type_e79aca65786bdfcd_0#name.); |
| 69 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(xmlp); |
| 70 | } |
| 71 | |
| 72 | static const char * |
| 73 | xml_preload_namefunccxx . . $ xml_preload_namefunc(6271d96ae060557f).(const void *item) |
| 74 | { |
| 75 | return (const char *) item; |
| 76 | } |
| 77 | |
| 78 | static void |
| 79 | xml_preload_freefunccxx . . $ xml_preload_freefunc(5d22bdacc48458e8).(void *item) |
| 80 | { |
| 81 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(item); |
| 82 | } |
| 83 | |
| 84 | void |
| 85 | stp_register_xml_parsercxx . . $ stp_register_xml_parser(91857625fba69e1d).(const char *name, stp_xml_parse_funccxx . . $ stp_xml_parse_func# parse_func) |
| 86 | { |
| 87 | stpi_xml_parse_registrycxx . . $ stpi_xml_parse_registry# *xmlp; |
| 88 | stp_list_item_tcxx . . $ stp_list_item_t# *item = stp_list_get_item_by_namecxx . . $ stp_list_get_item_by_name(27765cfe86595311).(stpi_xml_registrycxx . . $ stpi_xml_registry., name); |
| 89 | if (item) |
| 90 | xmlp = (stpi_xml_parse_registrycxx . . $ stpi_xml_parse_registry# *) stp_list_item_get_datacxx . . $ stp_list_item_get_data(9a5daa75441a53b5).(item); |
| 91 | else |
| 92 | { |
| 93 | xmlp = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(sizeof(stpi_xml_parse_registrycxx . . $ stpi_xml_parse_registry#)); |
| 94 | xmlp->namecxx . . $ $anonymous_type_e79aca65786bdfcd_0#name. = stp_strdupcxx . . $ stp_strdup(a8b8e32347182212).(name); |
| 95 | stp_list_item_createcxx . . $ stp_list_item_create(54f08bf465e39eec).(stpi_xml_registrycxx . . $ stpi_xml_registry., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, xmlp); |
| 96 | } |
| 97 | xmlp->parse_funccxx . . $ $anonymous_type_e79aca65786bdfcd_0#parse_func. = parse_func; |
| 98 | } |
| 99 | |
| 100 | void |
| 101 | stp_unregister_xml_parsercxx . . $ stp_unregister_xml_parser(85c52e162fed56f9).(const char *name) |
| 102 | { |
| 103 | stp_list_item_tcxx . . $ stp_list_item_t# *item = stp_list_get_item_by_namecxx . . $ stp_list_get_item_by_name(27765cfe86595311).(stpi_xml_registrycxx . . $ stpi_xml_registry., name); |
| 104 | if (item) |
| 105 | stp_list_item_destroycxx . . $ stp_list_item_destroy(e8436428ff1ae51).(stpi_xml_registrycxx . . $ stpi_xml_registry., item); |
| 106 | } |
| 107 | |
| 108 | void |
| 109 | stp_register_xml_preloadcxx . . $ stp_register_xml_preload(85c52e162fed56f9).(const char *filename) |
| 110 | { |
| 111 | stp_list_item_tcxx . . $ stp_list_item_t# *item = stp_list_get_item_by_namecxx . . $ stp_list_get_item_by_name(27765cfe86595311).(stpi_xml_preloadscxx . . $ stpi_xml_preloads., filename); |
| 112 | if (!item) |
| 113 | { |
| 114 | char *the_filename = stp_strdupcxx . . $ stp_strdup(a8b8e32347182212).(filename); |
| 115 | stp_list_item_createcxx . . $ stp_list_item_create(54f08bf465e39eec).(stpi_xml_preloadscxx . . $ stpi_xml_preloads., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, the_filename); |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | void |
| 120 | stp_unregister_xml_preloadcxx . . $ stp_unregister_xml_preload(85c52e162fed56f9).(const char *name) |
| 121 | { |
| 122 | stp_list_item_tcxx . . $ stp_list_item_t# *item = stp_list_get_item_by_namecxx . . $ stp_list_get_item_by_name(27765cfe86595311).(stpi_xml_preloadscxx . . $ stpi_xml_preloads., name); |
| 123 | if (item) |
| 124 | stp_list_item_destroycxx . . $ stp_list_item_destroy(e8436428ff1ae51).(stpi_xml_preloadscxx . . $ stpi_xml_preloads., item); |
| 125 | } |
| 126 | |
| 127 | |
| 128 | static void stpi_xml_process_gutenprintcxx . . $ stpi_xml_process_gutenprint(bce341e4e24d6ac9).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *gutenprint, const char *file); |
| 129 | |
| 130 | static char *saved_localecxx . . $ saved_locale.; /* Saved LC_ALL */ |
| 131 | static int xml_is_initialisedcxx . . $ xml_is_initialised.; /* Flag for init */ |
| 132 | |
| 133 | void |
| 134 | stp_xml_preinitcxx . . $ stp_xml_preinit(49f6e7a06ebc5aa8).(void) |
| 135 | { |
| 136 | if (! stpi_xml_registrycxx . . $ stpi_xml_registry.) |
| 137 | { |
| 138 | stpi_xml_registrycxx . . $ stpi_xml_registry. = stp_list_createcxx . . $ stp_list_create(728167c67729d082).(); |
| 139 | stp_list_set_freefunccxx . . $ stp_list_set_freefunc(309a84c3f950ef37).(stpi_xml_registrycxx . . $ stpi_xml_registry., xml_registry_freefunccxx . . $ xml_registry_freefunc(5d22bdacc48458e8).); |
| 140 | stp_list_set_namefunccxx . . $ stp_list_set_namefunc(83503c4472347457).(stpi_xml_registrycxx . . $ stpi_xml_registry., xml_registry_namefunccxx . . $ xml_registry_namefunc(6271d96ae060557f).); |
| 141 | } |
| 142 | if (! stpi_xml_preloadscxx . . $ stpi_xml_preloads.) |
| 143 | { |
| 144 | stpi_xml_preloadscxx . . $ stpi_xml_preloads. = stp_list_createcxx . . $ stp_list_create(728167c67729d082).(); |
| 145 | stp_list_set_freefunccxx . . $ stp_list_set_freefunc(309a84c3f950ef37).(stpi_xml_preloadscxx . . $ stpi_xml_preloads., xml_preload_freefunccxx . . $ xml_preload_freefunc(5d22bdacc48458e8).); |
| 146 | stp_list_set_namefunccxx . . $ stp_list_set_namefunc(83503c4472347457).(stpi_xml_preloadscxx . . $ stpi_xml_preloads., xml_preload_namefunccxx . . $ xml_preload_namefunc(6271d96ae060557f).); |
| 147 | } |
| 148 | if (! stpi_xml_files_loadedcxx . . $ stpi_xml_files_loaded.) |
| 149 | { |
| 150 | stpi_xml_files_loadedcxx . . $ stpi_xml_files_loaded. = stp_list_createcxx . . $ stp_list_create(728167c67729d082).(); |
| 151 | stp_list_set_freefunccxx . . $ stp_list_set_freefunc(309a84c3f950ef37).(stpi_xml_files_loadedcxx . . $ stpi_xml_files_loaded., xml_preload_freefunccxx . . $ xml_preload_freefunc(5d22bdacc48458e8).); |
| 152 | stp_list_set_namefunccxx . . $ stp_list_set_namefunc(83503c4472347457).(stpi_xml_files_loadedcxx . . $ stpi_xml_files_loaded., xml_preload_namefunccxx . . $ xml_preload_namefunc(6271d96ae060557f).); |
| 153 | } |
| 154 | if (! cached_xml_filescxx . . $ cached_xml_files.) |
| 155 | { |
| 156 | cached_xml_filescxx . . $ cached_xml_files. = stp_string_list_createcxx . . $ stp_string_list_create(f262b3b5e10fad14).(); |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | /* |
| 161 | * Call before using any of the static functions in this file. All |
| 162 | * public functions should call this before using any mxml |
| 163 | * functions. |
| 164 | */ |
| 165 | void |
| 166 | stp_xml_initcxx . . $ stp_xml_init(49f6e7a06ebc5aa8).(void) |
| 167 | { |
| 168 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3).(STP_DBG_XMLcxx . . $ `include/gutenprint/util.h:182:9`!, "stp_xml_init: entering at level %d\n", |
| 169 | xml_is_initialisedcxx . . $ xml_is_initialised.); |
| 170 | if (xml_is_initialisedcxx . . $ xml_is_initialised. >= 1) |
| 171 | { |
| 172 | xml_is_initialisedcxx . . $ xml_is_initialised.++; |
| 173 | return; |
| 174 | } |
| 175 | |
| 176 | /* Set some locale facets to "C" */ |
| 177 | #ifdef HAVE_LOCALE_Hcxx . . $ `../../config.h:97:9`! |
| 178 | saved_localecxx . . $ saved_locale. = stp_strdupcxx . . $ stp_strdup(a8b8e32347182212).(setlocalecxx . . $ setlocale(10ed28bce9115888).(LC_ALLcxx . . $ `<external>/3736975272097309885/locale.h:41:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)); |
| 179 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3).(STP_DBG_XMLcxx . . $ `include/gutenprint/util.h:182:9`!, "stp_xml_init: saving locale %s\n", saved_localecxx . . $ saved_locale.); |
| 180 | setlocalecxx . . $ setlocale(10ed28bce9115888).(LC_ALLcxx . . $ `<external>/3736975272097309885/locale.h:41:9`!, "C"); |
| 181 | #endif |
| 182 | |
| 183 | xml_is_initialisedcxx . . $ xml_is_initialised. = 1; |
| 184 | } |
| 185 | |
| 186 | /* |
| 187 | * Call after using any of the static functions in this file. All |
| 188 | * public functions should call this after using any mxml functions. |
| 189 | */ |
| 190 | void |
| 191 | stp_xml_exitcxx . . $ stp_xml_exit(49f6e7a06ebc5aa8).(void) |
| 192 | { |
| 193 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3).(STP_DBG_XMLcxx . . $ `include/gutenprint/util.h:182:9`!, "stp_xml_exit: entering at level %d\n", |
| 194 | xml_is_initialisedcxx . . $ xml_is_initialised.); |
| 195 | if (xml_is_initialisedcxx . . $ xml_is_initialised. > 1) /* don't restore original state */ |
| 196 | { |
| 197 | xml_is_initialisedcxx . . $ xml_is_initialised.--; |
| 198 | return; |
| 199 | } |
| 200 | else if (xml_is_initialisedcxx . . $ xml_is_initialised. < 1) |
| 201 | { |
| 202 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("stp_xml_exit: unmatched stp_xml_init!\n"); |
| 203 | stp_abortcxx . . $ stp_abort(49f6e7a06ebc5aa8).(); |
| 204 | } |
| 205 | |
| 206 | /* Restore locale */ |
| 207 | #ifdef HAVE_LOCALE_Hcxx . . $ `../../config.h:97:9`! |
| 208 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3).(STP_DBG_XMLcxx . . $ `include/gutenprint/util.h:182:9`!, "stp_xml_exit: restoring locale %s\n", saved_localecxx . . $ saved_locale.); |
| 209 | setlocalecxx . . $ setlocale(10ed28bce9115888).(LC_ALLcxx . . $ `<external>/3736975272097309885/locale.h:41:9`!, saved_localecxx . . $ saved_locale.); |
| 210 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(saved_localecxx . . $ saved_locale.); |
| 211 | saved_localecxx . . $ saved_locale. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 212 | #endif |
| 213 | xml_is_initialisedcxx . . $ xml_is_initialised. = 0; |
| 214 | } |
| 215 | |
| 216 | void |
| 217 | stp_xml_parse_file_namedcxx . . $ stp_xml_parse_file_named(85c52e162fed56f9).(const char *name) |
| 218 | { |
| 219 | stp_xml_preinitcxx . . $ stp_xml_preinit(49f6e7a06ebc5aa8).(); |
| 220 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3).(STP_DBG_XMLcxx . . $ `include/gutenprint/util.h:182:9`!, "stp_xml_parse_file_named(%s)\n", name); |
| 221 | if (! stp_list_get_item_by_namecxx . . $ stp_list_get_item_by_name(27765cfe86595311).(stpi_xml_files_loadedcxx . . $ stpi_xml_files_loaded., name)) |
| 222 | { |
| 223 | char *file_name = stp_path_find_filecxx . . $ stp_path_find_file(a713fe7b9a57cf96).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, name); |
| 224 | if (file_name) |
| 225 | { |
| 226 | stp_xml_parse_filecxx . . $ stp_xml_parse_file(5c4306d8553b3696).(file_name); |
| 227 | freecxx . . $ free(5d22bdacc48458e8).(file_name); |
| 228 | } |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | /* |
| 233 | * Read all available XML files. |
| 234 | */ |
| 235 | int |
| 236 | stp_xml_init_defaultscxx . . $ stp_xml_init_defaults(b126dc7c1de90089).(void) |
| 237 | { |
| 238 | stp_list_item_tcxx . . $ stp_list_item_t# *item; /* Pointer to current list item */ |
| 239 | |
| 240 | stp_xml_initcxx . . $ stp_xml_init(49f6e7a06ebc5aa8).(); |
| 241 | |
| 242 | /* Parse each XML file */ |
| 243 | item = stp_list_get_startcxx . . $ stp_list_get_start(44f6202a74729935).(stpi_xml_preloadscxx . . $ stpi_xml_preloads.); |
| 244 | while (item) |
| 245 | { |
| 246 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3).(STP_DBG_XMLcxx . . $ `include/gutenprint/util.h:182:9`!, "stp_xml_init_defaults: source file: %s\n", |
| 247 | (const char *) stp_list_item_get_datacxx . . $ stp_list_item_get_data(9a5daa75441a53b5).(item)); |
| 248 | stp_xml_parse_file_namedcxx . . $ stp_xml_parse_file_named(85c52e162fed56f9).((const char *) stp_list_item_get_datacxx . . $ stp_list_item_get_data(9a5daa75441a53b5).(item)); |
| 249 | item = stp_list_item_nextcxx . . $ stp_list_item_next(83833ec172b48f23).(item); |
| 250 | } |
| 251 | stp_list_destroycxx . . $ stp_list_destroy(29ae8ff464c7f7e5).(stpi_xml_preloadscxx . . $ stpi_xml_preloads.); |
| 252 | |
| 253 | stp_xml_exitcxx . . $ stp_xml_exit(49f6e7a06ebc5aa8).(); |
| 254 | |
| 255 | return 0; |
| 256 | } |
| 257 | |
| 258 | /* |
| 259 | * Parse a single XML file. |
| 260 | */ |
| 261 | int |
| 262 | stp_xml_parse_filecxx . . $ stp_xml_parse_file(5c4306d8553b3696).(const char *file) /* File to parse */ |
| 263 | { |
| 264 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *doc; |
| 265 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *cur; |
| 266 | int status = 0; |
| 267 | |
| 268 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3).(STP_DBG_XMLcxx . . $ `include/gutenprint/util.h:182:9`!, "stp_xml_parse_file: reading `%s'...\n", file); |
| 269 | |
| 270 | stp_xml_initcxx . . $ stp_xml_init(49f6e7a06ebc5aa8).(); |
| 271 | |
| 272 | doc = stp_mxmlLoadFromFilecxx . . $ stp_mxmlLoadFromFile(40d1ca7ef3f17308).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, file, STP_MXML_NO_CALLBACKcxx . . $ `include/gutenprint/mxml.h:48:11`!); |
| 273 | |
| 274 | if ((cur = stp_xml_get_nodecxx . . $ stp_xml_get_node(a1d8ee452fb78e99).(doc, "gutenprint", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 275 | { |
| 276 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("stp_xml_parse_file: %s: parse error\n", file); |
| 277 | status = 1; |
| 278 | } |
| 279 | else |
| 280 | /* The XML file was read and is the right format */ |
| 281 | stpi_xml_process_gutenprintcxx . . $ stpi_xml_process_gutenprint(bce341e4e24d6ac9).(cur, file); |
| 282 | |
| 283 | stp_mxmlDeletecxx . . $ stp_mxmlDelete(6927777f14b5e2a1).(doc); |
| 284 | |
| 285 | stp_xml_exitcxx . . $ stp_xml_exit(49f6e7a06ebc5aa8).(); |
| 286 | |
| 287 | return status; |
| 288 | } |
| 289 | |
| 290 | static stp_mxml_node_tcxx . . $ stp_mxml_node_t# * |
| 291 | xml_try_parse_file_1cxx . . $ xml_try_parse_file_1(6162c5f59f2ff8f9).(const char *pathname, const char *topnodename) |
| 292 | { |
| 293 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *root = |
| 294 | stp_mxmlLoadFromFilecxx . . $ stp_mxmlLoadFromFile(40d1ca7ef3f17308).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, pathname, STP_MXML_NO_CALLBACKcxx . . $ `include/gutenprint/mxml.h:48:11`!); |
| 295 | if (root) |
| 296 | { |
| 297 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *answer = |
| 298 | stp_xml_get_nodecxx . . $ stp_xml_get_node(a1d8ee452fb78e99).(root, "gutenprint", topnodename, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 299 | if (answer) |
| 300 | return answer; |
| 301 | stp_mxmlDeletecxx . . $ stp_mxmlDelete(6927777f14b5e2a1).(root); |
| 302 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 303 | } |
| 304 | else |
| 305 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 306 | } |
| 307 | |
| 308 | static stp_mxml_node_tcxx . . $ stp_mxml_node_t# * |
| 309 | xml_try_parse_filecxx . . $ xml_try_parse_file(6162c5f59f2ff8f9).(const char *pathname, const char *topnodename) |
| 310 | { |
| 311 | stp_xml_initcxx . . $ stp_xml_init(49f6e7a06ebc5aa8).(); |
| 312 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *answer = xml_try_parse_file_1cxx . . $ xml_try_parse_file_1(6162c5f59f2ff8f9).(pathname, topnodename); |
| 313 | stp_xml_exitcxx . . $ stp_xml_exit(49f6e7a06ebc5aa8).(); |
| 314 | return answer; |
| 315 | } |
| 316 | |
| 317 | static void |
| 318 | xml_cache_filecxx . . $ xml_cache_file(c6cfd0e58f1feb11).(const char *name, const char *cache, stp_mxml_node_tcxx . . $ stp_mxml_node_t# *node) |
| 319 | { |
| 320 | char *addr_string; |
| 321 | stp_asprintfcxx . . $ stp_asprintf(816f0239e6d49b84).(&addr_string, "%p", (void *) node); |
| 322 | /* |
| 323 | * A given XML object should never be in multiple caches! However, |
| 324 | * it's possible that different nodes of the same file will be in different |
| 325 | * caches. |
| 326 | */ |
| 327 | STPI_ASSERTcxx . . $ `src/main/gutenprint-internal.h:58:9`!(!stp_string_list_is_present(cached_xml_files, addr_string), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 328 | if (cache) |
| 329 | { |
| 330 | stp_refcache_add_itemcxx . . $ stp_refcache_add_item(285a709643be31b2).(cache, name, node); |
| 331 | stp_string_list_add_string_unsafecxx . . $ stp_string_list_add_string_unsafe(61ec312b340c2952).(cached_xml_filescxx . . $ cached_xml_files., addr_string, cache); |
| 332 | } |
| 333 | else |
| 334 | stp_string_list_add_string_unsafecxx . . $ stp_string_list_add_string_unsafe(61ec312b340c2952).(cached_xml_filescxx . . $ cached_xml_files., addr_string, ""); |
| 335 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(addr_string); |
| 336 | } |
| 337 | |
| 338 | static stp_mxml_node_tcxx . . $ stp_mxml_node_t# * |
| 339 | xml_parse_file_from_pathcxx . . $ xml_parse_file_from_path(89f6fddc1bc2d340).(const char *name, const char *topnodename, |
| 340 | const char *path, const char *cache) |
| 341 | { |
| 342 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *answer = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 343 | if (!(name[0] != '/' && strncmpcxx . . $ strncmp(fd278af2f295fa2e).(name, "./", 2) && strncmpcxx . . $ strncmp(fd278af2f295fa2e).(name, "../", 3))) |
| 344 | answer = xml_try_parse_filecxx . . $ xml_try_parse_file(6162c5f59f2ff8f9).(name, topnodename); |
| 345 | else |
| 346 | { |
| 347 | stp_list_tcxx . . $ stp_list_t# *path_to_search; |
| 348 | stp_list_item_tcxx . . $ stp_list_item_t# *item; |
| 349 | if (path) |
| 350 | path_to_search = stp_generate_pathcxx . . $ stp_generate_path(3c3f43458e8c52b9).(path); |
| 351 | else |
| 352 | path_to_search = stp_data_pathcxx . . $ stp_data_path(728167c67729d082).(); |
| 353 | item = stp_list_get_startcxx . . $ stp_list_get_start(44f6202a74729935).(path_to_search); |
| 354 | while (item) |
| 355 | { |
| 356 | const char *dn = (const char *) stp_list_item_get_datacxx . . $ stp_list_item_get_data(9a5daa75441a53b5).(item); |
| 357 | char *ffn = stpi_path_mergecxx . . $ stpi_path_merge(a713fe7b9a57cf96).(dn, name); |
| 358 | answer = xml_try_parse_filecxx . . $ xml_try_parse_file(6162c5f59f2ff8f9).(ffn, topnodename); |
| 359 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(ffn); |
| 360 | if (answer) |
| 361 | break; |
| 362 | item = stp_list_item_nextcxx . . $ stp_list_item_next(83833ec172b48f23).(item); |
| 363 | } |
| 364 | stp_list_destroycxx . . $ stp_list_destroy(29ae8ff464c7f7e5).(path_to_search); |
| 365 | } |
| 366 | if (answer) |
| 367 | xml_cache_filecxx . . $ xml_cache_file(c6cfd0e58f1feb11).(name, cache, answer); |
| 368 | return answer; |
| 369 | } |
| 370 | |
| 371 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# * |
| 372 | stp_xml_parse_file_from_path_uncachedcxx . . $ stp_xml_parse_file_from_path_uncached(5a8029715312b5a0).(const char *name, const char *topnodename, |
| 373 | const char *path) |
| 374 | { |
| 375 | return xml_parse_file_from_pathcxx . . $ xml_parse_file_from_path(89f6fddc1bc2d340).(name, topnodename, path, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 376 | } |
| 377 | |
| 378 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# * |
| 379 | stp_xml_parse_file_from_path_uncached_safecxx . . $ stp_xml_parse_file_from_path_uncached_safe(5a8029715312b5a0).(const char *name, |
| 380 | const char *topnodename, |
| 381 | const char *path) |
| 382 | { |
| 383 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *answer = |
| 384 | xml_parse_file_from_pathcxx . . $ xml_parse_file_from_path(89f6fddc1bc2d340).(name, topnodename, path, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 385 | if (! answer) |
| 386 | { |
| 387 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("Cannot find file %s of type %s\n", name, topnodename); |
| 388 | stp_abortcxx . . $ stp_abort(49f6e7a06ebc5aa8).(); |
| 389 | } |
| 390 | return answer; |
| 391 | } |
| 392 | |
| 393 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# * |
| 394 | stp_xml_parse_file_from_pathcxx . . $ stp_xml_parse_file_from_path(5a8029715312b5a0).(const char *name, const char *topnodename, |
| 395 | const char *path) |
| 396 | { |
| 397 | char *cache; |
| 398 | void *data; |
| 399 | stp_asprintfcxx . . $ stp_asprintf(816f0239e6d49b84).(&cache, "%s_%s_%s", "xml_cache", topnodename, |
| 400 | path ? path : "DEFAULT"); |
| 401 | data = stp_refcache_find_itemcxx . . $ stp_refcache_find_item(12e6862c879384a7).(cache, name); |
| 402 | if (! data) |
| 403 | data = xml_parse_file_from_pathcxx . . $ xml_parse_file_from_path(89f6fddc1bc2d340).(name, topnodename, path, cache); |
| 404 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(cache); |
| 405 | return (stp_mxml_node_tcxx . . $ stp_mxml_node_t# *) data; |
| 406 | } |
| 407 | |
| 408 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# * |
| 409 | stp_xml_parse_file_from_path_safecxx . . $ stp_xml_parse_file_from_path_safe(5a8029715312b5a0).(const char *name, const char *topnodename, |
| 410 | const char *path) |
| 411 | { |
| 412 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *answer = stp_xml_parse_file_from_pathcxx . . $ stp_xml_parse_file_from_path(5a8029715312b5a0).(name, topnodename, |
| 413 | path); |
| 414 | if (! answer) |
| 415 | { |
| 416 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("FATAL: Cannot find file %s of type %s\n", name, topnodename); |
| 417 | stp_abortcxx . . $ stp_abort(49f6e7a06ebc5aa8).(); |
| 418 | } |
| 419 | return answer; |
| 420 | } |
| 421 | |
| 422 | void |
| 423 | stp_xml_free_parsed_filecxx . . $ stp_xml_free_parsed_file(6927777f14b5e2a1).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *node) |
| 424 | { |
| 425 | char *addr_string; |
| 426 | /* free(NULL) is legal and a no-op. */ |
| 427 | if (! node) |
| 428 | return; |
| 429 | stp_asprintfcxx . . $ stp_asprintf(816f0239e6d49b84).(&addr_string, "%p", (void *) node); |
| 430 | stp_param_string_tcxx . . $ stp_param_string_t# *cache_entry = |
| 431 | stp_string_list_findcxx . . $ stp_string_list_find(e483be985c44e37a).(cached_xml_filescxx . . $ cached_xml_files., addr_string); |
| 432 | if (! cache_entry) |
| 433 | { |
| 434 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("FATAL: Trying to free unrecorded node %s\n", addr_string); |
| 435 | stp_abortcxx . . $ stp_abort(49f6e7a06ebc5aa8).(); |
| 436 | } |
| 437 | if (cache_entry->textcxx . . $ $anonymous_type_cb0224bbe5755622_0#text. && cache_entry->textcxx . . $ $anonymous_type_cb0224bbe5755622_0#text.[0] != '\0') |
| 438 | stp_refcache_remove_itemcxx . . $ stp_refcache_remove_item(2fa786934fe80e24).(cache_entry->textcxx . . $ $anonymous_type_cb0224bbe5755622_0#text., addr_string); |
| 439 | stp_string_list_remove_stringcxx . . $ stp_string_list_remove_string(24ca7d3bba3c474e).(cached_xml_filescxx . . $ cached_xml_files., addr_string); |
| 440 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(addr_string); |
| 441 | while (node->parentcxx . . $ stp_mxml_node_s#parent. && node->parentcxx . . $ stp_mxml_node_s#parent. != node) |
| 442 | node = node->parentcxx . . $ stp_mxml_node_s#parent.; |
| 443 | stp_xml_initcxx . . $ stp_xml_init(49f6e7a06ebc5aa8).(); |
| 444 | stp_mxmlDeletecxx . . $ stp_mxmlDelete(6927777f14b5e2a1).(node); |
| 445 | stp_xml_exitcxx . . $ stp_xml_exit(49f6e7a06ebc5aa8).(); |
| 446 | } |
| 447 | |
| 448 | /* |
| 449 | * Convert a text string into an integer. |
| 450 | */ |
| 451 | long |
| 452 | stp_xmlstrtolcxx . . $ stp_xmlstrtol(3c95bd14d5d5d286).(const char *textval) |
| 453 | { |
| 454 | long val; /* The value to return */ |
| 455 | val = strtolcxx . . $ strtol(44bbb87609b212fc).(textval, (char **)NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0); |
| 456 | |
| 457 | return val; |
| 458 | } |
| 459 | |
| 460 | /* |
| 461 | * Convert a text string into an unsigned int. |
| 462 | */ |
| 463 | unsigned long |
| 464 | stp_xmlstrtoulcxx . . $ stp_xmlstrtoul(751346f8406fd082).(const char *textval) |
| 465 | { |
| 466 | unsigned long val; /* The value to return */ |
| 467 | val = strtoulcxx . . $ strtoul(31746e8d6ec49860).(textval, (char **)NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0); |
| 468 | |
| 469 | return val; |
| 470 | } |
| 471 | |
| 472 | /* |
| 473 | * Convert a text string into a double. |
| 474 | */ |
| 475 | double |
| 476 | stp_xmlstrtodcxx . . $ stp_xmlstrtod(9a18bdb0e56c1bc2).(const char *textval) |
| 477 | { |
| 478 | double val; /* The value to return */ |
| 479 | val = strtodcxx . . $ strtod(3dfe5620a0d3160e).(textval, (char **)NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 480 | |
| 481 | return val; |
| 482 | } |
| 483 | |
| 484 | /* |
| 485 | * Convert a text string into a dimension. |
| 486 | */ |
| 487 | stp_dimension_tcxx . . $ stp_dimension_t# |
| 488 | stp_xmlstrtodimcxx . . $ stp_xmlstrtodim(9a18bdb0e56c1bc2).(const char *textval) |
| 489 | { |
| 490 | double val; /* The value to return */ |
| 491 | val = (stp_dimension_tcxx . . $ stp_dimension_t#) strtodcxx . . $ strtod(3dfe5620a0d3160e).(textval, (char **)NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 492 | |
| 493 | return val; |
| 494 | } |
| 495 | |
| 496 | /* |
| 497 | * Convert an encoded text string into a raw. |
| 498 | */ |
| 499 | stp_raw_tcxx . . $ stp_raw_t# * |
| 500 | stp_xmlstrtorawcxx . . $ stp_xmlstrtoraw(62ebf526a09225cc).(const char *textval) |
| 501 | { |
| 502 | size_t tcount; |
| 503 | stp_raw_tcxx . . $ stp_raw_t# *raw; |
| 504 | unsigned char *answer; |
| 505 | unsigned char *aptr; |
| 506 | if (! textval || *textval == 0) |
| 507 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 508 | tcount = strlencxx . . $ strlen(751346f8406fd082).(textval); |
| 509 | raw = stp_zalloccxx . . $ stp_zalloc(bfcfa4d6b7f7ef64).(sizeof(stp_raw_tcxx . . $ stp_raw_t#)); |
| 510 | answer = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(tcount + 1); /* Worst case -- we may not need it all */ |
| 511 | aptr = answer; |
| 512 | raw->datacxx . . $ $anonymous_type_c987533f3b833c82_4#data. = answer; |
| 513 | while (*textval) |
| 514 | { |
| 515 | if (*textval != '\\') |
| 516 | { |
| 517 | *aptr++ = *textval++; |
| 518 | raw->bytescxx . . $ $anonymous_type_c987533f3b833c82_4#bytes.++; |
| 519 | } |
| 520 | else |
| 521 | { |
| 522 | textval++; |
| 523 | if (textval[0] >= '0' && textval[0] <= '3' && |
| 524 | textval[1] >= '0' && textval[1] <= '7' && |
| 525 | textval[2] >= '0' && textval[2] <= '7') |
| 526 | { |
| 527 | *aptr++ = (((textval[0] - '0') << 6) + |
| 528 | ((textval[1] - '0') << 3) + |
| 529 | ((textval[2] - '0') << 0)); |
| 530 | raw->bytescxx . . $ $anonymous_type_c987533f3b833c82_4#bytes.++; |
| 531 | textval += 3; |
| 532 | } |
| 533 | else if (textval[0] == '\0' || textval[1] == '\0' || textval[2] == '\0') |
| 534 | break; |
| 535 | else |
| 536 | textval += 3; |
| 537 | } |
| 538 | } |
| 539 | *aptr = '\0'; |
| 540 | return raw; |
| 541 | } |
| 542 | |
| 543 | char * |
| 544 | stp_rawtoxmlstrcxx . . $ stp_rawtoxmlstr(275fd84c44e0eebb).(const stp_raw_tcxx . . $ stp_raw_t# *raw) |
| 545 | { |
| 546 | if (raw && raw->bytescxx . . $ $anonymous_type_c987533f3b833c82_4#bytes. > 0) |
| 547 | { |
| 548 | unsigned int i; |
| 549 | const unsigned char *data = (const unsigned char *) (raw->datacxx . . $ $anonymous_type_c987533f3b833c82_4#data.); |
| 550 | char *answer = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).((raw->bytescxx . . $ $anonymous_type_c987533f3b833c82_4#bytes. * 4) + 1); /* \012 */ |
| 551 | unsigned char *aptr = (unsigned char *) answer; |
| 552 | for (i = 0; i < raw->bytescxx . . $ $anonymous_type_c987533f3b833c82_4#bytes.; i++) |
| 553 | { |
| 554 | if (data[i] > ' ' && data[i] < '\177' && data[i] != '\\' && |
| 555 | data[i] != '<' && data[i] != '>' && data[i] != '&') |
| 556 | *aptr++ = data[i]; |
| 557 | else |
| 558 | { |
| 559 | *aptr++ = '\\'; |
| 560 | *aptr++ = '0' + ((data[i] & '\300') >> 6); |
| 561 | *aptr++ = '0' + ((data[i] & '\070') >> 3); |
| 562 | *aptr++ = '0' + ((data[i] & '\007') >> 0); |
| 563 | } |
| 564 | } |
| 565 | *aptr = '\0'; |
| 566 | return answer; |
| 567 | } |
| 568 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 569 | } |
| 570 | |
| 571 | char * |
| 572 | stp_strtoxmlstrcxx . . $ stp_strtoxmlstr(a8b8e32347182212).(const char *str) |
| 573 | { |
| 574 | if (str && strlencxx . . $ strlen(751346f8406fd082).(str) > 0) |
| 575 | { |
| 576 | unsigned int i; |
| 577 | unsigned int bytes = strlencxx . . $ strlen(751346f8406fd082).(str); |
| 578 | const unsigned char *data = (const unsigned char *) (str); |
| 579 | char *answer = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).((bytes * 4) + 1); /* "\012" is worst case */ |
| 580 | unsigned char *aptr = (unsigned char *) answer; |
| 581 | for (i = 0; i < bytes; i++) |
| 582 | { |
| 583 | if (data[i] > ' ' && data[i] < '\177' && data[i] != '\\' && |
| 584 | data[i] != '<' && data[i] != '>' && data[i] != '&') |
| 585 | *aptr++ = data[i]; |
| 586 | else |
| 587 | { |
| 588 | *aptr++ = '\\'; |
| 589 | *aptr++ = '0' + ((data[i] & '\300') >> 6); |
| 590 | *aptr++ = '0' + ((data[i] & '\070') >> 3); |
| 591 | *aptr++ = '0' + ((data[i] & '\007') >> 0); |
| 592 | } |
| 593 | } |
| 594 | *aptr = '\0'; |
| 595 | return answer; |
| 596 | } |
| 597 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 598 | } |
| 599 | |
| 600 | void |
| 601 | stp_prtrawcxx . . $ stp_prtraw(9980326a154431a3).(const stp_raw_tcxx . . $ stp_raw_t# *raw, FILEcxx . . $ FILE# *fp) |
| 602 | { |
| 603 | if (raw && raw->bytescxx . . $ $anonymous_type_c987533f3b833c82_4#bytes. > 0) |
| 604 | { |
| 605 | unsigned int i; |
| 606 | const unsigned char *data = (const unsigned char *) (raw->datacxx . . $ $anonymous_type_c987533f3b833c82_4#data.); |
| 607 | for (i = 0; i < raw->bytescxx . . $ $anonymous_type_c987533f3b833c82_4#bytes.; i++) |
| 608 | { |
| 609 | if (data[i] > ' ' && data[i] < '\177' && data[i] != '\\' && |
| 610 | data[i] != '<' && data[i] != '>' && data[i] != '&') |
| 611 | fputccxx . . $ fputc(b1cd03d6c470d1bd).(data[i], fp); |
| 612 | else |
| 613 | { |
| 614 | fputccxx . . $ fputc(b1cd03d6c470d1bd).('\\', fp); |
| 615 | fputccxx . . $ fputc(b1cd03d6c470d1bd).('0' + ((data[i] & '\300') >> 6), fp); |
| 616 | fputccxx . . $ fputc(b1cd03d6c470d1bd).('0' + ((data[i] & '\070') >> 3), fp); |
| 617 | fputccxx . . $ fputc(b1cd03d6c470d1bd).('0' + ((data[i] & '\007') >> 0), fp); |
| 618 | } |
| 619 | } |
| 620 | } |
| 621 | } |
| 622 | |
| 623 | |
| 624 | /* |
| 625 | * Find a node in an XML tree. This function takes an xmlNodePtr, |
| 626 | * followed by a NULL-terminated list of nodes which are required. |
| 627 | * For example stp_xml_get_node(myroot, "gutenprint", "dither") will |
| 628 | * return the first dither node in the tree. Additional dither nodes |
| 629 | * cannot be accessed with this function. |
| 630 | */ |
| 631 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# * |
| 632 | stp_xml_get_nodecxx . . $ stp_xml_get_node(a1d8ee452fb78e99).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *xmlroot, ...) |
| 633 | { |
| 634 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *child; |
| 635 | va_listcxx . . $ va_list# ap; |
| 636 | const char *target = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 637 | |
| 638 | va_startcxx . . $ `<external>/8105065126723003039/stdarg.h:50:9`!(ap, xmlroot); |
| 639 | |
| 640 | child = xmlroot; |
| 641 | target = va_argcxx . . $ `<external>/8105065126723003039/stdarg.h:53:9`!(ap, const char *); |
| 642 | |
| 643 | stp_xml_initcxx . . $ stp_xml_init(49f6e7a06ebc5aa8).(); |
| 644 | while (target && child) |
| 645 | { |
| 646 | child = stp_mxmlFindElementcxx . . $ stp_mxmlFindElement(9d3a1ee0d733a1fa).(child, child, target, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 647 | STP_MXML_DESCENDcxx . . $ `include/gutenprint/mxml.h:51:11`!); |
| 648 | target = va_argcxx . . $ `<external>/8105065126723003039/stdarg.h:53:9`!(ap, const char *); |
| 649 | } |
| 650 | stp_xml_exitcxx . . $ stp_xml_exit(49f6e7a06ebc5aa8).(); |
| 651 | va_endcxx . . $ `<external>/8105065126723003039/stdarg.h:52:9`!(ap); |
| 652 | return child; |
| 653 | } |
| 654 | |
| 655 | static void |
| 656 | stpi_xml_process_nodecxx . . $ stpi_xml_process_node(bce341e4e24d6ac9).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *node, const char *file) |
| 657 | { |
| 658 | stp_list_item_tcxx . . $ stp_list_item_t# *item = |
| 659 | stp_list_get_item_by_namecxx . . $ stp_list_get_item_by_name(27765cfe86595311).(stpi_xml_registrycxx . . $ stpi_xml_registry., node->valuecxx . . $ stp_mxml_node_s#value..elementcxx . . $ stp_mxml_value_u#element..namecxx . . $ stp_mxml_value_s#name.); |
| 660 | if (item) |
| 661 | { |
| 662 | stpi_xml_parse_registrycxx . . $ stpi_xml_parse_registry# *xmlp = |
| 663 | (stpi_xml_parse_registrycxx . . $ stpi_xml_parse_registry# *) stp_list_item_get_datacxx . . $ stp_list_item_get_data(9a5daa75441a53b5).(item); |
| 664 | (xmlp->parse_funccxx . . $ $anonymous_type_e79aca65786bdfcd_0#parse_func.)(node, file); |
| 665 | } |
| 666 | } |
| 667 | |
| 668 | /* |
| 669 | * Parse the <gutenprint> root node. |
| 670 | */ |
| 671 | static void |
| 672 | stpi_xml_process_gutenprintcxx . . $ stpi_xml_process_gutenprint(bce341e4e24d6ac9).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *cur, const char *file) /* The node to parse */ |
| 673 | { |
| 674 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *child; /* Child node pointer */ |
| 675 | |
| 676 | child = cur->childcxx . . $ stp_mxml_node_s#child.; |
| 677 | while (child) |
| 678 | { |
| 679 | /* process nodes with corresponding parser */ |
| 680 | if (child->typecxx . . $ stp_mxml_node_s#type. == STP_MXML_ELEMENTcxx . . $ STP_MXML_ELEMENT.) |
| 681 | stpi_xml_process_nodecxx . . $ stpi_xml_process_node(bce341e4e24d6ac9).(child, file); |
| 682 | child = child->nextcxx . . $ stp_mxml_node_s#next.; |
| 683 | } |
| 684 | } |
| 685 | |
| 686 | /* |
| 687 | * Create a basic gutenprint XML document tree root |
| 688 | */ |
| 689 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# * |
| 690 | stp_xmldoc_create_genericcxx . . $ stp_xmldoc_create_generic(2e406f0fc93e98f4).(void) |
| 691 | { |
| 692 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *doc; |
| 693 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *rootnode; |
| 694 | |
| 695 | stp_xml_initcxx . . $ stp_xml_init(49f6e7a06ebc5aa8).(); |
| 696 | /* Create the XML tree */ |
| 697 | doc = stp_mxmlNewElementcxx . . $ stp_mxmlNewElement(85c1b86a85cbb6d).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "?xml"); |
| 698 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(doc, "version", "1.0"); |
| 699 | |
| 700 | rootnode = stp_mxmlNewElementcxx . . $ stp_mxmlNewElement(85c1b86a85cbb6d).(doc, "gutenprint"); |
| 701 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502). |
| 702 | (rootnode, "xmlns", "http://gimp-print.sourceforge.net/xsd/gp.xsd-1.0"); |
| 703 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502). |
| 704 | (rootnode, "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); |
| 705 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502). |
| 706 | (rootnode, "xsi:schemaLocation", |
| 707 | "http://gimp-print.sourceforge.net/xsd/gp.xsd-1.0 gutenprint.xsd"); |
| 708 | stp_xml_exitcxx . . $ stp_xml_exit(49f6e7a06ebc5aa8).(); |
| 709 | |
| 710 | return doc; |
| 711 | } |
| 712 | |
| 713 | void |
| 714 | stpi_print_xml_nodecxx . . $ stpi_print_xml_node(6927777f14b5e2a1).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *node) |
| 715 | { |
| 716 | int i; |
| 717 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("Node @%p:\n", (void *) node); |
| 718 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).(" Type %d\n", node->typecxx . . $ stp_mxml_node_s#type.); |
| 719 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).(" Next @%p\n", (void *) node->nextcxx . . $ stp_mxml_node_s#next.); |
| 720 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).(" Prev @%p\n", (void *) node->prevcxx . . $ stp_mxml_node_s#prev.); |
| 721 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).(" Parent @%p\n", (void *) node->parentcxx . . $ stp_mxml_node_s#parent.); |
| 722 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).(" Child @%p\n", (void *) node->childcxx . . $ stp_mxml_node_s#child.); |
| 723 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).(" Last @%p\n", (void *) node->last_childcxx . . $ stp_mxml_node_s#last_child.); |
| 724 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).(" Value: "); |
| 725 | switch (node->typecxx . . $ stp_mxml_node_s#type.) |
| 726 | { |
| 727 | case STP_MXML_ELEMENTcxx . . $ STP_MXML_ELEMENT.: |
| 728 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("\n Element, name: %s\n", node->valuecxx . . $ stp_mxml_node_s#value..elementcxx . . $ stp_mxml_value_u#element..namecxx . . $ stp_mxml_value_s#name.); |
| 729 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).(" Attrs: %d\n", node->valuecxx . . $ stp_mxml_node_s#value..elementcxx . . $ stp_mxml_value_u#element..num_attrscxx . . $ stp_mxml_value_s#num_attrs.); |
| 730 | for (i = 0; i < node->valuecxx . . $ stp_mxml_node_s#value..elementcxx . . $ stp_mxml_value_u#element..num_attrscxx . . $ stp_mxml_value_s#num_attrs.; i++) |
| 731 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).(" %s => %s\n", |
| 732 | node->valuecxx . . $ stp_mxml_node_s#value..elementcxx . . $ stp_mxml_value_u#element..attrscxx . . $ stp_mxml_value_s#attrs.[i].namecxx . . $ stp_mxml_attr_s#name., |
| 733 | node->valuecxx . . $ stp_mxml_node_s#value..elementcxx . . $ stp_mxml_value_u#element..attrscxx . . $ stp_mxml_value_s#attrs.[i].valuecxx . . $ stp_mxml_attr_s#value.); |
| 734 | break; |
| 735 | case STP_MXML_INTEGERcxx . . $ STP_MXML_INTEGER.: |
| 736 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).(" Integer: %d\n", node->valuecxx . . $ stp_mxml_node_s#value..integercxx . . $ stp_mxml_value_u#integer.); |
| 737 | break; |
| 738 | case STP_MXML_REALcxx . . $ STP_MXML_REAL.: |
| 739 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).(" Real: %f\n", node->valuecxx . . $ stp_mxml_node_s#value..realcxx . . $ stp_mxml_value_u#real.); |
| 740 | break; |
| 741 | case STP_MXML_DIMENSIONcxx . . $ STP_MXML_DIMENSION.: |
| 742 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).(" Dimension: %f\n", node->valuecxx . . $ stp_mxml_node_s#value..realcxx . . $ stp_mxml_value_u#real.); |
| 743 | break; |
| 744 | case STP_MXML_OPAQUEcxx . . $ STP_MXML_OPAQUE.: |
| 745 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).(" Opaque: '%s'\n", node->valuecxx . . $ stp_mxml_node_s#value..opaquecxx . . $ stp_mxml_value_u#opaque.); |
| 746 | break; |
| 747 | case STP_MXML_TEXTcxx . . $ STP_MXML_TEXT.: |
| 748 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).(" Text: %d '%s'\n", node->valuecxx . . $ stp_mxml_node_s#value..textcxx . . $ stp_mxml_value_u#text..whitespacecxx . . $ stp_mxml_text_s#whitespace., |
| 749 | node->valuecxx . . $ stp_mxml_node_s#value..textcxx . . $ stp_mxml_value_u#text..stringcxx . . $ stp_mxml_text_s#string.); |
| 750 | break; |
| 751 | default: |
| 752 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("UNKNOWN!\n"); |
| 753 | } |
| 754 | } |