summaryrefslogtreecommitdiff
path: root/pango/querymodules.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2000-06-30 22:08:26 +0000
committerOwen Taylor <otaylor@src.gnome.org>2000-06-30 22:08:26 +0000
commitb49e8181c16e91afc0b2e771243f9adab9bc8b5d (patch)
treef3b463eec927649a43bd0b22464a5118f0b0d4a7 /pango/querymodules.c
parent036da71c38c9d81a087f20079cc7b96154fc5a3c (diff)
downloadpango-b49e8181c16e91afc0b2e771243f9adab9bc8b5d.tar.gz
A bunch of simple functions for reading from files, manipulating strings
Fri Jun 30 16:46:31 2000 Owen Taylor <otaylor@redhat.com> * pango/pango-utils.[ch] Makefile.am: A bunch of simple functions for reading from files, manipulating strings as necessary for config files. Also, a simple gnome-config/win.ini style config file reader. * pango/modules.c: Remove DOTFILES stuff. Instead, read names of modules file from pangorc. (Which can be set from PANGO_RC_FILE). Rewrite parsing code using pango-utils.c. * pango/pangox-fontmap.c: Read list of files from PangoX/AliasFiles key. Rewrite parsing code for alias files using pango-utils.c. * examples/pangox.aliases: Move to new name from pangox_aliases, reformat using new parsing code. * examples/pangorc (AliasFiles) examples/pango-viewer: Add a pangorc file for in-place testing. * pango/querymodules.c (main): Add comment to the top of the output indicating that the file should not be hand-edited.
Diffstat (limited to 'pango/querymodules.c')
-rw-r--r--pango/querymodules.c80
1 files changed, 58 insertions, 22 deletions
diff --git a/pango/querymodules.c b/pango/querymodules.c
index 9ddddb3d..051b41d7 100644
--- a/pango/querymodules.c
+++ b/pango/querymodules.c
@@ -20,8 +20,10 @@
*/
#include <glib.h>
+#include <dirent.h>
#include <gmodule.h>
#include "pango.h"
+#include "pango-utils.h"
#include <errno.h>
#include <string.h>
@@ -29,13 +31,27 @@
#include <stdio.h>
void
-query_module (GModule *module, gchar *name)
+query_module (const char *dir, const char *name)
{
void (*list) (PangoEngineInfo **engines, gint *n_engines);
PangoEngine *(*load) (const gchar *id);
void (*unload) (PangoEngine *engine);
+
+ GModule *module;
+ gchar *path;
+
+ if (name[0] == G_DIR_SEPARATOR)
+ path = g_strdup (name);
+ else
+ path = g_strconcat (dir, G_DIR_SEPARATOR_S, name, NULL);
- if (g_module_symbol (module, "script_engine_list", (gpointer)&list) &&
+ module = g_module_open (path, 0);
+
+ if (!module)
+ fprintf(stderr, "Cannot load module %s: %s\n", path, g_module_error());
+
+ if (module &&
+ g_module_symbol (module, "script_engine_list", (gpointer)&list) &&
g_module_symbol (module, "script_engine_load", (gpointer)&load) &&
g_module_symbol (module, "script_engine_unload", (gpointer)&unload))
{
@@ -47,7 +63,7 @@ query_module (GModule *module, gchar *name)
for (i=0; i<n_engines; i++)
{
- g_print ("%s %s %s %s ", name, engines[i].id, engines[i].engine_type, engines[i].render_type);
+ g_print ("%s %s %s %s ", path, engines[i].id, engines[i].engine_type, engines[i].render_type);
for (j=0; j < engines[i].n_ranges; j++)
{
if (j != 0)
@@ -62,40 +78,60 @@ query_module (GModule *module, gchar *name)
}
else
{
- fprintf (stderr, "%s does not export Pango module API\n", name);
+ fprintf (stderr, "%s does not export Pango module API\n", path);
}
+
+ g_free (path);
+ g_module_close (module);
}
int main (int argc, char **argv)
{
char cwd[PATH_MAX];
int i;
+ char *path;
- getcwd (cwd, PATH_MAX);
+ printf ("# Pango Modules file\n"
+ "# Automatically generated file, do not edit\n"
+ "#\n");
- for (i=1; i<argc; i++)
+ if (argc == 1) /* No arguments given */
{
- GModule *module;
- gchar *tmp;
+ char **dirs;
+ int i;
- if (argv[i][0] == '/')
- tmp = g_strdup (argv[i]);
- else
- tmp = g_strconcat (cwd, "/", argv[i], NULL);
+ path = pango_config_key_get ("Pango/ModulesPath");
+ if (!path)
+ path = g_strdup (LIBDIR "/pango/modules");
- module = g_module_open (tmp, 0);
- if (module)
- {
- query_module (module, tmp);
- g_module_close (module);
- }
- else
+ printf ("# ModulesPath = %s\n#\n", path);
+
+ dirs = pango_split_file_list (path);
+
+ for (i=0; dirs[i]; i++)
{
- fprintf(stderr, "Cannot load module %s: %s\n",
- tmp, g_module_error());
+ DIR *dir = opendir (dirs[i]);
+ if (dir)
+ {
+ struct dirent *dent;
+
+ while ((dent = readdir (dir)))
+ {
+ int len = strlen (dent->d_name);
+ if (len > 3 && strcmp (dent->d_name + len - 3, ".so") == 0)
+ query_module (dirs[i], dent->d_name);
+ }
+
+ closedir (dir);
+ }
}
+ }
+ else
+ {
+ getcwd (cwd, PATH_MAX);
- g_free (tmp);
+ for (i=1; i<argc; i++)
+ query_module (cwd, argv[i]);
}
return 0;