void * simage_add_loader(const struct simage_plugin * plugin, int addbefore) { add_internal_loaders(); return add_loader((loader_data *)malloc(sizeof(loader_data)), plugin->load_func, plugin->identify_func, plugin->error_func, 0, addbefore); }
static gboolean load_loader (PlumaPluginsEngine *engine, const gchar *filename, gpointer data) { PlumaObjectModule *module; gchar *base; gchar *path; const gchar *id; GType type; /* try to load in the module */ path = g_path_get_dirname (filename); base = g_path_get_basename (filename); /* for now they are all resident */ module = pluma_object_module_new (base, path, "register_pluma_plugin_loader", TRUE); g_free (base); g_free (path); /* make sure to load the type definition */ if (!g_type_module_use (G_TYPE_MODULE (module))) { g_object_unref (module); g_warning ("Plugin loader module `%s' could not be loaded", filename); return TRUE; } /* get the exported type and check the name as exported by the * loader interface */ type = pluma_object_module_get_object_type (module); id = pluma_plugin_loader_type_get_id (type); add_loader (engine, id, module); g_type_module_unuse (G_TYPE_MODULE (module)); return TRUE; }
static PlumaPluginLoader * get_plugin_loader (PlumaPluginsEngine *engine, PlumaPluginInfo *info) { const gchar *loader_id; LoaderInfo *loader_info; loader_id = info->loader; loader_info = (LoaderInfo *)g_hash_table_lookup ( engine->priv->loaders, loader_id); if (loader_info == NULL) { gchar *loader_dir; loader_dir = pluma_dirs_get_pluma_plugin_loaders_dir (); /* loader could not be found in the hash, try to find it by scanning */ load_dir_real (engine, loader_dir, LOADER_EXT, (LoadDirCallback)load_loader, NULL); g_free (loader_dir); loader_info = (LoaderInfo *)g_hash_table_lookup ( engine->priv->loaders, loader_id); } if (loader_info == NULL) { /* cache non-existent so we don't scan again */ add_loader (engine, loader_id, NULL); return NULL; } ensure_loader (loader_info); return loader_info->loader; }
static void add_internal_loaders(void) { static int first = 1; if (first) { first = 0; #ifdef SIMAGE_GDIPLUS_SUPPORT add_loader(&gdiplus_loader, simage_gdiplus_load, simage_gdiplus_identify, simage_gdiplus_error, 1, 0); gdiplus_loader.openfuncs.open_func = simage_gdiplus_open; gdiplus_loader.openfuncs.close_func = simage_gdiplus_close; gdiplus_loader.openfuncs.read_line_func = simage_gdiplus_read_line; #endif /* SIMAGE_GDIPLUS_SUPPORT */ #ifdef HAVE_JPEGLIB add_loader(&jpeg_loader, simage_jpeg_load, simage_jpeg_identify, simage_jpeg_error, 1, 0); #endif /* HAVE_JPEGLIB */ #ifdef HAVE_PNGLIB add_loader(&png_loader, simage_png_load, simage_png_identify, simage_png_error, 1, 0); #endif /* HAVE_PNGLIB */ #ifdef SIMAGE_TGA_SUPPORT add_loader(&targa_loader, simage_tga_load, simage_tga_identify, simage_tga_error, 1, 0); #endif /* SIMAGE_TGA_SUPPORT */ #ifdef HAVE_TIFFLIB add_loader(&tiff_loader, simage_tiff_load, simage_tiff_identify, simage_tiff_error, 1, 0); tiff_loader.openfuncs.open_func = simage_tiff_open; tiff_loader.openfuncs.close_func = simage_tiff_close; tiff_loader.openfuncs.read_line_func = simage_tiff_read_line; #endif /* HAVE_TIFFLIB */ #ifdef HAVE_JASPER add_loader(&jasper_loader, simage_jasper_load, simage_jasper_identify, simage_jasper_error, 1, 0); /* read_line API not supported by JASPER */ /* jasper_loader.openfuncs.open_func = simage_jasper_open; * jasper_loader.openfuncs.close_func = simage_jasper_close; * jasper_loader.openfuncs.read_line_func = simage_jasper_read_line; */ #endif /* HAVE_JASPER */ #ifdef SIMAGE_RGB_SUPPORT add_loader(&rgb_loader, simage_rgb_load, simage_rgb_identify, simage_rgb_error, 1, 0); rgb_loader.openfuncs.open_func = simage_rgb_open; rgb_loader.openfuncs.close_func = simage_rgb_close; rgb_loader.openfuncs.read_line_func = simage_rgb_read_line; #endif /* SIMAGE_RGB_SUPPORT */ #ifdef SIMAGE_PIC_SUPPORT add_loader(&pic_loader, simage_pic_load, simage_pic_identify, simage_pic_error, 1, 0); #endif /* SIMAGE_PIC_SUPPORT */ #ifdef HAVE_GIFLIB add_loader(&gif_loader, simage_gif_load, simage_gif_identify, simage_gif_error, 1, 0); #endif /* HAVE_GIFLIB */ #ifdef SIMAGE_XWD_SUPPORT add_loader(&xwd_loader, simage_xwd_load, simage_xwd_identify, simage_xwd_error, 1, 0); #endif /* SIMAGE_XWD_SUPPORT */ #ifdef SIMAGE_QIMAGE_SUPPORT add_loader(&qimage_loader, simage_qimage_load, simage_qimage_identify, simage_qimage_error, 1, 0); #endif /* SIMAGE_QIMAGE_SUPPORT */ #ifdef SIMAGE_QUICKTIME_SUPPORT add_loader(&quicktime_loader, simage_quicktime_load, simage_quicktime_identify, simage_quicktime_error, 1, 1); // add_before -- if we can use QuickTime, makeitso #endif /* SIMAGE_QUICKTIME_SUPPORT */ #ifdef SIMAGE_CGIMAGE_SUPPORT add_loader(&cgimage_loader, simage_cgimage_load, simage_cgimage_identify, simage_cgimage_error, 1, 1); // add_before -- if we can use CGImage, makeitso #endif /* SIMAGE_CGIMAGE_SUPPORT */ } }