kwo pushed a commit to branch master. http://git.enlightenment.org/legacy/imlib2_loaders.git/commit/?id=c74c3c72349da284470d5f148528d6e3f676a85d
commit c74c3c72349da284470d5f148528d6e3f676a85d Author: Kim Woelders <k...@woelders.dk> Date: Thu May 21 05:06:07 2020 +0200 Move loaders to load2() --- src/modules/loaders/loader_ani.c | 18 ++++++------------ src/modules/loaders/loader_xcf.c | 19 +++++-------------- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/src/modules/loaders/loader_ani.c b/src/modules/loaders/loader_ani.c index 20412e9..3113145 100644 --- a/src/modules/loaders/loader_ani.c +++ b/src/modules/loaders/loader_ani.c @@ -47,7 +47,6 @@ typedef struct _MsChunk { } MsChunk; typedef struct _MsAni { - char *filename; FILE *fp; DATA32 cp; @@ -96,17 +95,15 @@ ani_read_int32(FILE * fp, DATA32 * data, int count) } static MsAni * -ani_init(char *filename) +ani_init(FILE * fp) { MsAni *ani; if (!(ani = calloc(1, sizeof(MsAni)))) return NULL; - if (!(ani->fp = fopen(filename, "r"))) - goto bail; + ani->fp = fp; - ani->filename = filename; ani->cp += ani_read_int32(ani->fp, &ani->riff_id, 1); ani->cp += ani_read_int32(ani->fp, &ani->data_size, 1); ani->cp += ani_read_int32(ani->fp, &ani->chunk_id, 1); @@ -131,9 +128,6 @@ ani_cleanup(MsAni * ani) if (!ani) return; - if (ani->fp) - fclose(ani->fp); - for (c = ani->chunks; c;) { c_next = c->next; @@ -228,9 +222,8 @@ ani_save_ico(MsChunk * chunk) return strdup(tmp); } -char -load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity, - char load_data) +int +load2(ImlibImage * im, int load_data) { int rc; ImlibLoader *loader; @@ -241,7 +234,8 @@ load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity, if (!loader) return LOAD_FAIL; - if (!(ani = ani_init((im->real_file)))) + ani = ani_init(im->fp); + if (!ani) return LOAD_FAIL; ani_load(ani); diff --git a/src/modules/loaders/loader_xcf.c b/src/modules/loaders/loader_xcf.c index d426fa6..fbd1648 100644 --- a/src/modules/loaders/loader_xcf.c +++ b/src/modules/loaders/loader_xcf.c @@ -220,7 +220,6 @@ struct _Tile { */ struct _GimpImage { FILE *fp; - char *filename; int cp; /* file stream pointer */ int compression; /* file compression mode */ int file_version; @@ -1507,7 +1506,7 @@ xcf_load_image(void) } static int -xcf_file_init(char *filename) +xcf_file_init(FILE * fp) { char success = 1; char id[14]; @@ -1521,11 +1520,8 @@ xcf_file_init(char *filename) D("Loading only XCF layer %i.\n", image->single_layer_index); } #endif - image->fp = fopen(filename, "r"); - if (!image->fp) - return 0; + image->fp = fp; - image->filename = filename; image->layers = NULL; image->last_layer = NULL; image->cmap = NULL; @@ -1539,7 +1535,6 @@ xcf_file_init(char *filename) if (strncmp(id, "gimp xcf ", 9) != 0) { success = 0; - fclose(image->fp); } else if (strcmp(id + 9, "file") == 0) { @@ -1552,7 +1547,6 @@ xcf_file_init(char *filename) else { success = 0; - fclose(image->fp); } return success; @@ -1564,8 +1558,6 @@ xcf_cleanup(void) Layer *l; Layer *lp; - fclose(image->fp); - l = image->last_layer; while (l) { @@ -1591,14 +1583,13 @@ xcf_to_imlib(ImlibImage * im) im->data = image->data; } -char -load(ImlibImage * im, ImlibProgressFunction progress, char progress_granularity, - char load_data) +int +load2(ImlibImage * im, int load_data) { int rc = LOAD_FAIL; /* initialize */ - if (!xcf_file_init(im->real_file)) + if (!xcf_file_init(im->fp)) return LOAD_FAIL; /* do it! */ --