From 6eede4f6572f495e9363015b336d9e17662a5368 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 26 Apr 2006 11:12:31 +0000 Subject: [PATCH] Change config function in recType interface to return ZEBRA_RES to signal success/failure. --- include/idzebra/recctrl.h | 10 +++++----- recctrl/alvis.c | 9 +++++---- recctrl/csvread.c | 9 +++++---- recctrl/marcread.c | 5 +++-- recctrl/recctrl.c | 8 ++++++-- recctrl/rectext.c | 5 +++-- recctrl/regxread.c | 5 +++-- recctrl/safari.c | 6 +++--- recctrl/sgmlread.c | 6 +++--- recctrl/xslt.c | 9 +++++---- 10 files changed, 41 insertions(+), 31 deletions(-) diff --git a/include/idzebra/recctrl.h b/include/idzebra/recctrl.h index 4db54cc..3e1d66f 100644 --- a/include/idzebra/recctrl.h +++ b/include/idzebra/recctrl.h @@ -1,5 +1,5 @@ -/* $Id: recctrl.h,v 1.14 2005-08-22 08:19:51 adam Exp $ - Copyright (C) 1995-2005 +/* $Id: recctrl.h,v 1.15 2006-04-26 11:12:31 adam Exp $ + Copyright (C) 1995-2006 Index Data ApS This file is part of the Zebra server. @@ -20,8 +20,8 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef RECCTRL_H -#define RECCTRL_H +#ifndef IDZEBRA_RECCTRL_H +#define IDZEBRA_RECCTRL_H #include #include @@ -117,7 +117,7 @@ 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 */ + ZEBRA_RES (*config)(void *clientData, Res res, const char *args); /* Config */ void (*destroy)(void *clientData); /* Destroy function */ int (*extract)(void *clientData, struct recExtractCtrl *ctrl); /* Extract proc */ diff --git a/recctrl/alvis.c b/recctrl/alvis.c index 546fd7a..b898277 100644 --- a/recctrl/alvis.c +++ b/recctrl/alvis.c @@ -1,4 +1,4 @@ -/* $Id: alvis.c,v 1.8 2005-08-24 08:30:37 adam Exp $ +/* $Id: alvis.c,v 1.9 2006-04-26 11:12:31 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -249,15 +249,16 @@ static struct filter_schema *lookup_schema(struct filter_info *tinfo, return 0; } -static void filter_config(void *clientData, Res res, const char *args) +static ZEBRA_RES filter_config(void *clientData, Res res, const char *args) { struct filter_info *tinfo = clientData; if (!args || !*args) - args = "xsltfilter.xml"; + return ZEBRA_FAIL; if (tinfo->fname && !strcmp(args, tinfo->fname)) - return; + return ZEBRA_OK; destroy_schemas(tinfo); create_schemas(tinfo, args); + return ZEBRA_OK; } static void filter_destroy(void *clientData) diff --git a/recctrl/csvread.c b/recctrl/csvread.c index db681e7..cbf73e1 100644 --- a/recctrl/csvread.c +++ b/recctrl/csvread.c @@ -1,4 +1,4 @@ -/* $Id: csvread.c,v 1.3 2005-12-06 15:36:38 adam Exp $ +/* $Id: csvread.c,v 1.4 2006-04-26 11:12:31 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -66,7 +66,7 @@ struct csv_t { }; -static void grs_config_csv(void *clientData, Res res, const char *args) +static ZEBRA_RES grs_config_csv(void *clientData, Res res, const char *args) { int i; struct csv_t *csvp = (struct csv_t*) clientData; @@ -91,8 +91,8 @@ static void grs_config_csv(void *clientData, Res res, const char *args) /* csvp->field_names = 0; */ /*nmem_strdup(csvp->nmem, "a|b|c|d|e");*/ csvp->field_name - = nmem_malloc(csvp->nmem, - sizeof(*(csvp->field_name)) * csvp->max_nr_fields); + = nmem_malloc(csvp->nmem, + sizeof(*(csvp->field_name)) * csvp->max_nr_fields); for (i = 0; i < csvp->max_nr_fields; i++){ csvp->field_name[i] = 0; } @@ -103,6 +103,7 @@ static void grs_config_csv(void *clientData, Res res, const char *args) */ yaz_log (YLOG_LOG, "Ended CSV filter grs_config_csv"); + return ZEBRA_OK; } diff --git a/recctrl/marcread.c b/recctrl/marcread.c index 3da18e9..320cbde 100644 --- a/recctrl/marcread.c +++ b/recctrl/marcread.c @@ -1,4 +1,4 @@ -/* $Id: marcread.c,v 1.32 2005-12-08 11:06:49 adam Exp $ +/* $Id: marcread.c,v 1.33 2006-04-26 11:12:31 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -821,11 +821,12 @@ static void *init_marc(Res res, RecType rt) return p; } -static void config_marc(void *clientData, Res res, const char *args) +static ZEBRA_RES 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); + return ZEBRA_OK; } static void destroy_marc(void *clientData) diff --git a/recctrl/recctrl.c b/recctrl/recctrl.c index e1d949b..1130d01 100644 --- a/recctrl/recctrl.c +++ b/recctrl/recctrl.c @@ -1,4 +1,4 @@ -/* $Id: recctrl.c,v 1.22 2005-12-05 12:18:41 marc Exp $ +/* $Id: recctrl.c,v 1.23 2006-04-26 11:12:31 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -278,7 +278,11 @@ RecType recType_byName (RecTypes rts, Res res, const char *name, slen++; /* skip . */ if (rti->recType->config) - (*(rti->recType)->config)(rti->clientData, res, name+slen); + { + if ((*(rti->recType)->config) + (rti->clientData, res, name+slen) != ZEBRA_OK) + return 0; + } return rti->recType; } } diff --git a/recctrl/rectext.c b/recctrl/rectext.c index cf192c4..e984f84 100644 --- a/recctrl/rectext.c +++ b/recctrl/rectext.c @@ -1,4 +1,4 @@ -/* $Id: rectext.c,v 1.29 2005-06-23 06:45:47 adam Exp $ +/* $Id: rectext.c,v 1.30 2006-04-26 11:12:31 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -39,13 +39,14 @@ static void *filter_init (Res res, RecType recType) return tinfo; } -static void filter_config(void *clientData, Res res, const char *args) +static ZEBRA_RES filter_config(void *clientData, Res res, const char *args) { struct filter_info *tinfo = (struct filter_info*) clientData; xfree(tinfo->sep); tinfo->sep = 0; if (args && *args) tinfo->sep = xstrdup(args); + return ZEBRA_OK; } static void filter_destroy (void *clientData) diff --git a/recctrl/regxread.c b/recctrl/regxread.c index 98dca3d..4ec6a2c 100644 --- a/recctrl/regxread.c +++ b/recctrl/regxread.c @@ -1,4 +1,4 @@ -/* $Id: regxread.c,v 1.59 2005-03-31 12:42:07 adam Exp $ +/* $Id: regxread.c,v 1.60 2006-04-26 11:12:31 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -1866,11 +1866,12 @@ void *grs_init(Res res, RecType recType) } -void grs_config(void *clientData, Res res, const char *args) +ZEBRA_RES 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); + return ZEBRA_OK; } data1_node *grs_read_regx (struct grs_read_info *p) diff --git a/recctrl/safari.c b/recctrl/safari.c index 045bf70..3d73553 100644 --- a/recctrl/safari.c +++ b/recctrl/safari.c @@ -1,4 +1,4 @@ -/* $Id: safari.c,v 1.10 2006-03-21 14:36:22 adam Exp $ +/* $Id: safari.c,v 1.11 2006-04-26 11:12:32 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -39,9 +39,9 @@ static void *filter_init (Res res, RecType recType) return tinfo; } -static void filter_config(void *clientData, Res res, const char *args) +static ZEBRA_RES filter_config(void *clientData, Res res, const char *args) { - + return ZEBRA_OK; } static void filter_destroy(void *clientData) diff --git a/recctrl/sgmlread.c b/recctrl/sgmlread.c index 110be78..2fa0f93 100644 --- a/recctrl/sgmlread.c +++ b/recctrl/sgmlread.c @@ -1,4 +1,4 @@ -/* $Id: sgmlread.c,v 1.18 2005-11-16 04:33:22 adam Exp $ +/* $Id: sgmlread.c,v 1.19 2006-04-26 11:12:32 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -89,9 +89,9 @@ static void *grs_init_sgml(Res res, RecType recType) return p; } -static void grs_config_sgml(void *clientData, Res res, const char *args) +static ZEBRA_RES grs_config_sgml(void *clientData, Res res, const char *args) { - + return ZEBRA_OK; } static void grs_destroy_sgml(void *clientData) diff --git a/recctrl/xslt.c b/recctrl/xslt.c index 6787510..d4b3f08 100644 --- a/recctrl/xslt.c +++ b/recctrl/xslt.c @@ -1,4 +1,4 @@ -/* $Id: xslt.c,v 1.17 2005-08-24 08:30:37 adam Exp $ +/* $Id: xslt.c,v 1.18 2006-04-26 11:12:32 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -249,15 +249,16 @@ static struct filter_schema *lookup_schema(struct filter_info *tinfo, return 0; } -static void filter_config(void *clientData, Res res, const char *args) +static ZEBRA_RES filter_config(void *clientData, Res res, const char *args) { struct filter_info *tinfo = clientData; if (!args || !*args) - args = "xsltfilter.xml"; + return ZEBRA_FAIL; if (tinfo->fname && !strcmp(args, tinfo->fname)) - return; + return ZEBRA_OK; destroy_schemas(tinfo); create_schemas(tinfo, args); + return ZEBRA_OK; } static void filter_destroy(void *clientData) -- 1.7.10.4