-/* $Id: recctrl.c,v 1.9 2004-09-28 10:15:03 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
- Index Data Aps
+/* $Id: recctrl.c,v 1.19 2005-03-31 12:42:07 adam Exp $
+ Copyright (C) 1995-2005
+ Index Data ApS
This file is part of the Zebra server.
#include <stdio.h>
#include <assert.h>
#include <string.h>
+#if HAVE_DLFCN_H
#include <dlfcn.h>
+#endif
#include <direntz.h>
-#include <zebrautl.h>
+#include <idzebra/util.h>
#include <idzebra/recctrl.h>
struct recTypeClass {
const char *module_path = res_get_def(res, "modulePath",
DEFAULT_MODULE_PATH);
- extern RecType idzebra_filter_grs_sgml[];
- recTypeClass_add (&rts, idzebra_filter_grs_sgml, nmem, 0);
+#ifdef IDZEBRA_STATIC_GRS_SGML
+ if (1)
+ {
+ extern RecType idzebra_filter_grs_sgml[];
+ recTypeClass_add (&rts, idzebra_filter_grs_sgml, nmem, 0);
+ }
+#endif
#ifdef IDZEBRA_STATIC_TEXT
- extern RecType idzebra_filter_text[];
- recTypeClass_add (&rts, idzebra_filter_text, nmem, 0);
+ if (1)
+ {
+ extern RecType idzebra_filter_text[];
+ recTypeClass_add (&rts, idzebra_filter_text, nmem, 0);
+ }
#endif
#ifdef IDZEBRA_STATIC_GRS_XML
#if HAVE_EXPAT_H
- extern RecType idzebra_filter_grs_xml[];
- recTypeClass_add (&rts, idzebra_filter_grs_xml, nmem, 0);
+ if (1)
+ {
+ extern RecType idzebra_filter_grs_xml[];
+ recTypeClass_add (&rts, idzebra_filter_grs_xml, nmem, 0);
+ }
#endif
#endif
#ifdef IDZEBRA_STATIC_GRS_REGX
- extern RecType idzebra_filter_grs_regx[];
- recTypeClass_add (&rts, idzebra_filter_grs_regx, nmem, 0);
+ if (1)
+ {
+ extern RecType idzebra_filter_grs_regx[];
+ recTypeClass_add (&rts, idzebra_filter_grs_regx, nmem, 0);
+ }
#endif
#ifdef IDZEBRA_STATIC_GRS_MARC
- extern RecType idzebra_filter_grs_marc[];
- recTypeClass_add (&rts, idzebra_filter_grs_marc, nmem, 0);
-#endif
-#ifdef IDZEBRA_STATIC_GRS_PERL
- extern RecType idzebra_filter_grs_perl[];
- recTypeClass_add (&rts, idzebra_filter_grs_perl, nmem, 0);
+ if (1)
+ {
+ extern RecType idzebra_filter_grs_marc[];
+ recTypeClass_add (&rts, idzebra_filter_grs_marc, nmem, 0);
+ }
#endif
#ifdef IDZEBRA_STATIC_GRS_DANBIB
- extern RecType idzebra_filter_grs_danbib[];
- recTypeClass_add (&rts, idzebra_filter_grs_danbib, nmem, 0);
+ if (1)
+ {
+ extern RecType idzebra_filter_grs_danbib[];
+ recTypeClass_add (&rts, idzebra_filter_grs_danbib, nmem, 0);
+ }
+#endif
+#ifdef IDZEBRA_STATIC_SAFARI
+ if (1)
+ {
+ extern RecType idzebra_filter_safari[];
+ recTypeClass_add (&rts, idzebra_filter_safari, nmem, 0);
+ }
+#endif
+#ifdef IDZEBRA_STATIC_ALVIS
+ if (1)
+ {
+ extern RecType idzebra_filter_alvis[];
+ recTypeClass_add (&rts, idzebra_filter_alvis, nmem, 0);
+ }
#endif
+#if HAVE_DLFCN_H
if (module_path)
{
DIR *dir = opendir(module_path);
- yaz_log(LOG_LOG, "searching filters in %s", 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 ((de->d_type == DT_REG || de->d_type == DT_LNK)
- && dlen >= 5 &&
+ if (dlen >= 5 &&
!memcmp(de->d_name, "mod-", 4) &&
!strcmp(de->d_name + dlen - 3, ".so"))
{
mod_p = dlopen(fname, RTLD_NOW|RTLD_GLOBAL);
if (mod_p && (fl = dlsym(mod_p, "idzebra_filter")))
{
- yaz_log(LOG_LOG, "Loaded filter module %s", fname);
+ 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(LOG_WARN, "dlsym failed %s %s",
+ yaz_log(YLOG_WARN, "dlsym failed %s %s",
fname, err ? err : "none");
dlclose(mod_p);
}
else
{
const char *err = dlerror();
- yaz_log(LOG_WARN, "dlopen failed %s %s",
+ yaz_log(YLOG_WARN, "dlopen failed %s %s",
fname, err ? err : "none");
}
closedir(dir);
}
}
+#endif
return rts;
}
r->next = *rts;
*rts = r;
- yaz_log(LOG_LOG, "Adding filter %s", (*rt)->name);
+ 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;
{
for (; rtc; rtc = rtc->next)
{
+#if HAVE_DLFCN_H
if (rtc->module_handle)
dlclose(rtc->module_handle);
+#endif
}
}