| 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 | #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 <string.h> |
| 29 | |
| 30 | static void |
| 31 | free_list_elementcxx . . $ free_list_element(5d22bdacc48458e8).(void *item) |
| 32 | { |
| 33 | stp_param_string_tcxx . . $ stp_param_string_t# *string = (stp_param_string_tcxx . . $ stp_param_string_t# *) (item); |
| 34 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(stpi_cast_safecxx . . $ stpi_cast_safe(3343d82129b43479).(string->namecxx . . $ $anonymous_type_cb0224bbe5755622_0#name.)); |
| 35 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(stpi_cast_safecxx . . $ stpi_cast_safe(3343d82129b43479).(string->textcxx . . $ $anonymous_type_cb0224bbe5755622_0#text.)); |
| 36 | stp_freecxx . . $ stp_free(5d22bdacc48458e8).(string); |
| 37 | } |
| 38 | |
| 39 | static const char * |
| 40 | namefunccxx . . $ namefunc(6271d96ae060557f).(const void *item) |
| 41 | { |
| 42 | const stp_param_string_tcxx . . $ stp_param_string_t# *string = (const stp_param_string_tcxx . . $ stp_param_string_t# *) (item); |
| 43 | return string->namecxx . . $ $anonymous_type_cb0224bbe5755622_0#name.; |
| 44 | } |
| 45 | |
| 46 | static void * |
| 47 | copyfunccxx . . $ copyfunc(3343d82129b43479).(const void *item) |
| 48 | { |
| 49 | const stp_param_string_tcxx . . $ stp_param_string_t# *string = (const stp_param_string_tcxx . . $ stp_param_string_t# *) (item); |
| 50 | stp_param_string_tcxx . . $ stp_param_string_t# *new_string = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(sizeof(stp_param_string_tcxx . . $ stp_param_string_t#)); |
| 51 | new_string->namecxx . . $ $anonymous_type_cb0224bbe5755622_0#name. = stp_strdupcxx . . $ stp_strdup(a8b8e32347182212).(string->namecxx . . $ $anonymous_type_cb0224bbe5755622_0#name.); |
| 52 | new_string->textcxx . . $ $anonymous_type_cb0224bbe5755622_0#text. = stp_strdupcxx . . $ stp_strdup(a8b8e32347182212).(string->textcxx . . $ $anonymous_type_cb0224bbe5755622_0#text.); |
| 53 | return new_string; |
| 54 | } |
| 55 | |
| 56 | static const char * |
| 57 | long_namefunccxx . . $ long_namefunc(6271d96ae060557f).(const void *item) |
| 58 | { |
| 59 | const stp_param_string_tcxx . . $ stp_param_string_t# *string = (const stp_param_string_tcxx . . $ stp_param_string_t# *) (item); |
| 60 | return string->textcxx . . $ $anonymous_type_cb0224bbe5755622_0#text.; |
| 61 | } |
| 62 | |
| 63 | stp_string_list_tcxx . . $ stp_string_list_t# * |
| 64 | stp_string_list_createcxx . . $ stp_string_list_create(f262b3b5e10fad14).(void) |
| 65 | { |
| 66 | stp_list_tcxx . . $ stp_list_t# *ret = stp_list_createcxx . . $ stp_list_create(728167c67729d082).(); |
| 67 | stp_list_set_freefunccxx . . $ stp_list_set_freefunc(309a84c3f950ef37).(ret, free_list_elementcxx . . $ free_list_element(5d22bdacc48458e8).); |
| 68 | stp_list_set_namefunccxx . . $ stp_list_set_namefunc(83503c4472347457).(ret, namefunccxx . . $ namefunc(6271d96ae060557f).); |
| 69 | stp_list_set_copyfunccxx . . $ stp_list_set_copyfunc(84c06c9bbe527258).(ret, copyfunccxx . . $ copyfunc(3343d82129b43479).); |
| 70 | stp_list_set_long_namefunccxx . . $ stp_list_set_long_namefunc(83503c4472347457).(ret, long_namefunccxx . . $ long_namefunc(6271d96ae060557f).); |
| 71 | return (stp_string_list_tcxx . . $ stp_string_list_t# *) ret; |
| 72 | } |
| 73 | |
| 74 | void |
| 75 | stp_string_list_destroycxx . . $ stp_string_list_destroy(73d8582195bcdbb3).(stp_string_list_tcxx . . $ stp_string_list_t# *list) |
| 76 | { |
| 77 | stp_list_destroycxx . . $ stp_list_destroy(29ae8ff464c7f7e5).((stp_list_tcxx . . $ stp_list_t# *) list); |
| 78 | } |
| 79 | |
| 80 | stp_param_string_tcxx . . $ stp_param_string_t# * |
| 81 | stp_string_list_paramcxx . . $ stp_string_list_param(1d71fb1c8ad3926a).(const stp_string_list_tcxx . . $ stp_string_list_t# *list, size_t element) |
| 82 | { |
| 83 | stp_list_item_tcxx . . $ stp_list_item_t# *answer = |
| 84 | stp_list_get_item_by_indexcxx . . $ stp_list_get_item_by_index(868af1dce2882582).((const stp_list_tcxx . . $ stp_list_t# *)list, element); |
| 85 | if (answer) |
| 86 | return (stp_param_string_tcxx . . $ stp_param_string_t# *) stp_list_item_get_datacxx . . $ stp_list_item_get_data(9a5daa75441a53b5).(answer); |
| 87 | else |
| 88 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 89 | } |
| 90 | |
| 91 | stp_param_string_tcxx . . $ stp_param_string_t# * |
| 92 | stp_string_list_findcxx . . $ stp_string_list_find(e483be985c44e37a).(const stp_string_list_tcxx . . $ stp_string_list_t# *list, const char *name) |
| 93 | { |
| 94 | stp_list_item_tcxx . . $ stp_list_item_t# *answer = |
| 95 | stp_list_get_item_by_namecxx . . $ stp_list_get_item_by_name(27765cfe86595311).((const stp_list_tcxx . . $ stp_list_t# *)list, name); |
| 96 | if (answer) |
| 97 | return (stp_param_string_tcxx . . $ stp_param_string_t# *) stp_list_item_get_datacxx . . $ stp_list_item_get_data(9a5daa75441a53b5).(answer); |
| 98 | else |
| 99 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 100 | } |
| 101 | |
| 102 | size_t |
| 103 | stp_string_list_countcxx . . $ stp_string_list_count(53b7214102d1daf6).(const stp_string_list_tcxx . . $ stp_string_list_t# *list) |
| 104 | { |
| 105 | return stp_list_get_lengthcxx . . $ stp_list_get_length(c31cc8fb9e1f67aa).((const stp_list_tcxx . . $ stp_list_t# *)list); |
| 106 | } |
| 107 | |
| 108 | stp_string_list_tcxx . . $ stp_string_list_t# * |
| 109 | stp_string_list_create_copycxx . . $ stp_string_list_create_copy(e012ce47cdb87343).(const stp_string_list_tcxx . . $ stp_string_list_t# *list) |
| 110 | { |
| 111 | return (stp_string_list_tcxx . . $ stp_string_list_t# *) stp_list_copycxx . . $ stp_list_copy(a0eb3ec16ac58482).((const stp_list_tcxx . . $ stp_list_t# *)list); |
| 112 | } |
| 113 | |
| 114 | stp_string_list_tcxx . . $ stp_string_list_t# * |
| 115 | stp_string_list_create_from_paramscxx . . $ stp_string_list_create_from_params(ffe3182f372406ba).(const stp_param_string_tcxx . . $ stp_param_string_t# *list, |
| 116 | size_t count) |
| 117 | { |
| 118 | size_t i = 0; |
| 119 | stp_string_list_tcxx . . $ stp_string_list_t# *retval = stp_string_list_createcxx . . $ stp_string_list_create(f262b3b5e10fad14).(); |
| 120 | for (i = 0; i < count; i++) |
| 121 | stp_string_list_add_stringcxx . . $ stp_string_list_add_string(61ec312b340c2952).(retval, list[i].namecxx . . $ $anonymous_type_cb0224bbe5755622_0#name., list[i].textcxx . . $ $anonymous_type_cb0224bbe5755622_0#text.); |
| 122 | return retval; |
| 123 | } |
| 124 | |
| 125 | void |
| 126 | stp_string_list_add_stringcxx . . $ stp_string_list_add_string(61ec312b340c2952).(stp_string_list_tcxx . . $ stp_string_list_t# *list, |
| 127 | const char *name, |
| 128 | const char *text) |
| 129 | { |
| 130 | stp_param_string_tcxx . . $ stp_param_string_t# *new_string = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(sizeof(stp_param_string_tcxx . . $ stp_param_string_t#)); |
| 131 | do |
| 132 | { |
| 133 | const char *xname = name; |
| 134 | while (*xname) |
| 135 | { |
| 136 | if (!isalnumcxx . . $ `<external>/17904084882347303253/ctype.h:189:10`!(*xname) && |
| 137 | *xname != '_' && *xname != '-' && *xname != '+') |
| 138 | { |
| 139 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("Gutenprint: bad string %s (%s)\n", name, text); |
| 140 | break; |
| 141 | } |
| 142 | xname++; |
| 143 | } |
| 144 | } while(0); |
| 145 | new_string->namecxx . . $ $anonymous_type_cb0224bbe5755622_0#name. = stp_strdupcxx . . $ stp_strdup(a8b8e32347182212).(name); |
| 146 | new_string->textcxx . . $ $anonymous_type_cb0224bbe5755622_0#text. = stp_strdupcxx . . $ stp_strdup(a8b8e32347182212).(text); |
| 147 | stp_list_item_createcxx . . $ stp_list_item_create(54f08bf465e39eec).((stp_list_tcxx . . $ stp_list_t# *) list, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, new_string); |
| 148 | } |
| 149 | |
| 150 | void |
| 151 | stp_string_list_add_string_unsafecxx . . $ stp_string_list_add_string_unsafe(61ec312b340c2952).(stp_string_list_tcxx . . $ stp_string_list_t# *list, |
| 152 | const char *name, |
| 153 | const char *text) |
| 154 | { |
| 155 | stp_param_string_tcxx . . $ stp_param_string_t# *new_string = stp_malloccxx . . $ stp_malloc(bfcfa4d6b7f7ef64).(sizeof(stp_param_string_tcxx . . $ stp_param_string_t#)); |
| 156 | new_string->namecxx . . $ $anonymous_type_cb0224bbe5755622_0#name. = stp_strdupcxx . . $ stp_strdup(a8b8e32347182212).(name); |
| 157 | new_string->textcxx . . $ $anonymous_type_cb0224bbe5755622_0#text. = stp_strdupcxx . . $ stp_strdup(a8b8e32347182212).(text); |
| 158 | stp_list_item_createcxx . . $ stp_list_item_create(54f08bf465e39eec).((stp_list_tcxx . . $ stp_list_t# *) list, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, new_string); |
| 159 | } |
| 160 | |
| 161 | void |
| 162 | stp_string_list_remove_stringcxx . . $ stp_string_list_remove_string(24ca7d3bba3c474e).(stp_string_list_tcxx . . $ stp_string_list_t# *list, |
| 163 | const char *name) |
| 164 | { |
| 165 | stp_list_item_tcxx . . $ stp_list_item_t# *item = |
| 166 | stp_list_get_item_by_namecxx . . $ stp_list_get_item_by_name(27765cfe86595311).((const stp_list_tcxx . . $ stp_list_t# *) list, name); |
| 167 | if (item) |
| 168 | stp_list_item_destroycxx . . $ stp_list_item_destroy(e8436428ff1ae51).((stp_list_tcxx . . $ stp_list_t# *) list, item); |
| 169 | } |
| 170 | |
| 171 | int |
| 172 | stp_string_list_is_presentcxx . . $ stp_string_list_is_present(bf726c32497cc2b).(const stp_string_list_tcxx . . $ stp_string_list_t# *list, |
| 173 | const char *value) |
| 174 | { |
| 175 | if (list && value && |
| 176 | stp_list_get_item_by_namecxx . . $ stp_list_get_item_by_name(27765cfe86595311).((const stp_list_tcxx . . $ stp_list_t# *) list, value)) |
| 177 | return 1; |
| 178 | else |
| 179 | return 0; |
| 180 | } |