X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=recctrl%2Fperlread.c;h=ea8ac1ee3e09e200bb925fb61e9f82d35a2ebcf3;hb=36f8c4a15cad06268b2d5621aed28ab16c015cc5;hp=bdfb35ba7bb4604eddbc4904387d87eb1042710a;hpb=150e8c2e5ddf9ff8b9991902236826d128bcfb94;p=idzebra-moved-to-github.git diff --git a/recctrl/perlread.c b/recctrl/perlread.c index bdfb35b..ea8ac1e 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.11 2004-09-28 10:15:03 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004 Index Data Aps @@ -31,31 +31,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #include -#include -#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; -}; +#include /* Constructor call for the filter object */ void Filter_create (struct perl_context *context) @@ -143,6 +119,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 +211,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 +232,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 +262,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 +277,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 +340,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