New function to write out the information for a single loader, factored
Sun Nov 9 21:56:20 2003 Matthias Clasen <maclas@gmx.de> * queryloaders.c (write_loader_info): New function to write out the information for a single loader, factored out of query_module(). (loader_sanity_check): New function to perform sanity checks on a loader. (query_module): Use the new functions.
This commit is contained in:

committed by
Matthias Clasen

parent
70ec9facd2
commit
0af9579ea2
@ -1,3 +1,12 @@
|
|||||||
|
Sun Nov 9 21:56:20 2003 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* queryloaders.c (write_loader_info): New function to write
|
||||||
|
out the information for a single loader, factored out of
|
||||||
|
query_module().
|
||||||
|
(loader_sanity_check): New function to perform
|
||||||
|
sanity checks on a loader.
|
||||||
|
(query_module): Use the new functions.
|
||||||
|
|
||||||
Thu Nov 6 00:27:27 2003 Matthias Clasen <maclas@gmx.de>
|
Thu Nov 6 00:27:27 2003 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
* io-pcx.c (gdk_pixbuf__pcx_load_increment): Fold two similar
|
* io-pcx.c (gdk_pixbuf__pcx_load_increment): Fold two similar
|
||||||
|
@ -53,30 +53,57 @@ print_escaped (const char *str)
|
|||||||
g_free (tmp);
|
g_free (tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static int
|
||||||
query_module (const char *dir, const char *file)
|
loader_sanity_check (const char *path, GdkPixbufFormat *info, GdkPixbufModule *vtable)
|
||||||
{
|
{
|
||||||
char *path;
|
const GdkPixbufModulePattern *pattern;
|
||||||
GModule *module;
|
const char *error = "";
|
||||||
void (*fill_info) (GdkPixbufFormat *info);
|
|
||||||
void (*fill_vtable) (GdkPixbufModule *module);
|
for (pattern = info->signature; pattern->prefix; pattern++)
|
||||||
|
if (strlen (pattern->prefix) == 0)
|
||||||
|
{
|
||||||
|
error = "empty pattern";
|
||||||
|
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!vtable->load && !vtable->begin_load && !vtable->load_animation)
|
||||||
|
{
|
||||||
|
error = "no load method implemented";
|
||||||
|
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vtable->begin_load && (!vtable->stop_load || !vtable->load_increment))
|
||||||
|
{
|
||||||
|
error = "incremental loading support incomplete";
|
||||||
|
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((info->flags & GDK_PIXBUF_FORMAT_WRITABLE) & !vtable->save)
|
||||||
|
{
|
||||||
|
error = "loader claims to support saving but doesn't implement save";
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
error:
|
||||||
|
g_fprintf (stderr, "Loader sanity check failed for %s: %s\n",
|
||||||
|
path, error);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
write_loader_info (const char *path, GdkPixbufFormat *info)
|
||||||
|
{
|
||||||
|
const GdkPixbufModulePattern *pattern;
|
||||||
char **mime;
|
char **mime;
|
||||||
char **ext;
|
char **ext;
|
||||||
const GdkPixbufModulePattern *pattern;
|
|
||||||
|
|
||||||
if (g_path_is_absolute (file))
|
|
||||||
path = g_strdup (file);
|
|
||||||
else
|
|
||||||
path = g_build_filename (dir, file, NULL);
|
|
||||||
|
|
||||||
module = g_module_open (path, 0);
|
|
||||||
if (module &&
|
|
||||||
g_module_symbol (module, "fill_info", (gpointer *) &fill_info) &&
|
|
||||||
g_module_symbol (module, "fill_vtable", (gpointer *) &fill_vtable)) {
|
|
||||||
GdkPixbufFormat *info;
|
|
||||||
g_printf("\"%s\"\n", path);
|
g_printf("\"%s\"\n", path);
|
||||||
info = g_new0 (GdkPixbufFormat, 1);
|
|
||||||
(*fill_info) (info);
|
|
||||||
g_printf ("\"%s\" %d \"%s\" \"%s\"\n",
|
g_printf ("\"%s\" %d \"%s\" \"%s\"\n",
|
||||||
info->name, info->flags,
|
info->name, info->flags,
|
||||||
info->domain ? info->domain : GETTEXT_PACKAGE, info->description);
|
info->domain ? info->domain : GETTEXT_PACKAGE, info->description);
|
||||||
@ -94,7 +121,39 @@ query_module (const char *dir, const char *file)
|
|||||||
g_printf ("%d\n", pattern->relevance);
|
g_printf ("%d\n", pattern->relevance);
|
||||||
}
|
}
|
||||||
g_printf ("\n");
|
g_printf ("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
query_module (const char *dir, const char *file)
|
||||||
|
{
|
||||||
|
char *path;
|
||||||
|
GModule *module;
|
||||||
|
void (*fill_info) (GdkPixbufFormat *info);
|
||||||
|
void (*fill_vtable) (GdkPixbufModule *module);
|
||||||
|
|
||||||
|
if (g_path_is_absolute (file))
|
||||||
|
path = g_strdup (file);
|
||||||
|
else
|
||||||
|
path = g_build_filename (dir, file, NULL);
|
||||||
|
|
||||||
|
module = g_module_open (path, 0);
|
||||||
|
if (module &&
|
||||||
|
g_module_symbol (module, "fill_info", (gpointer *) &fill_info) &&
|
||||||
|
g_module_symbol (module, "fill_vtable", (gpointer *) &fill_vtable)) {
|
||||||
|
GdkPixbufFormat *info;
|
||||||
|
GdkPixbufModule *vtable;
|
||||||
|
|
||||||
|
info = g_new0 (GdkPixbufFormat, 1);
|
||||||
|
vtable = g_new0 (GdkPixbufModule, 1);
|
||||||
|
|
||||||
|
(*fill_info) (info);
|
||||||
|
(*fill_vtable) (vtable);
|
||||||
|
|
||||||
|
if (loader_sanity_check (path, info, vtable))
|
||||||
|
write_loader_info (path, info);
|
||||||
|
|
||||||
g_free (info);
|
g_free (info);
|
||||||
|
g_free (vtable);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (module == NULL)
|
if (module == NULL)
|
||||||
|
Reference in New Issue
Block a user