Added tempalte filter for the ALVIS project.
authorAdam Dickmeiss <adam@indexdata.dk>
Thu, 31 Mar 2005 12:42:06 +0000 (12:42 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Thu, 31 Mar 2005 12:42:06 +0000 (12:42 +0000)
Added new version member for struct recType.

12 files changed:
configure.in
include/idzebra/recctrl.h
recctrl/Makefile.am
recctrl/alvis.c [new file with mode: 0644]
recctrl/danbibr.c
recctrl/marcread.c
recctrl/recctrl.c
recctrl/rectext.c
recctrl/regxread.c
recctrl/safari.c
recctrl/sgmlread.c
recctrl/xmlread.c

index 75e27f9..5de0a75 100644 (file)
@@ -1,5 +1,5 @@
 dnl Zebra, Index Data ApS, 1995-2005
-dnl $Id: configure.in,v 1.115 2005-01-17 18:58:10 adam Exp $
+dnl $Id: configure.in,v 1.116 2005-03-31 12:42:06 adam Exp $
 dnl
 AC_INIT(include/idzebra/version.h)
 AM_INIT_AUTOMAKE(idzebra,1.4.0)
@@ -11,7 +11,7 @@ dnl
 dnl ------ Checking programs
 AC_PROG_CC
 AC_PROG_CPP
-AM_DISABLE_SHARED
+dnl AM_DISABLE_SHARED
 AM_PROG_LIBTOOL
 dnl
 dnl ------ headers
@@ -263,6 +263,7 @@ else
    def="no"
 fi
 ZEBRA_MODULE(grs-xml,[$def], [  --enable-mod-grs-xml    XML filter (Expat based)])
+ZEBRA_MODULE(alvis,shared,   [  --enable-mod-alvis      ALVIS XML filter])
 dnl ------ ANSI C Header files
 AC_STDC_HEADERS
 if test "$ac_cv_header_stdc" = "no"; then
index 0a1d567..abc8357 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: recctrl.h,v 1.8 2005-03-05 09:19:14 adam Exp $
+/* $Id: recctrl.h,v 1.9 2005-03-31 12:42:06 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -98,6 +98,7 @@ typedef struct recType *RecType;
 
 struct recType
 {
+    int version;
     char *name;                           /* Name of record type */
     void *(*init)(Res res, RecType recType);  /* Init function - called once */
     void (*config)(void *clientData, Res res, const char *args); /* Config */
index 4945e56..4647cf9 100644 (file)
@@ -1,4 +1,4 @@
-## $Id: Makefile.am,v 1.15 2004-11-29 21:55:28 adam Exp $
+## $Id: Makefile.am,v 1.16 2005-03-31 12:42:06 adam Exp $
 
 common_libs = libidzebra-recctrl.la \
  ../data1/libidzebra-data1.la \
@@ -32,13 +32,19 @@ mod_safari_la_LDFLAGS = -rpath $(pkglibdir) -module -avoid-version
 mod_safari_la_LADD =
 mod_safari_la_LIBADD = $(common_libs) $(mod_safari_la_LADD)
 
+mod_alvis_la_SOURCES = alvis.c
+mod_alvis_la_LDFLAGS = -rpath $(pkglibdir) -module -avoid-version
+mod_alvis_la_LADD =
+mod_alvis_la_LIBADD = $(common_libs) $(mod_alvis_la_LADD)
+
 pkglib_LTLIBRARIES = $(SHARED_MODULE_LA) 
 EXTRA_LTLIBRARIES = \
        mod-grs-regx.la \
        mod-grs-xml.la \
        mod-grs-marc.la  \
        mod-grs-danbib.la \
-       mod-safari.la
+       mod-safari.la \
+       mod-alvis.la
 
 # The common library
 lib_LTLIBRARIES = libidzebra-recctrl.la
diff --git a/recctrl/alvis.c b/recctrl/alvis.c
new file mode 100644 (file)
index 0000000..f86fd25
--- /dev/null
@@ -0,0 +1,268 @@
+/* $Id: alvis.c,v 1.1 2005-03-31 12:42:06 adam Exp $
+   Copyright (C) 1995-2005
+   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.
+*/
+
+
+#include <stdio.h>
+#include <assert.h>
+#include <ctype.h>
+
+#include <idzebra/util.h>
+#include <idzebra/recctrl.h>
+
+struct filter_info {
+    char *sep;
+};
+
+static void *filter_init (Res res, RecType recType)
+{
+    struct filter_info *tinfo = (struct filter_info *) xmalloc(sizeof(*tinfo));
+    tinfo->sep = 0;
+    return tinfo;
+}
+
+static void filter_config(void *clientData, Res res, const char *args)
+{
+
+}
+
+static void filter_destroy(void *clientData)
+{
+    struct filter_info *tinfo = clientData;
+    xfree (tinfo->sep);
+    xfree (tinfo);
+}
+
+struct fi_info {
+    struct recExtractCtrl *p;
+    char *buf;
+    int offset;
+    int max;
+};
+
+static struct fi_info *fi_open(struct recExtractCtrl *p)
+{
+    struct fi_info *fi = (struct fi_info *) xmalloc (sizeof(*fi));
+
+    fi->p = p;
+    fi->buf = (char *) xmalloc (4096);
+    fi->offset = 1;
+    fi->max = 1;
+    return fi;
+}
+
+static int fi_getchar(struct fi_info *fi, char *dst)
+{
+    if (fi->offset >= fi->max)
+    {
+        if (fi->max <= 0)
+            return 0;
+        fi->max = (*fi->p->readf)(fi->p->fh, fi->buf, 4096);
+        fi->offset = 0;
+        if (fi->max <= 0)
+            return 0;
+    }
+    *dst = fi->buf[(fi->offset)++];
+    return 1;
+}
+
+static int fi_gets(struct fi_info *fi, char *dst, int max)
+{
+    int l;
+    for (l = 0; l < max; l++)
+    {
+       if (!fi_getchar(fi, dst+l))
+           return 0;
+       if (dst[l] == '\n')
+           break;
+    }
+    dst[l] = '\0';
+    return 1;
+}
+
+static void fi_close (struct fi_info *fi)
+{
+    xfree (fi->buf);
+    xfree (fi);
+}
+
+static int filter_extract(void *clientData, struct recExtractCtrl *p)
+{
+    struct filter_info *tinfo = clientData;
+    char line[512];
+    RecWord recWord;
+    struct fi_info *fi = fi_open(p);
+
+#if 0
+    yaz_log(YLOG_LOG, "filter_extract off=%ld",
+           (long) (*fi->p->tellf)(fi->p->fh));
+#endif
+    xfree(tinfo->sep);
+    tinfo->sep = 0;
+    (*p->init)(p, &recWord);
+
+    if (!fi_gets(fi, line, sizeof(line)-1))
+       return RECCTRL_EXTRACT_ERROR_GENERIC;
+    sscanf(line, "%255s", p->match_criteria);
+    
+    recWord.reg_type = 'w';
+    while (fi_gets(fi, line, sizeof(line)-1))
+    {
+       int nor = 0;
+       char field[40];
+       char *cp;
+#if 0
+       yaz_log(YLOG_LOG, "safari line: %s", line);
+#endif
+       if (sscanf(line, ZINT_FORMAT " " ZINT_FORMAT " " ZINT_FORMAT " %39s %n",
+                  &recWord.record_id, &recWord.section_id, &recWord.seqno,
+                  field, &nor) < 4)
+       {
+           yaz_log(YLOG_WARN, "Bad safari record line: %s", line);
+           return RECCTRL_EXTRACT_ERROR_GENERIC;
+       }
+       for (cp = line + nor; *cp == ' '; cp++)
+           ;
+       recWord.attrStr = field;
+       recWord.term_buf = cp;
+       recWord.term_len = strlen(cp);
+       (*p->tokenAdd)(&recWord);
+    }
+    fi_close(fi);
+    return RECCTRL_EXTRACT_OK;
+}
+
+static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p)
+{
+    int r, filter_ptr = 0;
+    static char *filter_buf = NULL;
+    static int filter_size = 0;
+    int make_header = 1;
+    int make_body = 1;
+    const char *elementSetName = NULL;
+    int no_lines = 0;
+
+    if (p->comp && p->comp->which == Z_RecordComp_simple &&
+        p->comp->u.simple->which == Z_ElementSetNames_generic)
+        elementSetName = p->comp->u.simple->u.generic;
+
+    if (elementSetName)
+    {
+       /* don't make header for the R(aw) element set name */
+       if (!strcmp(elementSetName, "R"))
+       {
+           make_header = 0;
+           make_body = 1;
+       }
+       /* only make header for the H(eader) element set name */
+       else if (!strcmp(elementSetName, "H"))
+       {
+           make_header = 1;
+           make_body = 0;
+       }
+    }
+    while (1)
+    {
+        if (filter_ptr + 4096 >= filter_size)
+        {
+            char *nb;
+
+            filter_size = 2*filter_size + 8192;
+            nb = (char *) xmalloc (filter_size);
+            if (filter_buf)
+            {
+                memcpy (nb, filter_buf, filter_ptr);
+                xfree (filter_buf);
+            }
+            filter_buf = nb;
+        }
+        if (make_header && filter_ptr == 0)
+        {
+            if (p->score >= 0)
+            {
+                sprintf (filter_buf, "Rank: %d\n", p->score);
+                filter_ptr = strlen(filter_buf);
+            }
+            sprintf (filter_buf + filter_ptr, "Local Number: " ZINT_FORMAT "\n",
+                    p->localno);
+            filter_ptr = strlen(filter_buf);
+           if (p->fname)
+           {
+               sprintf (filter_buf + filter_ptr, "Filename: %s\n", p->fname);
+               filter_ptr = strlen(filter_buf);
+           }
+           strcpy(filter_buf+filter_ptr++, "\n");
+        }
+       if (!make_body)
+           break;
+        r = (*p->readf)(p->fh, filter_buf + filter_ptr, 4096);
+        if (r <= 0)
+            break;
+        filter_ptr += r;
+    }
+    filter_buf[filter_ptr] = '\0';
+    if (elementSetName)
+    {
+        if (!strcmp (elementSetName, "B"))
+            no_lines = 4;
+        if (!strcmp (elementSetName, "M"))
+            no_lines = 20;
+    }
+    if (no_lines)
+    {
+        char *p = filter_buf;
+        int i = 0;
+
+        while (++i <= no_lines && (p = strchr (p, '\n')))
+            p++;
+        if (p)
+        {
+            p[1] = '\0';
+            filter_ptr = p-filter_buf;
+        }
+    }
+    p->output_format = VAL_SUTRS;
+    p->rec_buf = filter_buf;
+    p->rec_len = filter_ptr; 
+    return 0;
+}
+
+static struct recType filter_type = {
+    0,
+    "alvis",
+    filter_init,
+    filter_config,
+    filter_destroy,
+    filter_extract,
+    filter_retrieve
+};
+
+RecType
+#ifdef IDZEBRA_STATIC_ALVIS
+idzebra_filter_alvis
+#else
+idzebra_filter
+#endif
+
+[] = {
+    &filter_type,
+    0,
+};
index 657d046..d949124 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: danbibr.c,v 1.9 2005-01-15 19:38:32 adam Exp $
+/* $Id: danbibr.c,v 1.10 2005-03-31 12:42:06 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -215,6 +215,7 @@ static int retrieve_danbib(void *clientData, struct recRetrieveCtrl *ctrl)
 }
 
 static struct recType danbib_type = {
+    0,
     "grs.danbib",
     init_danbib,
     0,
index 2c24daa..0719d54 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: marcread.c,v 1.30 2005-01-15 19:38:32 adam Exp $
+/* $Id: marcread.c,v 1.31 2005-03-31 12:42:06 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -804,6 +804,7 @@ static int retrieve_marc(void *clientData, struct recRetrieveCtrl *ctrl)
 }
 
 static struct recType marc_type = {
+    0,
     "grs.marc",
     init_marc,
     config_marc,
@@ -823,6 +824,7 @@ static int retrieve_marcxml(void *clientData, struct recRetrieveCtrl *ctrl)
 }
 
 static struct recType marcxml_type = {
+    0,
     "grs.marcxml",
     init_marc,
     config_marc,
index 0acba7d..e3f9746 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: recctrl.c,v 1.18 2005-03-30 09:25:24 adam Exp $
+/* $Id: recctrl.c,v 1.19 2005-03-31 12:42:07 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -50,30 +50,6 @@ struct recTypes {
     struct recTypeInstance *entries;
 };
 
-#ifdef IDZEBRA_STATIC_GRS_SGML
-    extern RecType idzebra_filter_grs_sgml[];
-#endif
-#ifdef IDZEBRA_STATIC_TEXT
-    extern RecType idzebra_filter_text[];
-#endif
-#ifdef IDZEBRA_STATIC_GRS_XML
-#if HAVE_EXPAT_H
-    extern RecType idzebra_filter_grs_xml[];
-#endif
-#endif
-#ifdef IDZEBRA_STATIC_GRS_REGX
-    extern RecType idzebra_filter_grs_regx[];
-#endif
-#ifdef IDZEBRA_STATIC_GRS_MARC
-    extern RecType idzebra_filter_grs_marc[];
-#endif
-#ifdef IDZEBRA_STATIC_GRS_DANBIB
-    extern RecType idzebra_filter_grs_danbib[];
-#endif
-#ifdef IDZEBRA_STATIC_SAFARI
-    extern RecType idzebra_filter_safari[];
-#endif
-
 static void recTypeClass_add (struct recTypeClass **rts, RecType *rt,
                              NMEM nmem, void *module_handle);
 
@@ -84,27 +60,62 @@ RecTypeClass recTypeClass_create (Res res, NMEM nmem)
                                          DEFAULT_MODULE_PATH);
 
 #ifdef IDZEBRA_STATIC_GRS_SGML
-    recTypeClass_add (&rts, idzebra_filter_grs_sgml, nmem, 0);
+    if (1)
+    {
+       extern RecType idzebra_filter_grs_sgml[];
+       recTypeClass_add (&rts, idzebra_filter_grs_sgml, nmem, 0);
+    }
 #endif
 #ifdef IDZEBRA_STATIC_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
-    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
-    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
-    recTypeClass_add (&rts, idzebra_filter_grs_marc, 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
-    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
-    recTypeClass_add (&rts, idzebra_filter_safari, nmem, 0);
+    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
index 48460d5..c243f8c 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rectext.c,v 1.25 2005-03-30 09:25:24 adam Exp $
+/* $Id: rectext.c,v 1.26 2005-03-31 12:42:07 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -28,25 +28,25 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <idzebra/util.h>
 #include <idzebra/recctrl.h>
 
-struct text_info {
+struct filter_info {
     char *sep;
 };
 
-static void *text_init (Res res, RecType recType)
+static void *filter_init (Res res, RecType recType)
 {
-    struct text_info *tinfo = (struct text_info *) xmalloc(sizeof(*tinfo));
+    struct filter_info *tinfo = (struct filter_info *) xmalloc(sizeof(*tinfo));
     tinfo->sep = 0;
     return tinfo;
 }
 
-static void text_config(void *clientData, Res res, const char *args)
+static void filter_config(void *clientData, Res res, const char *args)
 {
 
 }
 
-static void text_destroy (void *clientData)
+static void filter_destroy (void *clientData)
 {
-    struct text_info *tinfo = clientData;
+    struct filter_info *tinfo = clientData;
     xfree (tinfo->sep);
     xfree (tinfo);
 }
@@ -58,7 +58,7 @@ struct buf_info {
     int max;
 };
 
-struct buf_info *buf_open (struct recExtractCtrl *p)
+static struct buf_info *buf_open (struct recExtractCtrl *p)
 {
     struct buf_info *fi = (struct buf_info *) xmalloc (sizeof(*fi));
 
@@ -69,7 +69,7 @@ struct buf_info *buf_open (struct recExtractCtrl *p)
     return fi;
 }
 
-int buf_read (struct text_info *tinfo, struct buf_info *fi, char *dst)
+static int buf_read (struct filter_info *tinfo, struct buf_info *fi, char *dst)
 {
     if (fi->offset >= fi->max)
     {
@@ -90,22 +90,22 @@ int buf_read (struct text_info *tinfo, struct buf_info *fi, char *dst)
     return 1;
 }
 
-void buf_close (struct buf_info *fi)
+static void buf_close (struct buf_info *fi)
 {
     xfree (fi->buf);
     xfree (fi);
 }
 
-static int text_extract (void *clientData, struct recExtractCtrl *p)
+static int filter_extract (void *clientData, struct recExtractCtrl *p)
 {
-    struct text_info *tinfo = clientData;
+    struct filter_info *tinfo = clientData;
     char w[512];
     RecWord recWord;
     int r;
     struct buf_info *fi = buf_open (p);
 
 #if 0
-    yaz_log(YLOG_LOG, "text_extract off=%ld",
+    yaz_log(YLOG_LOG, "filter_extract off=%ld",
            (long) (*fi->p->tellf)(fi->p->fh));
 #endif
     xfree(tinfo->sep);
@@ -133,11 +133,11 @@ static int text_extract (void *clientData, struct recExtractCtrl *p)
     return RECCTRL_EXTRACT_OK;
 }
 
-static int text_retrieve (void *clientData, struct recRetrieveCtrl *p)
+static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p)
 {
-    int r, text_ptr = 0;
-    static char *text_buf = NULL;
-    static int text_size = 0;
+    int r, filter_ptr = 0;
+    static char *filter_buf = NULL;
+    static int filter_size = 0;
     int make_header = 1;
     int make_body = 1;
     const char *elementSetName = NULL;
@@ -164,44 +164,44 @@ static int text_retrieve (void *clientData, struct recRetrieveCtrl *p)
     }
     while (1)
     {
-        if (text_ptr + 4096 >= text_size)
+        if (filter_ptr + 4096 >= filter_size)
         {
             char *nb;
 
-            text_size = 2*text_size + 8192;
-            nb = (char *) xmalloc (text_size);
-            if (text_buf)
+            filter_size = 2*filter_size + 8192;
+            nb = (char *) xmalloc (filter_size);
+            if (filter_buf)
             {
-                memcpy (nb, text_buf, text_ptr);
-                xfree (text_buf);
+                memcpy (nb, filter_buf, filter_ptr);
+                xfree (filter_buf);
             }
-            text_buf = nb;
+            filter_buf = nb;
         }
-        if (make_header && text_ptr == 0)
+        if (make_header && filter_ptr == 0)
         {
             if (p->score >= 0)
             {
-                sprintf (text_buf, "Rank: %d\n", p->score);
-                text_ptr = strlen(text_buf);
+                sprintf (filter_buf, "Rank: %d\n", p->score);
+                filter_ptr = strlen(filter_buf);
             }
-            sprintf (text_buf + text_ptr, "Local Number: " ZINT_FORMAT "\n",
+            sprintf (filter_buf + filter_ptr, "Local Number: " ZINT_FORMAT "\n",
                     p->localno);
-            text_ptr = strlen(text_buf);
+            filter_ptr = strlen(filter_buf);
            if (p->fname)
            {
-               sprintf (text_buf + text_ptr, "Filename: %s\n", p->fname);
-               text_ptr = strlen(text_buf);
+               sprintf (filter_buf + filter_ptr, "Filename: %s\n", p->fname);
+               filter_ptr = strlen(filter_buf);
            }
-           strcpy(text_buf+text_ptr++, "\n");
+           strcpy(filter_buf+filter_ptr++, "\n");
         }
        if (!make_body)
            break;
-        r = (*p->readf)(p->fh, text_buf + text_ptr, 4096);
+        r = (*p->readf)(p->fh, filter_buf + filter_ptr, 4096);
         if (r <= 0)
             break;
-        text_ptr += r;
+        filter_ptr += r;
     }
-    text_buf[text_ptr] = '\0';
+    filter_buf[filter_ptr] = '\0';
     if (elementSetName)
     {
         if (!strcmp (elementSetName, "B"))
@@ -211,7 +211,7 @@ static int text_retrieve (void *clientData, struct recRetrieveCtrl *p)
     }
     if (no_lines)
     {
-        char *p = text_buf;
+        char *p = filter_buf;
         int i = 0;
 
         while (++i <= no_lines && (p = strchr (p, '\n')))
@@ -219,22 +219,23 @@ static int text_retrieve (void *clientData, struct recRetrieveCtrl *p)
         if (p)
         {
             p[1] = '\0';
-            text_ptr = p-text_buf;
+            filter_ptr = p-filter_buf;
         }
     }
     p->output_format = VAL_SUTRS;
-    p->rec_buf = text_buf;
-    p->rec_len = text_ptr; 
+    p->rec_buf = filter_buf;
+    p->rec_len = filter_ptr; 
     return 0;
 }
 
-static struct recType text_type = {
+static struct recType filter_type = {
+    0,
     "text",
-    text_init,
-    text_config,
-    text_destroy,
-    text_extract,
-    text_retrieve
+    filter_init,
+    filter_config,
+    filter_destroy,
+    filter_extract,
+    filter_retrieve
 };
 
 RecType
@@ -245,6 +246,6 @@ idzebra_filter
 #endif
 
 [] = {
-    &text_type,
+    &filter_type,
     0,
 };
index db605ad..98dca3d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: regxread.c,v 1.58 2005-03-30 09:25:24 adam Exp $
+/* $Id: regxread.c,v 1.59 2005-03-31 12:42:07 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -1920,6 +1920,7 @@ static int retrieve_regx(void *clientData, struct recRetrieveCtrl *ctrl)
 }
 
 static struct recType regx_type = {
+    0,
     "grs.regx",
     grs_init,
     grs_config,
@@ -1986,6 +1987,7 @@ static int retrieve_tcl(void *clientData, struct recRetrieveCtrl *ctrl)
 }
 
 static struct recType tcl_type = {
+    0,
     "grs.tcl",
     grs_init,
     grs_config,
index a3a98cb..c524599 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: safari.c,v 1.6 2005-03-30 09:25:24 adam Exp $
+/* $Id: safari.c,v 1.7 2005-03-31 12:42:07 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -28,25 +28,25 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <idzebra/util.h>
 #include <idzebra/recctrl.h>
 
-struct safari_info {
+struct filter_info {
     char *sep;
 };
 
-static void *safari_init (Res res, RecType recType)
+static void *filter_init (Res res, RecType recType)
 {
-    struct safari_info *tinfo = (struct safari_info *) xmalloc(sizeof(*tinfo));
+    struct filter_info *tinfo = (struct filter_info *) xmalloc(sizeof(*tinfo));
     tinfo->sep = 0;
     return tinfo;
 }
 
-static void safari_config(void *clientData, Res res, const char *args)
+static void filter_config(void *clientData, Res res, const char *args)
 {
 
 }
 
-static void safari_destroy(void *clientData)
+static void filter_destroy(void *clientData)
 {
-    struct safari_info *tinfo = clientData;
+    struct filter_info *tinfo = clientData;
     xfree (tinfo->sep);
     xfree (tinfo);
 }
@@ -58,7 +58,7 @@ struct fi_info {
     int max;
 };
 
-struct fi_info *fi_open(struct recExtractCtrl *p)
+static struct fi_info *fi_open(struct recExtractCtrl *p)
 {
     struct fi_info *fi = (struct fi_info *) xmalloc (sizeof(*fi));
 
@@ -69,7 +69,7 @@ struct fi_info *fi_open(struct recExtractCtrl *p)
     return fi;
 }
 
-int fi_getchar(struct fi_info *fi, char *dst)
+static int fi_getchar(struct fi_info *fi, char *dst)
 {
     if (fi->offset >= fi->max)
     {
@@ -84,7 +84,7 @@ int fi_getchar(struct fi_info *fi, char *dst)
     return 1;
 }
 
-int fi_gets(struct fi_info *fi, char *dst, int max)
+static int fi_gets(struct fi_info *fi, char *dst, int max)
 {
     int l;
     for (l = 0; l < max; l++)
@@ -98,21 +98,21 @@ int fi_gets(struct fi_info *fi, char *dst, int max)
     return 1;
 }
 
-void fi_close (struct fi_info *fi)
+static void fi_close (struct fi_info *fi)
 {
     xfree (fi->buf);
     xfree (fi);
 }
 
-static int safari_extract(void *clientData, struct recExtractCtrl *p)
+static int filter_extract(void *clientData, struct recExtractCtrl *p)
 {
-    struct safari_info *tinfo = clientData;
+    struct filter_info *tinfo = clientData;
     char line[512];
     RecWord recWord;
     struct fi_info *fi = fi_open(p);
 
 #if 0
-    yaz_log(YLOG_LOG, "safari_extract off=%ld",
+    yaz_log(YLOG_LOG, "filter_extract off=%ld",
            (long) (*fi->p->tellf)(fi->p->fh));
 #endif
     xfree(tinfo->sep);
@@ -150,11 +150,11 @@ static int safari_extract(void *clientData, struct recExtractCtrl *p)
     return RECCTRL_EXTRACT_OK;
 }
 
-static int safari_retrieve (void *clientData, struct recRetrieveCtrl *p)
+static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p)
 {
-    int r, safari_ptr = 0;
-    static char *safari_buf = NULL;
-    static int safari_size = 0;
+    int r, filter_ptr = 0;
+    static char *filter_buf = NULL;
+    static int filter_size = 0;
     int make_header = 1;
     int make_body = 1;
     const char *elementSetName = NULL;
@@ -181,44 +181,44 @@ static int safari_retrieve (void *clientData, struct recRetrieveCtrl *p)
     }
     while (1)
     {
-        if (safari_ptr + 4096 >= safari_size)
+        if (filter_ptr + 4096 >= filter_size)
         {
             char *nb;
 
-            safari_size = 2*safari_size + 8192;
-            nb = (char *) xmalloc (safari_size);
-            if (safari_buf)
+            filter_size = 2*filter_size + 8192;
+            nb = (char *) xmalloc (filter_size);
+            if (filter_buf)
             {
-                memcpy (nb, safari_buf, safari_ptr);
-                xfree (safari_buf);
+                memcpy (nb, filter_buf, filter_ptr);
+                xfree (filter_buf);
             }
-            safari_buf = nb;
+            filter_buf = nb;
         }
-        if (make_header && safari_ptr == 0)
+        if (make_header && filter_ptr == 0)
         {
             if (p->score >= 0)
             {
-                sprintf (safari_buf, "Rank: %d\n", p->score);
-                safari_ptr = strlen(safari_buf);
+                sprintf (filter_buf, "Rank: %d\n", p->score);
+                filter_ptr = strlen(filter_buf);
             }
-            sprintf (safari_buf + safari_ptr, "Local Number: " ZINT_FORMAT "\n",
+            sprintf (filter_buf + filter_ptr, "Local Number: " ZINT_FORMAT "\n",
                     p->localno);
-            safari_ptr = strlen(safari_buf);
+            filter_ptr = strlen(filter_buf);
            if (p->fname)
            {
-               sprintf (safari_buf + safari_ptr, "Filename: %s\n", p->fname);
-               safari_ptr = strlen(safari_buf);
+               sprintf (filter_buf + filter_ptr, "Filename: %s\n", p->fname);
+               filter_ptr = strlen(filter_buf);
            }
-           strcpy(safari_buf+safari_ptr++, "\n");
+           strcpy(filter_buf+filter_ptr++, "\n");
         }
        if (!make_body)
            break;
-        r = (*p->readf)(p->fh, safari_buf + safari_ptr, 4096);
+        r = (*p->readf)(p->fh, filter_buf + filter_ptr, 4096);
         if (r <= 0)
             break;
-        safari_ptr += r;
+        filter_ptr += r;
     }
-    safari_buf[safari_ptr] = '\0';
+    filter_buf[filter_ptr] = '\0';
     if (elementSetName)
     {
         if (!strcmp (elementSetName, "B"))
@@ -228,7 +228,7 @@ static int safari_retrieve (void *clientData, struct recRetrieveCtrl *p)
     }
     if (no_lines)
     {
-        char *p = safari_buf;
+        char *p = filter_buf;
         int i = 0;
 
         while (++i <= no_lines && (p = strchr (p, '\n')))
@@ -236,22 +236,23 @@ static int safari_retrieve (void *clientData, struct recRetrieveCtrl *p)
         if (p)
         {
             p[1] = '\0';
-            safari_ptr = p-safari_buf;
+            filter_ptr = p-filter_buf;
         }
     }
     p->output_format = VAL_SUTRS;
-    p->rec_buf = safari_buf;
-    p->rec_len = safari_ptr; 
+    p->rec_buf = filter_buf;
+    p->rec_len = filter_ptr; 
     return 0;
 }
 
-static struct recType safari_type = {
+static struct recType filter_type = {
+    0,
     "safari",
-    safari_init,
-    safari_config,
-    safari_destroy,
-    safari_extract,
-    safari_retrieve
+    filter_init,
+    filter_config,
+    filter_destroy,
+    filter_extract,
+    filter_retrieve
 };
 
 RecType
@@ -262,6 +263,6 @@ idzebra_filter
 #endif
 
 [] = {
-    &safari_type,
+    &filter_type,
     0,
 };
index d0cca8c..96a5450 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: sgmlread.c,v 1.16 2005-01-15 19:38:32 adam Exp $
+/* $Id: sgmlread.c,v 1.17 2005-03-31 12:42:07 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -115,6 +115,7 @@ static int grs_retrieve_sgml(void *clientData, struct recRetrieveCtrl *ctrl)
 
 static struct recType grs_type_sgml =
 {
+    0,
     "grs.sgml",
     grs_init_sgml,
     grs_config_sgml,
index 548f0d3..08c3e23 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: xmlread.c,v 1.18 2005-01-15 19:38:32 adam Exp $
+/* $Id: xmlread.c,v 1.19 2005-03-31 12:42:07 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -484,7 +484,7 @@ 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)
+static void *filter_init(Res res, RecType recType)
 {
     struct xml_info *p = (struct xml_info *) xmalloc (sizeof(*p));
 
@@ -493,30 +493,31 @@ static void *init_xml(Res res, RecType recType)
     return p;
 }
 
-static void destroy_xml(void *clientData)
+static void filter_destroy(void *clientData)
 {
     struct xml_info *p = (struct xml_info *) clientData;
 
     xfree (p);
 }
 
-static int extract_xml(void *clientData, struct recExtractCtrl *ctrl)
+static int filter_extract(void *clientData, struct recExtractCtrl *ctrl)
 {
     return zebra_grs_extract(clientData, ctrl, grs_read_xml);
 }
 
-static int retrieve_xml(void *clientData, struct recRetrieveCtrl *ctrl)
+static int filter_retrieve(void *clientData, struct recRetrieveCtrl *ctrl)
 {
     return zebra_grs_retrieve(clientData, ctrl, grs_read_xml);
 }
 
-static struct recType xml_type = {
+static struct recType filter_type = {
+    0,
     "grs.xml",
-    init_xml,
+    filter_init,
     0,
-    destroy_xml,
-    extract_xml,
-    retrieve_xml,
+    filter_destroy,
+    filter_extract,
+    filter_retrieve,
 };
 
 RecType
@@ -527,7 +528,7 @@ idzebra_filter
 #endif
 
 [] = {
-    &xml_type,
+    &filter_type,
     0,
 };