| File: | _build/../cdk-pixbuf/io-icns.c |
| Warning: | line 98, column 16 Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* Mac OS X .icns icons loader |
| 2 | * |
| 3 | * Copyright (c) 2007 Lyonel Vincent <lyonel@ezix.org> |
| 4 | * Copyright (c) 2007 Bastien Nocera <hadess@hadess.net> |
| 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | #ifndef _WIN32 |
| 21 | #define _GNU_SOURCE |
| 22 | #endif |
| 23 | #include "config.h" |
| 24 | |
| 25 | #include <stdlib.h> |
| 26 | #include <string.h> |
| 27 | #include <errno(*__errno_location ()).h> |
| 28 | |
| 29 | #include <glib-object.h> |
| 30 | #include <glib/gi18n-lib.h> |
| 31 | |
| 32 | #include "cdk-pixbuf-core.h" |
| 33 | #include "cdk-pixbuf-io.h" |
| 34 | #include "cdk-pixbuf-loader.h" |
| 35 | |
| 36 | G_MODULE_EXPORT__attribute__((visibility("default"))) void fill_vtable (CdkPixbufModule * module); |
| 37 | G_MODULE_EXPORT__attribute__((visibility("default"))) void fill_info (CdkPixbufFormat * info); |
| 38 | |
| 39 | #define IN /**/ |
| 40 | #define OUT /**/ |
| 41 | #define INOUT /**/ |
| 42 | |
| 43 | struct IcnsBlockHeader |
| 44 | { |
| 45 | char id[4]; |
| 46 | guint32 size; /* caution: bigendian */ |
| 47 | }; |
| 48 | typedef struct IcnsBlockHeader IcnsBlockHeader; |
| 49 | |
| 50 | typedef struct |
| 51 | { |
| 52 | CdkPixbufModuleSizeFunc size_func; |
| 53 | CdkPixbufModulePreparedFunc prepared_func; |
| 54 | CdkPixbufModuleUpdatedFunc updated_func; |
| 55 | gpointer user_data; |
| 56 | |
| 57 | GByteArray *byte_array; |
| 58 | CdkPixbuf *pixbuf; /* Our "target" */ |
| 59 | } IcnsProgressiveState; |
| 60 | |
| 61 | /* |
| 62 | * load raw icon data from 'icns' resource |
| 63 | * |
| 64 | * returns TRUE when successful |
| 65 | */ |
| 66 | static gboolean |
| 67 | load_resources (unsigned size, IN gpointer data, gsize datalen, |
| 68 | OUT guchar ** picture, OUT gsize * plen, |
| 69 | OUT guchar ** mask, OUT gsize * mlen) |
| 70 | { |
| 71 | IcnsBlockHeader *header = NULL((void*)0); |
| 72 | const char *bytes = NULL((void*)0); |
| 73 | const char *current = NULL((void*)0); |
| 74 | guint32 blocklen = 0; |
| 75 | guint32 icnslen = 0; |
| 76 | gboolean needs_mask = TRUE(!(0)); |
| 77 | |
| 78 | if (datalen < 2 * sizeof (guint32)) |
| 79 | return FALSE(0); |
| 80 | if (!data) |
| 81 | return FALSE(0); |
| 82 | |
| 83 | *picture = *mask = NULL((void*)0); |
| 84 | *plen = *mlen = 0; |
| 85 | |
| 86 | bytes = data; |
| 87 | header = (IcnsBlockHeader *) data; |
| 88 | if (memcmp (header->id, "icns", 4) != 0) |
| 89 | return FALSE(0); |
| 90 | |
| 91 | icnslen = GUINT32_FROM_BE (header->size)((((__extension__ ({ guint32 __v, __x = ((guint32) (header-> size)); if (__builtin_constant_p (__x)) __v = ((guint32) ( (( (guint32) (__x) & (guint32) 0x000000ffU) << 24) | ( ((guint32) (__x) & (guint32) 0x0000ff00U) << 8) | ( ((guint32) (__x) & (guint32) 0x00ff0000U) >> 8) | ( ((guint32) (__x) & (guint32) 0xff000000U) >> 24))); else __asm__ ("bswapl %0" : "=r" (__v) : "0" (__x)); __v; }) )))); |
| 92 | if ((icnslen > datalen) || (icnslen < 2 * sizeof (guint32))) |
| 93 | return FALSE(0); |
| 94 | |
| 95 | current = bytes + sizeof (IcnsBlockHeader); |
| 96 | while ((current - bytes < icnslen) && (icnslen - (current - bytes) >= sizeof (IcnsBlockHeader))) |
| 97 | { |
| 98 | header = (IcnsBlockHeader *) current; |
Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption | |
| 99 | blocklen = GUINT32_FROM_BE (header->size)((((__extension__ ({ guint32 __v, __x = ((guint32) (header-> size)); if (__builtin_constant_p (__x)) __v = ((guint32) ( (( (guint32) (__x) & (guint32) 0x000000ffU) << 24) | ( ((guint32) (__x) & (guint32) 0x0000ff00U) << 8) | ( ((guint32) (__x) & (guint32) 0x00ff0000U) >> 8) | ( ((guint32) (__x) & (guint32) 0xff000000U) >> 24))); else __asm__ ("bswapl %0" : "=r" (__v) : "0" (__x)); __v; }) )))); |
| 100 | |
| 101 | /* Check that blocklen isn't garbage */ |
| 102 | if (blocklen > icnslen - (current - bytes) || |
| 103 | blocklen < sizeof (IcnsBlockHeader)) |
| 104 | return FALSE(0); |
| 105 | |
| 106 | switch (size) |
| 107 | { |
| 108 | case 256: |
| 109 | case 512: |
| 110 | if (memcmp (header->id, "ic08", 4) == 0 /* 256x256 icon */ |
| 111 | || memcmp (header->id, "ic09", 4) == 0) /* 512x512 icon */ |
| 112 | { |
| 113 | *picture = (gpointer) (current + sizeof (IcnsBlockHeader)); |
| 114 | *plen = blocklen - sizeof (IcnsBlockHeader); |
| 115 | } |
| 116 | needs_mask = FALSE(0); |
| 117 | break; |
| 118 | case 128: |
| 119 | if (memcmp (header->id, "it32", 4) == 0) /* 128x128 icon */ |
| 120 | { |
| 121 | *picture = (gpointer) (current + sizeof (IcnsBlockHeader)); |
| 122 | *plen = blocklen - sizeof (IcnsBlockHeader); |
| 123 | if (memcmp (*picture, "\0\0\0\0", 4) == 0) |
| 124 | { |
| 125 | *picture += 4; |
| 126 | *plen -= 4; |
| 127 | } |
| 128 | } |
| 129 | if (memcmp (header->id, "t8mk", 4) == 0) /* 128x128 mask */ |
| 130 | { |
| 131 | *mask = (gpointer) (current + sizeof (IcnsBlockHeader)); |
| 132 | *mlen = blocklen - sizeof (IcnsBlockHeader); |
| 133 | } |
| 134 | break; |
| 135 | case 48: |
| 136 | if (memcmp (header->id, "ih32", 4) == 0) /* 48x48 icon */ |
| 137 | { |
| 138 | *picture = (gpointer) (current + sizeof (IcnsBlockHeader)); |
| 139 | *plen = blocklen - sizeof (IcnsBlockHeader); |
| 140 | } |
| 141 | if (memcmp (header->id, "h8mk", 4) == 0) /* 48x48 mask */ |
| 142 | { |
| 143 | *mask = (gpointer) (current + sizeof (IcnsBlockHeader)); |
| 144 | *mlen = blocklen - sizeof (IcnsBlockHeader); |
| 145 | } |
| 146 | break; |
| 147 | case 32: |
| 148 | if (memcmp (header->id, "il32", 4) == 0) /* 32x32 icon */ |
| 149 | { |
| 150 | *picture = (gpointer) (current + sizeof (IcnsBlockHeader)); |
| 151 | *plen = blocklen - sizeof (IcnsBlockHeader); |
| 152 | } |
| 153 | if (memcmp (header->id, "l8mk", 4) == 0) /* 32x32 mask */ |
| 154 | { |
| 155 | *mask = (gpointer) (current + sizeof (IcnsBlockHeader)); |
| 156 | *mlen = blocklen - sizeof (IcnsBlockHeader); |
| 157 | } |
| 158 | break; |
| 159 | case 16: |
| 160 | if (memcmp (header->id, "is32", 4) == 0) /* 16x16 icon */ |
| 161 | { |
| 162 | *picture = (gpointer) (current + sizeof (IcnsBlockHeader)); |
| 163 | *plen = blocklen - sizeof (IcnsBlockHeader); |
| 164 | } |
| 165 | if (memcmp (header->id, "s8mk", 4) == 0) /* 16x16 mask */ |
| 166 | { |
| 167 | *mask = (gpointer) (current + sizeof (IcnsBlockHeader)); |
| 168 | *mlen = blocklen - sizeof (IcnsBlockHeader); |
| 169 | } |
| 170 | break; |
| 171 | default: |
| 172 | return FALSE(0); |
| 173 | } |
| 174 | |
| 175 | current += blocklen; |
| 176 | } |
| 177 | |
| 178 | if (!*picture) |
| 179 | return FALSE(0); |
| 180 | if (needs_mask && !*mask) |
| 181 | return FALSE(0); |
| 182 | return TRUE(!(0)); |
| 183 | } |
| 184 | |
| 185 | /* |
| 186 | * uncompress RLE-encoded bytes into RGBA scratch zone: |
| 187 | * if firstbyte >= 0x80, it indicates the number of identical bytes + 125 |
| 188 | * (repeated value is stored next: 1 byte) |
| 189 | * otherwise, it indicates the number of non-repeating bytes - 1 |
| 190 | * (non-repeating values are stored next: n bytes) |
| 191 | */ |
| 192 | static gboolean |
| 193 | uncompress (unsigned size, INOUT guchar ** source, OUT guchar * target, INOUT gsize * _remaining) |
| 194 | { |
| 195 | guchar *data = *source; |
| 196 | gsize remaining; |
| 197 | gsize i = 0; |
| 198 | |
| 199 | /* The first time we're called, set remaining */ |
| 200 | if (*_remaining == 0) { |
| 201 | remaining = size * size; |
| 202 | } else { |
| 203 | remaining = *_remaining; |
| 204 | } |
| 205 | |
| 206 | while (remaining > 0) |
| 207 | { |
| 208 | guint8 count = 0; |
| 209 | |
| 210 | if (data[0] & 0x80) /* repeating byte */ |
| 211 | { |
| 212 | count = data[0] - 125; |
| 213 | |
| 214 | if (count > remaining) |
| 215 | return FALSE(0); |
| 216 | |
| 217 | for (i = 0; i < count; i++) |
| 218 | { |
| 219 | *target = data[1]; |
| 220 | target += 4; |
| 221 | } |
| 222 | |
| 223 | data += 2; |
| 224 | } |
| 225 | else /* non-repeating bytes */ |
| 226 | { |
| 227 | count = data[0] + 1; |
| 228 | |
| 229 | if (count > remaining) |
| 230 | return FALSE(0); |
| 231 | |
| 232 | for (i = 0; i < count; i++) |
| 233 | { |
| 234 | *target = data[i + 1]; |
| 235 | target += 4; |
| 236 | } |
| 237 | data += count + 1; |
| 238 | } |
| 239 | |
| 240 | remaining -= count; |
| 241 | } |
| 242 | |
| 243 | *source = data; |
| 244 | *_remaining = remaining; |
| 245 | return TRUE(!(0)); |
| 246 | } |
| 247 | |
| 248 | static CdkPixbuf * |
| 249 | load_icon (unsigned size, IN gpointer data, gsize datalen) |
| 250 | { |
| 251 | guchar *icon = NULL((void*)0); |
| 252 | guchar *mask = NULL((void*)0); |
| 253 | gsize isize = 0, msize = 0, i; |
| 254 | guchar *image = NULL((void*)0); |
| 255 | |
| 256 | if (!load_resources (size, data, datalen, &icon, &isize, &mask, &msize)) |
| 257 | return NULL((void*)0); |
| 258 | |
| 259 | /* 256x256 icons don't use RLE or uncompressed data, |
| 260 | * They're usually JPEG 2000 images */ |
| 261 | if (size == 256) |
| 262 | { |
| 263 | CdkPixbufLoader *loader; |
| 264 | CdkPixbuf *pixbuf; |
| 265 | |
| 266 | loader = cdk_pixbuf_loader_new (); |
| 267 | if (!cdk_pixbuf_loader_write (loader, icon, isize, NULL((void*)0)) |
| 268 | || !cdk_pixbuf_loader_close (loader, NULL((void*)0))) |
| 269 | { |
| 270 | g_object_unref (loader); |
| 271 | return NULL((void*)0); |
| 272 | } |
| 273 | |
| 274 | pixbuf = cdk_pixbuf_loader_get_pixbuf (loader); |
| 275 | g_object_ref (pixbuf)((__typeof__ (pixbuf)) (g_object_ref) (pixbuf)); |
| 276 | g_object_unref (loader); |
| 277 | |
| 278 | return pixbuf; |
| 279 | } |
| 280 | |
| 281 | g_assert (mask)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_15 = 0; if (mask) _g_boolean_var_15 = 1; _g_boolean_var_15; }), 1)) ; else g_assertion_message_expr ("CdkPixbuf", "../cdk-pixbuf/io-icns.c" , 281, ((const char*) (__func__)), "mask"); } while (0); |
| 282 | |
| 283 | if (msize != size * size) /* wrong mask size */ |
| 284 | return NULL((void*)0); |
| 285 | |
| 286 | image = (guchar *) g_try_malloc0 (size * size * 4); /* 4 bytes/pixel = RGBA */ |
| 287 | |
| 288 | if (!image) |
| 289 | return NULL((void*)0); |
| 290 | |
| 291 | if (isize == size * size * 4) /* icon data is uncompressed */ |
| 292 | for (i = 0; i < size * size; i++) /* 4 bytes/pixel = ARGB (A: ignored) */ |
| 293 | { |
| 294 | image[i * 4] = icon[4 * i + 1]; /* R */ |
| 295 | image[i * 4 + 1] = icon[4 * i + 2]; /* G */ |
| 296 | image[i * 4 + 2] = icon[4 * i + 3]; /* B */ |
| 297 | } |
| 298 | else |
| 299 | { |
| 300 | guchar *data = icon; |
| 301 | gsize remaining = 0; |
| 302 | |
| 303 | /* R */ |
| 304 | if (!uncompress (size, &data, image, &remaining)) |
| 305 | goto bail; |
| 306 | /* G */ |
| 307 | if (!uncompress (size, &data, image + 1, &remaining)) |
| 308 | goto bail; |
| 309 | /* B */ |
| 310 | if (!uncompress (size, &data, image + 2, &remaining)) |
| 311 | goto bail; |
| 312 | } |
| 313 | |
| 314 | for (i = 0; i < size * size; i++) /* copy mask to alpha channel */ |
| 315 | image[i * 4 + 3] = mask[i]; |
| 316 | |
| 317 | return cdk_pixbuf_new_from_data ((guchar *) image, CDK_COLORSPACE_RGB, /* RGB image */ |
| 318 | TRUE(!(0)), /* with alpha channel */ |
| 319 | 8, /* 8 bits per sample */ |
| 320 | size, /* width */ |
| 321 | size, /* height */ |
| 322 | size * 4, /* no gap between rows */ |
| 323 | (CdkPixbufDestroyNotify)g_free, /* free() function */ |
| 324 | NULL((void*)0)); /* param to free() function */ |
| 325 | |
| 326 | bail: |
| 327 | g_free (image); |
| 328 | return NULL((void*)0); |
| 329 | } |
| 330 | |
| 331 | static int sizes[] = { |
| 332 | 256, /* late-Tiger icons */ |
| 333 | 128, /* Standard OS X */ |
| 334 | 48, /* Not very common */ |
| 335 | 32, /* Standard Mac OS Classic (8 & 9) */ |
| 336 | 24, /* OS X toolbars */ |
| 337 | 16 /* used in Mac OS Classic and dialog boxes */ |
| 338 | }; |
| 339 | |
| 340 | static CdkPixbuf * |
| 341 | icns_image_load (FILE *f, GError ** error) |
| 342 | { |
| 343 | GByteArray *data; |
| 344 | CdkPixbuf *pixbuf = NULL((void*)0); |
| 345 | guint i; |
| 346 | |
| 347 | data = g_byte_array_new (); |
| 348 | while (!feof (f)) |
| 349 | { |
| 350 | gint save_errno; |
| 351 | guchar buf[4096]; |
| 352 | gsize bytes; |
| 353 | |
| 354 | bytes = fread (buf, 1, sizeof (buf), f); |
| 355 | save_errno = errno(*__errno_location ()); |
| 356 | data = g_byte_array_append (data, buf, bytes); |
| 357 | |
| 358 | if (ferror (f)) |
| 359 | { |
| 360 | g_set_error (error, |
| 361 | G_FILE_ERRORg_file_error_quark (), |
| 362 | g_file_error_from_errno (save_errno), |
| 363 | _("Error reading ICNS image: %s")((char *) g_dgettext ("cdk-pixbuf", "Error reading ICNS image: %s" )), |
| 364 | g_strerror (save_errno)); |
| 365 | |
| 366 | g_byte_array_free (data, TRUE(!(0))); |
| 367 | |
| 368 | return NULL((void*)0); |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | for (i = 0; i < G_N_ELEMENTS(sizes)(sizeof (sizes) / sizeof ((sizes)[0])) && !pixbuf; i++) |
| 373 | pixbuf = load_icon (sizes[i], data->data, data->len); |
| 374 | |
| 375 | g_byte_array_free (data, TRUE(!(0))); |
| 376 | |
| 377 | if (!pixbuf) |
| 378 | g_set_error_literal (error, CDK_PIXBUF_ERRORcdk_pixbuf_error_quark (), |
| 379 | CDK_PIXBUF_ERROR_CORRUPT_IMAGE, |
| 380 | _("Could not decode ICNS file")((char *) g_dgettext ("cdk-pixbuf", "Could not decode ICNS file" ))); |
| 381 | |
| 382 | return pixbuf; |
| 383 | } |
| 384 | |
| 385 | static void |
| 386 | context_free (IcnsProgressiveState *context) |
| 387 | { |
| 388 | g_byte_array_free (context->byte_array, TRUE(!(0))); |
| 389 | g_clear_object (&context->pixbuf)do { _Static_assert (sizeof *((&context->pixbuf)) == sizeof (gpointer), "Expression evaluates to false"); __typeof__ ((( &context->pixbuf))) _pp = ((&context->pixbuf)); __typeof__ (*((&context->pixbuf))) _ptr = *_pp; *_pp = ((void*)0); if (_ptr) (g_object_unref) (_ptr); } while (0); |
| 390 | g_free (context); |
| 391 | } |
| 392 | |
| 393 | static gpointer |
| 394 | cdk_pixbuf__icns_image_begin_load (CdkPixbufModuleSizeFunc size_func, |
| 395 | CdkPixbufModulePreparedFunc prepared_func, |
| 396 | CdkPixbufModuleUpdatedFunc updated_func, |
| 397 | gpointer user_data, |
| 398 | GError **error) |
| 399 | { |
| 400 | IcnsProgressiveState *context; |
| 401 | |
| 402 | g_assert (size_func != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_16 = 0; if (size_func != ((void*)0)) _g_boolean_var_16 = 1; _g_boolean_var_16 ; }), 1)) ; else g_assertion_message_expr ("CdkPixbuf", "../cdk-pixbuf/io-icns.c" , 402, ((const char*) (__func__)), "size_func != NULL"); } while (0); |
| 403 | g_assert (prepared_func != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_17 = 0; if (prepared_func != ((void*)0)) _g_boolean_var_17 = 1; _g_boolean_var_17; }), 1)) ; else g_assertion_message_expr ( "CdkPixbuf", "../cdk-pixbuf/io-icns.c", 403, ((const char*) ( __func__)), "prepared_func != NULL"); } while (0); |
| 404 | g_assert (updated_func != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_18 = 0; if (updated_func != ((void*)0)) _g_boolean_var_18 = 1; _g_boolean_var_18 ; }), 1)) ; else g_assertion_message_expr ("CdkPixbuf", "../cdk-pixbuf/io-icns.c" , 404, ((const char*) (__func__)), "updated_func != NULL"); } while (0); |
| 405 | |
| 406 | context = g_new0 (IcnsProgressiveState, 1)(IcnsProgressiveState *) (__extension__ ({ gsize __n = (gsize ) (1); gsize __s = sizeof (IcnsProgressiveState); gpointer __p ; if (__s == 1) __p = g_malloc0 (__n); else if (__builtin_constant_p (__n) && (__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s); __p; })); |
| 407 | context->size_func = size_func; |
| 408 | context->prepared_func = prepared_func; |
| 409 | context->updated_func = updated_func; |
| 410 | context->user_data = user_data; |
| 411 | context->byte_array = g_byte_array_new (); |
| 412 | |
| 413 | return context; |
| 414 | } |
| 415 | |
| 416 | static gboolean |
| 417 | cdk_pixbuf__icns_image_stop_load (gpointer data, |
| 418 | GError **error) |
| 419 | { |
| 420 | IcnsProgressiveState *context = data; |
| 421 | |
| 422 | g_return_val_if_fail (context != NULL, TRUE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_19 = 0; if (context != ((void*)0)) _g_boolean_var_19 = 1; _g_boolean_var_19 ; }), 1))) { } else { g_return_if_fail_warning ("CdkPixbuf", ( (const char*) (__func__)), "context != NULL"); return ((!(0)) ); } } while (0); |
| 423 | |
| 424 | context_free (context); |
| 425 | return TRUE(!(0)); |
| 426 | } |
| 427 | |
| 428 | static gboolean |
| 429 | cdk_pixbuf__icns_image_load_increment (gpointer data, |
| 430 | const guchar *buf, |
| 431 | guint size, |
| 432 | GError **error) |
| 433 | { |
| 434 | IcnsProgressiveState *context = data; |
| 435 | int i; |
| 436 | int filesize; |
| 437 | gint w, h; |
| 438 | |
| 439 | context->byte_array = g_byte_array_append (context->byte_array, buf, size); |
| 440 | |
| 441 | if (context->byte_array->len < 8) |
| 442 | return TRUE(!(0)); |
| 443 | |
| 444 | filesize = (context->byte_array->data[4] << 24) | |
| 445 | (context->byte_array->data[5] << 16) | |
| 446 | (context->byte_array->data[6] << 8) | |
| 447 | (context->byte_array->data[7]); |
| 448 | |
| 449 | if (context->byte_array->len < filesize) |
| 450 | return TRUE(!(0)); |
| 451 | |
| 452 | for (i = 0; i < G_N_ELEMENTS(sizes)(sizeof (sizes) / sizeof ((sizes)[0])) && !context->pixbuf; i++) |
| 453 | context->pixbuf = load_icon (sizes[i], |
| 454 | context->byte_array->data, |
| 455 | context->byte_array->len); |
| 456 | |
| 457 | if (!context->pixbuf) |
| 458 | { |
| 459 | g_set_error_literal (error, CDK_PIXBUF_ERRORcdk_pixbuf_error_quark (), |
| 460 | CDK_PIXBUF_ERROR_CORRUPT_IMAGE, |
| 461 | _("Could not decode ICNS file")((char *) g_dgettext ("cdk-pixbuf", "Could not decode ICNS file" ))); |
| 462 | return FALSE(0); |
| 463 | } |
| 464 | |
| 465 | w = cdk_pixbuf_get_width (context->pixbuf); |
| 466 | h = cdk_pixbuf_get_height (context->pixbuf); |
| 467 | |
| 468 | (*context->size_func) (&w, |
| 469 | &h, |
| 470 | context->user_data); |
| 471 | |
| 472 | (*context->prepared_func) (context->pixbuf, |
| 473 | NULL((void*)0), |
| 474 | context->user_data); |
| 475 | |
| 476 | (*context->updated_func) (context->pixbuf, |
| 477 | 0, |
| 478 | 0, |
| 479 | cdk_pixbuf_get_width (context->pixbuf), |
| 480 | cdk_pixbuf_get_height (context->pixbuf), |
| 481 | context->user_data); |
| 482 | |
| 483 | return TRUE(!(0)); |
| 484 | } |
| 485 | |
| 486 | #ifndef INCLUDE_icns |
| 487 | #define MODULE_ENTRY(function)__attribute__((visibility("default"))) void function G_MODULE_EXPORT__attribute__((visibility("default"))) void function |
| 488 | #else |
| 489 | #define MODULE_ENTRY(function)__attribute__((visibility("default"))) void function void _cdk_pixbuf__icns_ ## function |
| 490 | #endif |
| 491 | |
| 492 | MODULE_ENTRY (fill_vtable)__attribute__((visibility("default"))) void fill_vtable (CdkPixbufModule * module) |
| 493 | { |
| 494 | module->load = icns_image_load; |
| 495 | module->begin_load = cdk_pixbuf__icns_image_begin_load; |
| 496 | module->stop_load = cdk_pixbuf__icns_image_stop_load; |
| 497 | module->load_increment = cdk_pixbuf__icns_image_load_increment; |
| 498 | } |
| 499 | |
| 500 | MODULE_ENTRY (fill_info)__attribute__((visibility("default"))) void fill_info (CdkPixbufFormat * info) |
| 501 | { |
| 502 | static const CdkPixbufModulePattern signature[] = { |
| 503 | {"icns", NULL((void*)0), 100}, /* file begins with 'icns' */ |
| 504 | {NULL((void*)0), NULL((void*)0), 0} |
| 505 | }; |
| 506 | static const gchar *mime_types[] = { |
| 507 | "image/x-icns", |
| 508 | NULL((void*)0) |
| 509 | }; |
| 510 | static const gchar *extensions[] = { |
| 511 | "icns", |
| 512 | NULL((void*)0) |
| 513 | }; |
| 514 | |
| 515 | info->name = "icns"; |
| 516 | info->signature = (CdkPixbufModulePattern *) signature; |
| 517 | info->description = NC_("image format", "MacOS X icon")("MacOS X icon"); |
| 518 | info->mime_types = (gchar **) mime_types; |
| 519 | info->extensions = (gchar **) extensions; |
| 520 | info->flags = CDK_PIXBUF_FORMAT_THREADSAFE; |
| 521 | info->license = "GPL"; |
| 522 | info->disabled = FALSE(0); |
| 523 | } |
| 524 |