summaryrefslogtreecommitdiff
path: root/pango/modules.c
diff options
context:
space:
mode:
authorElliot Lee <sopwith@redhat.com>2000-06-19 17:15:45 +0000
committerElliot Lee <sopwith@src.gnome.org>2000-06-19 17:15:45 +0000
commite2dc9e117648e267953d7318bd3e0093cd5ab234 (patch)
tree4a582a231b2efca221ec86cf80e12dc7451e99d3 /pango/modules.c
parentb9aaea84c9092c83906676aa97d8a7ea89a51f36 (diff)
downloadpango-e2dc9e117648e267953d7318bd3e0093cd5ab234.tar.gz
g_strcasecmp returns 0 when strings are equal - negate return value.
2000-06-11 Elliot Lee <sopwith@redhat.com> * pango/fonts.c (pango_font_description_compare): g_strcasecmp returns 0 when strings are equal - negate return value. 2000-06-09 Elliot Lee <sopwith@redhat.com> * pango/pango-coverage.[ch]: Return 'coverage' from pango_coverage_ref. 2000-06-08 Elliot Lee <sopwith@redhat.com> * pango/Makefile.am: Add DOTMODULESDIR define to make it easier to change location of .modules files. * pango/modules.c: Make use of aforesaid define. Also scan the DOTMODULESDIR directory for multiple config files instead of just pango.modules. Also fclose() opened files.
Diffstat (limited to 'pango/modules.c')
-rw-r--r--pango/modules.c87
1 files changed, 67 insertions, 20 deletions
diff --git a/pango/modules.c b/pango/modules.c
index c109c3ef..66a75c2c 100644
--- a/pango/modules.c
+++ b/pango/modules.c
@@ -22,6 +22,8 @@
#include <ctype.h>
#include <stdio.h>
#include <string.h>
+#include <dirent.h>
+#include <limits.h>
#include <gmodule.h>
@@ -215,26 +217,11 @@ add_included_modules (void)
}
}
-static void
-read_modules (void)
+static gboolean /* Returns true if succeeded, false if failed */
+process_module_file(FILE *module_file)
{
- FILE *module_file;
char *line;
- /* FIXME FIXME FIXME - this is a potential security problem from leaving
- * pango.modules files scattered around to trojan modules.
- */
- module_file = fopen ("pango.modules", "r");
- if (!module_file)
- {
- module_file = fopen (LOCALSTATEDIR "/lib/pango/pango.modules", "r");
- if (!module_file)
- {
- fprintf(stderr, "Cannot load module file!\n");
- return; /* FIXME: Error */
- }
- }
-
while ((line = readline (module_file)))
{
PangoEnginePair *pair = g_new (PangoEnginePair, 1);
@@ -277,13 +264,13 @@ read_modules (void)
if (sscanf(q, "%d-%d:", &start, &end) != 2)
{
fprintf(stderr, "Error reading pango.modules");
- return;
+ return FALSE;
}
q = strchr (q, ':');
if (!q)
{
fprintf(stderr, "Error reading pango.modules");
- return;
+ return FALSE;
}
q++;
range->start = start;
@@ -311,7 +298,7 @@ read_modules (void)
if (i<3)
{
fprintf(stderr, "Error reading pango.modules");
- return;
+ return FALSE;
}
ranges = g_list_reverse (ranges);
@@ -333,6 +320,65 @@ read_modules (void)
engines = g_list_prepend (engines, pair);
}
+
+ return TRUE;
+}
+
+static void
+read_modules (void)
+{
+ FILE *module_file;
+ gboolean read_module_file = FALSE;
+
+ /* FIXME FIXME FIXME - this is a potential security problem from leaving
+ * pango.modules files scattered around to trojan modules.
+ */
+ module_file = fopen ("pango.modules", "r");
+ if(module_file)
+ {
+ read_module_file = read_module_file || process_module_file(module_file);
+ process_module_file(module_file);
+ fclose(module_file);
+ }
+ else
+ {
+ DIR *dirh;
+
+ dirh = opendir(DOTMODULEDIR);
+ if(dirh)
+ {
+ struct dirent *dent;
+
+ while((dent = readdir(dirh)))
+ {
+ char fullfn[PATH_MAX];
+ char *ctmp;
+
+ if(dent->d_name[0] == '.')
+ continue;
+
+ ctmp = strrchr(dent->d_name, '.');
+ if(!ctmp || strcmp(ctmp, ".modules") != 0)
+ continue;
+
+ g_snprintf(fullfn, sizeof(fullfn), DOTMODULEDIR "/%s", dent->d_name);
+ module_file = fopen(fullfn, "r");
+ if(module_file)
+ {
+ read_module_file = read_module_file || process_module_file(module_file);
+ fclose(module_file);
+ }
+ }
+ }
+
+ closedir(dirh);
+ }
+
+ if (!read_module_file)
+ {
+ fprintf(stderr, "Could not load any module files!\n");
+ /* FIXME: Error */
+ }
}
static void
@@ -377,6 +423,7 @@ build_map (PangoMapInfo *info)
init_modules();
info->map = map = g_new (PangoMap, 1);
+ map->n_submaps = 0;
for (i=0; i<256; i++)
{
map->submaps[i].is_leaf = TRUE;