/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- * Pango * querymodules.c: * * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is the Pango Library (www.pango.org) * * The Initial Developer of the Original Code is Red Hat Software * Portions created by Red Hat are Copyright (C) 1999 Red Hat Software. * * Contributor(s): * * Alternatively, the contents of this file may be used under the * terms of the GNU Lessor General Public License Version 2 (the * "LGPL"), in which case the provisions of the LGPL are applicable * instead of those above. If you wish to allow use of your * version of this file only under the terms of the LGPL and not to * allow others to use your version of this file under the MPL, * indicate your decision by deleting the provisions above and * replace them with the notice and other provisions required by * the LGPL. If you do not delete the provisions above, a recipient * may use your version of this file under either the MPL or the * LGPL. */ #include "config.h" #include #ifdef HAVE_DIRENT_H #include #endif #include #include "pango-break.h" #include "pango-context.h" #include "pango-utils.h" #include "pango-engine.h" #include #include #ifdef HAVE_UNISTD_H #include #endif #include #ifdef G_OS_WIN32 #define SOEXT ".dll" #ifndef PATH_MAX #include #define PATH_MAX _MAX_PATH #endif /* PATH_MAX */ #include /* for getcwd() with MSVC */ #include /* for getcwd() with mingw */ #define getcwd _getcwd #else #define SOEXT ".so" #endif void query_module (const char *dir, const char *name) { void (*list) (PangoliteEngineInfo **engines, gint *n_engines); PangoliteEngine *(*load) (const gchar *id); void (*unload) (PangoliteEngine *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); 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)) { gint i,j; PangoliteEngineInfo *engines; gint n_engines; (*list) (&engines, &n_engines); for (i=0; id_name); if (len > 3 && strcmp (dent->d_name + len - strlen (SOEXT), SOEXT) == 0) query_module (dirs[i], dent->d_name); } closedir (dir); } } } else { getcwd (cwd, PATH_MAX); for (i=1; i