-/* $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
#include <dfa.h>
#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)
{
can hide this whole compexity behind.
*/
+
+#if 0
void Filter_store_buff (struct perl_context *context, char *buff, size_t len)
{
dSP;
{
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));
}
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;
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;
/* 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];
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