| 1 | /* |
| 2 | * "xmlppd.c" |
| 3 | * |
| 4 | * PPD to XML converter. |
| 5 | * |
| 6 | * Copyright 2007 by Michael R Sweet and Robert Krawitz |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 21 | * 02110-1301 USA |
| 22 | */ |
| 23 | |
| 24 | #include <ctype.h> |
| 25 | #include <stdio.h> |
| 26 | #include <gutenprint/mxml.h>cxx . . $ `<file>/include/gutenprint/mxml.h`/ |
| 27 | #include <gutenprint/util.h>cxx . . $ `<file>/include/gutenprint/util.h`/ |
| 28 | #include <gutenprint/string-list.h>cxx . . $ `<file>/include/gutenprint/string-list.h`/ |
| 29 | #include <stdlib.h> |
| 30 | #include <strings.h> |
| 31 | #include "xmlppd.h"cxx . . $ `<file>/src/main/xmlppd.h`/ |
| 32 | |
| 33 | typedef structcxx . . $ $anonymous_type_6e128fd0d39b8ac9_0# |
| 34 | { |
| 35 | int ordercxx . . $ $anonymous_type_6e128fd0d39b8ac9_0#order.; |
| 36 | const char *namecxx . . $ $anonymous_type_6e128fd0d39b8ac9_0#name.; |
| 37 | } order_tcxx . . $ order_t#; |
| 38 | |
| 39 | static int |
| 40 | order_comparecxx . . $ order_compare(9148c8c3ff42c9d8).(const void *a, const void *b) |
| 41 | { |
| 42 | const order_tcxx . . $ order_t# *aa = (const order_tcxx . . $ order_t# *)a; |
| 43 | const order_tcxx . . $ order_t# *bb = (const order_tcxx . . $ order_t# *)b; |
| 44 | if (aa->ordercxx . . $ $anonymous_type_6e128fd0d39b8ac9_0#order. < bb->ordercxx . . $ $anonymous_type_6e128fd0d39b8ac9_0#order.) |
| 45 | return -1; |
| 46 | else if (aa->ordercxx . . $ $anonymous_type_6e128fd0d39b8ac9_0#order. > bb->ordercxx . . $ $anonymous_type_6e128fd0d39b8ac9_0#order.) |
| 47 | return 1; |
| 48 | else |
| 49 | return strcmpcxx . . $ strcmp(5ae29d726ae57f88).(aa->namecxx . . $ $anonymous_type_6e128fd0d39b8ac9_0#name., bb->namecxx . . $ $anonymous_type_6e128fd0d39b8ac9_0#name.); |
| 50 | } |
| 51 | |
| 52 | |
| 53 | static stp_mxml_node_tcxx . . $ stp_mxml_node_t# * |
| 54 | find_element_namedcxx . . $ find_element_named(822c2b108eb666bb).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *root, const char *name, const char *what) |
| 55 | { |
| 56 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *element; |
| 57 | if (root && name) |
| 58 | { |
| 59 | for (element = stp_mxmlFindElementcxx . . $ stp_mxmlFindElement(9d3a1ee0d733a1fa).(root, root, what, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, |
| 60 | STP_MXML_DESCENDcxx . . $ `include/gutenprint/mxml.h:51:11`!); |
| 61 | element; |
| 62 | element = stp_mxmlFindElementcxx . . $ stp_mxmlFindElement(9d3a1ee0d733a1fa).(element, root, what, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, |
| 63 | STP_MXML_DESCENDcxx . . $ `include/gutenprint/mxml.h:51:11`!)) |
| 64 | { |
| 65 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(element, "name"), name)) |
| 66 | return element; |
| 67 | } |
| 68 | } |
| 69 | return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 70 | } |
| 71 | |
| 72 | static stp_mxml_node_tcxx . . $ stp_mxml_node_t# * |
| 73 | find_element_indexcxx . . $ find_element_index(a1e8609c1a01b87b).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *root, int idx, const char *what) |
| 74 | { |
| 75 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *element; |
| 76 | int count = 0; |
| 77 | if (root && idx >= 0) |
| 78 | { |
| 79 | for (element = stp_mxmlFindElementcxx . . $ stp_mxmlFindElement(9d3a1ee0d733a1fa).(root, root, what, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, |
| 80 | STP_MXML_DESCENDcxx . . $ `include/gutenprint/mxml.h:51:11`!); |
| 81 | element; |
| 82 | element = stp_mxmlFindElementcxx . . $ stp_mxmlFindElement(9d3a1ee0d733a1fa).(element, root, what, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, |
| 83 | STP_MXML_DESCENDcxx . . $ `include/gutenprint/mxml.h:51:11`!)) |
| 84 | { |
| 85 | if (count++ == idx) |
| 86 | return element; |
| 87 | } |
| 88 | } |
| 89 | return NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 90 | } |
| 91 | |
| 92 | static size_t |
| 93 | find_element_countcxx . . $ find_element_count(2523011c8c65832b).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *root, const char *what) |
| 94 | { |
| 95 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *element; |
| 96 | size_t count = 0; |
| 97 | if (root) |
| 98 | { |
| 99 | for (element = stp_mxmlFindElementcxx . . $ stp_mxmlFindElement(9d3a1ee0d733a1fa).(root, root, what, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, |
| 100 | STP_MXML_DESCENDcxx . . $ `include/gutenprint/mxml.h:51:11`!); |
| 101 | element; |
| 102 | element = stp_mxmlFindElementcxx . . $ stp_mxmlFindElement(9d3a1ee0d733a1fa).(element, root, what, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, |
| 103 | STP_MXML_DESCENDcxx . . $ `include/gutenprint/mxml.h:51:11`!)) |
| 104 | count++; |
| 105 | } |
| 106 | return count; |
| 107 | } |
| 108 | |
| 109 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# * |
| 110 | stpi_xmlppd_find_group_namedcxx . . $ stpi_xmlppd_find_group_named(85c1b86a85cbb6d).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *root, const char *name) |
| 111 | { |
| 112 | return find_element_namedcxx . . $ find_element_named(822c2b108eb666bb).(root, name, "group"); |
| 113 | } |
| 114 | |
| 115 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# * |
| 116 | stpi_xmlppd_find_group_indexcxx . . $ stpi_xmlppd_find_group_index(617c7ca5462143a5).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *root, int idx) |
| 117 | { |
| 118 | return find_element_indexcxx . . $ find_element_index(a1e8609c1a01b87b).(root, idx, "group"); |
| 119 | } |
| 120 | |
| 121 | int |
| 122 | stpi_xmlppd_find_group_countcxx . . $ stpi_xmlppd_find_group_count(9003748477915f72).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *root) |
| 123 | { |
| 124 | return find_element_countcxx . . $ find_element_count(2523011c8c65832b).(root, "group"); |
| 125 | } |
| 126 | |
| 127 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# * |
| 128 | stpi_xmlppd_find_option_namedcxx . . $ stpi_xmlppd_find_option_named(85c1b86a85cbb6d).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *root, const char *name) |
| 129 | { |
| 130 | return find_element_namedcxx . . $ find_element_named(822c2b108eb666bb).(root, name, "option"); |
| 131 | } |
| 132 | |
| 133 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# * |
| 134 | stpi_xmlppd_find_option_indexcxx . . $ stpi_xmlppd_find_option_index(617c7ca5462143a5).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *root, int idx) |
| 135 | { |
| 136 | return find_element_indexcxx . . $ find_element_index(a1e8609c1a01b87b).(root, idx, "option"); |
| 137 | } |
| 138 | |
| 139 | int |
| 140 | stpi_xmlppd_find_option_countcxx . . $ stpi_xmlppd_find_option_count(9003748477915f72).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *root) |
| 141 | { |
| 142 | return find_element_countcxx . . $ find_element_count(2523011c8c65832b).(root, "option"); |
| 143 | } |
| 144 | |
| 145 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# * |
| 146 | stpi_xmlppd_find_choice_namedcxx . . $ stpi_xmlppd_find_choice_named(85c1b86a85cbb6d).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *option, const char *name) |
| 147 | { |
| 148 | return find_element_namedcxx . . $ find_element_named(822c2b108eb666bb).(option, name, "choice"); |
| 149 | } |
| 150 | |
| 151 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# * |
| 152 | stpi_xmlppd_find_choice_indexcxx . . $ stpi_xmlppd_find_choice_index(617c7ca5462143a5).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *option, int idx) |
| 153 | { |
| 154 | return find_element_indexcxx . . $ find_element_index(a1e8609c1a01b87b).(option, idx, "choice"); |
| 155 | } |
| 156 | |
| 157 | int |
| 158 | stpi_xmlppd_find_choice_countcxx . . $ stpi_xmlppd_find_choice_count(9003748477915f72).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *option) |
| 159 | { |
| 160 | return find_element_countcxx . . $ find_element_count(2523011c8c65832b).(option, "choice"); |
| 161 | } |
| 162 | |
| 163 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# * |
| 164 | stpi_xmlppd_find_page_sizecxx . . $ stpi_xmlppd_find_page_size(85c1b86a85cbb6d).(stp_mxml_node_tcxx . . $ stp_mxml_node_t# *root, const char *name) |
| 165 | { |
| 166 | return stpi_xmlppd_find_choice_namedcxx . . $ stpi_xmlppd_find_choice_named(85c1b86a85cbb6d).(stpi_xmlppd_find_option_namedcxx . . $ stpi_xmlppd_find_option_named(85c1b86a85cbb6d).(root, "PageSize"), name); |
| 167 | } |
| 168 | |
| 169 | static void |
| 170 | parse_valuescxx . . $ parse_values(d07bd281fd8df0db).(const char **data, int limit, char *value) |
| 171 | { |
| 172 | int dptr = 0; |
| 173 | char *where = value; |
| 174 | char *end = value; |
| 175 | for (dptr = 0; dptr < limit; dptr++) |
| 176 | data[dptr] = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 177 | for (dptr = 0; *where && dptr < limit; dptr++) |
| 178 | { |
| 179 | where = end; |
| 180 | while (*where && isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(*where)) |
| 181 | where++; |
| 182 | end = where; |
| 183 | while (*end && !isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(*end)) |
| 184 | end++; |
| 185 | *end++ = '\0'; |
| 186 | data[dptr] = where; |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | /* |
| 191 | * 'read_ppd_file()' - Read a PPD file into XML data. |
| 192 | */ |
| 193 | |
| 194 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# * /* O - PPD file as XML */ |
| 195 | stpi_xmlppd_read_ppd_filecxx . . $ stpi_xmlppd_read_ppd_file(bf16e72c8c0a696c).(const char *filename) /* I - PPD file */ |
| 196 | { |
| 197 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *ppd, /* Root node of "ppd" group */ |
| 198 | *group, /* Current group */ |
| 199 | *option, /* Current option */ |
| 200 | *choice; /* Current choice */ |
| 201 | FILEcxx . . $ FILE# *fp; /* PPD file */ |
| 202 | int ch, /* Current character */ |
| 203 | sawcolon, /* Saw a colon? */ |
| 204 | inquote, /* In a quoted string? */ |
| 205 | num_choices = 0; |
| 206 | char buffer[32768], /* Line buffer */ |
| 207 | *bufptr, /* Pointer into line */ |
| 208 | *xptr, /* Pointer into line */ |
| 209 | option_name[42], /* Option name */ |
| 210 | stp_option_data_name[64], /* Option name */ |
| 211 | *keyword, /* Pointer to option keyword */ |
| 212 | *text, /* Pointer to text */ |
| 213 | *value; /* Pointer to value */ |
| 214 | order_tcxx . . $ order_t# *order_array; /* Precedence order of options */ |
| 215 | unsigned int i; |
| 216 | unsigned int option_count; |
| 217 | int order_length; |
| 218 | char *order_list; |
| 219 | stp_string_list_tcxx . . $ stp_string_list_t# *ialist = stp_string_list_createcxx . . $ stp_string_list_create(f262b3b5e10fad14).(); |
| 220 | stp_string_list_tcxx . . $ stp_string_list_t# *pdlist = stp_string_list_createcxx . . $ stp_string_list_create(f262b3b5e10fad14).(); |
| 221 | |
| 222 | |
| 223 | /* |
| 224 | * Open the file... |
| 225 | */ |
| 226 | |
| 227 | if ((fp = fopencxx . . $ fopen(82ec0787cd37e0a3).(filename, "rb")) == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 228 | { |
| 229 | perrorcxx . . $ perror(85c52e162fed56f9).(filename); |
| 230 | return (NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 231 | } |
| 232 | |
| 233 | /* |
| 234 | * Create the base PPD file tree; the completed tree will look like: |
| 235 | * |
| 236 | * <?xml version="1.0"?> |
| 237 | * <ppd color="0/1" level="1/2/3"> |
| 238 | * <option name="..." text="..." default="..." section="..." order="..." |
| 239 | * type="..."> |
| 240 | * <choice name="..." text="...">code</choice> |
| 241 | * ... |
| 242 | * </option> |
| 243 | * ... |
| 244 | * <group name="..." text="..."> |
| 245 | * <option ...> |
| 246 | * <choice ...>code</choice> |
| 247 | * </option> |
| 248 | * </group> |
| 249 | * </ppd> |
| 250 | */ |
| 251 | |
| 252 | /* xml = stp_mxmlNewXML("1.0"); */ |
| 253 | /* ppd = stp_mxmlNewElement(xml, "ppd"); */ |
| 254 | ppd = stp_mxmlNewElementcxx . . $ stp_mxmlNewElement(85c1b86a85cbb6d).(STP_MXML_NO_PARENTcxx . . $ `include/gutenprint/mxml.h:49:11`!, "ppd"); |
| 255 | |
| 256 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(ppd, "color", "0"); |
| 257 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(ppd, "level", "2"); |
| 258 | |
| 259 | /* |
| 260 | * Read all of the lines of the form: |
| 261 | * |
| 262 | * *% comment |
| 263 | * *Keyword: value |
| 264 | * *Keyword OptionKeyword: value |
| 265 | * *Keyword OptionKeyword/Text: value |
| 266 | * |
| 267 | * Only save groups, options, and choices, along with specific metadata |
| 268 | * from the file... |
| 269 | */ |
| 270 | |
| 271 | group = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 272 | option = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 273 | option_name[0] = '\0'; |
| 274 | |
| 275 | while ((ch = getccxx . . $ getc(89bc1efcdac0ca22).(fp)) != EOFcxx . . $ `<external>/232824719582829767/stdio.h:105:9`!) |
| 276 | { |
| 277 | /* |
| 278 | * Read the line... |
| 279 | */ |
| 280 | |
| 281 | buffer[0] = ch; |
| 282 | bufptr = buffer + 1; |
| 283 | inquote = 0; |
| 284 | sawcolon = 0; |
| 285 | if (ch == '*') |
| 286 | { |
| 287 | if ((ch = getccxx . . $ getc(89bc1efcdac0ca22).(fp)) == '%') |
| 288 | { |
| 289 | while (1) |
| 290 | { |
| 291 | ch = getccxx . . $ getc(89bc1efcdac0ca22).(fp); |
| 292 | if (ch == '\n' || ch == EOFcxx . . $ `<external>/232824719582829767/stdio.h:105:9`!) |
| 293 | break; |
| 294 | } |
| 295 | continue; |
| 296 | } |
| 297 | else |
| 298 | ungetccxx . . $ ungetc(b1cd03d6c470d1bd).(ch, fp); |
| 299 | } |
| 300 | |
| 301 | while ((ch != '\n' || inquote) && bufptr < (buffer + sizeof(buffer) - 1)) |
| 302 | { |
| 303 | if ((ch = getccxx . . $ getc(89bc1efcdac0ca22).(fp)) == '\r') |
| 304 | { |
| 305 | if ((ch = getccxx . . $ getc(89bc1efcdac0ca22).(fp)) != '\n') |
| 306 | ungetccxx . . $ ungetc(b1cd03d6c470d1bd).(ch, fp); |
| 307 | } |
| 308 | |
| 309 | *bufptr++ = ch; |
| 310 | |
| 311 | if (ch == ':' && !sawcolon) |
| 312 | sawcolon = 1; |
| 313 | else if (ch == '\"' && sawcolon) |
| 314 | inquote = !inquote; |
| 315 | } |
| 316 | |
| 317 | /* |
| 318 | * Strip trailing whitespace... |
| 319 | */ |
| 320 | |
| 321 | for (bufptr --; bufptr > buffer && isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(bufptr[-1] & 255); bufptr --); |
| 322 | |
| 323 | *bufptr = '\0'; |
| 324 | |
| 325 | /* |
| 326 | * Now parse it... |
| 327 | */ |
| 328 | |
| 329 | if (!strncmpcxx . . $ strncmp(fd278af2f295fa2e).(buffer, "*%", 2) || !buffer[0]) |
| 330 | continue; |
| 331 | |
| 332 | if ((value = strchrcxx . . $ strchr(2050848944e00d54).(buffer, ':')) == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 333 | continue; |
| 334 | |
| 335 | for (*value++ = '\0'; |
| 336 | *value && (isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(*value & 255) || (*value & 255) == '"'); |
| 337 | value ++); |
| 338 | for (xptr = value; |
| 339 | *xptr && (*xptr & 255) != '"'; |
| 340 | xptr ++); |
| 341 | if (*xptr == '"') |
| 342 | *xptr = '\0'; |
| 343 | |
| 344 | for (keyword = buffer; *keyword && !isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(*keyword & 255); keyword ++); |
| 345 | |
| 346 | while (isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(*keyword & 255)) |
| 347 | *keyword++ = '\0'; |
| 348 | |
| 349 | if ((text = strchrcxx . . $ strchr(2050848944e00d54).(keyword, '/')) != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 350 | *text++ = '\0'; |
| 351 | |
| 352 | /* |
| 353 | * And then use the parsed values... |
| 354 | */ |
| 355 | |
| 356 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(buffer, "*ColorDevice")) |
| 357 | { |
| 358 | /* |
| 359 | * Color support... |
| 360 | */ |
| 361 | |
| 362 | if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(value, "true")) |
| 363 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(ppd, "color", "1"); |
| 364 | else |
| 365 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(ppd, "color", "0"); |
| 366 | } |
| 367 | else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(buffer, "*LanguageLevel") && atoicxx . . $ atoi(5c4306d8553b3696).(value) > 0) |
| 368 | { |
| 369 | /* |
| 370 | * PostScript language level... |
| 371 | */ |
| 372 | |
| 373 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(ppd, "level", value); |
| 374 | } |
| 375 | else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(buffer, "*StpDriverName")) |
| 376 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(ppd, "driver", value); |
| 377 | else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(buffer, "*ModelName")) |
| 378 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(ppd, "modelname", value); |
| 379 | else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(buffer, "*ShortNickName")) |
| 380 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(ppd, "shortnickname", value); |
| 381 | else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(buffer, "*NickName")) |
| 382 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(ppd, "nickname", value); |
| 383 | else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(buffer, "*OpenGroup")) |
| 384 | { |
| 385 | if ((text = strchrcxx . . $ strchr(2050848944e00d54).(value, '/')) != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 386 | *text++ = '\0'; |
| 387 | |
| 388 | group = stp_mxmlNewElementcxx . . $ stp_mxmlNewElement(85c1b86a85cbb6d).(ppd, "group"); |
| 389 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(group, "name", value); |
| 390 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(group, "text", text ? text : value); |
| 391 | } |
| 392 | else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(buffer, "*CloseGroup")) |
| 393 | group = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 394 | else if ((!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(buffer, "*OpenUI") || !strcmpcxx . . $ strcmp(5ae29d726ae57f88).(buffer, "*JCLOpenUI")) && |
| 395 | keyword[0] == '*' && keyword[1]) |
| 396 | { |
| 397 | /* |
| 398 | * Start a new option... |
| 399 | */ |
| 400 | |
| 401 | option = stp_mxmlNewElementcxx . . $ stp_mxmlNewElement(85c1b86a85cbb6d).(group ? group : ppd, "option"); |
| 402 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(option, "name", keyword + 1); |
| 403 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(option, "text", text ? text : keyword + 1); |
| 404 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(option, "ui", value); |
| 405 | |
| 406 | strncpycxx . . $ strncpy(255158a415b673b0).(option_name, keyword, sizeof(option_name) - 1); |
| 407 | option_name[sizeof(option_name) - 1] = '\0'; |
| 408 | strcpycxx . . $ strcpy(b7b3a83273496486).(stp_option_data_name, "*Stp"); |
| 409 | strcpycxx . . $ strcpy(b7b3a83273496486).(stp_option_data_name + 4, option_name + 1); |
| 410 | if (group) |
| 411 | { |
| 412 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(option, "groupname", stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(group, "name")); |
| 413 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(option, "grouptext", stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(group, "text")); |
| 414 | } |
| 415 | num_choices = 0; |
| 416 | } |
| 417 | else if (option && !strcmpcxx . . $ strcmp(5ae29d726ae57f88).(buffer, stp_option_data_name)) |
| 418 | { |
| 419 | const char *data[8]; |
| 420 | parse_valuescxx . . $ parse_values(d07bd281fd8df0db).(data, 8, value); |
| 421 | if (data[7]) |
| 422 | { |
| 423 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(option, "stptype", data[0]); |
| 424 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(option, "stpmandatory", data[1]); |
| 425 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(option, "stpclass", data[2]); |
| 426 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(option, "stplevel", data[3]); |
| 427 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(option, "stpchannel", data[4]); |
| 428 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(option, "stplower", data[5]); |
| 429 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(option, "stpupper", data[6]); |
| 430 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(option, "stpdefault", data[7]); |
| 431 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(option, "stpname", stp_option_data_name + 7); |
| 432 | } |
| 433 | } |
| 434 | else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(buffer, "*OrderDependency") && option) |
| 435 | { |
| 436 | /* |
| 437 | * Get order and section for option |
| 438 | */ |
| 439 | |
| 440 | char order[256], /* Order number */ |
| 441 | section[256]; /* Section name */ |
| 442 | |
| 443 | |
| 444 | if (sscanfcxx . . $ sscanf(5e8a2c12db2ea735).(value, "%255s%255s", order, section) == 2) |
| 445 | { |
| 446 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(option, "order", order); |
| 447 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(option, "section", section); |
| 448 | } |
| 449 | } |
| 450 | else if (!strncmpcxx . . $ strncmp(fd278af2f295fa2e).(buffer, "*Default", 8) && option && |
| 451 | !strcmpcxx . . $ strcmp(5ae29d726ae57f88).(buffer + 8, option_name + 1)) |
| 452 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(option, "default", value); |
| 453 | else if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(buffer, "*CloseUI") || !strcmpcxx . . $ strcmp(5ae29d726ae57f88).(buffer, "*JCLCloseUI")) |
| 454 | { |
| 455 | char buf[64]; |
| 456 | (void) sprintfcxx . . $ sprintf(26c8642d26409d6d).(buf, "%d", num_choices); |
| 457 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(option, "num_choices", buf); |
| 458 | option = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 459 | stp_option_data_name[0] = '\0'; |
| 460 | } |
| 461 | else if (option && !strcmpcxx . . $ strcmp(5ae29d726ae57f88).(buffer, option_name)) |
| 462 | { |
| 463 | /* |
| 464 | * A choice... |
| 465 | */ |
| 466 | |
| 467 | choice = stp_mxmlNewElementcxx . . $ stp_mxmlNewElement(85c1b86a85cbb6d).(option, "choice"); |
| 468 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(choice, "name", keyword); |
| 469 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(choice, "text", text ? text : keyword); |
| 470 | |
| 471 | if (value[0] == '\"') |
| 472 | value ++; |
| 473 | |
| 474 | if (bufptr > buffer && bufptr[-1] == '\"') |
| 475 | { |
| 476 | bufptr --; |
| 477 | *bufptr = '\0'; |
| 478 | } |
| 479 | |
| 480 | stp_mxmlNewOpaquecxx . . $ stp_mxmlNewOpaque(85c1b86a85cbb6d).(choice, value); |
| 481 | num_choices++; |
| 482 | } |
| 483 | else if (!option && !strcmpcxx . . $ strcmp(5ae29d726ae57f88).(buffer, "*ImageableArea")) |
| 484 | { |
| 485 | stp_string_list_add_stringcxx . . $ stp_string_list_add_string(61ec312b340c2952).(ialist, keyword, value); |
| 486 | } |
| 487 | else if (!option && !strcmpcxx . . $ strcmp(5ae29d726ae57f88).(buffer, "*PaperDimension")) |
| 488 | { |
| 489 | stp_string_list_add_stringcxx . . $ stp_string_list_add_string(61ec312b340c2952).(pdlist, keyword, value); |
| 490 | } |
| 491 | } |
| 492 | if (option) |
| 493 | { |
| 494 | char buf[64]; |
| 495 | (void) sprintfcxx . . $ sprintf(26c8642d26409d6d).(buf, "%d", num_choices); |
| 496 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(option, "num_choices", buf); |
| 497 | option = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 498 | stp_option_data_name[0] = '\0'; |
| 499 | } |
| 500 | |
| 501 | for (i = 0; i < stp_string_list_countcxx . . $ stp_string_list_count(53b7214102d1daf6).(ialist); i++) |
| 502 | { |
| 503 | stp_param_string_tcxx . . $ stp_param_string_t# *pstr = stp_string_list_paramcxx . . $ stp_string_list_param(1d71fb1c8ad3926a).(ialist, i); |
| 504 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *psize = stpi_xmlppd_find_page_sizecxx . . $ stpi_xmlppd_find_page_size(85c1b86a85cbb6d).(ppd, pstr->namecxx . . $ $anonymous_type_cb0224bbe5755622_0#name.); |
| 505 | if (psize) |
| 506 | { |
| 507 | const char *data[4]; |
| 508 | value = stp_strdupcxx . . $ stp_strdup(a8b8e32347182212).(pstr->textcxx . . $ $anonymous_type_cb0224bbe5755622_0#text.); |
| 509 | parse_valuescxx . . $ parse_values(d07bd281fd8df0db).(data, 4, value); |
| 510 | if (data[3]) |
| 511 | { |
| 512 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(psize, "left", data[0]); |
| 513 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(psize, "bottom", data[1]); |
| 514 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(psize, "right", data[2]); |
| 515 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(psize, "top", data[3]); |
| 516 | } |
| 517 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(value); |
| 518 | } |
| 519 | } |
| 520 | stp_string_list_destroycxx . . $ stp_string_list_destroy(73d8582195bcdbb3).(ialist); |
| 521 | for (i = 0; i < stp_string_list_countcxx . . $ stp_string_list_count(53b7214102d1daf6).(pdlist); i++) |
| 522 | { |
| 523 | stp_param_string_tcxx . . $ stp_param_string_t# *pstr = stp_string_list_paramcxx . . $ stp_string_list_param(1d71fb1c8ad3926a).(pdlist, i); |
| 524 | stp_mxml_node_tcxx . . $ stp_mxml_node_t# *psize = stpi_xmlppd_find_page_sizecxx . . $ stpi_xmlppd_find_page_size(85c1b86a85cbb6d).(ppd, pstr->namecxx . . $ $anonymous_type_cb0224bbe5755622_0#name.); |
| 525 | if (psize) |
| 526 | { |
| 527 | const char *data[2]; |
| 528 | value = stp_strdupcxx . . $ stp_strdup(a8b8e32347182212).(pstr->textcxx . . $ $anonymous_type_cb0224bbe5755622_0#text.); |
| 529 | parse_valuescxx . . $ parse_values(d07bd281fd8df0db).(data, 2, value); |
| 530 | if (data[1]) |
| 531 | { |
| 532 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(psize, "width", data[0]); |
| 533 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(psize, "height", data[1]); |
| 534 | } |
| 535 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(value); |
| 536 | } |
| 537 | } |
| 538 | stp_string_list_destroycxx . . $ stp_string_list_destroy(73d8582195bcdbb3).(pdlist); |
| 539 | option_count = stpi_xmlppd_find_option_countcxx . . $ stpi_xmlppd_find_option_count(9003748477915f72).(ppd); |
| 540 | order_length = 1; /* Terminating null */ |
| 541 | order_array = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(order_tcxx . . $ order_t#) * option_count); |
| 542 | i = 0; |
| 543 | for (option = stp_mxmlFindElementcxx . . $ stp_mxmlFindElement(9d3a1ee0d733a1fa).(ppd, ppd, "option", NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, |
| 544 | STP_MXML_DESCENDcxx . . $ `include/gutenprint/mxml.h:51:11`!); |
| 545 | option && i < option_count; |
| 546 | option = stp_mxmlFindElementcxx . . $ stp_mxmlFindElement(9d3a1ee0d733a1fa).(option, ppd, "option", NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, |
| 547 | STP_MXML_DESCENDcxx . . $ `include/gutenprint/mxml.h:51:11`!)) |
| 548 | { |
| 549 | if (stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(option, "order")) |
| 550 | { |
| 551 | order_array[i].namecxx . . $ $anonymous_type_6e128fd0d39b8ac9_0#name. = stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(option, "name"); |
| 552 | order_length += strlencxx . . $ strlen(751346f8406fd082).(order_array[i].namecxx . . $ $anonymous_type_6e128fd0d39b8ac9_0#name.) + 1; |
| 553 | order_array[i].ordercxx . . $ $anonymous_type_6e128fd0d39b8ac9_0#order. = atoicxx . . $ atoi(5c4306d8553b3696).(stp_mxmlElementGetAttrcxx . . $ stp_mxmlElementGetAttr(42933e0d82869bb1).(option, "order")); |
| 554 | i++; |
| 555 | } |
| 556 | } |
| 557 | option_count = i; |
| 558 | qsortcxx . . $ qsort(ebb60b13a65e77d7).(order_array, option_count, sizeof(order_tcxx . . $ order_t#), &order_comparecxx . . $ order_compare(9148c8c3ff42c9d8).); |
| 559 | order_list = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(order_length); |
| 560 | order_length = 0; |
| 561 | for (i = 0; i < option_count; i++) |
| 562 | { |
| 563 | if (i > 0) |
| 564 | order_list[order_length++] = ' '; |
| 565 | strcpycxx . . $ strcpy(b7b3a83273496486).(order_list + order_length, order_array[i].namecxx . . $ $anonymous_type_6e128fd0d39b8ac9_0#name.); |
| 566 | order_length += strlencxx . . $ strlen(751346f8406fd082).(order_array[i].namecxx . . $ $anonymous_type_6e128fd0d39b8ac9_0#name.); |
| 567 | } |
| 568 | stp_mxmlElementSetAttrcxx . . $ stp_mxmlElementSetAttr(22374eb3aa38e502).(ppd, "optionorder", order_list); |
| 569 | freecxx . . $ free(5d22bdacc48458e8).(order_list); |
| 570 | freecxx . . $ free(5d22bdacc48458e8).(order_array); |
| 571 | return (ppd); |
| 572 | } |
| 573 | |
| 574 | /* |
| 575 | * End of "xmlppd.c". |
| 576 | */ |