X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=rset%2Frstemp.c;h=3ad1422882ab70400241ae11fecdb29e7902b795;hb=7a2d0f25682890bde5d8f2883d6020df2ed0b365;hp=57e1bebbe7d9c016e2857628b4b9dabd4cdf5a68;hpb=f00e10dfcb19faeeabb42c5532f4b47f5548be97;p=idzebra-moved-to-github.git diff --git a/rset/rstemp.c b/rset/rstemp.c index 57e1beb..3ad1422 100644 --- a/rset/rstemp.c +++ b/rset/rstemp.c @@ -1,4 +1,4 @@ -/* $Id: rstemp.c,v 1.60 2005-01-17 01:21:44 adam Exp $ +/* $Id: rstemp.c,v 1.64 2005-05-24 11:35:43 adam Exp $ Copyright (C) 1995-2005 Index Data ApS @@ -32,7 +32,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #endif #include -#include +#include #include static RSFD r_open(RSET ct, int flag); @@ -44,7 +44,6 @@ static void r_pos(RSFD rfd, double *current, double *total); static void r_flush(RSFD rfd, int mk); static void r_reread(RSFD rfd); - static const struct rset_control control = { "temp", @@ -52,15 +51,13 @@ static const struct rset_control control = rset_get_one_term, r_open, r_close, - rset_default_forward, + 0, /* no forward */ r_pos, r_read, r_write, }; -const struct rset_control *rset_kind_temp = &control; - -struct rset_temp_info { +struct rset_private { int fd; /* file descriptor for temp file */ char *fname; /* name of temp file */ char *buf_mem; /* window buffer */ @@ -69,11 +66,11 @@ struct rset_temp_info { size_t pos_buf; /* position of first byte in window */ size_t pos_border; /* position of last byte+1 in window */ int dirty; /* window is dirty */ - zint hits; /* no of hits */ + zint hits; /* no of hits */ char *temp_path; }; -struct rset_temp_rfd { +struct rfd_private { void *buf; size_t pos_cur; /* current position in set */ /* FIXME - term pos or what ?? */ @@ -83,17 +80,18 @@ struct rset_temp_rfd { static int log_level = 0; static int log_level_initialized = 0; -RSET rstemp_create( NMEM nmem, const struct key_control *kcontrol, - int scope, const char *temp_path, TERMID term) +RSET rstemp_create(NMEM nmem, struct rset_key_control *kcontrol, + int scope, const char *temp_path, TERMID term) { - RSET rnew = rset_create_base(&control, nmem, kcontrol, scope,term); - struct rset_temp_info *info; + RSET rnew = rset_create_base(&control, nmem, kcontrol, scope, term, + 0, 0); + struct rset_private *info; if (!log_level_initialized) { log_level = yaz_log_module_level("rstemp"); log_level_initialized = 1; } - info = (struct rset_temp_info *) nmem_malloc(rnew->nmem, sizeof(*info)); + info = (struct rset_private *) nmem_malloc(rnew->nmem, sizeof(*info)); info->fd = -1; info->fname = NULL; info->buf_size = 4096; @@ -113,7 +111,7 @@ RSET rstemp_create( NMEM nmem, const struct key_control *kcontrol, static void r_delete(RSET ct) { - struct rset_temp_info *info = (struct rset_temp_info*) ct->priv; + struct rset_private *info = (struct rset_private*) ct->priv; yaz_log(log_level, "r_delete: set size %ld", (long) info->pos_end); if (info->fname) @@ -125,9 +123,9 @@ static void r_delete(RSET ct) static RSFD r_open(RSET ct, int flag) { - struct rset_temp_info *info = (struct rset_temp_info *) ct->priv; + struct rset_private *info = (struct rset_private *) ct->priv; RSFD rfd; - struct rset_temp_rfd *prfd; + struct rfd_private *prfd; if (info->fd == -1 && info->fname) { @@ -144,7 +142,7 @@ static RSFD r_open(RSET ct, int flag) rfd = rfd_create_base(ct); if (!rfd->priv) { - prfd = (struct rset_temp_rfd *) nmem_malloc(ct->nmem, sizeof(*prfd)); + prfd = (struct rfd_private *) nmem_malloc(ct->nmem, sizeof(*prfd)); rfd->priv = (void *)prfd; prfd->buf = nmem_malloc(ct->nmem,ct->keycontrol->key_size); } @@ -163,8 +161,7 @@ static RSFD r_open(RSET ct, int flag) */ static void r_flush(RSFD rfd, int mk) { - /* struct rset_temp_info *info = ((struct rset_temp_rfd*) rfd)->info; */ - struct rset_temp_info *info = rfd->rset->priv; + struct rset_private *info = rfd->rset->priv; if (!info->fname && mk) { @@ -224,8 +221,7 @@ static void r_flush(RSFD rfd, int mk) static void r_close(RSFD rfd) { - /*struct rset_temp_rfd *mrfd = (struct rset_temp_rfd*) rfd->priv; */ - struct rset_temp_info *info = (struct rset_temp_info *)rfd->rset->priv; + struct rset_private *info = (struct rset_private *)rfd->rset->priv; if (rfd_is_last(rfd)) { r_flush(rfd, 0); @@ -235,7 +231,6 @@ static void r_close(RSFD rfd) info->fd = -1; } } - rfd_delete_base(rfd); } @@ -245,8 +240,8 @@ static void r_close(RSFD rfd) */ static void r_reread(RSFD rfd) { - struct rset_temp_rfd *mrfd = (struct rset_temp_rfd*) rfd->priv; - struct rset_temp_info *info = (struct rset_temp_info *)rfd->rset->priv; + struct rfd_private *mrfd = (struct rfd_private*) rfd->priv; + struct rset_private *info = (struct rset_private *)rfd->rset->priv; if (info->fname) { @@ -282,8 +277,8 @@ static void r_reread(RSFD rfd) static int r_read(RSFD rfd, void *buf, TERMID *term) { - struct rset_temp_rfd *mrfd = (struct rset_temp_rfd*) rfd->priv; - struct rset_temp_info *info = (struct rset_temp_info *)rfd->rset->priv; + struct rfd_private *mrfd = (struct rfd_private*) rfd->priv; + struct rset_private *info = (struct rset_private *)rfd->rset->priv; size_t nc = mrfd->pos_cur + rfd->rset->keycontrol->key_size; @@ -307,8 +302,8 @@ static int r_read(RSFD rfd, void *buf, TERMID *term) static int r_write(RSFD rfd, const void *buf) { - struct rset_temp_rfd *mrfd = (struct rset_temp_rfd*) rfd->priv; - struct rset_temp_info *info = (struct rset_temp_info *)rfd->rset->priv; + struct rfd_private *mrfd = (struct rfd_private*) rfd->priv; + struct rset_private *info = (struct rset_private *)rfd->rset->priv; size_t nc = mrfd->pos_cur + rfd->rset->keycontrol->key_size; @@ -331,9 +326,8 @@ static int r_write(RSFD rfd, const void *buf) static void r_pos(RSFD rfd, double *current, double *total) { - /* struct rset_temp_rfd *mrfd = (struct rset_temp_rfd*) rfd; */ - struct rset_temp_rfd *mrfd = (struct rset_temp_rfd*) rfd->priv; - struct rset_temp_info *info = (struct rset_temp_info *)rfd->rset->priv; + struct rfd_private *mrfd = (struct rfd_private*) rfd->priv; + struct rset_private *info = (struct rset_private *)rfd->rset->priv; *current = (double) mrfd->cur; *total = (double) info->hits;