From: Adam Dickmeiss Date: Tue, 28 Sep 2004 12:52:03 +0000 (+0000) Subject: Move Perl away. It is now a separate CVS project: idzebra-perl X-Git-Tag: snippet.version.1~324 X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=commitdiff_plain;h=5e9aca2e8f33fe023b6b9da6df55642f96efcb50 Move Perl away. It is now a separate CVS project: idzebra-perl --- diff --git a/Makefile.am b/Makefile.am index c4dcaef..c61a483 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -## $Id: Makefile.am,v 1.17 2004-09-15 09:17:25 adam Exp $ +## $Id: Makefile.am,v 1.18 2004-09-28 12:52:03 adam Exp $ AUTOMAKE_OPTIONS=foreign @@ -27,12 +27,6 @@ dist-hook: cp $(srcdir)/debian/rules $(distdir)/debian cp $(srcdir)/debian/postinst $(distdir)/debian cp $(srcdir)/debian/copyright $(distdir)/debian - mkdir -p $(distdir)/perl - cd $(srcdir)/perl && ./doswig - for f in `cat $(srcdir)/perl/MANIFEST`; do \ - (pdir=`cd $(distdir)/perl && pwd`; \ - cd $(srcdir)/perl;cp --parents $$f $$pdir); \ - done rpm: $(PACKAGE)-$(VERSION).tar.gz cp $(PACKAGE)-$(VERSION).tar.gz /usr/src/redhat/SOURCES diff --git a/configure.in b/configure.in index 0c738ce..9ce87b3 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Zebra, Index Data Aps, 1995-2004 -dnl $Id: configure.in,v 1.102 2004-09-28 08:44:48 adam Exp $ +dnl $Id: configure.in,v 1.103 2004-09-28 12:52:03 adam Exp $ dnl AC_INIT(include/idzebra/version.h) AM_INIT_AUTOMAKE(idzebra,1.4.0) @@ -7,13 +7,6 @@ dnl ------ Substitutions AC_SUBST(TCL_INCLUDE) AC_SUBST(TCL_LIB) AC_SUBST(READLINE_LIBS) -dnl ------ Perl substitutions -AC_SUBST(PERL_BINARY) -AC_SUBST(PERL_XS_INIT) -AC_SUBST(PERL_XS_INIT_INCLUDE) -AC_SUBST(PERL_LIBS) -AC_SUBST(PERL_CFLAGS) -AC_SUBST(ZPERL_LIBS) dnl dnl ------ Checking programs AC_PROG_CC @@ -180,9 +173,6 @@ if test "$expat" != "no"; then CFLAGS="$xCFLAGS" fi dnl -dnl ------ PERL -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 @@ -269,85 +259,6 @@ else def="no" fi ZEBRA_MODULE(grs-xml,[$def], [ --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="" -if test "$myen" != "no"; then - AC_MSG_CHECKING(for perl binary) - if test "$perl" = "yes"; then - perlbin=`which perl` - else - perlbin="$perl" - fi - if test -x "$perlbin"; then - AC_MSG_RESULT($perlbin) - AC_MSG_CHECKING(perl core directory) - archdir=`$perlbin -MConfig -e 'print $Config{archlib}'`; - perlcore="$archdir/CORE"; - if test -d "$perlcore"; then - PERL_BINARY="$perlbin" - AC_MSG_RESULT($perlcore) - else - AC_MSG_RESULT(Failed) - fi - - AC_MSG_CHECKING("for ExtUtils::Embed to determine ccopts") - PERL_CFLAGS=`$perlbin -MExtUtils::Embed -e ccopts 2>/dev/null` - if test "$PERL_CFLAGS"; then - AC_MSG_RESULT(OK) - else - PERL_CFLAGS="-I$perlcore" - AC_MSG_RESULT(Using defaults) - fi - - AC_MSG_CHECKING("for ExtUtils::Embed to determine ldflags") - PERL_LIBS=`$perlbin -MExtUtils::Embed -e ldopts 2>/dev/null` - if test "$PERL_LIBS"; then - AC_MSG_RESULT(OK) - else - PERL_LIBS="-L$perlcore -lperl -lm" - AC_MSG_RESULT(Using defaults) - fi - - AC_MSG_CHECKING("for ExtUtils::Embed to create xs_init") - xsf="recctrl/xsinit.h" - `rm $xsf 2>/dev/null`; - - `$perlbin -MExtUtils::Embed -e xsinit -- -o $xsf 2>/dev/null` - if test -r "$xsf"; then - AC_MSG_RESULT(OK) - PERL_XS_INIT="xs_init" - PERL_XS_INIT_INCLUDE='#include "xsinit.h"' - else - AC_MSG_RESULT(XS libraries are not going to be available) - fi - - xLIBS="$LIBS" - xCFLAGS="$CFLAGS" - CFLAGS="$PERL_CFLAGS $CFLAGS" - LIBS="$PERL_LIBS $LIBS" - - AC_MSG_CHECKING(for perl library) - AC_TRY_LINK([ - #include - ],[ - ; - ],AM_CONDITIONAL(perl,true) - AC_DEFINE(HAVE_PERL,1) - AC_MSG_RESULT(found) - ZPERL_LIBS="$xLIBS" - , - AC_MSG_RESULT(not found) - AC_DEFINE(HAVE_PERL,0)) - LIBS="$xLIBS" - CFLAGS="$xCFLAGS" - else - AC_DEFINE(HAVE_PERL,0) - AC_MSG_RESULT(Not found) - fi -fi - dnl ------ ANSI C Header files AC_STDC_HEADERS if test "$ac_cv_header_stdc" = "no"; then @@ -370,7 +281,6 @@ AC_OUTPUT([ rset/Makefile data1/Makefile recctrl/Makefile - recctrl/perlread.h index/Makefile include/Makefile include/idzebra/Makefile tab/Makefile @@ -383,16 +293,13 @@ AC_OUTPUT([ test/Makefile test/gils/Makefile test/usmarc/Makefile test/api/Makefile test/rusmarc/Makefile test/cddb/Makefile test/malxml/Makefile test/config/Makefile test/sort2/Makefile - perl/Makefile.PL test/xelm/Makefile + test/xelm/Makefile test/dmoz/Makefile test/xpath/Makefile test/sort/Makefile test/zsh/Makefile test/marcxml/Makefile test/charmap/Makefile test/codec/Makefile examples/Makefile examples/gils/Makefile examples/zthes/Makefile idzebra.spec idzebra-config ],[sed s%idzebra_echo_source=yes%idzebra_echo_source=no%g < idzebra-config > util/idzebra-config && chmod +x idzebra-config util/idzebra-config]) -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-yaz=DIR to specify location." test -f /etc/debian_version && echo "Debian package libyaz-dev is required." diff --git a/recctrl/Makefile.am b/recctrl/Makefile.am index 1a5e9fd..7ed19b9 100644 --- a/recctrl/Makefile.am +++ b/recctrl/Makefile.am @@ -1,4 +1,4 @@ -## $Id: Makefile.am,v 1.13 2004-09-28 10:15:03 adam Exp $ +## $Id: Makefile.am,v 1.14 2004-09-28 12:52:03 adam Exp $ common_libs = libidzebra-recctrl.la \ ../data1/libidzebra-data1.la \ @@ -7,11 +7,6 @@ common_libs = libidzebra-recctrl.la \ $(YAZLALIB) # 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) @@ -34,7 +29,6 @@ mod_grs_danbib_la_LIBADD = $(common_libs) $(mod_grs_danbib_la_LADD) pkglib_LTLIBRARIES = $(SHARED_MODULE_LA) EXTRA_LTLIBRARIES = \ - mod-grs-perl.la \ mod-grs-regx.la \ mod-grs-xml.la \ mod-grs-marc.la \ @@ -52,11 +46,9 @@ libidzebra_recctrl_la_LIBADD = $(STATIC_MODULE_OBJ) \ 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 +AM_CPPFLAGS = -I$(srcdir)/../include $(YAZINC) $(TCL_INCLUDE) -DDEFAULT_MODULE_PATH=\"$(pkglibdir)\" diff --git a/recctrl/perlread.c b/recctrl/perlread.c deleted file mode 100644 index ea8ac1e..0000000 --- a/recctrl/perlread.c +++ /dev/null @@ -1,379 +0,0 @@ -/* $Id: perlread.c,v 1.11 2004-09-28 10:15:03 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. - -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. -*/ - -#if HAVE_PERL -#include "perlread.h" -#include "EXTERN.h" -#include "perl.h" -#include "XSUB.h" - -#include -#include -#include - -#include -#include - -/* Constructor call for the filter object */ -void Filter_create (struct perl_context *context) -{ - dSP; - SV *msv; - - PUSHMARK(SP) ; - XPUSHs(sv_2mortal(newSVpv(context->filterClass, - strlen(context->filterClass)))) ; - msv = sv_newmortal(); - sv_setref_pv(msv, "_p_perl_context", (void*)context); - XPUSHs(msv) ; - PUTBACK ; - call_method("new", G_EVAL); - - SPAGAIN ; - context->filterRef = POPs; - PUTBACK ; -} - -/* - Execute the process call on the filter. This is a bit dirty. - The perl code is going to get dh and nmem from the context trough callbacks, - then call readf, to get the stream, and then set the res (d1 node) - in the context. However, it's safer, to let swig do as much of wrapping - as possible. - */ -int Filter_process (struct perl_context *context) - -{ - - int res; - - dSP; - - ENTER; - SAVETMPS; - - PUSHMARK(SP) ; - XPUSHs(context->filterRef); - PUTBACK ; - call_method("_process", 0); - SPAGAIN ; - res = POPi; - PUTBACK ; - - FREETMPS; - LEAVE; - - return (res); -} - -/* - This one is called to transfer the results of a readf. It's going to create - a temporary variable there... - - So the call stack is something like: - - - ->Filter_process(context) [C] - -> _process($context) [Perl] - -> grs_perl_get_dh($context) [Perl] - -> grs_perl_get_dh(context) [C] - -> grs_perl_get_mem($context) [Perl] - -> grs_perl_get_mem(context) [C] - -> process() [Perl] - ... - -> grs_perl_readf($context,$len) [Perl] - -> grs_perl_readf(context, len) [C] - ->(*context->readf)(context->fh, buf, len) [C] - -> Filter_store_buff(context, buf, r) [C] - -> _store_buff($buff) [Perl] - [... returns buff and length ...] - ... - [... returns d1 node ...] - -> grs_perl_set_res($context, $node) [Perl] - -> grs_perl_set_res(context, node) [C] - - [... The result is in context->res ...] - - Dirty, isn't it? It may become nicer, if I'll have some more time to work on - it. However, these changes are not going to hurt the filter api, as - Filter.pm, which is inherited into all specific filter implementations - can hide this whole compexity behind. - -*/ - -#if 0 -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 - -/* The filter handlers (init, destroy, read) */ -static void *init_perl(Res res, RecType rt) -{ - struct perl_context *context = - (struct perl_context *) xmalloc (sizeof(*context)); - - /* If there is an interpreter (context) running, - we are calling - indexing and retrieval from the perl API - we don't create a new one. */ - context->origi = PL_curinterp; - - if (!context->origi) { - context->perli = perl_alloc(); - PERL_SET_CONTEXT(context->perli); - logf (LOG_LOG, "Initializing new perl interpreter context (%p)",context->perli); - } else { - logf (LOG_LOG, "Using existing perl interpreter context (%p)",context->origi); - } - context->perli_ready = 0; - strcpy(context->filterClass, ""); - 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); -} - -static void destroy_perl(void *clientData) -{ - struct perl_context *context = (struct perl_context *) clientData; - - logf (LOG_LOG, "Destroying perl interpreter context"); - if (context->perli_ready) { - /* - FREETMPS; - LEAVE; - */ - if (context->origi == NULL) perl_destruct(context->perli); - } - if (context->origi == NULL) perl_free(context->perli); - xfree (context); -} - -static data1_node *grs_read_perl (struct grs_read_info *p) -{ - struct perl_context *context = (struct perl_context *) p->clientData; - char *filterClass = context->type; - - /* The "file" manipulation function wrappers */ - context->readf = p->readf; - context->seekf = p->seekf; - context->tellf = p->tellf; - context->endf = p->endf; - - /* The "file", data1 and NMEM handles */ - context->fh = p->fh; - context->dh = p->dh; - context->mem = p->mem; - - /* If the class was not interpreted before... */ - /* This is not too efficient, when indexing with many different filters... */ - if (strcmp(context->filterClass, filterClass)) { - - char modarg[GRS_PERL_MODULE_NAME_MAXLEN + 2]; - char initarg[GRS_PERL_MODULE_NAME_MAXLEN + 2]; - char *arglist[6] = { "", "-I", "", "-M", "-e", "" }; - - if (context->perli_ready) { - /* - FREETMPS; - LEAVE; - */ - if (context->origi == NULL) { - perl_destruct(context->perli); - } - } - if (context->origi == NULL) { - perl_construct(context->perli); - } - - - /* - ENTER; - SAVETMPS; - */ - context->perli_ready = 1; - - /* parse, and run the init call */ - if (context->origi == NULL) { - logf (LOG_LOG, "Interpreting filter class:%s", filterClass); - - arglist[2] = (char *) data1_get_tabpath(p->dh); - sprintf(modarg,"-M%s",filterClass); - arglist[3] = (char *) &modarg; - sprintf(initarg,"%s->init;",filterClass); - arglist[5] = (char *) &initarg; - - perl_parse(context->perli, PERL_XS_INIT, 6, arglist, NULL); - perl_run(context->perli); - } - - strcpy(context->filterClass, filterClass); - - /* create the filter object as a filterClass blessed reference */ - Filter_create(context); - } - - /* Wow... if calling with individual update_record calls from perl, - the filter object reference may go out of scope... */ - if (!sv_isa(context->filterRef, context->filterClass)) { - Filter_create(context); - logf (LOG_DEBUG,"Filter recreated"); - } - - if (!SvTRUE(context->filterRef)) - { - logf (LOG_WARN,"Failed to initialize perl filter %s",context->filterClass); - return (0); - } - - /* call the process method */ - Filter_process(context); - - /* return the created data1 node */ - return context->res; -} - -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, -}; - -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 deleted file mode 100644 index d9e5888..0000000 --- a/recctrl/perlread.h.in +++ /dev/null @@ -1,32 +0,0 @@ -/* Perl configuration */ -#include -#include - -#define PERL_BINARY @PERL_BINARY@ -#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 0a9fc80..9240951 100644 --- a/recctrl/recctrl.c +++ b/recctrl/recctrl.c @@ -1,4 +1,4 @@ -/* $Id: recctrl.c,v 1.9 2004-09-28 10:15:03 adam Exp $ +/* $Id: recctrl.c,v 1.10 2004-09-28 12:52:03 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -77,10 +77,6 @@ RecTypeClass recTypeClass_create (Res res, NMEM nmem) 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);