| 1 | /* |
| 2 | * |
| 3 | * Print plug-in driver utility functions for the GIMP. |
| 4 | * |
| 5 | * Copyright 1997-2000 Michael Sweet ([email protected]) and |
| 6 | * Robert Krawitz ([email protected]) |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public License as published by the Free |
| 10 | * Software Foundation; either version 2 of the License, or (at your option) |
| 11 | * any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, but |
| 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 15 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 16 | * for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This file must include only standard C header files. The core code must |
| 24 | * compile on generic platforms that don't support glib, gimp, gtk, etc. |
| 25 | */ |
| 26 | |
| 27 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:411:9`! |
| 28 | #include <config.h>cxx . . $ `<file>/config.h`/ |
| 29 | #endif |
| 30 | #include <gutenprint/gutenprint.h>cxx . . $ `<file>/include/gutenprint/gutenprint.h`/ |
| 31 | #include "gutenprint-internal.h"cxx . . $ `<file>/src/main/gutenprint-internal.h`/ |
| 32 | #include <gutenprint/gutenprint-intl-internal.h>cxx . . $ `<file>/include/gutenprint/gutenprint-intl-internal.h`/ |
| 33 | #include <math.h> |
| 34 | #ifdef HAVE_LIMITS_Hcxx . . $ `config.h:94:9`! |
| 35 | #include <limits.h> |
| 36 | #endif |
| 37 | #include <string.h> |
| 38 | #include <stdlib.h> |
| 39 | #include <sys/param.h> |
| 40 | |
| 41 | typedef structcxx . . $ $anonymous_type_51d68c5e9adc72d3_0# |
| 42 | { |
| 43 | char *namecxx . . $ $anonymous_type_51d68c5e9adc72d3_0#name.; |
| 44 | stp_papersize_list_tcxx . . $ stp_papersize_list_t# *listcxx . . $ $anonymous_type_51d68c5e9adc72d3_0#list.; |
| 45 | } papersize_list_impl_tcxx . . $ papersize_list_impl_t#; |
| 46 | |
| 47 | static stp_list_tcxx . . $ stp_list_t# *list_of_papersize_listscxx . . $ list_of_papersize_lists. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 48 | |
| 49 | static void |
| 50 | papersize_list_impl_freefunccxx . . $ papersize_list_impl_freefunc(5d22bdacc48458e8).(void *item) |
| 51 | { |
| 52 | papersize_list_impl_tcxx . . $ papersize_list_impl_t# *papersize_list = (papersize_list_impl_tcxx . . $ papersize_list_impl_t# *) item; |
| 53 | stp_list_destroycxx . . $ stp_list_destroy(29ae8ff464c7f7e5).(papersize_list->listcxx . . $ $anonymous_type_51d68c5e9adc72d3_0#list.); |
| 54 | STP_SAFE_FREEcxx . . $ `include/gutenprint/util.h:210:9`!(papersize_list->name); |
| 55 | STP_SAFE_FREEcxx . . $ `include/gutenprint/util.h:210:9`!(papersize_list); |
| 56 | } |
| 57 | |
| 58 | static const char * |
| 59 | papersize_list_impl_namefunccxx . . $ papersize_list_impl_namefunc(6271d96ae060557f).(const void *item) |
| 60 | { |
| 61 | return ((const papersize_list_impl_tcxx . . $ papersize_list_impl_t# *) item)->namecxx . . $ $anonymous_type_51d68c5e9adc72d3_0#name.; |
| 62 | } |
| 63 | |
| 64 | static const char * |
| 65 | papersize_list_impl_long_namefunccxx . . $ papersize_list_impl_long_namefunc(6271d96ae060557f).(const void *item) |
| 66 | { |
| 67 | return ((const papersize_list_impl_tcxx . . $ papersize_list_impl_t# *) item)->namecxx . . $ $anonymous_type_51d68c5e9adc72d3_0#name.; |
| 68 | } |
| 69 | |
| 70 | static void |
| 71 | check_list_of_papersize_listscxx . . $ check_list_of_papersize_lists(49f6e7a06ebc5aa8).(void) |
| 72 | { |
| 73 | if (! list_of_papersize_listscxx . . $ list_of_papersize_lists.) |
| 74 | { |
| 75 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3).(STP_DBG_PAPERcxx . . $ `include/gutenprint/util.h:180:9`!, "Initializing...\n"); |
| 76 | list_of_papersize_listscxx . . $ list_of_papersize_lists. = stp_list_createcxx . . $ stp_list_create(728167c67729d082).(); |
| 77 | stp_list_set_freefunccxx . . $ stp_list_set_freefunc(309a84c3f950ef37).(list_of_papersize_listscxx . . $ list_of_papersize_lists., papersize_list_impl_freefunccxx . . $ papersize_list_impl_freefunc(5d22bdacc48458e8).); |
| 78 | stp_list_set_namefunccxx . . $ stp_list_set_namefunc(83503c4472347457).(list_of_papersize_listscxx . . $ list_of_papersize_lists., papersize_list_impl_namefunccxx . . $ papersize_list_impl_namefunc(6271d96ae060557f).); |
| 79 | stp_list_set_long_namefunccxx . . $ stp_list_set_long_namefunc(83503c4472347457).(list_of_papersize_listscxx . . $ list_of_papersize_lists., papersize_list_impl_long_namefunccxx . . $ papersize_list_impl_long_namefunc(6271d96ae060557f).); |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | static void |
| 84 | stpi_papersize_freefunccxx . . $ stpi_papersize_freefunc(5d22bdacc48458e8).(void *item) |
| 85 | { |
| 86 | stp_papersize_tcxx . . $ stp_papersize_t# *paper = (stp_papersize_tcxx . . $ stp_papersize_t# *) (item); |
| 87 | #pragma GCC diagnostic push |
| 88 | #pragma GCC diagnostic ignored "-Wcast-qual" |
| 89 | STP_SAFE_FREEcxx . . $ `include/gutenprint/util.h:210:9`!(paper->name); |
| 90 | STP_SAFE_FREEcxx . . $ `include/gutenprint/util.h:210:9`!(paper->text); |
| 91 | STP_SAFE_FREEcxx . . $ `include/gutenprint/util.h:210:9`!(paper->comment); |
| 92 | #pragma GCC diagnostic pop |
| 93 | STP_SAFE_FREEcxx . . $ `include/gutenprint/util.h:210:9`!(paper); |
| 94 | } |
| 95 | |
| 96 | static const char * |
| 97 | stpi_papersize_namefunccxx . . $ stpi_papersize_namefunc(6271d96ae060557f).(const void *item) |
| 98 | { |
| 99 | const stp_papersize_tcxx . . $ stp_papersize_t# *paper = (const stp_papersize_tcxx . . $ stp_papersize_t# *) (item); |
| 100 | return paper->namecxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#name.; |
| 101 | } |
| 102 | |
| 103 | static const char * |
| 104 | stpi_papersize_long_namefunccxx . . $ stpi_papersize_long_namefunc(6271d96ae060557f).(const void *item) |
| 105 | { |
| 106 | const stp_papersize_tcxx . . $ stp_papersize_t# *paper = (const stp_papersize_tcxx . . $ stp_papersize_t# *) (item); |
| 107 | return paper->textcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#text.; |
| 108 | } |
| 109 | |
| 110 | stp_papersize_list_tcxx . . $ stp_papersize_list_t# * |
| 111 | stpi_create_papersize_listcxx . . $ stpi_create_papersize_list(728167c67729d082).(void) |
| 112 | { |
| 113 | stp_list_tcxx . . $ stp_list_t# *papersize_list = stp_list_createcxx . . $ stp_list_create(728167c67729d082).(); |
| 114 | stp_list_set_freefunccxx . . $ stp_list_set_freefunc(309a84c3f950ef37).(papersize_list, stpi_papersize_freefunccxx . . $ stpi_papersize_freefunc(5d22bdacc48458e8).); |
| 115 | stp_list_set_namefunccxx . . $ stp_list_set_namefunc(83503c4472347457).(papersize_list, stpi_papersize_namefunccxx . . $ stpi_papersize_namefunc(6271d96ae060557f).); |
| 116 | stp_list_set_long_namefunccxx . . $ stp_list_set_long_namefunc(83503c4472347457).(papersize_list, stpi_papersize_long_namefunccxx . . $ stpi_papersize_long_namefunc(6271d96ae060557f).); |
| 117 | return (stp_papersize_list_tcxx . . $ stp_papersize_list_t# *) papersize_list; |
| 118 | } |
| 119 | |
| 120 | int |
| 121 | stpi_papersize_createcxx . . $ stpi_papersize_create(57cbead4fcb67a71).(stp_papersize_list_tcxx . . $ stp_papersize_list_t# *list, stp_papersize_tcxx . . $ stp_papersize_t# *p) |
| 122 | { |
| 123 | stp_list_item_tcxx . . $ stp_list_item_t# *papersize_item; |
| 124 | |
| 125 | /* |
| 126 | * Check the paper does not already exist |
| 127 | * Not the most efficient way of doing it, but the number of papers |
| 128 | * is not large enough to be a significant bottleneck. |
| 129 | */ |
| 130 | papersize_item = stp_list_get_startcxx . . $ stp_list_get_start(44f6202a74729935).(list); |
| 131 | while (papersize_item) |
| 132 | { |
| 133 | const stp_papersize_tcxx . . $ stp_papersize_t# *ep = |
| 134 | (const stp_papersize_tcxx . . $ stp_papersize_t# *) stp_list_item_get_datacxx . . $ stp_list_item_get_data(9a5daa75441a53b5).(papersize_item); |
| 135 | if (ep && !strcmpcxx . . $ strcmp(5ae29d726ae57f88).(p->namecxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#name., ep->namecxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#name.)) |
| 136 | { |
| 137 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("Duplicate paper size `%s'\n", p->namecxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#name.); |
| 138 | stpi_papersize_freefunccxx . . $ stpi_papersize_freefunc(5d22bdacc48458e8).(p); |
| 139 | return 1; |
| 140 | } |
| 141 | papersize_item = stp_list_item_nextcxx . . $ stp_list_item_next(83833ec172b48f23).(papersize_item); |
| 142 | } |
| 143 | |
| 144 | /* Add paper to list */ |
| 145 | stp_list_item_createcxx . . $ stp_list_item_create(54f08bf465e39eec).(list, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, (void *) p); |
| 146 | |
| 147 | return 0; |
| 148 | } |
| 149 | |
| 150 | int |
| 151 | stpi_papersize_countcxx . . $ stpi_papersize_count(c31cc8fb9e1f67aa).(const stp_papersize_list_tcxx . . $ stp_papersize_list_t# *paper_size_list) |
| 152 | { |
| 153 | return stp_list_get_lengthcxx . . $ stp_list_get_length(c31cc8fb9e1f67aa).(paper_size_list); |
| 154 | } |
| 155 | |
| 156 | const stp_papersize_tcxx . . $ stp_papersize_t# * |
| 157 | stpi_get_papersize_by_namecxx . . $ stpi_get_papersize_by_name(6661a5a01ab7b09d).(const stp_papersize_list_tcxx . . $ stp_papersize_list_t# *list, const char *name) |
| 158 | { |
| 159 | stp_list_item_tcxx . . $ stp_list_item_t# *paper; |
| 160 | |
| 161 | paper = stp_list_get_item_by_namecxx . . $ stp_list_get_item_by_name(27765cfe86595311).(list, name); |
| 162 | if (!paper) |
| 163 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 164 | else |
| 165 | return (const stp_papersize_tcxx . . $ stp_papersize_t# *) stp_list_item_get_datacxx . . $ stp_list_item_get_data(9a5daa75441a53b5).(paper); |
| 166 | } |
| 167 | |
| 168 | const stp_papersize_tcxx . . $ stp_papersize_t# * |
| 169 | stpi_get_listed_papersizecxx . . $ stpi_get_listed_papersize(49f21dd3ffd9359c).(const char *name, const char *papersize_list) |
| 170 | { |
| 171 | const stp_papersize_list_tcxx . . $ stp_papersize_list_t# *list = |
| 172 | stpi_get_papersize_list_namedcxx . . $ stpi_get_papersize_list_named(81f88378de3f2d3).(papersize_list, ""); |
| 173 | if (list) |
| 174 | return stpi_get_papersize_by_namecxx . . $ stpi_get_papersize_by_name(6661a5a01ab7b09d).(list, name); |
| 175 | else |
| 176 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 177 | } |
| 178 | |
| 179 | const stp_papersize_tcxx . . $ stp_papersize_t# * |
| 180 | stpi_standard_describe_papersizecxx . . $ stpi_standard_describe_papersize(977e5bf217e59ec).(const stp_vars_tcxx . . $ stp_vars_t# *v, const char *name) |
| 181 | { |
| 182 | STPI_ASSERTcxx . . $ `src/main/gutenprint-internal.h:58:9`!(v, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 183 | return stpi_get_listed_papersizecxx . . $ stpi_get_listed_papersize(49f21dd3ffd9359c).(name, "standard"); |
| 184 | } |
| 185 | |
| 186 | const stp_papersize_tcxx . . $ stp_papersize_t# * |
| 187 | stp_describe_papersizecxx . . $ stp_describe_papersize(977e5bf217e59ec).(const stp_vars_tcxx . . $ stp_vars_t# *v, const char *name) |
| 188 | { |
| 189 | return stpi_printer_describe_papersizecxx . . $ stpi_printer_describe_papersize(977e5bf217e59ec).(v, name); |
| 190 | } |
| 191 | |
| 192 | static int |
| 193 | papersize_size_mismatchcxx . . $ papersize_size_mismatch(8864420f1a93b895).(stp_dimension_tcxx . . $ stp_dimension_t# l, stp_dimension_tcxx . . $ stp_dimension_t# w, |
| 194 | const stp_papersize_tcxx . . $ stp_papersize_t# *val) |
| 195 | { |
| 196 | stp_dimension_tcxx . . $ stp_dimension_t# hdiff = STP_DABScxx . . $ `include/gutenprint/types.h:33:9`!(l - (stp_dimension_tcxx . . $ stp_dimension_t#) val->heightcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#height.); |
| 197 | stp_dimension_tcxx . . $ stp_dimension_t# vdiff = STP_DABScxx . . $ `include/gutenprint/types.h:33:9`!(w - (stp_dimension_tcxx . . $ stp_dimension_t#) val->widthcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#width.); |
| 198 | return hdiff > vdiff ? hdiff : vdiff; |
| 199 | } |
| 200 | |
| 201 | static const stp_papersize_tcxx . . $ stp_papersize_t# * |
| 202 | get_papersize_by_size_internalcxx . . $ get_papersize_by_size_internal(92573c218850ec06).(const stp_papersize_list_tcxx . . $ stp_papersize_list_t# *list, |
| 203 | stp_dimension_tcxx . . $ stp_dimension_t# l, stp_dimension_tcxx . . $ stp_dimension_t# w, |
| 204 | int exact) |
| 205 | { |
| 206 | int score = INT_MAXcxx . . $ `<external>/67164224788392828/limits.h:120:9`!; |
| 207 | const stp_papersize_tcxx . . $ stp_papersize_t# *ref = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 208 | const stp_papersize_tcxx . . $ stp_papersize_t# *val = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 209 | const stp_papersize_list_item_tcxx . . $ stp_papersize_list_item_t# *ptli = |
| 210 | stpi_papersize_list_get_startcxx . . $ `src/main/gutenprint-internal.h:121:9`!(list); |
| 211 | STPI_ASSERTcxx . . $ `src/main/gutenprint-internal.h:58:9`!(list, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 212 | while (ptli) |
| 213 | { |
| 214 | val = stpi_paperlist_item_get_datacxx . . $ `src/main/gutenprint-internal.h:125:9`!(ptli); |
| 215 | |
| 216 | if (val->widthcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#width. == w && val->heightcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#height. == l) |
| 217 | { |
| 218 | if (val->topcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#top. == 0 && val->leftcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#left. == 0 && |
| 219 | val->bottomcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#bottom. == 0 && val->rightcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#right. == 0) |
| 220 | return val; |
| 221 | else |
| 222 | ref = val; |
| 223 | } |
| 224 | else if (!exact) |
| 225 | { |
| 226 | int myscore = papersize_size_mismatchcxx . . $ papersize_size_mismatch(8864420f1a93b895).(l, w, val); |
| 227 | if (myscore < score && myscore < 5) |
| 228 | { |
| 229 | ref = val; |
| 230 | score = myscore; |
| 231 | } |
| 232 | } |
| 233 | ptli = stpi_paperlist_item_nextcxx . . $ `src/main/gutenprint-internal.h:123:9`!(ptli); |
| 234 | } |
| 235 | return ref; |
| 236 | } |
| 237 | |
| 238 | const stp_papersize_tcxx . . $ stp_papersize_t# * |
| 239 | stpi_get_papersize_by_sizecxx . . $ stpi_get_papersize_by_size(a19d0c2e517567dd).(const stp_papersize_list_tcxx . . $ stp_papersize_list_t# *list, |
| 240 | stp_dimension_tcxx . . $ stp_dimension_t# l, stp_dimension_tcxx . . $ stp_dimension_t# w) |
| 241 | { |
| 242 | return get_papersize_by_size_internalcxx . . $ get_papersize_by_size_internal(92573c218850ec06).(list, l, w, 0); |
| 243 | } |
| 244 | |
| 245 | const stp_papersize_tcxx . . $ stp_papersize_t# * |
| 246 | stpi_get_papersize_by_size_exactcxx . . $ stpi_get_papersize_by_size_exact(a19d0c2e517567dd).(const stp_papersize_list_tcxx . . $ stp_papersize_list_t# *list, |
| 247 | stp_dimension_tcxx . . $ stp_dimension_t# l, stp_dimension_tcxx . . $ stp_dimension_t# w) |
| 248 | { |
| 249 | return get_papersize_by_size_internalcxx . . $ get_papersize_by_size_internal(92573c218850ec06).(list, l, w, 1); |
| 250 | } |
| 251 | |
| 252 | void |
| 253 | stp_default_media_sizecxx . . $ stp_default_media_size(2eafa46ec96dc268).(const stp_vars_tcxx . . $ stp_vars_t# *v, /* I */ |
| 254 | stp_dimension_tcxx . . $ stp_dimension_t# *width, /* O - Width in points */ |
| 255 | stp_dimension_tcxx . . $ stp_dimension_t# *height) /* O - Height in points */ |
| 256 | { |
| 257 | if (stp_get_page_widthcxx . . $ stp_get_page_width(7f9a8d44e8193bba).(v) > 0 && stp_get_page_heightcxx . . $ stp_get_page_height(7f9a8d44e8193bba).(v) > 0) |
| 258 | { |
| 259 | *width = stp_get_page_widthcxx . . $ stp_get_page_width(7f9a8d44e8193bba).(v); |
| 260 | *height = stp_get_page_heightcxx . . $ stp_get_page_height(7f9a8d44e8193bba).(v); |
| 261 | } |
| 262 | else |
| 263 | { |
| 264 | const char *page_size = stp_get_string_parametercxx . . $ stp_get_string_parameter(3e3ce5d385745545).(v, "PageSize"); |
| 265 | const stp_papersize_tcxx . . $ stp_papersize_t# *papersize = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 266 | if (page_size) |
| 267 | papersize = stp_describe_papersizecxx . . $ stp_describe_papersize(977e5bf217e59ec).(v, page_size); |
| 268 | if (!papersize) |
| 269 | { |
| 270 | *width = 1; |
| 271 | *height = 1; |
| 272 | } |
| 273 | else |
| 274 | { |
| 275 | *width = papersize->widthcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#width.; |
| 276 | *height = papersize->heightcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#height.; |
| 277 | } |
| 278 | if (*width == 0) |
| 279 | *width = 612; |
| 280 | if (*height == 0) |
| 281 | *height = 792; |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | /* |
| 286 | * Process the <paper> node. |
| 287 | */ |
| 288 | static stp_papersize_tcxx . . $ stp_papersize_t# * |
| 289 | stp_xml_process_papercxx . . $ stp_xml_process_paper(d4aef107eae68dae).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *paper) /* The paper node */ |
| 290 | { |
| 291 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *prop; /* Temporary node pointer */ |
| 292 | const char *stmp; /* Temporary string */ |
| 293 | /* props[] (unused) is the correct tag sequence */ |
| 294 | /* const char *props[] = |
| 295 | { |
| 296 | "name", |
| 297 | "description", |
| 298 | "width", |
| 299 | "height", |
| 300 | "left", |
| 301 | "right", |
| 302 | "bottom", |
| 303 | "top", |
| 304 | "unit", |
| 305 | "type", |
| 306 | NULL |
| 307 | };*/ |
| 308 | stp_papersize_tcxx . . $ stp_papersize_t# *outpaper; /* Generated paper */ |
| 309 | int |
| 310 | id = 0, /* Check id is present */ |
| 311 | name = 0, /* Check name is present */ |
| 312 | height = 0, /* Check height is present */ |
| 313 | width = 0, /* Check width is present */ |
| 314 | unit = 0; /* Check unit is present */ |
| 315 | |
| 316 | if (stp_get_debug_levelcxx . . $ stp_get_debug_level(f708dce9a8856c70).() & STP_DBG_XMLcxx . . $ `include/gutenprint/util.h:182:9`!) |
| 317 | { |
| 318 | stmp = stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(paper, (const char*) "name"); |
| 319 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("stp_xml_process_paper: name: %s\n", stmp); |
| 320 | } |
| 321 | |
| 322 | outpaper = stp_zalloccxx . . $ stp_zalloc(bfcfa4d6b7f7ef64).(sizeof(stp_papersize_tcxx . . $ stp_papersize_t#)); |
| 323 | if (!outpaper) |
| 324 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 325 | |
| 326 | outpaper->namecxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#name. = stp_strdupcxx . . $ stp_strdup(a8b8e32347182212).(stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(paper, "name")); |
| 327 | |
| 328 | outpaper->topcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#top. = 0; |
| 329 | outpaper->leftcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#left. = 0; |
| 330 | outpaper->bottomcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#bottom. = 0; |
| 331 | outpaper->rightcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#right. = 0; |
| 332 | outpaper->paper_size_typecxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#paper_size_type. = PAPERSIZE_TYPE_STANDARDcxx . . $ PAPERSIZE_TYPE_STANDARD.; |
| 333 | if (outpaper->namecxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#name.) |
| 334 | id = 1; |
| 335 | |
| 336 | prop = paper->childcxx . . $ stp_mxml_node_s#child.; |
| 337 | while(prop) |
| 338 | { |
| 339 | if (prop->typecxx . . $ stp_mxml_node_s#type. == STP_MXML_ELEMENTcxx . . $ STP_MXML_ELEMENT.) |
| 340 | { |
| 341 | const char *prop_name = prop->valuecxx . . $ stp_mxml_node_s#value..elementcxx . . $ stp_mxml_value_u#element..namecxx . . $ stp_mxml_value_s#name.; |
| 342 | |
| 343 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(prop_name, "description")) |
| 344 | { |
| 345 | outpaper->textcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#text. = stp_strdupcxx . . $ stp_strdup(a8b8e32347182212).(stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(prop, "value")); |
| 346 | name = 1; |
| 347 | } |
| 348 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(prop_name, "comment")) |
| 349 | outpaper->commentcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#comment. = stp_strdupcxx . . $ stp_strdup(a8b8e32347182212).(stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(prop, "value")); |
| 350 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(prop_name, "width")) |
| 351 | { |
| 352 | stmp = stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(prop, "value"); |
| 353 | if (stmp) |
| 354 | { |
| 355 | outpaper->widthcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#width. = stp_xmlstrtodimcxx . . $ stp_xmlstrtodim(9a18bdb0e56c1bc2).(stmp); |
| 356 | width = 1; |
| 357 | } |
| 358 | } |
| 359 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(prop_name, "height")) |
| 360 | { |
| 361 | stmp = stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(prop, "value"); |
| 362 | if (stmp) |
| 363 | { |
| 364 | outpaper->heightcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#height. = stp_xmlstrtodimcxx . . $ stp_xmlstrtodim(9a18bdb0e56c1bc2).(stmp); |
| 365 | height = 1; |
| 366 | } |
| 367 | } |
| 368 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(prop_name, "left")) |
| 369 | { |
| 370 | stmp = stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(prop, "value"); |
| 371 | outpaper->leftcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#left. = stp_xmlstrtodimcxx . . $ stp_xmlstrtodim(9a18bdb0e56c1bc2).(stmp); |
| 372 | } |
| 373 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(prop_name, "right")) |
| 374 | { |
| 375 | stmp = stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(prop, "value"); |
| 376 | outpaper->rightcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#right. = stp_xmlstrtodimcxx . . $ stp_xmlstrtodim(9a18bdb0e56c1bc2).(stmp); |
| 377 | } |
| 378 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(prop_name, "bottom")) |
| 379 | { |
| 380 | stmp = stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(prop, "value"); |
| 381 | outpaper->bottomcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#bottom. = stp_xmlstrtodimcxx . . $ stp_xmlstrtodim(9a18bdb0e56c1bc2).(stmp); |
| 382 | } |
| 383 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(prop_name, "top")) |
| 384 | { |
| 385 | stmp = stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(prop, "value"); |
| 386 | outpaper->topcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#top. = stp_xmlstrtodimcxx . . $ stp_xmlstrtodim(9a18bdb0e56c1bc2).(stmp); |
| 387 | } |
| 388 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(prop_name, "unit")) |
| 389 | { |
| 390 | stmp = stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(prop, "value"); |
| 391 | if (stmp) |
| 392 | { |
| 393 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(stmp, "english")) |
| 394 | outpaper->paper_unitcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#paper_unit. = PAPERSIZE_ENGLISH_STANDARDcxx . . $ PAPERSIZE_ENGLISH_STANDARD.; |
| 395 | else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(stmp, "english-extended")) |
| 396 | outpaper->paper_unitcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#paper_unit. = PAPERSIZE_ENGLISH_EXTENDEDcxx . . $ PAPERSIZE_ENGLISH_EXTENDED.; |
| 397 | else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(stmp, "metric")) |
| 398 | outpaper->paper_unitcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#paper_unit. = PAPERSIZE_METRIC_STANDARDcxx . . $ PAPERSIZE_METRIC_STANDARD.; |
| 399 | else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(stmp, "metric-extended")) |
| 400 | outpaper->paper_unitcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#paper_unit. = PAPERSIZE_METRIC_EXTENDEDcxx . . $ PAPERSIZE_METRIC_EXTENDED.; |
| 401 | /* Default unit */ |
| 402 | else |
| 403 | outpaper->paper_unitcxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#paper_unit. = PAPERSIZE_METRIC_EXTENDEDcxx . . $ PAPERSIZE_METRIC_EXTENDED.; |
| 404 | unit = 1; |
| 405 | } |
| 406 | } |
| 407 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(prop_name, "type")) |
| 408 | { |
| 409 | stmp = stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(prop, "value"); |
| 410 | if (stmp) |
| 411 | { |
| 412 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(stmp, "envelope")) |
| 413 | outpaper->paper_size_typecxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#paper_size_type. = PAPERSIZE_TYPE_ENVELOPEcxx . . $ PAPERSIZE_TYPE_ENVELOPE.; |
| 414 | else |
| 415 | outpaper->paper_size_typecxx . . $ $anonymous_type_51fd7f0ef3c7bff0_2#paper_size_type. = PAPERSIZE_TYPE_STANDARDcxx . . $ PAPERSIZE_TYPE_STANDARD.; |
| 416 | } |
| 417 | } |
| 418 | } |
| 419 | prop = prop->nextcxx . . $ stp_mxml_node_s#next.; |
| 420 | } |
| 421 | if (id && name && width && height && unit) /* Margins and type are optional */ |
| 422 | return outpaper; |
| 423 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(outpaper); |
| 424 | outpaper = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 425 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 426 | } |
| 427 | |
| 428 | /* |
| 429 | * Parse the <paperdef> node. |
| 430 | */ |
| 431 | static int |
| 432 | stp_xml_process_papersize_defcxx . . $ stp_xml_process_papersize_def(4ba3f1fd0678e091).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *paperdef, const char *file, |
| 433 | stp_papersize_list_tcxx . . $ stp_papersize_list_t# *papersize_list) |
| 434 | { |
| 435 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *paper; /* paper node pointer */ |
| 436 | stp_papersize_tcxx . . $ stp_papersize_t# *outpaper; /* Generated paper */ |
| 437 | |
| 438 | (void)file; |
| 439 | |
| 440 | paper = paperdef->childcxx . . $ stp_mxml_node_s#child.; |
| 441 | while (paper) |
| 442 | { |
| 443 | if (paper->typecxx . . $ stp_mxml_node_s#type. == STP_MXML_ELEMENTcxx . . $ STP_MXML_ELEMENT.) |
| 444 | { |
| 445 | const char *papersize_name = paper->valuecxx . . $ stp_mxml_node_s#value..elementcxx . . $ stp_mxml_value_u#element..namecxx . . $ stp_mxml_value_s#name.; |
| 446 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(papersize_name, "paper")) |
| 447 | { |
| 448 | outpaper = stp_xml_process_papercxx . . $ stp_xml_process_paper(d4aef107eae68dae).(paper); |
| 449 | if (outpaper) |
| 450 | stpi_papersize_createcxx . . $ stpi_papersize_create(57cbead4fcb67a71).(papersize_list, outpaper); |
| 451 | } |
| 452 | } |
| 453 | paper = paper->nextcxx . . $ stp_mxml_node_s#next.; |
| 454 | } |
| 455 | return 1; |
| 456 | } |
| 457 | |
| 458 | const stp_papersize_list_tcxx . . $ stp_papersize_list_t# * |
| 459 | stpi_get_papersize_list_namedcxx . . $ stpi_get_papersize_list_named(81f88378de3f2d3).(const char *name, const char *file) |
| 460 | { |
| 461 | stp_list_item_tcxx . . $ stp_list_item_t# *item; |
| 462 | papersize_list_impl_tcxx . . $ papersize_list_impl_t# *impl; |
| 463 | |
| 464 | check_list_of_papersize_listscxx . . $ check_list_of_papersize_lists(49f6e7a06ebc5aa8).(); |
| 465 | item = stp_list_get_item_by_namecxx . . $ stp_list_get_item_by_name(27765cfe86595311).(list_of_papersize_listscxx . . $ list_of_papersize_lists., name); |
| 466 | if (item) |
| 467 | { |
| 468 | impl = (papersize_list_impl_tcxx . . $ papersize_list_impl_t# *) stp_list_item_get_datacxx . . $ stp_list_item_get_data(9a5daa75441a53b5).(item); |
| 469 | } |
| 470 | else |
| 471 | { |
| 472 | char buf[MAXPATHLENcxx . . $ `<external>/1231830743887005719/param.h:48:10`!+1]; |
| 473 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3).(STP_DBG_PAPERcxx . . $ `include/gutenprint/util.h:180:9`!, "Loading paper list %s from %s\n", |
| 474 | name, file ? file : "(null)"); |
| 475 | if (! file) |
| 476 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 477 | else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(file, "")) |
| 478 | (void) snprintfcxx . . $ snprintf(ea502d73e74c754c).(buf, MAXPATHLENcxx . . $ `<external>/1231830743887005719/param.h:48:10`!, "papers/%s.xml", name); |
| 479 | else |
| 480 | strncpycxx . . $ strncpy(255158a415b673b0).(buf, file, MAXPATHLENcxx . . $ `<external>/1231830743887005719/param.h:48:10`!); |
| 481 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *node = |
| 482 | stp_xml_parse_file_from_path_safecxx . . $ stp_xml_parse_file_from_path_safe(5a8029715312b5a0).(buf, "paperdef", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 483 | const char *stmp = stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(node, "name"); |
| 484 | STPI_ASSERTcxx . . $ `src/main/gutenprint-internal.h:58:9`!(stmp && !strcmp(name, stmp), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 485 | impl = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(sizeof(papersize_list_impl_tcxx . . $ papersize_list_impl_t#)); |
| 486 | impl->namecxx . . $ $anonymous_type_51d68c5e9adc72d3_0#name. = stp_strdupcxx . . $ stp_strdup(a8b8e32347182212).(name); |
| 487 | impl->listcxx . . $ $anonymous_type_51d68c5e9adc72d3_0#list. = stpi_create_papersize_listcxx . . $ stpi_create_papersize_list(728167c67729d082).(); |
| 488 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3).(STP_DBG_PAPERcxx . . $ `include/gutenprint/util.h:180:9`!, " Loading %s\n", stmp); |
| 489 | stp_list_item_createcxx . . $ stp_list_item_create(54f08bf465e39eec).(list_of_papersize_listscxx . . $ list_of_papersize_lists., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, impl); |
| 490 | stp_xml_process_papersize_defcxx . . $ stp_xml_process_papersize_def(4ba3f1fd0678e091).(node, buf, impl->listcxx . . $ $anonymous_type_51d68c5e9adc72d3_0#list.); |
| 491 | } |
| 492 | return impl->listcxx . . $ $anonymous_type_51d68c5e9adc72d3_0#list.; |
| 493 | } |
| 494 | |
| 495 | stp_papersize_list_tcxx . . $ stp_papersize_list_t# * |
| 496 | stpi_find_papersize_list_namedcxx . . $ stpi_find_papersize_list_named(3c3f43458e8c52b9).(const char *name) |
| 497 | { |
| 498 | stp_list_item_tcxx . . $ stp_list_item_t# *item; |
| 499 | |
| 500 | check_list_of_papersize_listscxx . . $ check_list_of_papersize_lists(49f6e7a06ebc5aa8).(); |
| 501 | item = stp_list_get_item_by_namecxx . . $ stp_list_get_item_by_name(27765cfe86595311).(list_of_papersize_listscxx . . $ list_of_papersize_lists., name); |
| 502 | if (item) |
| 503 | { |
| 504 | papersize_list_impl_tcxx . . $ papersize_list_impl_t# *impl = |
| 505 | (papersize_list_impl_tcxx . . $ papersize_list_impl_t# *) stp_list_item_get_datacxx . . $ stp_list_item_get_data(9a5daa75441a53b5).(item); |
| 506 | if (impl) |
| 507 | return impl->listcxx . . $ $anonymous_type_51d68c5e9adc72d3_0#list.; |
| 508 | } |
| 509 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 510 | } |
| 511 | |
| 512 | stp_papersize_list_tcxx . . $ stp_papersize_list_t# * |
| 513 | stpi_new_papersize_listcxx . . $ stpi_new_papersize_list(3c3f43458e8c52b9).(const char *name) |
| 514 | { |
| 515 | stp_list_item_tcxx . . $ stp_list_item_t# *item; |
| 516 | papersize_list_impl_tcxx . . $ papersize_list_impl_t# *impl; |
| 517 | |
| 518 | check_list_of_papersize_listscxx . . $ check_list_of_papersize_lists(49f6e7a06ebc5aa8).(); |
| 519 | item = stp_list_get_item_by_namecxx . . $ stp_list_get_item_by_name(27765cfe86595311).(list_of_papersize_listscxx . . $ list_of_papersize_lists., name); |
| 520 | if (item) |
| 521 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 522 | impl = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(sizeof(papersize_list_impl_tcxx . . $ papersize_list_impl_t#)); |
| 523 | impl->namecxx . . $ $anonymous_type_51d68c5e9adc72d3_0#name. = stp_strdupcxx . . $ stp_strdup(a8b8e32347182212).(name); |
| 524 | impl->listcxx . . $ $anonymous_type_51d68c5e9adc72d3_0#list. = stpi_create_papersize_listcxx . . $ stpi_create_papersize_list(728167c67729d082).(); |
| 525 | stp_list_item_createcxx . . $ stp_list_item_create(54f08bf465e39eec).(list_of_papersize_listscxx . . $ list_of_papersize_lists., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, impl); |
| 526 | return impl->listcxx . . $ $anonymous_type_51d68c5e9adc72d3_0#list.; |
| 527 | } |
| 528 | |
| 529 | const stp_papersize_list_tcxx . . $ stp_papersize_list_t# * |
| 530 | stpi_get_standard_papersize_listcxx . . $ stpi_get_standard_papersize_list(d3875b0f088d0326).(void) |
| 531 | { |
| 532 | return stpi_get_papersize_list_namedcxx . . $ stpi_get_papersize_list_named(81f88378de3f2d3).("standard", ""); |
| 533 | } |