From 2c2827a0071c5a5511e1489c456ce64fdd42364a Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 28 Jun 2013 11:26:31 +0200 Subject: [PATCH] Read-only sets uses common no write handler --- include/rset.h | 2 ++ rset/rsbetween.c | 11 +---------- rset/rsbool.c | 10 +--------- rset/rset.c | 6 ++++++ rset/rsisamb.c | 10 ++-------- rset/rsisamc.c | 10 +--------- rset/rsisams.c | 9 +-------- rset/rsmultiandor.c | 11 ++--------- rset/rsnull.c | 8 +------- rset/rsprox.c | 9 +-------- 10 files changed, 18 insertions(+), 68 deletions(-) diff --git a/include/rset.h b/include/rset.h index 2eb7153..e555cad 100644 --- a/include/rset.h +++ b/include/rset.h @@ -260,6 +260,8 @@ void rset_visit(RSET rset, int level); void rset_set_hits_limit(RSET rs, zint l); +int rset_no_write(RSFD rfd, const void *buf); + YAZ_END_CDECL #endif diff --git a/rset/rsbetween.c b/rset/rsbetween.c index 15b5e47..fc3d22c 100644 --- a/rset/rsbetween.c +++ b/rset/rsbetween.c @@ -46,7 +46,6 @@ static void r_delete(RSET ct); static int r_forward(RSFD rfd, void *buf, TERMID *term, const void *untilbuf); static int r_read(RSFD rfd, void *buf, TERMID *term ); -static int r_write(RSFD rfd, const void *buf); static void r_pos(RSFD rfd, double *current, double *total); static void r_get_terms(RSET ct, TERMID *terms, int maxterms, int *curterm); @@ -60,7 +59,7 @@ static const struct rset_control control = r_forward, r_pos, r_read, - r_write, + rset_no_write, }; #define STARTTAG 0 @@ -302,14 +301,6 @@ static int r_read(RSFD rfd, void *buf, TERMID *term) } /* r_read */ - -static int r_write(RSFD rfd, const void *buf) -{ - yaz_log(YLOG_FATAL, "between set type is read-only"); - return -1; -} - - static void r_pos(RSFD rfd, double *current, double *total) { struct rset_between_rfd *p=(struct rset_between_rfd *)rfd->priv; diff --git a/rset/rsbool.c b/rset/rsbool.c index c573e10..2344258 100644 --- a/rset/rsbool.c +++ b/rset/rsbool.c @@ -38,7 +38,6 @@ static void r_delete(RSET ct); static int r_forward(RSFD rfd, void *buf, TERMID *term, const void *untilbuf); static void r_pos(RSFD rfd, double *current, double *total); static int r_read_not(RSFD rfd, void *buf, TERMID *term); -static int r_write(RSFD rfd, const void *buf); static void r_get_terms(RSET ct, TERMID *terms, int maxterms, int *curterm); static const struct rset_control control_not = @@ -51,7 +50,7 @@ static const struct rset_control control_not = r_forward, r_pos, r_read_not, - r_write, + rset_no_write, }; struct rset_private { @@ -225,13 +224,6 @@ static int r_read_not(RSFD rfd, void *buf, TERMID *term) return 0; } - -static int r_write(RSFD rfd, const void *buf) -{ - yaz_log(YLOG_FATAL, "bool set type is read-only"); - return -1; -} - static void r_pos(RSFD rfd, double *current, double *total) { struct rfd_private *p = (struct rfd_private *)rfd->priv; diff --git a/rset/rset.c b/rset/rset.c index e0aea89..6c298f7 100644 --- a/rset/rset.c +++ b/rset/rset.c @@ -430,6 +430,12 @@ void rset_visit(RSET rset, int level) rset_visit(rset->children[i], level+1); } +int rset_no_write(RSFD rfd, const void *buf) +{ + yaz_log(YLOG_FATAL, "%s set type is read-only", rfd->rset->control->desc); + return -1; +} + /* * Local variables: * c-basic-offset: 4 diff --git a/rset/rsisamb.c b/rset/rsisamb.c index 496e78a..ea755a0 100644 --- a/rset/rsisamb.c +++ b/rset/rsisamb.c @@ -33,7 +33,6 @@ static int r_forward(RSFD rfd, void *buf, TERMID *term, const void *untilbuf); static void r_pos(RSFD rfd, double *current, double *total); static int r_read(RSFD rfd, void *buf, TERMID *term); static int r_read_filter(RSFD rfd, void *buf, TERMID *term); -static int r_write(RSFD rfd, const void *buf); static const struct rset_control control = { @@ -45,7 +44,7 @@ static const struct rset_control control = r_forward, r_pos, r_read, - r_write, + rset_no_write, }; static const struct rset_control control_filter = @@ -58,7 +57,7 @@ static const struct rset_control control_filter = r_forward, r_pos, r_read_filter, - r_write, + rset_no_write, }; struct rfd_private { @@ -181,11 +180,6 @@ static int r_read_filter(RSFD rfd, void *buf, TERMID *term) return rc; } -static int r_write(RSFD rfd, const void *buf) -{ - yaz_log(YLOG_FATAL, "ISAMB set type is read-only"); - return -1; -} /* * Local variables: * c-basic-offset: 4 diff --git a/rset/rsisamc.c b/rset/rsisamc.c index 7a72020..588d88c 100644 --- a/rset/rsisamc.c +++ b/rset/rsisamc.c @@ -30,7 +30,6 @@ static RSFD r_open (RSET ct, int flag); static void r_close (RSFD rfd); static void r_delete (RSET ct); static int r_read (RSFD rfd, void *buf, TERMID *term); -static int r_write (RSFD rfd, const void *buf); static void r_pos (RSFD rfd, double *current, double *total); static const struct rset_control control = @@ -43,7 +42,7 @@ static const struct rset_control control = 0, /* no forward */ r_pos, r_read, - r_write, + rset_no_write, }; struct rset_pp_info { @@ -127,12 +126,6 @@ static int r_read (RSFD rfd, void *buf, TERMID *term) return r; } -static int r_write (RSFD rfd, const void *buf) -{ - yaz_log(YLOG_FATAL, "ISAMC set type is read-only"); - return -1; -} - static void r_pos (RSFD rfd, double *current, double *total) { *current = -1; /* sorry, not implemented yet */ @@ -140,7 +133,6 @@ static void r_pos (RSFD rfd, double *current, double *total) } - /* * Local variables: * c-basic-offset: 4 diff --git a/rset/rsisams.c b/rset/rsisams.c index 4b028df..7ed4be9 100644 --- a/rset/rsisams.c +++ b/rset/rsisams.c @@ -29,7 +29,6 @@ static RSFD r_open (RSET ct, int flag); static void r_close (RSFD rfd); static void r_delete (RSET ct); static int r_read (RSFD rfd, void *buf, TERMID *term); -static int r_write (RSFD rfd, const void *buf); static void r_pos (RSFD rfd, double *current, double *total); static const struct rset_control control = @@ -42,7 +41,7 @@ static const struct rset_control control = 0, /* no forward */ r_pos, r_read, - r_write, + rset_no_write, }; struct rfd_private { @@ -113,12 +112,6 @@ static int r_read (RSFD rfd, void *buf, TERMID *term) return rc; } -static int r_write (RSFD rfd, const void *buf) -{ - yaz_log (YLOG_FATAL, "ISAMS set type is read-only"); - return -1; -} - static void r_pos (RSFD rfd, double *current, double *total) { *current=-1; /* sorry, not implemented yet */ diff --git a/rset/rsmultiandor.c b/rset/rsmultiandor.c index a6d4c72..4aec929 100644 --- a/rset/rsmultiandor.c +++ b/rset/rsmultiandor.c @@ -50,7 +50,6 @@ static void r_close(RSFD rfd); static void r_delete(RSET ct); static int r_read_and(RSFD rfd, void *buf, TERMID *term); static int r_read_or(RSFD rfd, void *buf, TERMID *term); -static int r_write(RSFD rfd, const void *buf); static int r_forward_and(RSFD rfd, void *buf, TERMID *term, const void *untilbuf); static int r_forward_or(RSFD rfd, void *buf, TERMID *term, @@ -69,7 +68,7 @@ static const struct rset_control control_or = r_forward_or, r_pos_or, r_read_or, - r_write, + rset_no_write, }; static const struct rset_control control_and = @@ -82,7 +81,7 @@ static const struct rset_control control_and = r_forward_and, r_pos_and, r_read_and, - r_write, + rset_no_write, }; /* The heap structure: @@ -650,12 +649,6 @@ static void r_pos_or(RSFD rfd, double *current, double *total) r_pos_x(rfd, current, total, 0); } -static int r_write(RSFD rfd, const void *buf) -{ - yaz_log(YLOG_FATAL, "multior set type is read-only"); - return -1; -} - static void r_get_terms(RSET ct, TERMID *terms, int maxterms, int *curterm) { if (ct->term) diff --git a/rset/rsnull.c b/rset/rsnull.c index c9e8a61..b3628ce 100644 --- a/rset/rsnull.c +++ b/rset/rsnull.c @@ -30,7 +30,6 @@ static void r_close(RSFD rfd); static void r_delete(RSET ct); static void r_pos(RSFD rfd, double *current, double *total); static int r_read(RSFD rfd, void *buf, TERMID *term); -static int r_write(RSFD rfd, const void *buf); static const struct rset_control control = { @@ -42,7 +41,7 @@ static const struct rset_control control = 0, /* no forward */ r_pos, r_read, - r_write, + rset_no_write, }; RSET rset_create_null(NMEM nmem, struct rset_key_control *kcontrol, @@ -90,11 +89,6 @@ static int r_read(RSFD rfd, void *buf, TERMID *term) return 0; } -static int r_write(RSFD rfd, const void *buf) -{ - yaz_log(YLOG_FATAL, "NULL set type is read-only"); - return -1; -} /* * Local variables: * c-basic-offset: 4 diff --git a/rset/rsprox.c b/rset/rsprox.c index 00856f0..e772ee4 100644 --- a/rset/rsprox.c +++ b/rset/rsprox.c @@ -37,7 +37,6 @@ static void r_close(RSFD rfd); static void r_delete(RSET ct); static int r_forward(RSFD rfd, void *buf, TERMID *term, const void *untilbuf); static int r_read(RSFD rfd, void *buf, TERMID *term); -static int r_write(RSFD rfd, const void *buf); static void r_pos(RSFD rfd, double *current, double *total); static void r_get_terms(RSET ct, TERMID *terms, int maxterms, int *curterm); @@ -51,7 +50,7 @@ static const struct rset_control control = r_forward, r_pos, r_read, - r_write, + rset_no_write, }; struct rset_prox_info { @@ -305,12 +304,6 @@ static int r_read(RSFD rfd, void *buf, TERMID *term) return r_forward(rfd, buf, term, 0); } -static int r_write(RSFD rfd, const void *buf) -{ - yaz_log(YLOG_FATAL, "prox set type is read-only"); - return -1; -} - static void r_pos(RSFD rfd, double *current, double *total) { RSET ct = rfd->rset; -- 1.7.10.4