1 /* -*- mode: C; c-file-style: "linux" -*- */
5 * Copyright (C) 2002 The Free Software Foundation
7 * Author: Matthias Clasen <maclas@gmx.de>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
28 #include <glib/gprintf.h>
37 #include "gdk-pixbuf/gdk-pixbuf.h"
38 #include "gdk-pixbuf/gdk-pixbuf-private.h"
39 #include "gdk-pixbuf/gdk-pixbuf-io.h"
44 #define SOEXT ("." G_MODULE_SUFFIX)
46 #define SOEXT_LEN (strlen (SOEXT))
49 print_escaped (const char *str)
51 gchar *tmp = g_strescape (str, "");
52 g_printf ("\"%s\" ", tmp);
57 query_module (const char *dir, const char *file)
61 void (*fill_info) (GdkPixbufFormat *info);
62 void (*fill_vtable) (GdkPixbufModule *module);
65 const GdkPixbufModulePattern *pattern;
67 if (g_path_is_absolute (dir))
68 path = g_build_filename (dir, file, NULL);
70 char *cwd = g_get_current_dir ();
71 path = g_build_filename (cwd, dir, file, NULL);
76 module = g_module_open (path, 0);
78 g_module_symbol (module, "fill_info", (gpointer *) &fill_info) &&
79 g_module_symbol (module, "fill_vtable", (gpointer *) &fill_vtable)) {
80 GdkPixbufFormat *info;
81 g_printf("\"%s\"\n", path);
82 info = g_new0 (GdkPixbufFormat, 1);
84 g_printf ("\"%s\" %d \"%s\" \"%s\"\n",
85 info->name, info->flags,
86 info->domain ? info->domain : GETTEXT_PACKAGE, info->description);
87 for (mime = info->mime_types; *mime; mime++) {
88 g_printf ("\"%s\" ", *mime);
91 for (ext = info->extensions; *ext; ext++) {
92 g_printf ("\"%s\" ", *ext);
95 for (pattern = info->signature; pattern->prefix; pattern++) {
96 print_escaped (pattern->prefix);
97 print_escaped (pattern->mask ? (const char *)pattern->mask : "");
98 g_printf ("%d\n", pattern->relevance);
104 g_fprintf (stderr, "Cannot load loader %s\n", path);
107 g_module_close (module);
111 int main (int argc, char **argv)
115 g_printf ("# GdkPixbuf Image Loader Modules file\n"
116 "# Automatically generated file, do not edit\n"
124 path = g_getenv ("GDK_PIXBUF_MODULEDIR");
125 if (path == NULL || *path == '\0')
126 path = PIXBUF_LIBDIR;
128 g_printf ("# LoaderDir = %s\n#\n", path);
130 dir = g_dir_open (path, 0, NULL);
134 while ((dent = g_dir_read_name (dir))) {
135 gint len = strlen (dent);
136 if (len > SOEXT_LEN &&
137 strcmp (dent + len - SOEXT_LEN, SOEXT) == 0) {
138 query_module (path, dent);
144 g_printf ("# dynamic loading of modules not supported\n");
148 char *cwd = g_get_current_dir ();
150 for (i = 1; i < argc; i++)
151 query_module (cwd, argv[i]);