dIMCTXim(im);
im_log((aIMCTX, 1,"i_img_destroy(im %p)\n",im));
i_img_exorcise(im);
- if (im) { myfree(im); }
+ myfree(im);
im_context_refdec(aIMCTX, "img_destroy");
}
}
}
-struct magic_entry {
- unsigned char *magic;
- size_t magic_size;
- char *name;
- unsigned char *mask;
-};
-
static int
-test_magic(unsigned char *buffer, size_t length, struct magic_entry const *magic) {
+test_magic(unsigned char *buffer, size_t length, struct file_magic_entry const *magic) {
if (length < magic->magic_size)
return 0;
if (magic->mask) {
{ (unsigned char *)(magic ""), sizeof(magic)-1, type, (unsigned char *)(mask) }
const char *
-i_test_format_probe(io_glue *data, int length) {
- static const struct magic_entry formats[] = {
+im_test_format_probe(im_context_t ctx, io_glue *data, int length) {
+ static const struct file_magic_entry formats[] = {
FORMAT_ENTRY("\xFF\xD8", "jpeg"),
FORMAT_ENTRY("GIF87a", "gif"),
FORMAT_ENTRY("GIF89a", "gif"),
/* FLIF - Free Lossless Image Format - https://flif.info/spec.html */
FORMAT_ENTRY("FLIF", "flif")
};
- static const struct magic_entry more_formats[] = {
+ static const struct file_magic_entry more_formats[] = {
/* these were originally both listed as ico, but cur files can
include hotspot information */
FORMAT_ENTRY("\x00\x00\x01\x00", "ico"), /* Windows icon */
}
#endif
+ {
+ im_file_magic *p = ctx->file_magic;
+ while (p) {
+ if (test_magic(head, rc, &p->m)) {
+ return p->m.name;
+ }
+ p = p->next;
+ }
+ }
+
for(i=0; i<sizeof(formats)/sizeof(formats[0]); i++) {
- struct magic_entry const *entry = formats + i;
+ struct file_magic_entry const *entry = formats + i;
if (test_magic(head, rc, entry))
return entry->name;
return "tga";
for(i=0; i<sizeof(more_formats)/sizeof(more_formats[0]); i++) {
- struct magic_entry const *entry = more_formats + i;
+ struct file_magic_entry const *entry = more_formats + i;
if (test_magic(head, rc, entry))
return entry->name;