X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fretrieve.c;h=0fc202ad36d4f728673940d7ad5d315f09334150;hb=583fe2d2582ab4078527c152b232ddf359336e91;hp=d824a1a105e05050c6d2ebd4fde34b5e44776d1b;hpb=68f2ac443fce741dad6036c30c31f8c150f5271f;p=idzebra-moved-to-github.git diff --git a/index/retrieve.c b/index/retrieve.c index d824a1a..0fc202a 100644 --- a/index/retrieve.c +++ b/index/retrieve.c @@ -1,54 +1,26 @@ -/* - * Copyright (C) 1995-1999, Index Data - * All rights reserved. - * Sebastian Hammer, Adam Dickmeiss - * - * $Log: retrieve.c,v $ - * Revision 1.14 2001-01-22 11:41:41 adam - * Added support for raw retrieval (element set name "R"). - * - * Revision 1.13 2000/03/20 19:08:36 adam - * Added remote record import using Z39.50 extended services and Segment - * Requests. - * - * Revision 1.12 2000/03/15 15:00:30 adam - * First work on threaded version. - * - * Revision 1.11 1999/10/29 10:00:00 adam - * Fixed minor bug where database name wasn't set in zebra_record_fetch. - * - * Revision 1.10 1999/05/26 07:49:13 adam - * C++ compilation. - * - * Revision 1.9 1999/05/20 12:57:18 adam - * Implemented TCL filter. Updated recctrl system. - * - * Revision 1.8 1999/03/09 16:27:49 adam - * More work on SDRKit integration. - * - * Revision 1.7 1999/03/02 16:15:43 quinn - * Added "tagsysno" and "tagrank" directives to zebra.cfg. - * - * Revision 1.6 1999/02/18 15:01:25 adam - * Minor changes. - * - * Revision 1.5 1999/02/17 11:29:56 adam - * Fixed in record_fetch. Minor updates to API. - * - * Revision 1.4 1999/02/02 14:51:07 adam - * Updated WIN32 code specific sections. Changed header. - * - * Revision 1.3 1998/10/28 10:54:40 adam - * SDRKit integration. - * - * Revision 1.2 1998/10/16 08:14:33 adam - * Updated record control system. - * - * Revision 1.1 1998/03/05 08:45:13 adam - * New result set model and modular ranking system. Moved towards - * descent server API. System information stored as "SGML" records. - * - */ +/* $Id: retrieve.c,v 1.20 2002-08-02 19:26:55 adam Exp $ + Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 + Index Data Aps + +This file is part of the Zebra server. + +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 +Software Foundation; either version 2, or (at your option) any later +version. + +Zebra is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +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. +*/ + + #include #include @@ -61,16 +33,8 @@ #include #endif -#include -#include "zserver.h" - -#ifndef ZEBRASDR -#define ZEBRASDR 0 -#endif - -#if ZEBRASDR -#include "zebrasdr.h" -#endif +#include "index.h" +#include int zebra_record_ext_read (void *fh, char *buf, size_t count) { @@ -134,14 +98,14 @@ int zebra_record_fetch (ZebraHandle zh, int sysno, int score, ODR stream, RecordAttr *recordAttr; void *clientData; - rec = rec_get (zh->service->records, sysno); + rec = rec_get (zh->reg->records, sysno); if (!rec) { logf (LOG_DEBUG, "rec_get fail on sysno=%d", sysno); *basenamep = 0; return 14; } - recordAttr = rec_init_attr (zh->service->zei, rec); + recordAttr = rec_init_attr (zh->reg->zei, rec); file_type = rec->info[recInfo_fileType]; fname = rec->info[recInfo_filename]; @@ -155,7 +119,7 @@ int zebra_record_fetch (ZebraHandle zh, int sysno, int score, ODR stream, if (!strcmp (comp->u.simple->u.generic, "R")) file_type = "text"; } - if (!(rt = recType_byName (zh->service->recTypes, + if (!(rt = recType_byName (zh->reg->recTypes, file_type, subType, &clientData))) { logf (LOG_WARN, "Retrieve: Cannot handle type %s", file_type); @@ -164,6 +128,7 @@ int zebra_record_fetch (ZebraHandle zh, int sysno, int score, ODR stream, logf (LOG_DEBUG, "retrieve localno=%d score=%d", sysno, score); retrieveCtrl.fh = &fc; fc.fd = -1; + retrieveCtrl.fname = fname; if (rec->size[recInfo_storeData] > 0) { retrieveCtrl.readf = zebra_record_int_read; @@ -176,10 +141,22 @@ int zebra_record_fetch (ZebraHandle zh, int sysno, int score, ODR stream, } else { - if ((fc.fd = open (fname, O_BINARY|O_RDONLY)) == -1) + char full_rep[1024]; + + if (zh->path_reg && !yaz_is_abspath (fname)) + { + strcpy (full_rep, zh->path_reg); + strcat (full_rep, "/"); + strcat (full_rep, fname); + } + else + strcpy (full_rep, fname); + + + if ((fc.fd = open (full_rep, O_BINARY|O_RDONLY)) == -1) { logf (LOG_WARN|LOG_ERRNO, "Retrieve fail; missing file: %s", - fname); + full_rep); rec_rm (&rec); return 14; } @@ -198,9 +175,13 @@ int zebra_record_fetch (ZebraHandle zh, int sysno, int score, ODR stream, retrieveCtrl.odr = stream; retrieveCtrl.input_format = retrieveCtrl.output_format = input_format; retrieveCtrl.comp = comp; + retrieveCtrl.encoding = zh->record_encoding; retrieveCtrl.diagnostic = 0; - retrieveCtrl.dh = zh->service->dh; - retrieveCtrl.res = zh->service->res; + retrieveCtrl.dh = zh->reg->dh; + retrieveCtrl.res = zh->res; + retrieveCtrl.rec_buf = 0; + retrieveCtrl.rec_len = -1; + (*rt->retrieve)(clientData, &retrieveCtrl); *output_format = retrieveCtrl.output_format; *rec_bufp = (char *) retrieveCtrl.rec_buf;