X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=blobdiff_plain;f=rset%2Frsnull.c;h=4e9cc70de764d02207ec9dac47cda04748f9781f;hp=895a24446d08a382e6e8af57595b7fd729adf414;hb=HEAD;hpb=e6b40b4f140e8f7348fff1f7be78ac78946421ff diff --git a/rset/rsnull.c b/rset/rsnull.c index 895a244..4e9cc70 100644 --- a/rset/rsnull.c +++ b/rset/rsnull.c @@ -1,8 +1,5 @@ -/* $Id: rsnull.c,v 1.17 2004-08-03 12:15:45 heikki Exp $ - Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 - Index Data Aps - -This file is part of the Zebra server. +/* This file is part of the Zebra server. + Copyright (C) Index Data 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 @@ -15,99 +12,89 @@ 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. -*/ - +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#if HAVE_CONFIG_H +#include +#endif #include -#include -#include +#include +#include +#include -static void *r_create(RSET ct, const struct rset_control *sel, void *parms); -static RSFD r_open (RSET ct, int flag); -static void r_close (RSFD rfd); -static void r_delete (RSET ct); -static void r_rewind (RSFD rfd); -/* static int r_count (RSET ct); */ -static int r_read (RSFD rfd, void *buf, int *term_index); -static int r_write (RSFD rfd, const void *buf); +static RSFD r_open(RSET ct, int flag); +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 const struct rset_control control = +static const struct rset_control control = { "null", - r_create, + r_delete, + rset_get_one_term, r_open, r_close, - r_delete, - r_rewind, - rset_default_forward, - /* r_count, */ + 0, /* no forward */ + r_pos, r_read, - r_write, + rset_no_write, }; -const struct rset_control *rset_kind_null = &control; - -static void *r_create(RSET ct, const struct rset_control *sel, void *parms) +RSET rset_create_null(NMEM nmem, struct rset_key_control *kcontrol, + TERMID term) { - rset_null_parms *null_parms = (rset_null_parms *) parms; - - ct->no_rset_terms = 1; - ct->rset_terms = (RSET_TERM *) xmalloc (sizeof(*ct->rset_terms)); - if (parms && null_parms->rset_term) - ct->rset_terms[0] = null_parms->rset_term; - else - ct->rset_terms[0] = rset_term_create ("term", -1, "rank-0", - 0); - ct->rset_terms[0]->nn = 0; - - return NULL; + RSET rnew = rset_create_base(&control, nmem, kcontrol, 0, term, 0, 0); + rnew->priv = 0; + return rnew; } -static RSFD r_open (RSET ct, int flag) +static RSFD r_open(RSET ct, int flag) { + RSFD rfd; if (flag & RSETF_WRITE) { - logf (LOG_FATAL, "NULL set type is read-only"); - return NULL; + yaz_log (YLOG_FATAL, "NULL set type is read-only"); + return NULL; } - return ""; + rfd = rfd_create_base(ct); + rfd->priv = 0; + return rfd; } -static void r_close (RSFD rfd) +static void r_close(RSFD rfd) { } -static void r_delete (RSET ct) +static void r_delete(RSET ct) { - rset_term_destroy (ct->rset_terms[0]); - xfree (ct->rset_terms); } -static void r_rewind (RSFD rfd) +static void r_pos(RSFD rfd, double *current, double *total) { - logf (LOG_DEBUG, "rsnull_rewind"); + assert(rfd); + assert(current); + assert(total); + *total = 0; + *current = 0; } -/* -static int r_count (RSET ct) +static int r_read(RSFD rfd, void *buf, TERMID *term) { + if (term) + *term = 0; return 0; } -*/ -static int r_read (RSFD rfd, void *buf, int *term_index) -{ - *term_index = -1; - return 0; -} - -static int r_write (RSFD rfd, const void *buf) -{ - logf (LOG_FATAL, "NULL set type is read-only"); - return -1; -} +/* + * Local variables: + * c-basic-offset: 4 + * c-file-style: "Stroustrup" + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */