| 1 | /* |
| 2 | * |
| 3 | * Array data type. This type is designed to be derived from by |
| 4 | * the curve and dither matrix types. |
| 5 | * |
| 6 | * Copyright 2002-2003 Robert Krawitz ([email protected]) |
| 7 | * Copyright 2003 Roger Leigh ([email protected]) |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify it |
| 10 | * under the terms of the GNU General Public License as published by the Free |
| 11 | * Software Foundation; either version 2 of the License, or (at your option) |
| 12 | * any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, but |
| 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 16 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 17 | * for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 21 | */ |
| 22 | |
| 23 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:411:9`! |
| 24 | #include <config.h>cxx . . $ `<file>/config.h`/ |
| 25 | #endif |
| 26 | #include <gutenprint/gutenprint.h>cxx . . $ `<file>/include/gutenprint/gutenprint.h`/ |
| 27 | #include "gutenprint-internal.h"cxx . . $ `<file>/src/main/gutenprint-internal.h`/ |
| 28 | #include <gutenprint/gutenprint-intl-internal.h>cxx . . $ `<file>/include/gutenprint/gutenprint-intl-internal.h`/ |
| 29 | #include <math.h> |
| 30 | #include <string.h> |
| 31 | #include <stdlib.h> |
| 32 | #include <limits.h> |
| 33 | #include <unistd.h> |
| 34 | #include <sys/types.h> |
| 35 | #include <sys/stat.h> |
| 36 | #include <strings.h> |
| 37 | |
| 38 | |
| 39 | struct stp_arraycxx . . $ stp_array# |
| 40 | { |
| 41 | stp_sequence_tcxx . . $ stp_sequence_t# *datacxx . . $ stp_array#data.; /* First member, to allow typecasting to sequence. */ |
| 42 | int x_sizecxx . . $ stp_array#x_size.; |
| 43 | int y_sizecxx . . $ stp_array#y_size.; |
| 44 | }; |
| 45 | |
| 46 | /* |
| 47 | * We could do more sanity checks here if we want. |
| 48 | */ |
| 49 | #define CHECK_ARRAYcxx . . $ `src/main/array.c:49:9`!(array) STPI_ASSERTcxx . . $ `src/main/gutenprint-internal.h:58:9`!(array != 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`!) |
| 50 | |
| 51 | static void array_ctorcxx . . $ array_ctor(71c46815489e5a45).(stp_array_tcxx . . $ stp_array_t# *array) |
| 52 | { |
| 53 | array->datacxx . . $ stp_array#data. = stp_sequence_createcxx . . $ stp_sequence_create(c0c0907aae0ab0a0).(); |
| 54 | stp_sequence_set_sizecxx . . $ stp_sequence_set_size(cb447bd5d582db64).(array->datacxx . . $ stp_array#data., array->x_sizecxx . . $ stp_array#x_size. * array->y_sizecxx . . $ stp_array#y_size.); |
| 55 | } |
| 56 | |
| 57 | stp_array_tcxx . . $ stp_array_t# * |
| 58 | stp_array_createcxx . . $ stp_array_create(3312a96e2cd8fef).(int x_size, int y_size) |
| 59 | { |
| 60 | stp_array_tcxx . . $ stp_array_t# *ret; |
| 61 | ret = stp_zalloccxx . . $ stp_zalloc(bfcfa4d6b7f7ef64).(sizeof(stp_array_tcxx . . $ stp_array_t#)); |
| 62 | ret->x_sizecxx . . $ stp_array#x_size. = x_size; |
| 63 | ret->y_sizecxx . . $ stp_array#y_size. = y_size; |
| 64 | ret->datacxx . . $ stp_array#data. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 65 | array_ctorcxx . . $ array_ctor(71c46815489e5a45).(ret); |
| 66 | return ret; |
| 67 | } |
| 68 | |
| 69 | |
| 70 | static void |
| 71 | array_dtorcxx . . $ array_dtor(71c46815489e5a45).(stp_array_tcxx . . $ stp_array_t# *array) |
| 72 | { |
| 73 | if (array->datacxx . . $ stp_array#data.) |
| 74 | stp_sequence_destroycxx . . $ stp_sequence_destroy(58667e1f04cce976).(array->datacxx . . $ stp_array#data.); |
| 75 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(array, 0, sizeof(stp_array_tcxx . . $ stp_array_t#)); |
| 76 | } |
| 77 | |
| 78 | void |
| 79 | stp_array_destroycxx . . $ stp_array_destroy(71c46815489e5a45).(stp_array_tcxx . . $ stp_array_t# *array) |
| 80 | { |
| 81 | CHECK_ARRAYcxx . . $ `src/main/array.c:49:9`!(array); |
| 82 | array_dtorcxx . . $ array_dtor(71c46815489e5a45).(array); |
| 83 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(array); |
| 84 | } |
| 85 | |
| 86 | void |
| 87 | stp_array_copycxx . . $ stp_array_copy(11aade5881f014d6).(stp_array_tcxx . . $ stp_array_t# *dest, const stp_array_tcxx . . $ stp_array_t# *source) |
| 88 | { |
| 89 | CHECK_ARRAYcxx . . $ `src/main/array.c:49:9`!(dest); |
| 90 | CHECK_ARRAYcxx . . $ `src/main/array.c:49:9`!(source); |
| 91 | |
| 92 | dest->x_sizecxx . . $ stp_array#x_size. = source->x_sizecxx . . $ stp_array#x_size.; |
| 93 | dest->y_sizecxx . . $ stp_array#y_size. = source->y_sizecxx . . $ stp_array#y_size.; |
| 94 | if (dest->datacxx . . $ stp_array#data.) |
| 95 | stp_sequence_destroycxx . . $ stp_sequence_destroy(58667e1f04cce976).(dest->datacxx . . $ stp_array#data.); |
| 96 | dest->datacxx . . $ stp_array#data. = stp_sequence_create_copycxx . . $ stp_sequence_create_copy(e5907136df4f5f97).(source->datacxx . . $ stp_array#data.); |
| 97 | } |
| 98 | |
| 99 | stp_array_tcxx . . $ stp_array_t# * |
| 100 | stp_array_create_copycxx . . $ stp_array_create_copy(37186108ffa989df).(const stp_array_tcxx . . $ stp_array_t# *array) |
| 101 | { |
| 102 | stp_array_tcxx . . $ stp_array_t# *ret; |
| 103 | CHECK_ARRAYcxx . . $ `src/main/array.c:49:9`!(array); |
| 104 | ret = stp_array_createcxx . . $ stp_array_create(3312a96e2cd8fef).(0, 0); /* gets freed next */ |
| 105 | stp_array_copycxx . . $ stp_array_copy(11aade5881f014d6).(ret, array); |
| 106 | return ret; |
| 107 | } |
| 108 | |
| 109 | |
| 110 | void |
| 111 | stp_array_set_sizecxx . . $ stp_array_set_size(74babb51cf5b00aa).(stp_array_tcxx . . $ stp_array_t# *array, int x_size, int y_size) |
| 112 | { |
| 113 | CHECK_ARRAYcxx . . $ `src/main/array.c:49:9`!(array); |
| 114 | if (array->datacxx . . $ stp_array#data.) /* Free old data */ |
| 115 | stp_sequence_destroycxx . . $ stp_sequence_destroy(58667e1f04cce976).(array->datacxx . . $ stp_array#data.); |
| 116 | array->x_sizecxx . . $ stp_array#x_size. = x_size; |
| 117 | array->y_sizecxx . . $ stp_array#y_size. = y_size; |
| 118 | array->datacxx . . $ stp_array#data. = stp_sequence_createcxx . . $ stp_sequence_create(c0c0907aae0ab0a0).(); |
| 119 | stp_sequence_set_sizecxx . . $ stp_sequence_set_size(cb447bd5d582db64).(array->datacxx . . $ stp_array#data., array->x_sizecxx . . $ stp_array#x_size. * array->y_sizecxx . . $ stp_array#y_size.); |
| 120 | } |
| 121 | |
| 122 | void |
| 123 | stp_array_get_sizecxx . . $ stp_array_get_size(87544005943869ab).(const stp_array_tcxx . . $ stp_array_t# *array, int *x_size, int *y_size) |
| 124 | { |
| 125 | CHECK_ARRAYcxx . . $ `src/main/array.c:49:9`!(array); |
| 126 | *x_size = array->x_sizecxx . . $ stp_array#x_size.; |
| 127 | *y_size = array->y_sizecxx . . $ stp_array#y_size.; |
| 128 | return; |
| 129 | } |
| 130 | |
| 131 | void |
| 132 | stp_array_set_datacxx . . $ stp_array_set_data(6a451208afab017d).(stp_array_tcxx . . $ stp_array_t# *array, const double *data) |
| 133 | { |
| 134 | CHECK_ARRAYcxx . . $ `src/main/array.c:49:9`!(array); |
| 135 | stp_sequence_set_datacxx . . $ stp_sequence_set_data(eaf6acc80580ab39).(array->datacxx . . $ stp_array#data., array->x_sizecxx . . $ stp_array#x_size. * array->y_sizecxx . . $ stp_array#y_size., |
| 136 | data); |
| 137 | } |
| 138 | |
| 139 | void |
| 140 | stp_array_get_datacxx . . $ stp_array_get_data(2467a0d58b908ca6).(const stp_array_tcxx . . $ stp_array_t# *array, size_t *size, const double **data) |
| 141 | { |
| 142 | CHECK_ARRAYcxx . . $ `src/main/array.c:49:9`!(array); |
| 143 | stp_sequence_get_datacxx . . $ stp_sequence_get_data(5acce6d1b35abc9a).(array->datacxx . . $ stp_array#data., size, data); |
| 144 | } |
| 145 | |
| 146 | int |
| 147 | stp_array_set_pointcxx . . $ stp_array_set_point(ae72de3a930e93bb).(stp_array_tcxx . . $ stp_array_t# *array, int x, int y, double data) |
| 148 | { |
| 149 | CHECK_ARRAYcxx . . $ `src/main/array.c:49:9`!(array); |
| 150 | |
| 151 | if (((array->x_sizecxx . . $ stp_array#x_size. * x) + y) >= (array->x_sizecxx . . $ stp_array#x_size. * array->y_sizecxx . . $ stp_array#y_size.)) |
| 152 | return 0; |
| 153 | |
| 154 | return stp_sequence_set_pointcxx . . $ stp_sequence_set_point(e632f4aa9a6329ba).(array->datacxx . . $ stp_array#data., (array->x_sizecxx . . $ stp_array#x_size. * x) + y, data);} |
| 155 | |
| 156 | int |
| 157 | stp_array_get_pointcxx . . $ stp_array_get_point(cdb7dafdef7a3ec0).(const stp_array_tcxx . . $ stp_array_t# *array, int x, int y, double *data) |
| 158 | { |
| 159 | CHECK_ARRAYcxx . . $ `src/main/array.c:49:9`!(array); |
| 160 | |
| 161 | if (((array->x_sizecxx . . $ stp_array#x_size. * x) + y) >= array->x_sizecxx . . $ stp_array#x_size. * array->y_sizecxx . . $ stp_array#y_size.) |
| 162 | return 0; |
| 163 | return stp_sequence_get_pointcxx . . $ stp_sequence_get_point(dd05bfc28554384c).(array->datacxx . . $ stp_array#data., |
| 164 | (array->x_sizecxx . . $ stp_array#x_size. * x) + y, data); |
| 165 | } |
| 166 | |
| 167 | const stp_sequence_tcxx . . $ stp_sequence_t# * |
| 168 | stp_array_get_sequencecxx . . $ stp_array_get_sequence(38ecccb1b7a939c6).(const stp_array_tcxx . . $ stp_array_t# *array) |
| 169 | { |
| 170 | CHECK_ARRAYcxx . . $ `src/main/array.c:49:9`!(array); |
| 171 | |
| 172 | return array->datacxx . . $ stp_array#data.; |
| 173 | } |
| 174 | |
| 175 | static stp_array_tcxx . . $ stp_array_t# * |
| 176 | xml_doc_get_arraycxx . . $ xml_doc_get_array(ca9ac7ca662c1ab8).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *doc) |
| 177 | { |
| 178 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *cur; |
| 179 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *xmlarray; |
| 180 | stp_array_tcxx . . $ stp_array_t# *array = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 181 | |
| 182 | if (doc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 183 | { |
| 184 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3).(STP_DBG_ARRAY_ERRORScxx . . $ `include/gutenprint/util.h:192:9`!, |
| 185 | "xml_doc_get_array: XML file not parsed successfully.\n"); |
| 186 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 187 | } |
| 188 | |
| 189 | cur = doc->childcxx . . $ stp_mxml_node_s#child.; |
| 190 | |
| 191 | if (cur == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 192 | { |
| 193 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3).(STP_DBG_ARRAY_ERRORScxx . . $ `include/gutenprint/util.h:192:9`!, |
| 194 | "xml_doc_get_array: empty document\n"); |
| 195 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 196 | } |
| 197 | |
| 198 | xmlarray = stp_xml_get_nodecxx . . $ stp_xml_get_node(a1d8ee452fb78e99).(cur, "gutenprint", "array", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 199 | |
| 200 | if (xmlarray) |
| 201 | array = stp_array_create_from_xmltreecxx . . $ stp_array_create_from_xmltree(ca9ac7ca662c1ab8).(xmlarray); |
| 202 | |
| 203 | return array; |
| 204 | } |
| 205 | |
| 206 | stp_array_tcxx . . $ stp_array_t# * |
| 207 | stp_array_create_from_filecxx . . $ stp_array_create_from_file(c5329b465f7335df).(const char* file) |
| 208 | { |
| 209 | stp_array_tcxx . . $ stp_array_t# *array = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 210 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *doc; |
| 211 | FILEcxx . . $ FILE# *fp = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 212 | if (file[0] != '/' && strncmpcxx . . $ strncmp(fd278af2f295fa2e).(file, "./", 2) && strncmpcxx . . $ strncmp(fd278af2f295fa2e).(file, "../", 3)) |
| 213 | { |
| 214 | char *fn = stp_path_find_filecxx . . $ stp_path_find_file(a713fe7b9a57cf96).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, file); |
| 215 | if (fn) |
| 216 | { |
| 217 | fp = fopencxx . . $ fopen(82ec0787cd37e0a3).(file, "r"); |
| 218 | freecxx . . $ free(5d22bdacc48458e8).(fn); |
| 219 | } |
| 220 | } |
| 221 | else if (file) |
| 222 | { |
| 223 | fp = fopencxx . . $ fopen(82ec0787cd37e0a3).(file, "r"); |
| 224 | } |
| 225 | if (!fp) |
| 226 | { |
| 227 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3).(STP_DBG_ARRAY_ERRORScxx . . $ `include/gutenprint/util.h:192:9`!, |
| 228 | "stp_array_create_from_file: unable to open %s: %s\n", |
| 229 | file, strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 230 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 231 | } |
| 232 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3).(STP_DBG_XMLcxx . . $ `include/gutenprint/util.h:182:9`!, "stp_array_create_from_file: reading `%s'...\n", |
| 233 | file); |
| 234 | |
| 235 | stp_xml_initcxx . . $ stp_xml_init(49f6e7a06ebc5aa8).(); |
| 236 | |
| 237 | doc = stp_mxmlLoadFilecxx . . $ stp_mxmlLoadFile(3a8302cc33115af5).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, fp, STP_MXML_NO_CALLBACKcxx . . $ `include/gutenprint/mxml.h:48:11`!); |
| 238 | |
| 239 | array = xml_doc_get_arraycxx . . $ xml_doc_get_array(ca9ac7ca662c1ab8).(doc); |
| 240 | |
| 241 | if (doc) |
| 242 | stp_mxmlDeletecxx . . $ stp_mxmlDelete(6927777f14b5e2a1).(doc); |
| 243 | |
| 244 | stp_xml_exitcxx . . $ stp_xml_exit(49f6e7a06ebc5aa8).(); |
| 245 | (void) fclosecxx . . $ fclose(89bc1efcdac0ca22).(fp); |
| 246 | return array; |
| 247 | |
| 248 | } |
| 249 | |
| 250 | stp_array_tcxx . . $ stp_array_t# * |
| 251 | stp_array_create_from_xmltreecxx . . $ stp_array_create_from_xmltree(ca9ac7ca662c1ab8).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *array) /* The array node */ |
| 252 | { |
| 253 | const char *stmp; /* Temporary string */ |
| 254 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *child; /* Child sequence node */ |
| 255 | unsigned int x_size, y_size; |
| 256 | size_t count; |
| 257 | stp_sequence_tcxx . . $ stp_sequence_t# *seq = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 258 | stp_array_tcxx . . $ stp_array_t# *ret = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 259 | |
| 260 | /* FIXME Need protection against unlimited recursion */ |
| 261 | if ((stmp = stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(array, "src")) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 262 | return stp_array_create_from_filecxx . . $ stp_array_create_from_file(c5329b465f7335df).(stmp); |
| 263 | stmp = stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(array, "x-size"); |
| 264 | if (stmp) |
| 265 | { |
| 266 | x_size = (int) strtoulcxx . . $ strtoul(31746e8d6ec49860).(stmp, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0); |
| 267 | } |
| 268 | else |
| 269 | { |
| 270 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("stp_array_create_from_xmltree: \"x-size\" missing\n"); |
| 271 | goto error; |
| 272 | } |
| 273 | /* Get y-size */ |
| 274 | stmp = stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(array, "y-size"); |
| 275 | if (stmp) |
| 276 | { |
| 277 | y_size = (int) strtoulcxx . . $ strtoul(31746e8d6ec49860).(stmp, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0); |
| 278 | } |
| 279 | else |
| 280 | { |
| 281 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("stp_array_create_from_xmltree: \"y-size\" missing\n"); |
| 282 | goto error; |
| 283 | } |
| 284 | |
| 285 | /* Get the sequence data */ |
| 286 | |
| 287 | child = stp_xml_get_nodecxx . . $ stp_xml_get_node(a1d8ee452fb78e99).(array, "sequence", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 288 | if (child) |
| 289 | seq = stp_sequence_create_from_xmltreecxx . . $ stp_sequence_create_from_xmltree(46d170727e408206).(child); |
| 290 | |
| 291 | if (seq == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 292 | goto error; |
| 293 | |
| 294 | ret = stp_array_createcxx . . $ stp_array_create(3312a96e2cd8fef).(x_size, y_size); |
| 295 | if (ret->datacxx . . $ stp_array#data.) |
| 296 | stp_sequence_destroycxx . . $ stp_sequence_destroy(58667e1f04cce976).(ret->datacxx . . $ stp_array#data.); |
| 297 | ret->datacxx . . $ stp_array#data. = seq; |
| 298 | |
| 299 | count = stp_sequence_get_sizecxx . . $ stp_sequence_get_size(57c44cb7f90fb5bc).(seq); |
| 300 | if (count != (x_size * y_size)) |
| 301 | { |
| 302 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("stp_array_create_from_xmltree: size mismatch between array and sequence\n"); |
| 303 | goto error; |
| 304 | } |
| 305 | |
| 306 | return ret; |
| 307 | |
| 308 | error: |
| 309 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("stp_array_create_from_xmltree: error during array read\n"); |
| 310 | if (ret) |
| 311 | stp_array_destroycxx . . $ stp_array_destroy(71c46815489e5a45).(ret); |
| 312 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 313 | } |
| 314 | |
| 315 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# * |
| 316 | stp_xmltree_create_from_arraycxx . . $ stp_xmltree_create_from_array(c19231002c449293).(const stp_array_tcxx . . $ stp_array_t# *array) /* The array */ |
| 317 | { |
| 318 | int x_size, y_size; |
| 319 | char *xs, *ys; |
| 320 | |
| 321 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *arraynode = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 322 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *child = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 323 | |
| 324 | stp_xml_initcxx . . $ stp_xml_init(49f6e7a06ebc5aa8).(); |
| 325 | |
| 326 | /* Get array details */ |
| 327 | stp_array_get_sizecxx . . $ stp_array_get_size(87544005943869ab).(array, &x_size, &y_size); |
| 328 | |
| 329 | /* Construct the allocated strings required */ |
| 330 | stp_asprintfcxx . . $ stp_asprintf(816f0239e6d49b84).(&xs, "%d", x_size); |
| 331 | stp_asprintfcxx . . $ stp_asprintf(816f0239e6d49b84).(&ys, "%d", y_size); |
| 332 | |
| 333 | arraynode = stp_mxmlNewElementcxx . . $ stp_mxmlNewElement(85c1b86a85cbb6d).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, "array"); |
| 334 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(arraynode, "x-size", xs); |
| 335 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(arraynode, "y-size", ys); |
| 336 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(xs); |
| 337 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(ys); |
| 338 | |
| 339 | child = stp_xmltree_create_from_sequencecxx . . $ stp_xmltree_create_from_sequence(5a8928e2ae29fea3).(stp_array_get_sequencecxx . . $ stp_array_get_sequence(38ecccb1b7a939c6).(array)); |
| 340 | |
| 341 | if (child) |
| 342 | stp_mxmlAddcxx . . $ stp_mxmlAdd(bd5d61ecf5707a05).(arraynode, STP_MXML_ADD_AFTERcxx . . $ `include/gutenprint/mxml.h:61:11`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, child); |
| 343 | else |
| 344 | { |
| 345 | stp_mxmlDeletecxx . . $ stp_mxmlDelete(6927777f14b5e2a1).(arraynode); |
| 346 | arraynode = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 347 | } |
| 348 | |
| 349 | stp_xml_exitcxx . . $ stp_xml_exit(49f6e7a06ebc5aa8).(); |
| 350 | |
| 351 | return arraynode; |
| 352 | } |
| 353 | |
| 354 | static stp_mxml_node_tcxx . . $ stp_mxml_node_t# * |
| 355 | xmldoc_create_from_arraycxx . . $ xmldoc_create_from_array(c19231002c449293).(const stp_array_tcxx . . $ stp_array_t# *array) |
| 356 | { |
| 357 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *xmldoc; |
| 358 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *rootnode; |
| 359 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *arraynode; |
| 360 | |
| 361 | /* Get array details */ |
| 362 | arraynode = stp_xmltree_create_from_arraycxx . . $ stp_xmltree_create_from_array(c19231002c449293).(array); |
| 363 | if (arraynode == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 364 | { |
| 365 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3).(STP_DBG_ARRAY_ERRORScxx . . $ `include/gutenprint/util.h:192:9`!, |
| 366 | "xmldoc_create_from_array: error creating array node\n"); |
| 367 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 368 | } |
| 369 | /* Create the XML tree */ |
| 370 | xmldoc = stp_xmldoc_create_genericcxx . . $ stp_xmldoc_create_generic(2e406f0fc93e98f4).(); |
| 371 | if (xmldoc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 372 | { |
| 373 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3).(STP_DBG_ARRAY_ERRORScxx . . $ `include/gutenprint/util.h:192:9`!, |
| 374 | "xmldoc_create_from_array: error creating XML document\n"); |
| 375 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 376 | } |
| 377 | rootnode = xmldoc->childcxx . . $ stp_mxml_node_s#child.; |
| 378 | if (rootnode == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 379 | { |
| 380 | stp_mxmlDeletecxx . . $ stp_mxmlDelete(6927777f14b5e2a1).(xmldoc); |
| 381 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3).(STP_DBG_ARRAY_ERRORScxx . . $ `include/gutenprint/util.h:192:9`!, |
| 382 | "xmldoc_create_from_array: error getting XML document root node\n"); |
| 383 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 384 | } |
| 385 | |
| 386 | stp_mxmlAddcxx . . $ stp_mxmlAdd(bd5d61ecf5707a05).(rootnode, STP_MXML_ADD_AFTERcxx . . $ `include/gutenprint/mxml.h:61:11`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, arraynode); |
| 387 | |
| 388 | return xmldoc; |
| 389 | } |
| 390 | |
| 391 | static int |
| 392 | array_whitespace_callbackcxx . . $ array_whitespace_callback(90e46f0b0341a80e).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *node, int where) |
| 393 | { |
| 394 | if (node->typecxx . . $ stp_mxml_node_s#type. != STP_MXML_ELEMENTcxx . . $ STP_MXML_ELEMENT.) |
| 395 | return 0; |
| 396 | if (strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(node->valuecxx . . $ stp_mxml_node_s#value..elementcxx . . $ stp_mxml_value_u#element..namecxx . . $ stp_mxml_value_s#name., "gutenprint") == 0) |
| 397 | { |
| 398 | switch (where) |
| 399 | { |
| 400 | case STP_MXML_WS_AFTER_OPENcxx . . $ `include/gutenprint/mxml.h:56:11`!: |
| 401 | case STP_MXML_WS_BEFORE_CLOSEcxx . . $ `include/gutenprint/mxml.h:57:11`!: |
| 402 | case STP_MXML_WS_AFTER_CLOSEcxx . . $ `include/gutenprint/mxml.h:58:11`!: |
| 403 | return '\n'; |
| 404 | case STP_MXML_WS_BEFORE_OPENcxx . . $ `include/gutenprint/mxml.h:55:11`!: |
| 405 | default: |
| 406 | return 0; |
| 407 | } |
| 408 | } |
| 409 | else if (strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(node->valuecxx . . $ stp_mxml_node_s#value..elementcxx . . $ stp_mxml_value_u#element..namecxx . . $ stp_mxml_value_s#name., "array") == 0) |
| 410 | { |
| 411 | switch (where) |
| 412 | { |
| 413 | case STP_MXML_WS_AFTER_OPENcxx . . $ `include/gutenprint/mxml.h:56:11`!: |
| 414 | return '\n'; |
| 415 | case STP_MXML_WS_BEFORE_CLOSEcxx . . $ `include/gutenprint/mxml.h:57:11`!: |
| 416 | case STP_MXML_WS_AFTER_CLOSEcxx . . $ `include/gutenprint/mxml.h:58:11`!: |
| 417 | case STP_MXML_WS_BEFORE_OPENcxx . . $ `include/gutenprint/mxml.h:55:11`!: |
| 418 | default: |
| 419 | return 0; |
| 420 | } |
| 421 | } |
| 422 | else if (strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(node->valuecxx . . $ stp_mxml_node_s#value..elementcxx . . $ stp_mxml_value_u#element..namecxx . . $ stp_mxml_value_s#name., "sequence") == 0) |
| 423 | { |
| 424 | const char *count; |
| 425 | switch (where) |
| 426 | { |
| 427 | case STP_MXML_WS_BEFORE_CLOSEcxx . . $ `include/gutenprint/mxml.h:57:11`!: |
| 428 | count = stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(node, "count"); |
| 429 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(count, "0") == 0) |
| 430 | return 0; |
| 431 | else |
| 432 | return '\n'; |
| 433 | case STP_MXML_WS_AFTER_OPENcxx . . $ `include/gutenprint/mxml.h:56:11`!: |
| 434 | case STP_MXML_WS_AFTER_CLOSEcxx . . $ `include/gutenprint/mxml.h:58:11`!: |
| 435 | return '\n'; |
| 436 | case STP_MXML_WS_BEFORE_OPENcxx . . $ `include/gutenprint/mxml.h:55:11`!: |
| 437 | default: |
| 438 | return 0; |
| 439 | } |
| 440 | } |
| 441 | else |
| 442 | return 0; |
| 443 | } |
| 444 | |
| 445 | |
| 446 | int |
| 447 | stp_array_writecxx . . $ stp_array_write(4ac80873794eca50).(FILEcxx . . $ FILE# *file, const stp_array_tcxx . . $ stp_array_t# *array) /* The array */ |
| 448 | { |
| 449 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *xmldoc = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 450 | |
| 451 | stp_xml_initcxx . . $ stp_xml_init(49f6e7a06ebc5aa8).(); |
| 452 | |
| 453 | xmldoc = xmldoc_create_from_arraycxx . . $ xmldoc_create_from_array(c19231002c449293).(array); |
| 454 | if (xmldoc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 455 | { |
| 456 | stp_xml_exitcxx . . $ stp_xml_exit(49f6e7a06ebc5aa8).(); |
| 457 | return 1; |
| 458 | } |
| 459 | |
| 460 | stp_mxmlSaveFilecxx . . $ stp_mxmlSaveFile(9223bc6fc3a01114).(xmldoc, file, array_whitespace_callbackcxx . . $ array_whitespace_callback(90e46f0b0341a80e).); |
| 461 | |
| 462 | if (xmldoc) |
| 463 | stp_mxmlDeletecxx . . $ stp_mxmlDelete(6927777f14b5e2a1).(xmldoc); |
| 464 | |
| 465 | stp_xml_exitcxx . . $ stp_xml_exit(49f6e7a06ebc5aa8).(); |
| 466 | |
| 467 | return 0; |
| 468 | } |
| 469 | |
| 470 | char * |
| 471 | stp_array_write_stringcxx . . $ stp_array_write_string(83dccbe0cb2c3bc7).(const stp_array_tcxx . . $ stp_array_t# *array) /* The array */ |
| 472 | { |
| 473 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *xmldoc = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 474 | char *retval; |
| 475 | |
| 476 | stp_xml_initcxx . . $ stp_xml_init(49f6e7a06ebc5aa8).(); |
| 477 | |
| 478 | xmldoc = xmldoc_create_from_arraycxx . . $ xmldoc_create_from_array(c19231002c449293).(array); |
| 479 | if (xmldoc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 480 | { |
| 481 | stp_xml_exitcxx . . $ stp_xml_exit(49f6e7a06ebc5aa8).(); |
| 482 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 483 | } |
| 484 | |
| 485 | retval = stp_mxmlSaveAllocStringcxx . . $ stp_mxmlSaveAllocString(a1f48baf55c04762).(xmldoc, array_whitespace_callbackcxx . . $ array_whitespace_callback(90e46f0b0341a80e).); |
| 486 | |
| 487 | if (xmldoc) |
| 488 | stp_mxmlDeletecxx . . $ stp_mxmlDelete(6927777f14b5e2a1).(xmldoc); |
| 489 | |
| 490 | stp_xml_exitcxx . . $ stp_xml_exit(49f6e7a06ebc5aa8).(); |
| 491 | |
| 492 | return retval; |
| 493 | } |