-/* $Id: retrieve.c,v 1.22 2004-08-04 08:35:23 adam Exp $
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
- Index Data Aps
+/* $Id: retrieve.c,v 1.29 2005-04-14 12:02:58 adam Exp $
+ Copyright (C) 1995-2005
+ Index Data ApS
This file is part of the Zebra server.
int l = fc->record_int_len - fc->record_int_pos;
if (l <= 0)
return 0;
- l = (l < (int) count) ? l : count;
+ l = (l < (int) count) ? l : (int) count;
memcpy (buf, fc->record_int_buf + fc->record_int_pos, l);
fc->record_int_pos += l;
return l;
int zebra_record_fetch (ZebraHandle zh, SYSNO sysno, int score, ODR stream,
oid_value input_format, Z_RecordComposition *comp,
oid_value *output_format, char **rec_bufp,
- int *rec_lenp, char **basenamep)
+ int *rec_lenp, char **basenamep,
+ char **addinfo)
{
Record rec;
char *fname, *file_type, *basename;
RecType rt;
struct recRetrieveCtrl retrieveCtrl;
- char subType[128];
struct zebra_fetch_control fc;
RecordAttr *recordAttr;
void *clientData;
int raw_mode = 0;
+ *basenamep = 0;
+ *addinfo = 0;
+ if (comp && comp->which == Z_RecordComp_simple &&
+ comp->u.simple->which == Z_ElementSetNames_generic &&
+ !strcmp (comp->u.simple->u.generic, "_sysno_"))
+ {
+ char rec_str[60];
+ sprintf(rec_str, ZINT_FORMAT, sysno);
+ *output_format = VAL_SUTRS;
+ *rec_lenp = strlen(rec_str);
+ *rec_bufp = odr_strdup(stream, rec_str);
+ return 0;
+ }
rec = rec_get (zh->reg->records, sysno);
if (!rec)
{
- logf (LOG_DEBUG, "rec_get fail on sysno=" ZINT_FORMAT, sysno);
- *basenamep = 0;
+ yaz_log (YLOG_DEBUG, "rec_get fail on sysno=" ZINT_FORMAT, sysno);
+ *basenamep = 0;
return 14;
}
recordAttr = rec_init_attr (zh->reg->zei, rec);
strcpy (*basenamep, basename);
if (comp && comp->which == Z_RecordComp_simple &&
- comp->u.simple->which == Z_ElementSetNames_generic)
+ comp->u.simple->which == Z_ElementSetNames_generic &&
+ !strcmp (comp->u.simple->u.generic, "R"))
{
- if (!strcmp (comp->u.simple->u.generic, "R"))
- raw_mode = 1;
+ raw_mode = 1;
}
- if (!(rt = recType_byName (zh->reg->recTypes,
- file_type, subType, &clientData)))
+ if (!(rt = recType_byName (zh->reg->recTypes, zh->res,
+ file_type, &clientData)))
{
- logf (LOG_WARN, "Retrieve: Cannot handle type %s", file_type);
+ yaz_log (YLOG_WARN, "Retrieve: Cannot handle type %s", file_type);
return 14;
}
- logf (LOG_DEBUG, "retrieve localno=" ZINT_FORMAT " score=%d", sysno,score);
+ yaz_log (YLOG_DEBUG, "retrieve localno=" ZINT_FORMAT " score=%d", sysno,score);
retrieveCtrl.fh = &fc;
fc.fd = -1;
retrieveCtrl.fname = fname;
fc.record_int_len = rec->size[recInfo_storeData];
fc.record_int_buf = rec->info[recInfo_storeData];
fc.record_int_pos = 0;
- logf (LOG_DEBUG, "Internal retrieve. %d bytes", fc.record_int_len);
+ yaz_log (YLOG_DEBUG, "Internal retrieve. %d bytes", fc.record_int_len);
if (raw_mode)
{
*output_format = VAL_SUTRS;
if ((fc.fd = open (full_rep, O_BINARY|O_RDONLY)) == -1)
{
- logf (LOG_WARN|LOG_ERRNO, "Retrieve fail; missing file: %s",
+ yaz_log (YLOG_WARN|YLOG_ERRNO, "Retrieve fail; missing file: %s",
full_rep);
rec_rm (&rec);
return 14;
return 0;
}
}
- retrieveCtrl.subType = subType;
retrieveCtrl.localno = sysno;
retrieveCtrl.score = score;
retrieveCtrl.recordSize = recordAttr->recordSize;
retrieveCtrl.comp = comp;
retrieveCtrl.encoding = zh->record_encoding;
retrieveCtrl.diagnostic = 0;
+ retrieveCtrl.addinfo = 0;
retrieveCtrl.dh = zh->reg->dh;
retrieveCtrl.res = zh->res;
retrieveCtrl.rec_buf = 0;
close (fc.fd);
rec_rm (&rec);
+ *addinfo = retrieveCtrl.addinfo;
return retrieveCtrl.diagnostic;
}