-/* $Id: recctrl.c,v 1.1 2006-07-03 14:27:09 adam Exp $
- Copyright (C) 1995-2006
+/* $Id: recctrl.c,v 1.6 2007-02-07 12:08:54 adam Exp $
+ Copyright (C) 1995-2007
Index Data ApS
This file is part of the Zebra server.
for more details.
You should have received a copy of the GNU General Public License
-along with Zebra; see the file LICENSE.zebra. If not, write to the
-Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
*/
#endif
#ifdef IDZEBRA_STATIC_ALVIS
-#if HAVE_XSLT
if (1)
{
extern RecType idzebra_filter_alvis[];
recTypeClass_add (&rts, idzebra_filter_alvis, nmem, 0);
}
#endif
+
+#ifdef IDZEBRA_STATIC_DOM
+ if (1)
+ {
+ extern RecType idzebra_filter_dom[];
+ recTypeClass_add (&rts, idzebra_filter_dom, nmem, 0);
+ }
#endif
return rts;
}
-void recTypeClass_load_modules(RecTypeClass *rts, NMEM nmem,
- const char *module_path)
+static void load_from_dir(RecTypeClass *rts, NMEM nmem, const char *dirname)
{
#if HAVE_DLFCN_H
- if (module_path)
+ DIR *dir = opendir(dirname);
+ if (dir)
{
- DIR *dir = opendir(module_path);
- yaz_log(YLOG_LOG, "searching filters in %s", module_path);
- if (dir)
- {
- struct dirent *de;
-
- while ((de = readdir(dir)))
- {
- size_t dlen = strlen(de->d_name);
- if (dlen >= 5 &&
- !memcmp(de->d_name, "mod-", 4) &&
- !strcmp(de->d_name + dlen - 3, ".so"))
- {
- void *mod_p, *fl;
- char fname[FILENAME_MAX*2+1];
- sprintf(fname, "%.*s/%.*s",
- FILENAME_MAX, module_path,
- FILENAME_MAX, de->d_name);
- mod_p = dlopen(fname, RTLD_NOW|RTLD_GLOBAL);
- if (mod_p && (fl = dlsym(mod_p, "idzebra_filter")))
- {
- yaz_log(YLOG_LOG, "Loaded filter module %s", fname);
- recTypeClass_add(rts, fl, nmem, mod_p);
- }
- else if (mod_p)
- {
- const char *err = dlerror();
- yaz_log(YLOG_WARN, "dlsym failed %s %s",
- fname, err ? err : "none");
- dlclose(mod_p);
- }
- else
- {
- const char *err = dlerror();
- yaz_log(YLOG_WARN, "dlopen failed %s %s",
- fname, err ? err : "none");
-
- }
- }
- }
- closedir(dir);
- }
+ struct dirent *de;
+
+ while ((de = readdir(dir)))
+ {
+ size_t dlen = strlen(de->d_name);
+ if (dlen >= 5 &&
+ !memcmp(de->d_name, "mod-", 4) &&
+ !strcmp(de->d_name + dlen - 3, ".so"))
+ {
+ void *mod_p, *fl;
+ char fname[FILENAME_MAX*2+1];
+ sprintf(fname, "%.*s/%.*s",
+ FILENAME_MAX, dirname,
+ FILENAME_MAX, de->d_name);
+ mod_p = dlopen(fname, RTLD_NOW|RTLD_GLOBAL);
+ if (mod_p && (fl = dlsym(mod_p, "idzebra_filter")))
+ {
+ yaz_log(YLOG_LOG, "Loaded filter module %s", fname);
+ recTypeClass_add(rts, fl, nmem, mod_p);
+ }
+ else if (mod_p)
+ {
+ const char *err = dlerror();
+ yaz_log(YLOG_WARN, "dlsym failed %s %s",
+ fname, err ? err : "none");
+ dlclose(mod_p);
+ }
+ else
+ {
+ const char *err = dlerror();
+ yaz_log(YLOG_WARN, "dlopen failed %s %s",
+ fname, err ? err : "none");
+
+ }
+ }
+ }
+ closedir(dir);
}
#endif
}
+void recTypeClass_load_modules(RecTypeClass *rts, NMEM nmem,
+ const char *module_path)
+{
+ while (module_path)
+ {
+ const char *comp_ptr;
+ char comp[FILENAME_MAX+1];
+ size_t len;
+
+ len = yaz_filepath_comp(&module_path, &comp_ptr);
+ if (!len || len >= FILENAME_MAX)
+ break;
+
+ memcpy(comp, comp_ptr, len);
+ comp[len] = '\0';
+
+ load_from_dir(rts, nmem, comp);
+ }
+}
+
static void recTypeClass_add(struct recTypeClass **rts, RecType *rt,
NMEM nmem, void *module_handle)
{
r->next = *rts;
*rts = r;
- yaz_log(YLOG_LOG, "Adding filter %s", (*rt)->name);
r->module_handle = module_handle;
module_handle = 0; /* so that we only store module_handle once */
r->recType = *rt;