From 8ee402d79e37344b08c2b54ad45b50e8327a6c03 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 27 Sep 2004 10:44:47 +0000 Subject: [PATCH] Implemented loadable filters. --- buildconf.sh | 8 +- configure.in | 151 ++++++++++++++++++++------------ examples/gils/zebra.cfg | 8 +- include/idzebra/api.h | 6 +- include/recctrl.h | 27 +++--- index/Makefile.am | 8 +- index/extract.c | 14 ++- index/index.h | 4 +- index/main.c | 37 ++++---- index/retrieve.c | 8 +- index/zebraapi.c | 14 ++- perl/demo/zebra.cfg | 2 + perl/zebra_perl.c | 97 ++++++++++++++++++++- recctrl/Makefile.am | 70 ++++++++++++--- recctrl/danbibr.c | 45 +++++++--- recctrl/grsread.h | 26 ++---- recctrl/marcread.c | 85 ++++++++++++++---- recctrl/perlread.c | 82 ++++++++++-------- recctrl/perlread.h.in | 24 ++++++ recctrl/recctrl.c | 220 ++++++++++++++++++++++++++++++++++++----------- recctrl/recgrs.c | 133 ++++------------------------ recctrl/recgrs.h | 40 --------- recctrl/rectext.c | 28 ++++-- recctrl/rectext.h | 40 --------- recctrl/regxread.c | 75 +++++++++++++--- recctrl/sgmlread.c | 39 +++++++-- recctrl/xmlread.c | 49 ++++++++--- test/cddb/zebra.cfg | 4 +- test/charmap/test1.sh | 4 +- test/charmap/test2.sh | 2 +- test/charmap/zebra.cfg | 4 +- test/config/test2.sh | 4 +- test/config/zebra.cfg | 4 +- test/malxml/test1.sh | 4 +- test/malxml/zebra.cfg | 4 +- test/marcxml/test1.sh | 4 +- test/marcxml/test2.sh | 10 ++- test/marcxml/zebra.cfg | 4 +- test/rusmarc/test1.sh | 10 ++- test/rusmarc/zebra.cfg | 7 +- test/usmarc/zebra.cfg | 4 +- 41 files changed, 886 insertions(+), 523 deletions(-) delete mode 100644 recctrl/recgrs.h delete mode 100644 recctrl/rectext.h diff --git a/buildconf.sh b/buildconf.sh index 40377c2..9c3d450 100755 --- a/buildconf.sh +++ b/buildconf.sh @@ -1,12 +1,8 @@ #!/bin/sh -# $Id: buildconf.sh,v 1.11 2004-08-24 10:37:18 adam Exp $ +# $Id: buildconf.sh,v 1.12 2004-09-27 10:44:47 adam Exp $ set -x dir=`aclocal --print-ac-dir` -if [ -f $dir/yaz.m4 ]; then - aclocal -else - aclocal -I . -fi +aclocal -I . libtoolize --automake --force automake -a automake -a diff --git a/configure.in b/configure.in index 1bb8d3a..e92c7d3 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Zebra, Index Data Aps, 1995-2004 -dnl $Id: configure.in,v 1.100 2004-09-27 08:29:38 adam Exp $ +dnl $Id: configure.in,v 1.101 2004-09-27 10:44:47 adam Exp $ dnl AC_INIT(include/idzebra/version.h) AM_INIT_AUTOMAKE(idzebra,1.4.0) @@ -156,9 +156,12 @@ fi dnl dnl ------ -lm AC_CHECK_LIB(m,sqrt) +dnl ------ -ldl +AC_CHECK_LIB(dl,dlopen) dnl dnl ------ EXPAT expat=yes +AC_SUBST(EXPAT_LIBS) AC_ARG_WITH(expat, [ --with-expat[=DIR] EXPAT library in DIR],[expat=$withval]) if test "$expat" != "no"; then xLIBS="$LIBS"; @@ -169,23 +172,103 @@ if test "$expat" != "no"; then CFLAGS="$EXPAT_CFLAGS $CFLAGS" LIBS="$EXPAT_LIBS $LIBS" fi - AC_CHECK_LIB(expat,XML_ParserCreate,[LIBS="$LIBS -lexpat"]) + AC_CHECK_LIB(expat,XML_ParserCreate,[EXPAT_LIBS="$EXPAT_LIBS -lexpat"]) if test "$ac_cv_lib_expat_XML_ParserCreate" = "yes"; then AC_CHECK_HEADERS(expat.h) - else - LIBS="$xLIBS" - CFLAGS="$xCFLAGS" fi + LIBS="$xLIBS" + CFLAGS="$xCFLAGS" fi dnl dnl ------ PERL -AM_CONDITIONAL(perl,false) -perl=no +AC_ARG_WITH(perl, [ --with-perl[=FILE] perl binary location],[perl=$withval],[perl=yes]) + +dnl ------- 64 bit files +AC_MSG_CHECKING(for LFS) +AC_TRY_RUN([#define _FILE_OFFSET_BITS 64 +#include +#include +#include +#include +#include +#include +int main(int argc, char **argv) +{ + off_t o; + char tmp_str[32]; + int fd; + struct flock area; + if (sizeof(off_t) != 8) + exit (1); + o = 2000000000; + sprintf (tmp_str, "%Ld", o+o+o); + if (strcmp (tmp_str, "6000000000")) + exit (1); + fd = creat ("config.tmp", 0644); + if (fd < 0) + exit (1); + area.l_type = F_WRLCK; + area.l_whence = SEEK_SET; + area.l_len = area.l_start = 0L; + if (fcntl(fd, F_SETLKW, &area)) + exit (1); + close (fd); + unlink ("config.tmp"); + exit (0); +} +],bits=64,bits=32,bits=32) +if test "$bits" = "64"; then + AC_DEFINE(_FILE_OFFSET_BITS,64) + AC_MSG_RESULT(yes) +else + AC_MSG_RESULT(no) +fi +dnl ------ Modules +AC_SUBST(SHARED_MODULE_LA) +SHARED_MODULE_LA="" +AC_SUBST(STATIC_MODULE_OBJ) +STATIC_MODULE_OBJ="" +AC_SUBST(STATIC_MODULE_LADD) +STATIC_MODULE_LADD="" +AC_DEFUN([ZEBRA_MODULE],[ + AC_ARG_ENABLE(mod-$1,[$3],[myen=$enableval],[myen=$2]) + AC_MSG_CHECKING([for module $1]) + if test "$myen" = "yes"; then + myen="shared" + fi + if test "$enable_shared" != "yes"; then + if test "$myen" = "shared"; then + myen="static" + fi + fi + m=`echo $1|tr .- __` + if test "$myen" = "shared"; then + AC_MSG_RESULT([shared]) + SHARED_MODULE_LA="${SHARED_MODULE_LA} mod-$1.la" + elif test "$myen" = "static" -o "$myen" = "yes"; then + AC_MSG_RESULT([static]) + STATIC_MODULE_OBJ="${STATIC_MODULE_OBJ} \$(mod_${m}_la_OBJECTS)" + STATIC_MODULE_LADD="${STATIC_MODULE_LADD} \$(mod_${m}_la_LADD)" + modcpp=`echo $1|tr a-z- A-Z_` + AC_DEFINE_UNQUOTED([IDZEBRA_STATIC_$modcpp]) + elif test "$myen" = "no"; then + AC_MSG_RESULT([disabled]) + else + AC_MSG_RESULT([bad value. Assuming disabled]) + fi +]) + +ZEBRA_MODULE(text,static, [ --enable-mod-text Text filter]) +ZEBRA_MODULE(grs-sgml,static,[ --enable-mod-grs-sgml Simple SGML/XML filter]) +ZEBRA_MODULE(grs-regx,shared,[ --enable-mod-grs-regx REGX/TCL filter]) +ZEBRA_MODULE(grs-marc,shared,[ --enable-mod-grs-marc MARC filter]) +ZEBRA_MODULE(grs-danbib,shared,[ --enable-mod-grs-danbib DanBib filter (DBC)]) +ZEBRA_MODULE(grs-xml,shared, [ --enable-mod-grs-xml XML filter (Expat based)]) +ZEBRA_MODULE(grs-perl,no, [ --enable-mod-grs-perl Perl filter]) PERL_XS_INIT="NULL" PERL_XS_INIT_INCLUDE='' PERL_BINARY="" -AC_ARG_WITH(perl, [ --with-perl[=FILE] perl binary location],[perl=$withval]) -if test "$perl" != "no"; then +if test "$myen" != "no"; then AC_MSG_CHECKING(for perl binary) if test "$perl" = "yes"; then perlbin=`which perl` @@ -251,55 +334,15 @@ if test "$perl" != "no"; then ZPERL_LIBS="$xLIBS" , AC_MSG_RESULT(not found) - AC_DEFINE(HAVE_PERL,0) - LIBS="$xLIBS" - CFLAGS="$xCFLAGS") + AC_DEFINE(HAVE_PERL,0)) + LIBS="$xLIBS" + CFLAGS="$xCFLAGS" else AC_DEFINE(HAVE_PERL,0) AC_MSG_RESULT(Not found) fi fi -dnl ------- 64 bit files -AC_MSG_CHECKING(for LFS) -AC_TRY_RUN([#define _FILE_OFFSET_BITS 64 -#include -#include -#include -#include -#include -#include -int main(int argc, char **argv) -{ - off_t o; - char tmp_str[32]; - int fd; - struct flock area; - if (sizeof(off_t) != 8) - exit (1); - o = 2000000000; - sprintf (tmp_str, "%Ld", o+o+o); - if (strcmp (tmp_str, "6000000000")) - exit (1); - fd = creat ("config.tmp", 0644); - if (fd < 0) - exit (1); - area.l_type = F_WRLCK; - area.l_whence = SEEK_SET; - area.l_len = area.l_start = 0L; - if (fcntl(fd, F_SETLKW, &area)) - exit (1); - close (fd); - unlink ("config.tmp"); - exit (0); -} -],bits=64,bits=32,bits=32) -if test "$bits" = "64"; then - AC_DEFINE(_FILE_OFFSET_BITS,64) - AC_MSG_RESULT(yes) -else - AC_MSG_RESULT(no) -fi -dnl + dnl ------ ANSI C Header files AC_STDC_HEADERS if test "$ac_cv_header_stdc" = "no"; then @@ -346,7 +389,7 @@ if test -x "$perlbin"; then res=`cd perl ; $perlbin Makefile.PL ; cd .. ;`; fi if test -z "$YAZLIB"; then - echo "YAZ was not found. Use --with-yazconfig=DIR to specify location." + echo "YAZ was not found. Use --with-yaz=DIR to specify location." test -f /etc/debian_version && echo "Debian package libyaz-dev is required." fi diff --git a/examples/gils/zebra.cfg b/examples/gils/zebra.cfg index cc54678..e9ce979 100644 --- a/examples/gils/zebra.cfg +++ b/examples/gils/zebra.cfg @@ -1,8 +1,8 @@ # Simple Zebra configuration file -# $Id: zebra.cfg,v 1.3 2004-08-04 08:35:23 adam Exp $ +# $Id: zebra.cfg,v 1.4 2004-09-27 10:44:47 adam Exp $ # # Where the schema files, attribute files, etc are located. -profilePath: ../../tab +profilePath: .:../../tab # Files that describe the attribute sets supported. attset: bib1.att @@ -13,3 +13,7 @@ recordtype: grs.sgml isam: c #recordId: (bib-1,identifier-standard) + +modulePath: ../../recctrl/.libs +shadow: shadow:100M +register: register:100M diff --git a/include/idzebra/api.h b/include/idzebra/api.h index c11e08d..75a5d65 100644 --- a/include/idzebra/api.h +++ b/include/idzebra/api.h @@ -1,4 +1,4 @@ -/* $Id: api.h,v 1.1 2004-08-25 09:23:36 adam Exp $ +/* $Id: api.h,v 1.2 2004-09-27 10:44:48 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -89,6 +89,10 @@ YAZ_EXPORT ZebraService zebra_start_res (const char *configName, /* Close the whole Zebra */ YAZ_EXPORT int zebra_stop (ZebraService zs); +/* Report name of each record class (filter) */ +YAZ_EXPORT void zebra_filter_info(ZebraService zs, void *cd, + void (*cb)(void *cd, const char *name)); + /* Open a ZebraHandle */ /* There should be one handle for each thred doing something */ diff --git a/include/recctrl.h b/include/recctrl.h index 3a32935..f134e3d 100644 --- a/include/recctrl.h +++ b/include/recctrl.h @@ -1,5 +1,5 @@ -/* $Id: recctrl.h,v 1.41 2004-08-06 12:28:22 adam Exp $ - Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 +/* $Id: recctrl.h,v 1.42 2004-09-27 10:44:48 adam Exp $ + Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps This file is part of the Zebra server. @@ -28,6 +28,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #include #include +#include #include #include @@ -55,7 +56,6 @@ struct recExtractCtrl { off_t (*tellf)(void *fh); /* tell function */ void (*endf)(void *fh, off_t offset); /* end of record position */ off_t offset; /* start offset */ - char *subType; void (*init)(struct recExtractCtrl *p, RecWord *w); void *clientData; void (*tokenAdd)(RecWord *w); @@ -83,7 +83,6 @@ struct recRetrieveCtrl { int score; /* score 0-1000 or -1 if none */ int recordSize; /* size of record in bytes */ char *fname; /* name of file (or NULL if internal) */ - char *subType; data1_handle dh; /* response */ @@ -99,7 +98,8 @@ typedef struct recType *RecType; struct recType { char *name; /* Name of record type */ - void *(*init)(RecType recType); /* Init function - called once */ + void *(*init)(Res res, RecType recType); /* Init function - called once */ + void (*config)(void *clientData, Res res, const char *args); /* Config */ void (*destroy)(void *clientData); /* Destroy function */ int (*extract)(void *clientData, struct recExtractCtrl *ctrl); /* Extract proc */ @@ -112,14 +112,21 @@ struct recType #define RECCTRL_EXTRACT_ERROR_GENERIC 2 #define RECCTRL_EXTRACT_ERROR_NO_SUCH_FILTER 3 +typedef struct recTypeClass *RecTypeClass; typedef struct recTypes *RecTypes; -RecTypes recTypes_init (data1_handle dh); -void recTypes_destroy (RecTypes recTypes); -void recTypes_default_handlers (RecTypes recTypes); +RecTypeClass recTypeClass_create (Res res, NMEM nmem); +void recTypeClass_destroy(RecTypeClass rtc); +void recTypeClass_info(RecTypeClass rtc, void *cd, + void (*cb)(void *cd, const char *s)); + +RecTypes recTypes_init(RecTypeClass rtc, data1_handle dh); +void recTypes_destroy(RecTypes recTypes); +void recTypes_default_handlers(RecTypes recTypes, Res res); + +RecType recType_byName(RecTypes rts, Res res, const char *name, + void **clientDataP); -RecType recType_byName (RecTypes rts, const char *name, char *subType, - void **clientDataP); int grs_extract_tree(struct recExtractCtrl *p, data1_node *n); diff --git a/index/Makefile.am b/index/Makefile.am index 3ee1193..feadea7 100644 --- a/index/Makefile.am +++ b/index/Makefile.am @@ -1,4 +1,4 @@ -## $Id: Makefile.am,v 1.27 2004-08-30 21:36:53 adam Exp $ +## $Id: Makefile.am,v 1.28 2004-09-27 10:44:49 adam Exp $ noinst_PROGRAMS = apitest kdump @@ -32,10 +32,10 @@ zebrash_SOURCES = zebrash.c apitest_SOURCES = apitest.c kdump_SOURCES = kdump.c -AM_CPPFLAGS = -I$(srcdir)/../include $(YAZINC) $(TCL_INCLUDE) \ +AM_CPPFLAGS = -I$(srcdir)/../include $(YAZINC) \ -DDEFAULT_PROFILE_PATH=\"$(pkgdatadir)/tab\" -zebrash_LDADD= $(zebralibs) $(YAZLALIB) $(TCL_LIB) $(READLINE_LIBS) +zebrash_LDADD= $(zebralibs) $(YAZLALIB) $(READLINE_LIBS) -LDADD = $(zebralibs) $(YAZLALIB) $(TCL_LIB) +LDADD = $(zebralibs) $(YAZLALIB) diff --git a/index/extract.c b/index/extract.c index 107b4ca..2e6654d 100644 --- a/index/extract.c +++ b/index/extract.c @@ -1,4 +1,4 @@ -/* $Id: extract.c,v 1.162 2004-09-15 08:13:51 adam Exp $ +/* $Id: extract.c,v 1.163 2004-09-27 10:44:49 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -400,10 +400,9 @@ static int file_extract_record(ZebraHandle zh, off_t recordOffset = 0; RecType recType; void *clientData; - char subType[128]; if (!(recType = - recType_byName (zh->reg->recTypes, zh->m_record_type, subType, + recType_byName (zh->reg->recTypes, zh->res, zh->m_record_type, &clientData))) { logf (LOG_WARN, "No such record type: %s", zh->m_record_type); @@ -436,7 +435,6 @@ static int file_extract_record(ZebraHandle zh, extractCtrl.tellf = file_tell; extractCtrl.endf = file_end; extractCtrl.fh = fi; - extractCtrl.subType = subType; extractCtrl.init = extract_init; extractCtrl.tokenAdd = extract_token_add; extractCtrl.schemaAdd = extract_schema_add; @@ -824,7 +822,6 @@ int buffer_extract_record (ZebraHandle zh, int i, r; const char *matchStr = 0; RecType recType = NULL; - char subType[1024]; void *clientData; Record rec; long recordOffset = 0; @@ -861,7 +858,7 @@ int buffer_extract_record (ZebraHandle zh, if (recordType && *recordType) { logf (LOG_DEBUG, "Record type explicitly specified: %s", recordType); - recType = recType_byName (zh->reg->recTypes, recordType, subType, + recType = recType_byName (zh->reg->recTypes, zh->res, recordType, &clientData); } else { if (!(zh->m_record_type)) { @@ -869,8 +866,8 @@ int buffer_extract_record (ZebraHandle zh, return 0; } logf (LOG_DEBUG, "Get record type from rgroup: %s",zh->m_record_type); - recType = recType_byName (zh->reg->recTypes, zh->m_record_type, subType, - &clientData); + recType = recType_byName (zh->reg->recTypes, zh->res, + zh->m_record_type, &clientData); recordType = zh->m_record_type; } @@ -879,7 +876,6 @@ int buffer_extract_record (ZebraHandle zh, return 0; } - extractCtrl.subType = subType; extractCtrl.init = extract_init; extractCtrl.tokenAdd = extract_token_add; extractCtrl.schemaAdd = extract_schema_add; diff --git a/index/index.h b/index/index.h index cb9c020..d32ada4 100644 --- a/index/index.h +++ b/index/index.h @@ -1,4 +1,4 @@ -/* $Id: index.h,v 1.120 2004-09-15 08:13:51 adam Exp $ +/* $Id: index.h,v 1.121 2004-09-27 10:44:49 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -259,6 +259,8 @@ struct zebra_service { Zebra_mutex_cond session_lock; Passwd_db passwd_db; const char *path_root; + RecTypeClass record_classes; + NMEM nmem; }; diff --git a/index/main.c b/index/main.c index 8a1dac4..392a7d4 100644 --- a/index/main.c +++ b/index/main.c @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.114 2004-09-26 20:38:50 adam Exp $ +/* $Id: main.c,v 1.115 2004-09-27 10:44:49 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -35,19 +35,21 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #endif -#if HAVE_TCL_H -#include -#endif - -#if HAVE_EXPAT_H -#include -#endif - #include #include char *prog; +static void filter_cb(void *cd, const char *name) +{ + puts (name); +} + +static void show_filters(ZebraService zs) +{ + zebra_filter_info(zs, 0, filter_cb); +} + int main (int argc, char **argv) { int ret; @@ -180,6 +182,10 @@ int main (int argc, char **argv) { zebra_compact (zh); } + else if (!strcmp (arg, "filters")) + { + show_filters(zs); + } else { logf (LOG_FATAL, "unknown command: %s", arg); @@ -232,17 +238,6 @@ int main (int argc, char **argv) #if HAVE_BZLIB_H printf("Using: libbzip2, (C) 1996-1999 Julian R Seward. All rights reserved.\n"); #endif -#if HAVE_TCL_H - printf("Using: Tcl %s\n", TCL_VERSION); -#endif -#if HAVE_EXPAT_H - if (1) - { - XML_Expat_Version v = XML_ExpatVersionInfo(); - printf ("Using: Expat %d.%d.%d\n", - v.major, v.minor, v.micro); - } -#endif } else if (ret == 'v') yaz_log_init_level (yaz_log_mask_str(arg)); @@ -264,7 +259,7 @@ int main (int argc, char **argv) res_set(res, "recordType", arg); else if (ret == 'n') enable_commit = 0; - else if (ret == 'L') + else if (ret == 'L') res_set(res, "followLinks", "0"); else logf (LOG_WARN, "unknown option '-%s'", arg); diff --git a/index/retrieve.c b/index/retrieve.c index 1f30851..dffb20c 100644 --- a/index/retrieve.c +++ b/index/retrieve.c @@ -1,4 +1,4 @@ -/* $Id: retrieve.c,v 1.24 2004-08-10 08:19:15 heikki Exp $ +/* $Id: retrieve.c,v 1.25 2004-09-27 10:44:49 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -91,7 +91,6 @@ int zebra_record_fetch (ZebraHandle zh, SYSNO sysno, int score, ODR stream, char *fname, *file_type, *basename; RecType rt; struct recRetrieveCtrl retrieveCtrl; - char subType[128]; struct zebra_fetch_control fc; RecordAttr *recordAttr; void *clientData; @@ -118,8 +117,8 @@ int zebra_record_fetch (ZebraHandle zh, SYSNO sysno, int score, ODR stream, if (!strcmp (comp->u.simple->u.generic, "R")) raw_mode = 1; } - if (!(rt = recType_byName (zh->reg->recTypes, - file_type, subType, &clientData))) + if (!(rt = recType_byName (zh->reg->recTypes, zh->res, + file_type, &clientData))) { logf (LOG_WARN, "Retrieve: Cannot handle type %s", file_type); return 14; @@ -185,7 +184,6 @@ int zebra_record_fetch (ZebraHandle zh, SYSNO sysno, int score, ODR stream, return 0; } } - retrieveCtrl.subType = subType; retrieveCtrl.localno = sysno; retrieveCtrl.score = score; retrieveCtrl.recordSize = recordAttr->recordSize; diff --git a/index/zebraapi.c b/index/zebraapi.c index cab09ed..9030da1 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.132 2004-09-15 08:13:51 adam Exp $ +/* $Id: zebraapi.c,v 1.133 2004-09-27 10:44:49 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -178,11 +178,18 @@ ZebraService zebra_start_res (const char *configName, Res def_res, Res over_res) res_get (zh->global_res, "passwd")); } zh->path_root = res_get (zh->global_res, "root"); + zh->nmem = nmem_create(); + zh->record_classes = recTypeClass_create (zh->global_res, zh->nmem); return zh; } return 0; } +void zebra_filter_info(ZebraService zs, void *cd, + void (*cb)(void *cd, const char *name)) +{ + recTypeClass_info(zs->record_classes, cd, cb); +} void zebra_pidfname(ZebraService zs, char *path) { @@ -253,8 +260,7 @@ struct zebra_register *zebra_register_open (ZebraService zs, const char *name, data1_set_tabpath (reg->dh, profilePath); data1_set_tabroot (reg->dh, reg_path); - reg->recTypes = recTypes_init (reg->dh); - recTypes_default_handlers (reg->recTypes); + reg->recTypes = recTypes_init (zs->record_classes, reg->dh); reg->zebra_maps = zebra_maps_open (res, reg_path); reg->rank_classes = NULL; @@ -452,6 +458,8 @@ int zebra_stop(ZebraService zs) if (zs->passwd_db) passwd_db_close (zs->passwd_db); + recTypeClass_destroy(zs->record_classes); + nmem_destroy(zs->nmem); res_close (zs->global_res); xfree (zs->configName); xfree (zs); diff --git a/perl/demo/zebra.cfg b/perl/demo/zebra.cfg index 330cf24..9900ec3 100644 --- a/perl/demo/zebra.cfg +++ b/perl/demo/zebra.cfg @@ -2,6 +2,8 @@ profilePath: blib/lib:blib/arch:blib/lib:demo/:../tab:../../yaz/tab +modulePath: /home/adam/proj/zebra/recctrl/.libs + # Files that describe the attribute sets supported. attset: bib1.att attset: explain.att diff --git a/perl/zebra_perl.c b/perl/zebra_perl.c index 8f42896..793c410 100644 --- a/perl/zebra_perl.c +++ b/perl/zebra_perl.c @@ -13,6 +13,7 @@ #include #include "zebra_perl.h" +#include "../recctrl/perlread.h" #include NMEM handles; @@ -20,12 +21,12 @@ NMEM handles; void init (void) { nmem_init (); yaz_log_init_prefix ("ZebraPerl"); - yaz_log (LOG_DEBUG, "Zebra API initialized"); + yaz_log (LOG_LOG, "Zebra API initialized"); } void DESTROY (void) { nmem_exit (); - yaz_log (LOG_DEBUG, "Zebra API destroyed"); + yaz_log (LOG_LOG, "Zebra API destroyed"); } /* Logging facilities from yaz */ @@ -266,3 +267,95 @@ scanEntry *getScanEntry(ScanObj *so, int pos) { return (&so->entries[pos-1]); } +#if 1 +void Filter_store_buff (struct perl_context *context, char *buff, size_t len) +{ + dSP; + + ENTER; + SAVETMPS; + + PUSHMARK(SP) ; + XPUSHs(context->filterRef); + XPUSHs(sv_2mortal(newSVpv(buff, len))); + PUTBACK ; + call_method("_store_buff", 0); + SPAGAIN ; + PUTBACK ; + + FREETMPS; + LEAVE; +} + +/* The "file" manipulation function wrappers */ +int grs_perl_readf(struct perl_context *context, size_t len) +{ + int r; + char *buf = (char *) xmalloc (len+1); + r = (*context->readf)(context->fh, buf, len); + if (r > 0) Filter_store_buff (context, buf, r); + xfree (buf); + return (r); +} + +int grs_perl_readline(struct perl_context *context) +{ + int r; + char *buf = (char *) xmalloc (4096); + char *p = buf; + + while ((r = (*context->readf)(context->fh,p,1)) && (p-buf < 4095)) { + p++; + if (*(p-1) == 10) break; + } + + *p = 0; + + if (p != buf) Filter_store_buff (context, buf, p - buf); + xfree (buf); + return (p - buf); +} + +char grs_perl_getc(struct perl_context *context) +{ + int r; + char *p; + if ((r = (*context->readf)(context->fh,p,1))) { + return (*p); + } else { + return (0); + } +} + +off_t grs_perl_seekf(struct perl_context *context, off_t offset) +{ + return ((*context->seekf)(context->fh, offset)); +} + +off_t grs_perl_tellf(struct perl_context *context) +{ + return ((*context->tellf)(context->fh)); +} + +void grs_perl_endf(struct perl_context *context, off_t offset) +{ + (*context->endf)(context->fh, offset); +} + +/* Get pointers from the context. Easyer to wrap this by SWIG */ +data1_handle *grs_perl_get_dh(struct perl_context *context) +{ + return(&context->dh); +} + +NMEM *grs_perl_get_mem(struct perl_context *context) +{ + return(&context->mem); +} + +/* Set the result in the context */ +void grs_perl_set_res(struct perl_context *context, data1_node *n) +{ + context->res = n; +} +#endif diff --git a/recctrl/Makefile.am b/recctrl/Makefile.am index bd1573a..543bdc3 100644 --- a/recctrl/Makefile.am +++ b/recctrl/Makefile.am @@ -1,18 +1,62 @@ -## $Id: Makefile.am,v 1.11 2004-08-24 10:37:18 adam Exp $ +## $Id: Makefile.am,v 1.12 2004-09-27 10:44:50 adam Exp $ -lib_LTLIBRARIES = libidzebra-recctrl.la +common_libs = libidzebra-recctrl.la \ + ../data1/libidzebra-data1.la \ + ../dfa/libidzebra-dfa.la \ + ../util/libidzebra-util.la \ + $(YAZLALIB) -EXTRA_DIST=perlread.c perlread.h.in +# The shared modules +mod_grs_perl_la_SOURCES = perlread.c perlread.h.in +mod_grs_perl_la_LDFLAGS = -rpath $(pkglibdir) -module -avoid-version +mod_grs_perl_la_LADD = $(PERL_LIBS) +mod_grs_perl_la_LIBADD = $(common_libs) $(mod_grs_perl_la_LADD) + +mod_grs_regx_la_SOURCES = regxread.c +mod_grs_regx_la_LDFLAGS = -rpath $(pkglibdir) -module -avoid-version +mod_grs_regx_la_LADD = $(TCL_LIB) +mod_grs_regx_la_LIBADD = $(common_libs) $(mod_grs_regx_la_LADD) + +mod_grs_xml_la_SOURCES = xmlread.c +mod_grs_xml_la_LDFLAGS = -rpath $(pkglibdir) -module -avoid-version +mod_grs_xml_la_LADD = $(EXPAT_LIBS) +mod_grs_xml_la_LIBADD = $(common_libs) $(mod_grs_xml_la_LADD) + +mod_grs_marc_la_SOURCES = marcread.c marcomp.c marcomp.h inline.c inline.h +mod_grs_marc_la_LDFLAGS = -rpath $(pkglibdir) -module -avoid-version +mod_grs_marc_la_LADD = +mod_grs_marc_la_LIBADD = $(common_libs) $(mod_grs_marc_la_LADD) -if perl -PERLREAD=perlread.c -else -PERLREAD= -endif +mod_grs_danbib_la_SOURCES = danbibr.c +mod_grs_danbib_la_LDFLAGS = -rpath $(pkglibdir) -module -avoid-version +mod_grs_danbib_la_LADD = +mod_grs_danbib_la_LIBADD = $(common_libs) $(mod_grs_danbib_la_LADD) -libidzebra_recctrl_la_SOURCES = recctrl.c recgrs.c sgmlread.c regxread.c \ - marcread.c marcomp.c marcomp.h inline.c inline.h rectext.c \ - grsread.h recgrs.h rectext.h xmlread.c danbibr.c \ - $(PERLREAD) +pkglib_LTLIBRARIES = $(SHARED_MODULE_LA) +EXTRA_LTLIBRARIES = \ + mod-grs-perl.la \ + mod-grs-regx.la \ + mod-grs-xml.la \ + mod-grs-marc.la \ + mod-grs-danbib.la -AM_CPPFLAGS = -I$(srcdir)/../include $(YAZINC) $(TCL_INCLUDE) +# The common library +lib_LTLIBRARIES = libidzebra-recctrl.la +libidzebra_recctrl_la_SOURCES = recctrl.c recgrs.c sgmlread.c rectext.c grsread.h +libidzebra_recctrl_la_LDFLAGS = -export-dynamic +libidzebra_recctrl_la_LIBADD = $(STATIC_MODULE_OBJ) \ + ../data1/libidzebra-data1.la \ + ../dfa/libidzebra-dfa.la \ + ../util/libidzebra-util.la \ + $(STATIC_MODULE_LADD) +libidzebra_recctrl_la_DEPENDENCIES = $(STATIC_MODULE_OBJ) + +EXTRA_libidzebra_recctrl_la_SOURCES = \ + $(mod_grs_perl_la_SOURCES) \ + $(mod_grs_regx_la_SOURCES) \ + $(mod_grs_xml_la_SOURCES) \ + $(mod_grs_marc_la_SOURCES) \ + $(mod_grs_danbib_la_SOURCES) + +AM_CPPFLAGS = -I$(srcdir)/../include $(YAZINC) $(TCL_INCLUDE) $(PERL_CFLAGS) -DDEFAULT_MODULE_PATH=\"$(pkglibdir)\" +EXTRA_DIST=perlread.c perlread.h.in diff --git a/recctrl/danbibr.c b/recctrl/danbibr.c index 6459d98..f01a94d 100644 --- a/recctrl/danbibr.c +++ b/recctrl/danbibr.c @@ -1,4 +1,4 @@ -/* $Id: danbibr.c,v 1.4 2004-05-26 13:47:08 adam Exp $ +/* $Id: danbibr.c,v 1.5 2004-09-27 10:44:50 adam Exp $ Copyright (C) 2004 Index Data Aps @@ -39,7 +39,7 @@ struct danbibr_info { char read_buf[READ_CHUNK+1]; /* space for \0 */ }; -static void *grs_init_danbib(void) +static void *init_danbib(Res res, RecType rt) { struct danbibr_info *p = (struct danbibr_info *) xmalloc (sizeof(*p)); @@ -188,7 +188,7 @@ static data1_node *mk_tree(struct grs_read_info *p, const char *rec_buf) return root; } -static data1_node *grs_read_danbib (struct grs_read_info *p) +static data1_node *read_danbib (struct grs_read_info *p) { struct danbibr_info *info = p->clientData; @@ -197,7 +197,7 @@ static data1_node *grs_read_danbib (struct grs_read_info *p) return 0; } -static void grs_destroy_danbib(void *clientData) +static void destroy_danbib(void *clientData) { struct danbibr_info *p = (struct danbibr_info *) clientData; @@ -205,12 +205,37 @@ static void grs_destroy_danbib(void *clientData) xfree (p); } -static struct recTypeGrs danbib_type = { - "danbib", - grs_init_danbib, - grs_destroy_danbib, - grs_read_danbib + +static int extract_danbib(void *clientData, struct recExtractCtrl *ctrl) +{ + return zebra_grs_extract(clientData, ctrl, read_danbib); +} + +static int retrieve_danbib(void *clientData, struct recRetrieveCtrl *ctrl) +{ + return zebra_grs_retrieve(clientData, ctrl, read_danbib); +} + +static struct recType danbib_type = { + "grs.danbib", + init_danbib, + 0, + destroy_danbib, + extract_danbib, + retrieve_danbib, }; -RecTypeGrs recTypeGrs_danbib = &danbib_type; +RecType +#ifdef IDZEBRA_STATIC_GRS_DANBIB +idzebra_filter_grs_danbib +#else +idzebra_filter +#endif + +[] = { + &danbib_type, + 0, +}; + + diff --git a/recctrl/grsread.h b/recctrl/grsread.h index 480e1dd..316178e 100644 --- a/recctrl/grsread.h +++ b/recctrl/grsread.h @@ -1,5 +1,5 @@ -/* $Id: grsread.h,v 1.14 2004-05-21 11:58:56 adam Exp $ - Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 +/* $Id: grsread.h,v 1.15 2004-09-27 10:44:50 adam Exp $ + Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps This file is part of the Zebra server. @@ -20,12 +20,11 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - - #ifndef GRSREAD_H #define GRSREAD_H #include +#include #ifdef __cplusplus extern "C" { @@ -39,26 +38,15 @@ struct grs_read_info { void (*endf)(void *, off_t); void *fh; off_t offset; - char type[80]; NMEM mem; data1_handle dh; }; -typedef struct recTypeGrs { - char *type; - void *(*init)(void); - void (*destroy)(void *clientData); - data1_node *(*read)(struct grs_read_info *p); -} *RecTypeGrs; +int zebra_grs_extract(void *clientData, struct recExtractCtrl *p, + data1_node *(*grs_read)(struct grs_read_info *)); -extern RecTypeGrs recTypeGrs_sgml; -extern RecTypeGrs recTypeGrs_regx; -extern RecTypeGrs recTypeGrs_tcl; -extern RecTypeGrs recTypeGrs_marc; -extern RecTypeGrs recTypeGrs_marcxml; -extern RecTypeGrs recTypeGrs_xml; -extern RecTypeGrs recTypeGrs_perl; -extern RecTypeGrs recTypeGrs_danbib; +int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, + data1_node *(*grs_read)(struct grs_read_info *)); #ifdef __cplusplus } diff --git a/recctrl/marcread.c b/recctrl/marcread.c index 323e96f..a651e05 100644 --- a/recctrl/marcread.c +++ b/recctrl/marcread.c @@ -1,4 +1,4 @@ -/* $Id: marcread.c,v 1.24 2004-06-16 22:12:30 adam Exp $ +/* $Id: marcread.c,v 1.25 2004-09-27 10:44:50 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -34,8 +34,13 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #define MARC_DEBUG 0 #define MARCOMP_DEBUG 0 +struct marc_info { + char type[256]; +}; + static data1_node *grs_read_iso2709 (struct grs_read_info *p, int marc_xml) { + struct marc_info *mi = (struct marc_info*) p->clientData; char buf[100000]; int entry_p; int record_length; @@ -76,7 +81,7 @@ static data1_node *grs_read_iso2709 (struct grs_read_info *p, int marc_xml) if (p->endf) (*p->endf)(p->fh, cur_offset - 1); } - absynName = p->type; + absynName = mi->type; res_root = data1_mk_root (p->dh, p->mem, absynName); if (!res_root) { @@ -768,29 +773,75 @@ data1_node *grs_read_marc(struct grs_read_info *p) return root; } -static void *grs_init_marc(void) +static void *init_marc(Res res, RecType rt) { - return 0; + struct marc_info *p = xmalloc(sizeof(*p)); + strcpy(p->type, ""); + return p; +} + +static void config_marc(void *clientData, Res res, const char *args) +{ + struct marc_info *p = (struct marc_info*) clientData; + if (strlen(args) < sizeof(p->type)) + strcpy(p->type, args); +} + +static void destroy_marc(void *clientData) +{ + struct marc_info *p = (struct marc_info*) clientData; + xfree (p); +} + + +static int extract_marc(void *clientData, struct recExtractCtrl *ctrl) +{ + return zebra_grs_extract(clientData, ctrl, grs_read_marc); } -static void grs_destroy_marc(void *clientData) +static int retrieve_marc(void *clientData, struct recRetrieveCtrl *ctrl) { + return zebra_grs_retrieve(clientData, ctrl, grs_read_marc); } -static struct recTypeGrs marc_type = { - "marc", - grs_init_marc, - grs_destroy_marc, - grs_read_marc +static struct recType marc_type = { + "grs.marc", + init_marc, + config_marc, + destroy_marc, + extract_marc, + retrieve_marc, }; -RecTypeGrs recTypeGrs_marc = &marc_type; +static int extract_marcxml(void *clientData, struct recExtractCtrl *ctrl) +{ + return zebra_grs_extract(clientData, ctrl, grs_read_marcxml); +} -static struct recTypeGrs marcxml_type = { - "marcxml", - grs_init_marc, - grs_destroy_marc, - grs_read_marcxml +static int retrieve_marcxml(void *clientData, struct recRetrieveCtrl *ctrl) +{ + return zebra_grs_retrieve(clientData, ctrl, grs_read_marcxml); +} + +static struct recType marcxml_type = { + "grs.marcxml", + init_marc, + config_marc, + destroy_marc, + extract_marcxml, + retrieve_marcxml, }; -RecTypeGrs recTypeGrs_marcxml = &marcxml_type; +RecType +#ifdef IDZEBRA_STATIC_GRS_MARC +idzebra_filter_grs_marc +#else +idzebra_filter +#endif + +[] = { + &marc_type, + &marcxml_type, + 0, +}; + diff --git a/recctrl/perlread.c b/recctrl/perlread.c index bdfb35b..e52b534 100644 --- a/recctrl/perlread.c +++ b/recctrl/perlread.c @@ -1,4 +1,4 @@ -/* $Id: perlread.c,v 1.9 2004-09-06 09:31:34 adam Exp $ +/* $Id: perlread.c,v 1.10 2004-09-27 10:44:50 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -35,28 +35,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #include "grsread.h" - -#define GRS_PERL_MODULE_NAME_MAXLEN 255 - -/* Context information for the filter */ -struct perl_context { - PerlInterpreter *perli; - PerlInterpreter *origi; - int perli_ready; - char filterClass[GRS_PERL_MODULE_NAME_MAXLEN]; - SV *filterRef; - - int (*readf)(void *, char *, size_t); - off_t (*seekf)(void *, off_t); - off_t (*tellf)(void *); - void (*endf)(void *, off_t); - - void *fh; - data1_handle dh; - NMEM mem; - data1_node *res; -}; - /* Constructor call for the filter object */ void Filter_create (struct perl_context *context) { @@ -143,6 +121,8 @@ int Filter_process (struct perl_context *context) can hide this whole compexity behind. */ + +#if 0 void Filter_store_buff (struct perl_context *context, char *buff, size_t len) { dSP; @@ -233,9 +213,10 @@ void grs_perl_set_res(struct perl_context *context, data1_node *n) { context->res = n; } +#endif /* The filter handlers (init, destroy, read) */ -static void *grs_init_perl(void) +static void *init_perl(Res res, RecType rt) { struct perl_context *context = (struct perl_context *) xmalloc (sizeof(*context)); @@ -253,10 +234,18 @@ static void *grs_init_perl(void) } context->perli_ready = 0; strcpy(context->filterClass, ""); - return (context); + strcpy(context->type, ""); + return context; +} + +static void config_perl(void *clientData, Res res, const char *args) +{ + struct perl_context *p = (struct perl_context*) clientData; + if (strlen(args) < sizeof(p->type)) + strcpy(p->type, args); } -void grs_destroy_perl(void *clientData) +static void destroy_perl(void *clientData) { struct perl_context *context = (struct perl_context *) clientData; @@ -275,7 +264,7 @@ void grs_destroy_perl(void *clientData) static data1_node *grs_read_perl (struct grs_read_info *p) { struct perl_context *context = (struct perl_context *) p->clientData; - char *filterClass = p->type; + char *filterClass = context->type; /* The "file" manipulation function wrappers */ context->readf = p->readf; @@ -290,7 +279,7 @@ static data1_node *grs_read_perl (struct grs_read_info *p) /* If the class was not interpreted before... */ /* This is not too efficient, when indexing with many different filters... */ - if (strcmp(context->filterClass,filterClass)) { + if (strcmp(context->filterClass, filterClass)) { char modarg[GRS_PERL_MODULE_NAME_MAXLEN + 2]; char initarg[GRS_PERL_MODULE_NAME_MAXLEN + 2]; @@ -353,17 +342,40 @@ static data1_node *grs_read_perl (struct grs_read_info *p) Filter_process(context); /* return the created data1 node */ - return (context->res); + return context->res; } -static struct recTypeGrs perl_type = { - "perl", - grs_init_perl, - grs_destroy_perl, - grs_read_perl +static int extract_perl(void *clientData, struct recExtractCtrl *ctrl) +{ + return zebra_grs_extract(clientData, ctrl, grs_read_perl); +} + +static int retrieve_perl(void *clientData, struct recRetrieveCtrl *ctrl) +{ + return zebra_grs_retrieve(clientData, ctrl, grs_read_perl); +} + +static struct recType perl_type = { + "grs.perl", + init_perl, + config_perl, + destroy_perl, + extract_perl, + retrieve_perl, }; -RecTypeGrs recTypeGrs_perl = &perl_type; +RecType +#ifdef IDZEBRA_STATIC_GRS_PERL +idzebra_filter_grs_perl +#else +idzebra_filter +#endif + +[] = { + &perl_type, + 0, +}; + /* HAVE_PERL */ #endif diff --git a/recctrl/perlread.h.in b/recctrl/perlread.h.in index 2a5c606..c153d4e 100644 --- a/recctrl/perlread.h.in +++ b/recctrl/perlread.h.in @@ -6,3 +6,27 @@ #define PERL_XS_INIT @PERL_XS_INIT@ @PERL_XS_INIT_INCLUDE@ + +#define GRS_PERL_MODULE_NAME_MAXLEN 255 + +#include + +/* Context information for the filter */ +struct perl_context { + PerlInterpreter *perli; + PerlInterpreter *origi; + int perli_ready; + char filterClass[GRS_PERL_MODULE_NAME_MAXLEN]; + SV *filterRef; + + int (*readf)(void *, char *, size_t); + off_t (*seekf)(void *, off_t); + off_t (*tellf)(void *); + void (*endf)(void *, off_t); + + void *fh; + data1_handle dh; + NMEM mem; + data1_node *res; + char type[GRS_PERL_MODULE_NAME_MAXLEN]; +}; diff --git a/recctrl/recctrl.c b/recctrl/recctrl.c index 4c3a605..2870cf3 100644 --- a/recctrl/recctrl.c +++ b/recctrl/recctrl.c @@ -1,5 +1,5 @@ -/* $Id: recctrl.c,v 1.6 2002-08-02 19:26:56 adam Exp $ - Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 +/* $Id: recctrl.c,v 1.7 2004-09-27 10:44:50 adam Exp $ + Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps This file is part of the Zebra server. @@ -24,87 +24,207 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #include #include +#include +#include #include -#include "rectext.h" -#include "recgrs.h" +#include -struct recTypeEntry { +struct recTypeClass { RecType recType; - struct recTypeEntry *next; + struct recTypeClass *next; + void *module_handle; +}; + +struct recTypeInstance { + RecType recType; + struct recTypeInstance *next; int init_flag; void *clientData; }; struct recTypes { data1_handle dh; - struct recTypeEntry *entries; + struct recTypeInstance *entries; }; -RecTypes recTypes_init (data1_handle dh) +static void recTypeClass_add (struct recTypeClass **rts, RecType *rt, + NMEM nmem, void *module_handle); + +RecTypeClass recTypeClass_create (Res res, NMEM nmem) { - RecTypes p = (RecTypes) nmem_malloc (data1_nmem_get (dh), sizeof(*p)); + struct recTypeClass *rts = 0; + 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_TEXT + extern RecType idzebra_filter_text[]; + recTypeClass_add (&rts, idzebra_filter_text, nmem, 0); +#endif +#ifdef IDZEBRA_STATIC_GRS_XML + extern RecType idzebra_filter_grs_xml[]; + recTypeClass_add (&rts, idzebra_filter_grs_xml, nmem, 0); +#endif +#ifdef IDZEBRA_STATIC_GRS_REGX + 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); +#endif +#ifdef IDZEBRA_STATIC_GRS_DANBIB + extern RecType idzebra_filter_grs_danbib[]; + recTypeClass_add (&rts, idzebra_filter_grs_danbib, nmem, 0); +#endif + + if (module_path) + { + DIR *dir = opendir(module_path); + yaz_log(LOG_LOG, "searching filters in %s", module_path); + if (dir) + { + struct dirent *de; - p->dh = dh; - p->entries = 0; - return p; + while ((de = readdir(dir))) + { + size_t dlen = strlen(de->d_name); + if ((de->d_type == DT_REG || de->d_type == DT_LNK) + && 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(LOG_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", + fname, err ? err : "none"); + dlclose(mod_p); + } + else + { + const char *err = dlerror(); + yaz_log(LOG_WARN, "dlopen failed %s %s", + fname, err ? err : "none"); + + } + } + } + closedir(dir); + } + } + return rts; } -void recTypes_destroy (RecTypes rts) +static void recTypeClass_add (struct recTypeClass **rts, RecType *rt, + NMEM nmem, void *module_handle) +{ + while (*rt) + { + struct recTypeClass *r = (struct recTypeClass *) + nmem_malloc (nmem, sizeof(*r)); + + r->next = *rts; + *rts = r; + + yaz_log(LOG_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; + + rt++; + } +} + +void recTypeClass_info(RecTypeClass rtc, void *cd, + void (*cb)(void *cd, const char *s)) { - struct recTypeEntry *rte; + for (; rtc; rtc = rtc->next) + (*cb)(cd, rtc->recType->name); +} - for (rte = rts->entries; rte; rte = rte->next) - if (rte->init_flag) - (*(rte->recType)->destroy)(rte->clientData); +void recTypeClass_destroy(RecTypeClass rtc) +{ + for (; rtc; rtc = rtc->next) + { + if (rtc->module_handle) + dlclose(rtc->module_handle); + } } -void recTypes_add_handler (RecTypes rts, RecType rt) +RecTypes recTypes_init(RecTypeClass rtc, data1_handle dh) { - struct recTypeEntry *rte; + RecTypes rts = (RecTypes) nmem_malloc(data1_nmem_get(dh), sizeof(*rts)); - rte = (struct recTypeEntry *) - nmem_malloc (data1_nmem_get (rts->dh), sizeof(*rte)); + struct recTypeInstance **rti = &rts->entries; + + rts->dh = dh; - rte->recType = rt; - rte->init_flag = 0; - rte->clientData = 0; - rte->next = rts->entries; - rts->entries = rte; + for (; rtc; rtc = rtc->next) + { + *rti = nmem_malloc(data1_nmem_get(dh), sizeof(**rti)); + (*rti)->recType = rtc->recType; + (*rti)->init_flag = 0; + rti = &(*rti)->next; + } + *rti = 0; + return rts; } -RecType recType_byName (RecTypes rts, const char *name, char *subType, - void **clientDataP) +void recTypes_destroy (RecTypes rts) { - struct recTypeEntry *rte; - char *p; - char tmpname[256]; + struct recTypeInstance *rti; - strcpy (tmpname, name); - if ((p = strchr (tmpname, '.'))) + for (rti = rts->entries; rti; rti = rti->next) { - *p = '\0'; - strcpy (subType, p+1); + if (rti->init_flag) + (*(rti->recType)->destroy)(rti->clientData); } - else - *subType = '\0'; - for (rte = rts->entries; rte; rte = rte->next) - if (!strcmp (rte->recType->name, tmpname)) +} + +RecType recType_byName (RecTypes rts, Res res, const char *name, + void **clientDataP) +{ + struct recTypeInstance *rti; + + for (rti = rts->entries; rti; rti = rti->next) + { + size_t slen = strlen(rti->recType->name); + if (!strncmp (rti->recType->name, name, slen) + && (name[slen] == '\0' || name[slen] == '.')) { - if (!rte->init_flag) + if (!rti->init_flag) { - rte->init_flag = 1; - rte->clientData = - (*(rte->recType)->init)(rte->recType); + rti->init_flag = 1; + rti->clientData = + (*(rti->recType)->init)(res, rti->recType); } - *clientDataP = rte->clientData; - return rte->recType; + *clientDataP = rti->clientData; + if (name[slen]) + slen++; /* skip . */ + + if (rti->recType->config) + (*(rti->recType)->config)(rti->clientData, res, name+slen); + return rti->recType; } + } return 0; } -void recTypes_default_handlers (RecTypes rts) -{ - recTypes_add_handler (rts, recTypeGrs); - recTypes_add_handler (rts, recTypeText); -} diff --git a/recctrl/recgrs.c b/recctrl/recgrs.c index cc7e2f6..c879c25 100644 --- a/recctrl/recgrs.c +++ b/recctrl/recgrs.c @@ -1,4 +1,4 @@ -/* $Id: recgrs.c,v 1.89 2004-08-24 14:29:09 adam Exp $ +/* $Id: recgrs.c,v 1.90 2004-09-27 10:44:50 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -25,6 +25,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #ifndef WIN32 #include +#include #endif #include @@ -35,97 +36,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #define GRS_MAX_WORD 512 -struct grs_handler { - RecTypeGrs type; - void *clientData; - int initFlag; - struct grs_handler *next; -}; - -struct grs_handlers { - struct grs_handler *handlers; -}; - -static int read_grs_type (struct grs_handlers *h, - struct grs_read_info *p, const char *type, - data1_node **root) -{ - struct grs_handler *gh = h->handlers; - const char *cp = strchr (type, '.'); - - if (cp == NULL || cp == type) - { - cp = strlen(type) + type; - *p->type = 0; - } - else - strcpy (p->type, cp+1); - for (gh = h->handlers; gh; gh = gh->next) - { - if (!memcmp (type, gh->type->type, cp-type) && - gh->type->type[cp-type] == '\0') - { - if (!gh->initFlag) - { - gh->initFlag = 1; - gh->clientData = (*gh->type->init)(); - } - p->clientData = gh->clientData; - *root = (gh->type->read)(p); - gh->clientData = p->clientData; - return 0; - } - } - return 1; -} - -static void grs_add_handler (struct grs_handlers *h, RecTypeGrs t) -{ - struct grs_handler *gh = (struct grs_handler *) xmalloc (sizeof(*gh)); - gh->next = h->handlers; - h->handlers = gh; - gh->initFlag = 0; - gh->clientData = 0; - gh->type = t; -} - -static void *grs_init(RecType recType) -{ - struct grs_handlers *h = (struct grs_handlers *) xmalloc (sizeof(*h)); - h->handlers = 0; - - grs_add_handler (h, recTypeGrs_sgml); - grs_add_handler (h, recTypeGrs_regx); -#if HAVE_TCL_H - grs_add_handler (h, recTypeGrs_tcl); -#endif - grs_add_handler (h, recTypeGrs_marc); - grs_add_handler (h, recTypeGrs_marcxml); -#if HAVE_EXPAT_H - grs_add_handler (h, recTypeGrs_xml); -#endif -#if HAVE_PERL - grs_add_handler (h, recTypeGrs_perl); -#endif - grs_add_handler (h, recTypeGrs_danbib); - return h; -} - -static void grs_destroy(void *clientData) -{ - struct grs_handlers *h = (struct grs_handlers *) clientData; - struct grs_handler *gh = h->handlers, *gh_next; - while (gh) - { - gh_next = gh->next; - if (gh->initFlag) - (*gh->type->destroy)(gh->clientData); - xfree (gh); - gh = gh_next; - } - xfree (h); -} - struct source_parser { int len; const char *tok; @@ -923,8 +833,9 @@ int grs_extract_tree(struct recExtractCtrl *p, data1_node *n) return dumpkeys(n, p, 0, &wrd); } -static int grs_extract_sub(struct grs_handlers *h, struct recExtractCtrl *p, - NMEM mem) +static int grs_extract_sub(void *clientData, struct recExtractCtrl *p, + NMEM mem, + data1_node *(*grs_read)(struct grs_read_info *)) { data1_node *n; struct grs_read_info gri; @@ -940,9 +851,9 @@ static int grs_extract_sub(struct grs_handlers *h, struct recExtractCtrl *p, gri.offset = p->offset; gri.mem = mem; gri.dh = p->dh; + gri.clientData = clientData; - if (read_grs_type (h, &gri, p->subType, &n)) - return RECCTRL_EXTRACT_ERROR_NO_SUCH_FILTER; + n = (*grs_read)(&gri); if (!n) return RECCTRL_EXTRACT_EOF; oe.proto = PROTO_Z3950; @@ -976,13 +887,12 @@ static int grs_extract_sub(struct grs_handlers *h, struct recExtractCtrl *p, return RECCTRL_EXTRACT_OK; } -static int grs_extract(void *clientData, struct recExtractCtrl *p) +int zebra_grs_extract(void *clientData, struct recExtractCtrl *p, + data1_node *(*grs_read)(struct grs_read_info *)) { int ret; NMEM mem = nmem_create (); - struct grs_handlers *h = (struct grs_handlers *) clientData; - - ret = grs_extract_sub(h, p, mem); + ret = grs_extract_sub(clientData, p, mem, grs_read); nmem_destroy(mem); return ret; } @@ -1110,7 +1020,8 @@ static void zebra_xml_metadata (struct recRetrieveCtrl *p, data1_node *top, data1_mk_text (p->dh, mem, i2, n); } -static int grs_retrieve(void *clientData, struct recRetrieveCtrl *p) +int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, + data1_node *(*grs_read)(struct grs_read_info *)) { data1_node *node = 0, *onode = 0, *top; data1_node *dnew; @@ -1119,7 +1030,7 @@ static int grs_retrieve(void *clientData, struct recRetrieveCtrl *p) NMEM mem; struct grs_read_info gri; const char *tagname; - struct grs_handlers *h = (struct grs_handlers *) clientData; + int requested_schema = VAL_NONE; data1_marctab *marctab; int dummy; @@ -1133,14 +1044,10 @@ static int grs_retrieve(void *clientData, struct recRetrieveCtrl *p) gri.offset = 0; gri.mem = mem; gri.dh = p->dh; + gri.clientData = clientData; yaz_log(LOG_DEBUG, "grs_retrieve"); - if (read_grs_type (h, &gri, p->subType, &node)) - { - p->diagnostic = 14; - nmem_destroy (mem); - return 0; - } + node = (*grs_read)(&gri); if (!node) { p->diagnostic = 14; @@ -1422,13 +1329,3 @@ static int grs_retrieve(void *clientData, struct recRetrieveCtrl *p) return 0; } -static struct recType grs_type = -{ - "grs", - grs_init, - grs_destroy, - grs_extract, - grs_retrieve -}; - -RecType recTypeGrs = &grs_type; diff --git a/recctrl/recgrs.h b/recctrl/recgrs.h deleted file mode 100644 index 4fda9f1..0000000 --- a/recctrl/recgrs.h +++ /dev/null @@ -1,40 +0,0 @@ -/* $Id: recgrs.h,v 1.5 2002-08-02 19:26:56 adam Exp $ - Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 - Index Data Aps - -This file is part of the Zebra server. - -Zebra is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2, or (at your option) any later -version. - -Zebra is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -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. -*/ - - - -#ifndef RECGRS_H -#define RECGRS_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -extern RecType recTypeGrs; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/recctrl/rectext.c b/recctrl/rectext.c index fd7f38d..9d8d165 100644 --- a/recctrl/rectext.c +++ b/recctrl/rectext.c @@ -1,4 +1,4 @@ -/* $Id: rectext.c,v 1.19 2004-08-06 12:55:03 adam Exp $ +/* $Id: rectext.c,v 1.20 2004-09-27 10:44:50 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -26,19 +26,24 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #include -#include "rectext.h" +#include struct text_info { char *sep; }; -static void *text_init (RecType recType) +static void *text_init (Res res, RecType recType) { struct text_info *tinfo = (struct text_info *) xmalloc(sizeof(*tinfo)); tinfo->sep = 0; return tinfo; } +static void text_config(void *clientData, Res res, const char *args) +{ + +} + static void text_destroy (void *clientData) { struct text_info *tinfo = clientData; @@ -105,10 +110,6 @@ static int text_extract (void *clientData, struct recExtractCtrl *p) #endif xfree(tinfo->sep); tinfo->sep = 0; - if (p->subType) { - if (!strncmp(p->subType, "sep=", 4)) - tinfo->sep = xstrdup(p->subType+4); - } (*p->init)(p, &recWord); recWord.reg_type = 'w'; do @@ -230,9 +231,20 @@ static int text_retrieve (void *clientData, struct recRetrieveCtrl *p) static struct recType text_type = { "text", text_init, + text_config, text_destroy, text_extract, text_retrieve }; -RecType recTypeText = &text_type; +RecType +#ifdef IDZEBRA_STATIC_TEXT +idzebra_filter_text +#else +idzebra_filter +#endif + +[] = { + &text_type, + 0, +}; diff --git a/recctrl/rectext.h b/recctrl/rectext.h deleted file mode 100644 index 59cbffd..0000000 --- a/recctrl/rectext.h +++ /dev/null @@ -1,40 +0,0 @@ -/* $Id: rectext.h,v 1.5 2002-08-02 19:26:56 adam Exp $ - Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 - Index Data Aps - -This file is part of the Zebra server. - -Zebra is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2, or (at your option) any later -version. - -Zebra is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -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. -*/ - - - -#ifndef RECTEXT_H -#define RECTEXT_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -extern RecType recTypeText; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/recctrl/regxread.c b/recctrl/regxread.c index d809993..67f6510 100644 --- a/recctrl/regxread.c +++ b/recctrl/regxread.c @@ -1,4 +1,4 @@ -/* $Id: regxread.c,v 1.52 2004-08-15 17:22:45 adam Exp $ +/* $Id: regxread.c,v 1.53 2004-09-27 10:44:50 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -139,6 +139,7 @@ struct lexSpec { struct lexSpecs { struct lexSpec *spec; + char type[256]; }; static char *f_win_get (struct lexSpec *spec, off_t start_pos, off_t end_pos, @@ -1856,13 +1857,22 @@ void grs_destroy(void *clientData) xfree (specs); } -void *grs_init(void) +void *grs_init(Res res, RecType recType) { struct lexSpecs *specs = (struct lexSpecs *) xmalloc (sizeof(*specs)); specs->spec = 0; + strcpy(specs->type, ""); return specs; } + +void grs_config(void *clientData, Res res, const char *args) +{ + struct lexSpecs *specs = (struct lexSpecs *) clientData; + if (strlen(args) < sizeof(specs->type)) + strcpy(specs->type, args); +} + data1_node *grs_read_regx (struct grs_read_info *p) { int res; @@ -1872,11 +1882,11 @@ data1_node *grs_read_regx (struct grs_read_info *p) #if REGX_DEBUG logf (LOG_LOG, "grs_read_regx"); #endif - if (!*curLexSpec || strcmp ((*curLexSpec)->name, p->type)) + if (!*curLexSpec || strcmp ((*curLexSpec)->name, specs->type)) { if (*curLexSpec) lexSpecDestroy (curLexSpec); - *curLexSpec = lexSpecCreate (p->type, p->dh); + *curLexSpec = lexSpecCreate (specs->type, p->dh); res = readFileSpec (*curLexSpec); if (res) { @@ -1899,14 +1909,25 @@ data1_node *grs_read_regx (struct grs_read_info *p) return lexRoot (*curLexSpec, p->offset, "main"); } -static struct recTypeGrs regx_type = { - "regx", +static int extract_regx(void *clientData, struct recExtractCtrl *ctrl) +{ + return zebra_grs_extract(clientData, ctrl, grs_read_regx); +} + +static int retrieve_regx(void *clientData, struct recRetrieveCtrl *ctrl) +{ + return zebra_grs_retrieve(clientData, ctrl, grs_read_regx); +} + +static struct recType regx_type = { + "grs.regx", grs_init, + grs_config, grs_destroy, - grs_read_regx + extract_regx, + retrieve_regx, }; -RecTypeGrs recTypeGrs_regx = ®x_type; #if HAVE_TCL_H data1_node *grs_read_tcl (struct grs_read_info *p) @@ -1918,12 +1939,12 @@ data1_node *grs_read_tcl (struct grs_read_info *p) #if REGX_DEBUG logf (LOG_LOG, "grs_read_tcl"); #endif - if (!*curLexSpec || strcmp ((*curLexSpec)->name, p->type)) + if (!*curLexSpec || strcmp ((*curLexSpec)->name, specs->type)) { Tcl_Interp *tcl_interp; if (*curLexSpec) lexSpecDestroy (curLexSpec); - *curLexSpec = lexSpecCreate (p->type, p->dh); + *curLexSpec = lexSpecCreate (specs->type, p->dh); Tcl_FindExecutable(""); tcl_interp = (*curLexSpec)->tcl_interp = Tcl_CreateInterp(); Tcl_Init(tcl_interp); @@ -1954,12 +1975,38 @@ data1_node *grs_read_tcl (struct grs_read_info *p) return lexRoot (*curLexSpec, p->offset, "main"); } -static struct recTypeGrs tcl_type = { - "tcl", +static int extract_tcl(void *clientData, struct recExtractCtrl *ctrl) +{ + return zebra_grs_extract(clientData, ctrl, grs_read_tcl); +} + +static int retrieve_tcl(void *clientData, struct recRetrieveCtrl *ctrl) +{ + return zebra_grs_retrieve(clientData, ctrl, grs_read_tcl); +} + +static struct recType tcl_type = { + "grs.tcl", grs_init, + grs_config, grs_destroy, - grs_read_tcl + extract_tcl, + retrieve_tcl, }; -RecTypeGrs recTypeGrs_tcl = &tcl_type; #endif + +RecType +#ifdef IDZEBRA_STATIC_GRS_REGX +idzebra_filter_grs_regx +#else +idzebra_filter +#endif + +[] = { + ®x_type, +#if HAVE_TCL_H + &tcl_type, +#endif + 0, +}; diff --git a/recctrl/sgmlread.c b/recctrl/sgmlread.c index c22cd51..948307e 100644 --- a/recctrl/sgmlread.c +++ b/recctrl/sgmlread.c @@ -1,4 +1,4 @@ -/* $Id: sgmlread.c,v 1.11 2002-08-02 19:26:56 adam Exp $ +/* $Id: sgmlread.c,v 1.12 2004-09-27 10:44:50 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -80,7 +80,7 @@ static data1_node *grs_read_sgml (struct grs_read_info *p) return node; } -static void *grs_init_sgml(void) +static void *grs_init_sgml(Res res, RecType recType) { struct sgml_getc_info *p = (struct sgml_getc_info *) xmalloc (sizeof(*p)); p->buf_size = 512; @@ -89,6 +89,11 @@ static void *grs_init_sgml(void) return p; } +static void grs_config_sgml(void *clientData, Res res, const char *args) +{ + +} + static void grs_destroy_sgml(void *clientData) { struct sgml_getc_info *p = (struct sgml_getc_info *) clientData; @@ -98,12 +103,34 @@ static void grs_destroy_sgml(void *clientData) xfree (p); } -static struct recTypeGrs sgml_type = { - "sgml", +static int grs_extract_sgml(void *clientData, struct recExtractCtrl *ctrl) +{ + return zebra_grs_extract(clientData, ctrl, grs_read_sgml); +} + +static int grs_retrieve_sgml(void *clientData, struct recRetrieveCtrl *ctrl) +{ + return zebra_grs_retrieve(clientData, ctrl, grs_read_sgml); +} + +static struct recType grs_type_sgml = +{ + "grs.sgml", grs_init_sgml, + grs_config_sgml, grs_destroy_sgml, - grs_read_sgml + grs_extract_sgml, + grs_retrieve_sgml }; -RecTypeGrs recTypeGrs_sgml = &sgml_type; +RecType +#ifdef IDZEBRA_STATIC_GRS_SGML +idzebra_filter_grs_sgml +#else +idzebra_filter +#endif +[] = { + &grs_type_sgml, + 0, +}; diff --git a/recctrl/xmlread.c b/recctrl/xmlread.c index d140323..e680435 100644 --- a/recctrl/xmlread.c +++ b/recctrl/xmlread.c @@ -1,4 +1,4 @@ -/* $Id: xmlread.c,v 1.13 2004-08-11 13:36:13 adam Exp $ +/* $Id: xmlread.c,v 1.14 2004-09-27 10:44:50 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -480,7 +480,12 @@ struct xml_info { XML_Expat_Version expat_version; }; -static void *grs_init_xml(void) +static data1_node *grs_read_xml (struct grs_read_info *p) +{ + return zebra_read_xml (p->dh, p->readf, p->fh, p->mem); +} + +static void *init_xml(Res res, RecType recType) { struct xml_info *p = (struct xml_info *) xmalloc (sizeof(*p)); @@ -489,27 +494,43 @@ static void *grs_init_xml(void) return p; } -static data1_node *grs_read_xml (struct grs_read_info *p) +static void destroy_xml(void *clientData) { - return zebra_read_xml (p->dh, p->readf, p->fh, p->mem); + struct xml_info *p = (struct xml_info *) clientData; + + xfree (p); } -static void grs_destroy_xml(void *clientData) +static int extract_xml(void *clientData, struct recExtractCtrl *ctrl) { - struct xml_info *p = (struct xml_info *) clientData; + return zebra_grs_extract(clientData, ctrl, grs_read_xml); +} - xfree (p); +static int retrieve_xml(void *clientData, struct recRetrieveCtrl *ctrl) +{ + return zebra_grs_retrieve(clientData, ctrl, grs_read_xml); } -static struct recTypeGrs xml_type = { - "xml", - grs_init_xml, - grs_destroy_xml, - grs_read_xml +static struct recType xml_type = { + "grs.xml", + init_xml, + 0, + destroy_xml, + extract_xml, + retrieve_xml, }; -RecTypeGrs recTypeGrs_xml = &xml_type; +RecType +#ifdef IDZEBRA_STATIC_GRS_XML +idzebra_filter_grs_xml +#else +idzebra_filter +#endif -/* HAVE_EXPAT_H */ +[] = { + &xml_type, + 0, +}; + #endif diff --git a/test/cddb/zebra.cfg b/test/cddb/zebra.cfg index 0cf9a05..521c14e 100644 --- a/test/cddb/zebra.cfg +++ b/test/cddb/zebra.cfg @@ -1,5 +1,5 @@ # Simple Zebra configuration file -# $Id: zebra.cfg,v 1.2 2001-02-27 10:10:40 adam Exp $ +# $Id: zebra.cfg,v 1.3 2004-09-27 10:44:50 adam Exp $ # # Where the schema files, attribute files, etc are located. profilePath: .:../../tab:../../../yaz/tab @@ -14,3 +14,5 @@ recordtype: grs.tcl.cddb storekeys: 1 storedata: 1 #recordId: (bib1,identifier-standard) + +modulePath: ../../recctrl/.libs diff --git a/test/charmap/test1.sh b/test/charmap/test1.sh index 966ff5e..696cfa1 100755 --- a/test/charmap/test1.sh +++ b/test/charmap/test1.sh @@ -1,11 +1,11 @@ #!/bin/sh -# $Id: test1.sh,v 1.3 2004-06-15 09:43:27 adam Exp $ +# $Id: test1.sh,v 1.4 2004-09-27 10:44:50 adam Exp $ pp=${srcdir:-"."} LOG=test1.log rm -f $LOG -if ../../index/zebraidx -c $pp/zebra.cfg -l $LOG -V|grep Expat >/dev/null; then +if ../../index/zebraidx -c $pp/zebra.cfg -l $LOG filters|grep grs.xml >/dev/null; then ../../index/zebraidx -c $pp/zebra.cfg -l$LOG init else exit 0 diff --git a/test/charmap/test2.sh b/test/charmap/test2.sh index cf84466..87217dd 100755 --- a/test/charmap/test2.sh +++ b/test/charmap/test2.sh @@ -5,7 +5,7 @@ pp=${srcdir:-"."} LOG=test2.log rm -f $LOG -if ../../index/zebraidx -c $pp/zebra.cfg -l $LOG -V|grep Expat >/dev/null; then +if ../../index/zebraidx -c $pp/zebra.cfg -l $LOG filters|grep grs.xml >/dev/null; then ../../index/zebraidx -c $pp/zebra.cfg -l$LOG init else exit 0 diff --git a/test/charmap/zebra.cfg b/test/charmap/zebra.cfg index 8ea6070..7800c3e 100644 --- a/test/charmap/zebra.cfg +++ b/test/charmap/zebra.cfg @@ -1,5 +1,5 @@ # Simple Zebra configuration file -# $Id: zebra.cfg,v 1.2 2004-06-15 09:43:30 adam Exp $ +# $Id: zebra.cfg,v 1.3 2004-09-27 10:44:50 adam Exp $ # # Where the schema files, attribute files, etc are located. profilePath: ${srcdir:-.}:${srcdir:-.}/../../tab @@ -13,3 +13,5 @@ attset: explain.att recordtype: grs.xml isam: b + +modulePath: ../../recctrl/.libs diff --git a/test/config/test2.sh b/test/config/test2.sh index ad2f79d..23d8828 100755 --- a/test/config/test2.sh +++ b/test/config/test2.sh @@ -1,11 +1,11 @@ #!/bin/sh -# $Id: test2.sh,v 1.4 2004-06-15 09:43:30 adam Exp $ +# $Id: test2.sh,v 1.5 2004-09-27 10:44:50 adam Exp $ pp=${srcdir:-"."} LOG=test2.log -if ../../index/zebraidx -c $pp/zebra.cfg -l $LOG -V|grep Tcl >/dev/null; then +if ../../index/zebraidx -c $pp/zebra.cfg -l $LOG filters|grep grs.tcl >/dev/null; then ../../index/zebraidx -c $pp/zebra.cfg -l $LOG init ../../index/zebraidx -c $pp/zebra.cfg -l $LOG -s -t grs.tcl.m update $pp/m.rec | grep tag:dc:subject >/dev/null else diff --git a/test/config/zebra.cfg b/test/config/zebra.cfg index 3c5891c..3554db2 100644 --- a/test/config/zebra.cfg +++ b/test/config/zebra.cfg @@ -1,5 +1,5 @@ # Simple Zebra configuration file -# $Id: zebra.cfg,v 1.2 2004-06-15 08:06:34 adam Exp $ +# $Id: zebra.cfg,v 1.3 2004-09-27 10:44:50 adam Exp $ # # Where the schema files, attribute files, etc are located. profilePath: ${srcdir:-.}:${srcdir:-.}/../../tab @@ -15,3 +15,5 @@ recordtype: grs.sgml #storedata: 1 #recordId: (bib1,identifier-standard) isam: b + +modulePath: ../../recctrl/.libs diff --git a/test/malxml/test1.sh b/test/malxml/test1.sh index c5a5607..76158ce 100755 --- a/test/malxml/test1.sh +++ b/test/malxml/test1.sh @@ -1,12 +1,12 @@ #!/bin/sh -# $Id: test1.sh,v 1.5 2004-06-15 09:43:32 adam Exp $ +# $Id: test1.sh,v 1.6 2004-09-27 10:44:51 adam Exp $ pp=${srcdir:-"."} LOG=test1.log rm -f $LOG -if ../../index/zebraidx -l $LOG -V|grep Expat >/dev/null; then +if ../../index/zebraidx -c $pp/zebra.cfg -l $LOG filters|grep grs.xml >/dev/null; then ../../index/zebraidx -c $pp/zebra.cfg -l$LOG init else exit 0 diff --git a/test/malxml/zebra.cfg b/test/malxml/zebra.cfg index 809a9f1..8e66781 100644 --- a/test/malxml/zebra.cfg +++ b/test/malxml/zebra.cfg @@ -1,5 +1,5 @@ # Simple Zebra configuration file -# $Id: zebra.cfg,v 1.2 2004-06-15 08:06:34 adam Exp $ +# $Id: zebra.cfg,v 1.3 2004-09-27 10:44:51 adam Exp $ # # Where the schema files, attribute files, etc are located. profilePath: ${srcdir:-.}/../../tab @@ -15,3 +15,5 @@ recordtype: grs.xml #storedata: 1 #recordId: (bib1,identifier-standard) isam: b + +modulePath: ../../recctrl/.libs diff --git a/test/marcxml/test1.sh b/test/marcxml/test1.sh index 7921101..1490d8e 100755 --- a/test/marcxml/test1.sh +++ b/test/marcxml/test1.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $Id: test1.sh,v 1.5 2004-08-24 14:29:09 adam Exp $ +# $Id: test1.sh,v 1.6 2004-09-27 10:44:51 adam Exp $ pp=${srcdir:-"."} @@ -7,7 +7,7 @@ LOG=test1.log DBG="-v 1647" rm -f $LOG -if ../../index/zebraidx -c $pp/zebra.cfg -l $LOG -V|grep Expat >/dev/null; then +if ../../index/zebraidx -c $pp/zebra.cfg -l $LOG filters|grep grs.xml >/dev/null; then ../../index/zebraidx -c $pp/zebra.cfg -l $LOG $DBG init else exit 0 diff --git a/test/marcxml/test2.sh b/test/marcxml/test2.sh index 26e899d..6ef8acd 100755 --- a/test/marcxml/test2.sh +++ b/test/marcxml/test2.sh @@ -1,11 +1,17 @@ #!/bin/sh -# $Id: test2.sh,v 1.3 2004-06-15 09:43:33 adam Exp $ +# $Id: test2.sh,v 1.4 2004-09-27 10:44:51 adam Exp $ pp=${srcdir:-"."} LOG=test2.log rm -f $LOG -../../index/zebraidx -c $pp/zebra.cfg -l$LOG init + +if ../../index/zebraidx -c $pp/zebra.cfg -l $LOG filters|grep grs.marcxml >/dev/null ; then + ../../index/zebraidx -c $pp/zebra.cfg -l $LOG $DBG init +else + exit 0 +fi + ../../index/zebraidx -c $pp/zebra.cfg -l$LOG -t grs.marcxml.record update $pp/sample-marc ../../index/zebrasrv -c $pp/zebra.cfg -l$LOG unix:socket & sleep 1 diff --git a/test/marcxml/zebra.cfg b/test/marcxml/zebra.cfg index 9503768..3fc1245 100644 --- a/test/marcxml/zebra.cfg +++ b/test/marcxml/zebra.cfg @@ -1,5 +1,5 @@ # Simple Zebra configuration file -# $Id: zebra.cfg,v 1.2 2004-06-15 09:43:33 adam Exp $ +# $Id: zebra.cfg,v 1.3 2004-09-27 10:44:51 adam Exp $ # # Where the schema files, attribute files, etc are located. profilePath: ${srcdir:-.}:${srcdir:-.}/../../tab @@ -15,3 +15,5 @@ recordtype: grs.xml #storedata: 1 #recordId: (bib1,identifier-standard) isam: b + +modulePath: ../../recctrl/.libs diff --git a/test/rusmarc/test1.sh b/test/rusmarc/test1.sh index aab681c..44f18ff 100755 --- a/test/rusmarc/test1.sh +++ b/test/rusmarc/test1.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $Id: test1.sh,v 1.5 2004-06-16 21:48:57 adam Exp $ +# $Id: test1.sh,v 1.6 2004-09-27 10:44:52 adam Exp $ pp=${srcdir:-"."} @@ -8,7 +8,13 @@ rm -f $LOG test -d tmp || mkdir tmp test -d lock || mkdir lock test -d register || mkdir register -../../index/zebraidx -c $pp/zebra.cfg -l$LOG init + +if ../../index/zebraidx -c $pp/zebra.cfg -l $LOG filters|grep grs.marc >/dev/null; then + ../../index/zebraidx -c $pp/zebra.cfg -l$LOG init +else + exit 0 +fi + if grep 'UTF-8 to koi8-r unsupported' $LOG >/dev/null; then exit 0 fi diff --git a/test/rusmarc/zebra.cfg b/test/rusmarc/zebra.cfg index 9ecef3a..c5ea4c9 100644 --- a/test/rusmarc/zebra.cfg +++ b/test/rusmarc/zebra.cfg @@ -1,6 +1,6 @@ # Simple Zebra configuration file that defines # Database with RUSMARC records. -# $Id: zebra.cfg,v 1.3 2004-06-15 09:43:33 adam Exp $ +# $Id: zebra.cfg,v 1.4 2004-09-27 10:44:52 adam Exp $ # # Where are the config files located? profilePath: ${srcdir:-.}/tab:${srcdir:-.}/../../tab @@ -28,4 +28,7 @@ memMax: 4 register: register:100M # Default encoding -encoding: koi8-r \ No newline at end of file +encoding: koi8-r + +# Set up modulePath +modulePath: ../../recctrl/.libs diff --git a/test/usmarc/zebra.cfg b/test/usmarc/zebra.cfg index b6f4255..a09b925 100644 --- a/test/usmarc/zebra.cfg +++ b/test/usmarc/zebra.cfg @@ -1,6 +1,6 @@ # Simple Zebra configuration file that defines # a database with USMARC records. -# $Id: zebra.cfg,v 1.5 2004-06-15 08:06:35 adam Exp $ +# $Id: zebra.cfg,v 1.6 2004-09-27 10:44:52 adam Exp $ # # Where are the config files located? profilePath: ${srcdir:-.}/../../tab @@ -23,3 +23,5 @@ keyTmpDir: tmp # Approx. Memory usage during indexing memMax: 4 + +modulePath: ../../recctrl/.libs -- 1.7.10.4