int LCUI_InitImageReader(LCUI_ImageReader reader) { int ret, i; for (i = 0; i < n_interfaces; ++i) { reader->fn_rewind(reader->stream_data); ret = LCUI_InitImageReaderByType(reader, i); if (ret == 0) { return 0; } LCUI_DestroyImageReader(reader); } reader->fn_rewind(reader->stream_data); reader->type = LCUI_UNKNOWN_READER; return -ENOENT; }
static int LCUI_InitImageReaderByType(LCUI_ImageReader reader, int type) { int ret; reader->fn_rewind(reader->stream_data); ret = interfaces[type].init(reader); if (ret != 0) { return -2; } if (LCUI_SetImageReaderJump(reader)) { return -2; } return interfaces[type].read_header(reader); }