X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=rset%2Frstemp.c;h=aa886beab40343d123bb22a9dd6ec630abcd3667;hb=3ef0c861c68e520a9a1cb0fa523251a2d3d739ee;hp=32048c9310d4d47eeb203f4bda678dc2051e0f2d;hpb=c8b510c1c66a9119ede10b63975fc5f7f1ea49f5;p=idzebra-moved-to-github.git diff --git a/rset/rstemp.c b/rset/rstemp.c index 32048c9..aa886be 100644 --- a/rset/rstemp.c +++ b/rset/rstemp.c @@ -1,5 +1,5 @@ -/* $Id: rstemp.c,v 1.62 2005-04-26 10:09:38 adam Exp $ - Copyright (C) 1995-2005 +/* $Id: rstemp.c,v 1.67 2006-06-06 21:01:31 adam Exp $ + Copyright (C) 1995-2006 Index Data ApS This file is part of the Zebra server. @@ -27,7 +27,8 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include #ifdef WIN32 #include -#else +#endif +#if HAVE_UNISTD_H #include #endif #include @@ -51,13 +52,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, }; -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 */ @@ -70,7 +71,7 @@ struct rset_temp_info { 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 ?? */ @@ -80,17 +81,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 rset_create_temp(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; @@ -110,7 +112,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) @@ -122,9 +124,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) { @@ -141,7 +143,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); } @@ -160,8 +162,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) { @@ -221,8 +222,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); @@ -232,7 +232,6 @@ static void r_close(RSFD rfd) info->fd = -1; } } - rfd_delete_base(rfd); } @@ -242,8 +241,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) { @@ -279,8 +278,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; @@ -304,8 +303,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; @@ -328,10 +327,17 @@ 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; } +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +