| 1 | /* |
| 2 | * |
| 3 | * Gimp-Print color module interface. |
| 4 | * |
| 5 | * Copyright (C) 2003 Roger Leigh ([email protected]) |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License as published by the Free |
| 9 | * Software Foundation; either version 2 of the License, or (at your option) |
| 10 | * any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 15 | * for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | /* |
| 22 | * This file must include only standard C header files. The core code must |
| 23 | * compile on generic platforms that don't support glib, gimp, gtk, etc. |
| 24 | */ |
| 25 | |
| 26 | #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:411:9`! |
| 27 | #include <config.h>cxx . . $ `<file>/config.h`/ |
| 28 | #endif |
| 29 | #include <gutenprint/gutenprint.h>cxx . . $ `<file>/include/gutenprint/gutenprint.h`/ |
| 30 | #include "gutenprint-internal.h"cxx . . $ `<file>/src/main/gutenprint-internal.h`/ |
| 31 | #include <gutenprint/gutenprint-intl-internal.h>cxx . . $ `<file>/include/gutenprint/gutenprint-intl-internal.h`/ |
| 32 | #include <string.h> |
| 33 | #include <stdlib.h> |
| 34 | |
| 35 | |
| 36 | static const char* stpi_color_namefunccxx . . $ stpi_color_namefunc(6271d96ae060557f).(const void *item); |
| 37 | static const char* stpi_color_long_namefunccxx . . $ stpi_color_long_namefunc(6271d96ae060557f).(const void *item); |
| 38 | |
| 39 | static stp_list_tcxx . . $ stp_list_t# *color_listcxx . . $ color_list. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 40 | |
| 41 | |
| 42 | static int |
| 43 | stpi_init_color_listcxx . . $ stpi_init_color_list(b126dc7c1de90089).(void) |
| 44 | { |
| 45 | STPI_ASSERTcxx . . $ `src/main/gutenprint-internal.h:58:9`!(color_list == 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`!); |
| 46 | color_listcxx . . $ color_list. = stp_list_createcxx . . $ stp_list_create(728167c67729d082).(); |
| 47 | stp_list_set_namefunccxx . . $ stp_list_set_namefunc(83503c4472347457).(color_listcxx . . $ color_list., stpi_color_namefunccxx . . $ stpi_color_namefunc(6271d96ae060557f).); |
| 48 | stp_list_set_long_namefunccxx . . $ stp_list_set_long_namefunc(83503c4472347457).(color_listcxx . . $ color_list., stpi_color_long_namefunccxx . . $ stpi_color_long_namefunc(6271d96ae060557f).); |
| 49 | /* stp_list_set_sortfunc(color_list, stpi_color_sortfunc); */ |
| 50 | |
| 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | static inline void |
| 55 | check_listcxx . . $ check_list(49f6e7a06ebc5aa8).(void) |
| 56 | { |
| 57 | if (color_listcxx . . $ color_list. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 58 | { |
| 59 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("No color drivers found: " |
| 60 | "are STP_DATA_PATH and STP_MODULE_PATH correct?\n"); |
| 61 | stpi_init_color_listcxx . . $ stpi_init_color_list(b126dc7c1de90089).(); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | |
| 66 | |
| 67 | int |
| 68 | stp_color_countcxx . . $ stp_color_count(b126dc7c1de90089).(void) |
| 69 | { |
| 70 | if (color_listcxx . . $ color_list. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 71 | { |
| 72 | stp_erprintfcxx . . $ stp_erprintf(326aeb464d16410c).("No color modules found: " |
| 73 | "is STP_MODULE_PATH correct?\n"); |
| 74 | stpi_init_color_listcxx . . $ stpi_init_color_list(b126dc7c1de90089).(); |
| 75 | } |
| 76 | return stp_list_get_lengthcxx . . $ stp_list_get_length(c31cc8fb9e1f67aa).(color_listcxx . . $ color_list.); |
| 77 | } |
| 78 | |
| 79 | #define CHECK_COLORcxx . . $ `src/main/color.c:79:9`!(c) STPI_ASSERTcxx . . $ `src/main/gutenprint-internal.h:58:9`!(c != 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`!) |
| 80 | |
| 81 | const stp_color_tcxx . . $ stp_color_t# * |
| 82 | stp_get_color_by_indexcxx . . $ stp_get_color_by_index(74d2389ca1d26e2b).(int idx) |
| 83 | { |
| 84 | stp_list_item_tcxx . . $ stp_list_item_t# *color; |
| 85 | |
| 86 | check_listcxx . . $ check_list(49f6e7a06ebc5aa8).(); |
| 87 | |
| 88 | color = stp_list_get_item_by_indexcxx . . $ stp_list_get_item_by_index(868af1dce2882582).(color_listcxx . . $ color_list., idx); |
| 89 | if (color == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 90 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 91 | return (const stp_color_tcxx . . $ stp_color_t# *) stp_list_item_get_datacxx . . $ stp_list_item_get_data(9a5daa75441a53b5).(color); |
| 92 | } |
| 93 | |
| 94 | |
| 95 | static const char * |
| 96 | stpi_color_namefunccxx . . $ stpi_color_namefunc(6271d96ae060557f).(const void *item) |
| 97 | { |
| 98 | const stp_color_tcxx . . $ stp_color_t# *color = (const stp_color_tcxx . . $ stp_color_t# *) item; |
| 99 | CHECK_COLORcxx . . $ `src/main/color.c:79:9`!(color); |
| 100 | return color->short_namecxx . . $ stp_color#short_name.; |
| 101 | } |
| 102 | |
| 103 | |
| 104 | static const char * |
| 105 | stpi_color_long_namefunccxx . . $ stpi_color_long_namefunc(6271d96ae060557f).(const void *item) |
| 106 | { |
| 107 | const stp_color_tcxx . . $ stp_color_t# *color = (const stp_color_tcxx . . $ stp_color_t# *) item; |
| 108 | CHECK_COLORcxx . . $ `src/main/color.c:79:9`!(color); |
| 109 | return color->long_namecxx . . $ stp_color#long_name.; |
| 110 | } |
| 111 | |
| 112 | |
| 113 | const char * |
| 114 | stp_color_get_namecxx . . $ stp_color_get_name(4c8c6fbd29ac5d1c).(const stp_color_tcxx . . $ stp_color_t# *c) |
| 115 | { |
| 116 | const stp_color_tcxx . . $ stp_color_t# *val = (const stp_color_tcxx . . $ stp_color_t# *) c; |
| 117 | CHECK_COLORcxx . . $ `src/main/color.c:79:9`!(val); |
| 118 | return val->short_namecxx . . $ stp_color#short_name.; |
| 119 | } |
| 120 | |
| 121 | const char * |
| 122 | stp_color_get_long_namecxx . . $ stp_color_get_long_name(4c8c6fbd29ac5d1c).(const stp_color_tcxx . . $ stp_color_t# *c) |
| 123 | { |
| 124 | const stp_color_tcxx . . $ stp_color_t# *val = (const stp_color_tcxx . . $ stp_color_t# *) c; |
| 125 | CHECK_COLORcxx . . $ `src/main/color.c:79:9`!(val); |
| 126 | return gettextcxx . . $ `include/gutenprint/gutenprint-intl-internal.h:61:11`!(val->long_name); |
| 127 | } |
| 128 | |
| 129 | |
| 130 | static const stp_colorfuncs_tcxx . . $ stp_colorfuncs_t# * |
| 131 | stpi_get_colorfuncscxx . . $ stpi_get_colorfuncs(1981acf2d01fda7f).(const stp_color_tcxx . . $ stp_color_t# *c) |
| 132 | { |
| 133 | const stp_color_tcxx . . $ stp_color_t# *val = (const stp_color_tcxx . . $ stp_color_t# *) c; |
| 134 | CHECK_COLORcxx . . $ `src/main/color.c:79:9`!(val); |
| 135 | return val->colorfuncscxx . . $ stp_color#colorfuncs.; |
| 136 | } |
| 137 | |
| 138 | |
| 139 | const stp_color_tcxx . . $ stp_color_t# * |
| 140 | stp_get_color_by_namecxx . . $ stp_get_color_by_name(b19d89c6f1b190f4).(const char *name) |
| 141 | { |
| 142 | stp_list_item_tcxx . . $ stp_list_item_t# *color; |
| 143 | |
| 144 | check_listcxx . . $ check_list(49f6e7a06ebc5aa8).(); |
| 145 | |
| 146 | color = stp_list_get_item_by_namecxx . . $ stp_list_get_item_by_name(27765cfe86595311).(color_listcxx . . $ color_list., name); |
| 147 | if (!color) |
| 148 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 149 | return (const stp_color_tcxx . . $ stp_color_t# *) stp_list_item_get_datacxx . . $ stp_list_item_get_data(9a5daa75441a53b5).(color); |
| 150 | } |
| 151 | |
| 152 | const stp_color_tcxx . . $ stp_color_t# * |
| 153 | stp_get_color_by_colorfuncscxx . . $ stp_get_color_by_colorfuncs(c92845191cf63e12).(stp_colorfuncs_tcxx . . $ stp_colorfuncs_t# *colorfuncs) |
| 154 | { |
| 155 | stp_list_item_tcxx . . $ stp_list_item_t# *color_item; |
| 156 | stp_color_tcxx . . $ stp_color_t# *color; |
| 157 | |
| 158 | check_listcxx . . $ check_list(49f6e7a06ebc5aa8).(); |
| 159 | |
| 160 | color_item = stp_list_get_startcxx . . $ stp_list_get_start(44f6202a74729935).(color_listcxx . . $ color_list.); |
| 161 | while (color_item) |
| 162 | { |
| 163 | color = (stp_color_tcxx . . $ stp_color_t# *) stp_list_item_get_datacxx . . $ stp_list_item_get_data(9a5daa75441a53b5).(color_item); |
| 164 | if (color->colorfuncscxx . . $ stp_color#colorfuncs. == colorfuncs) |
| 165 | return color; |
| 166 | color_item = stp_list_item_nextcxx . . $ stp_list_item_next(83833ec172b48f23).(color_item); |
| 167 | } |
| 168 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 169 | } |
| 170 | |
| 171 | |
| 172 | int |
| 173 | stp_color_initcxx . . $ stp_color_init(8474e95f5358b69d).(stp_vars_tcxx . . $ stp_vars_t# *v, |
| 174 | stp_image_tcxx . . $ stp_image_t# *image, |
| 175 | size_t steps) |
| 176 | { |
| 177 | const stp_colorfuncs_tcxx . . $ stp_colorfuncs_t# *colorfuncs = |
| 178 | stpi_get_colorfuncscxx . . $ stpi_get_colorfuncs(1981acf2d01fda7f).(stp_get_color_by_namecxx . . $ stp_get_color_by_name(b19d89c6f1b190f4).(stp_get_color_conversioncxx . . $ stp_get_color_conversion(4be828c28602b542).(v))); |
| 179 | return colorfuncs->initcxx . . $ $anonymous_type_59c2473a996a5952_0#init.(v, image, steps); |
| 180 | } |
| 181 | |
| 182 | int |
| 183 | stp_color_get_rowcxx . . $ stp_color_get_row(ba7b466a9562988e).(stp_vars_tcxx . . $ stp_vars_t# *v, |
| 184 | stp_image_tcxx . . $ stp_image_t# *image, |
| 185 | int row, |
| 186 | unsigned *zero_mask) |
| 187 | { |
| 188 | const stp_colorfuncs_tcxx . . $ stp_colorfuncs_t# *colorfuncs = |
| 189 | stpi_get_colorfuncscxx . . $ stpi_get_colorfuncs(1981acf2d01fda7f).(stp_get_color_by_namecxx . . $ stp_get_color_by_name(b19d89c6f1b190f4).(stp_get_color_conversioncxx . . $ stp_get_color_conversion(4be828c28602b542).(v))); |
| 190 | return colorfuncs->get_rowcxx . . $ $anonymous_type_59c2473a996a5952_0#get_row.(v, image, row, zero_mask); |
| 191 | } |
| 192 | |
| 193 | stp_parameter_list_tcxx . . $ stp_parameter_list_t# |
| 194 | stp_color_list_parameterscxx . . $ stp_color_list_parameters(817585d40f809196).(const stp_vars_tcxx . . $ stp_vars_t# *v) |
| 195 | { |
| 196 | const stp_colorfuncs_tcxx . . $ stp_colorfuncs_t# *colorfuncs = |
| 197 | stpi_get_colorfuncscxx . . $ stpi_get_colorfuncs(1981acf2d01fda7f).(stp_get_color_by_namecxx . . $ stp_get_color_by_name(b19d89c6f1b190f4).(stp_get_color_conversioncxx . . $ stp_get_color_conversion(4be828c28602b542).(v))); |
| 198 | return colorfuncs->list_parameterscxx . . $ $anonymous_type_59c2473a996a5952_0#list_parameters.(v); |
| 199 | } |
| 200 | |
| 201 | void |
| 202 | stp_color_describe_parametercxx . . $ stp_color_describe_parameter(dfd5b9531b51a6d2).(const stp_vars_tcxx . . $ stp_vars_t# *v, const char *name, |
| 203 | stp_parameter_tcxx . . $ stp_parameter_t# *description) |
| 204 | { |
| 205 | const stp_colorfuncs_tcxx . . $ stp_colorfuncs_t# *colorfuncs = |
| 206 | stpi_get_colorfuncscxx . . $ stpi_get_colorfuncs(1981acf2d01fda7f).(stp_get_color_by_namecxx . . $ stp_get_color_by_name(b19d89c6f1b190f4).(stp_get_color_conversioncxx . . $ stp_get_color_conversion(4be828c28602b542).(v))); |
| 207 | colorfuncs->describe_parametercxx . . $ $anonymous_type_59c2473a996a5952_0#describe_parameter.(v, name, description); |
| 208 | } |
| 209 | |
| 210 | |
| 211 | int |
| 212 | stp_color_registercxx . . $ stp_color_register(ab934adf54b95da0).(const stp_color_tcxx . . $ stp_color_t# *color) |
| 213 | { |
| 214 | if (color_listcxx . . $ color_list. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 215 | { |
| 216 | stpi_init_color_listcxx . . $ stpi_init_color_list(b126dc7c1de90089).(); |
| 217 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3).(STP_DBG_COLORFUNCcxx . . $ `include/gutenprint/util.h:167:9`!, |
| 218 | "stpi_color_register(): initialising color_list...\n"); |
| 219 | } |
| 220 | |
| 221 | CHECK_COLORcxx . . $ `src/main/color.c:79:9`!(color); |
| 222 | |
| 223 | if (color) |
| 224 | { |
| 225 | /* Add new color algorithm if it does not already exist */ |
| 226 | if (stp_get_color_by_namecxx . . $ stp_get_color_by_name(b19d89c6f1b190f4).(color->short_namecxx . . $ stp_color#short_name.) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 227 | { |
| 228 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3). |
| 229 | (STP_DBG_COLORFUNCcxx . . $ `include/gutenprint/util.h:167:9`!, |
| 230 | "stpi_color_register(): registered colour module \"%s\"\n", |
| 231 | color->short_namecxx . . $ stp_color#short_name.); |
| 232 | stp_list_item_createcxx . . $ stp_list_item_create(54f08bf465e39eec).(color_listcxx . . $ color_list., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, color); |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | return 0; |
| 237 | } |
| 238 | |
| 239 | int |
| 240 | stp_color_unregistercxx . . $ stp_color_unregister(ab934adf54b95da0).(const stp_color_tcxx . . $ stp_color_t# *color) |
| 241 | { |
| 242 | stp_list_item_tcxx . . $ stp_list_item_t# *color_item; |
| 243 | stp_color_tcxx . . $ stp_color_t# *color_data; |
| 244 | |
| 245 | if (color_listcxx . . $ color_list. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 246 | { |
| 247 | stpi_init_color_listcxx . . $ stpi_init_color_list(b126dc7c1de90089).(); |
| 248 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3). |
| 249 | (STP_DBG_COLORFUNCcxx . . $ `include/gutenprint/util.h:167:9`!, |
| 250 | "stpi_family_unregister(): initialising color_list...\n"); |
| 251 | } |
| 252 | |
| 253 | CHECK_COLORcxx . . $ `src/main/color.c:79:9`!(color); |
| 254 | |
| 255 | color_item = stp_list_get_startcxx . . $ stp_list_get_start(44f6202a74729935).(color_listcxx . . $ color_list.); |
| 256 | while (color_item) |
| 257 | { |
| 258 | color_data = (stp_color_tcxx . . $ stp_color_t# *) stp_list_item_get_datacxx . . $ stp_list_item_get_data(9a5daa75441a53b5).(color_item); |
| 259 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(color->short_namecxx . . $ stp_color#short_name., color_data->short_namecxx . . $ stp_color#short_name.) == 0) |
| 260 | { |
| 261 | stp_deprintfcxx . . $ stp_deprintf(3d303ebd7ab3b1e3). |
| 262 | (STP_DBG_COLORFUNCcxx . . $ `include/gutenprint/util.h:167:9`!, |
| 263 | "stpi_color_unregister(): unregistered colour module \"%s\"\n", |
| 264 | color->short_namecxx . . $ stp_color#short_name.); |
| 265 | stp_list_item_destroycxx . . $ stp_list_item_destroy(e8436428ff1ae51).(color_listcxx . . $ color_list., color_item); |
| 266 | break; |
| 267 | } |
| 268 | color_item = stp_list_item_nextcxx . . $ stp_list_item_next(83833ec172b48f23).(color_item); |
| 269 | } |
| 270 | |
| 271 | return 0; |
| 272 | } |