* Sebastian Hammer, Adam Dickmeiss
*
* $Log: ir-tcl.c,v $
- * Revision 1.62 1995-10-18 17:20:33 adam
+ * Revision 1.63 1995-11-13 09:55:39 adam
+ * Multiple records at a position in a result-set with differnt
+ * element specs.
+ *
+ * Revision 1.62 1995/10/18 17:20:33 adam
* Work on target setup in client.tcl.
*
* Revision 1.61 1995/10/18 16:42:42 adam
int argc, char **argv);
static IrTcl_RecordList *new_IR_record (IrTcl_SetObj *setobj,
- int no, int which)
+ int no, int which,
+ const char *elements)
{
IrTcl_RecordList *rl;
for (rl = setobj->record_list; rl; rl = rl->next)
{
- if (no == rl->no)
+ if (no == rl->no && (!rl->elements || !elements ||
+ !strcmp(elements, rl->elements)))
{
+ free (rl->elements);
switch (rl->which)
{
case Z_NamePlusRecord_databaseRecord:
setobj->record_list = rl;
}
rl->which = which;
+ ir_tcl_strdup (NULL, &rl->elements, elements);
return rl;
}
IrTcl_RecordList *rl;
for (rl = setobj->record_list; rl; rl = rl->next)
- if (no == rl->no)
+ if (no == rl->no &&
+ (!setobj->recordElements || !rl->elements ||
+ !strcmp (setobj->recordElements, rl->elements)))
return rl;
return NULL;
}
delete_IR_records (obj);
return TCL_OK;
}
- if (argc < 3)
+ if (argc != 3)
{
sprintf (interp->result, "wrong # args");
return TCL_ERROR;
{
return TCL_OK;
}
- if (argc < 3)
+ if (argc != 3)
{
sprintf (interp->result, "wrong # args");
return TCL_ERROR;
}
/*
+ * set record elements (for record extraction)
+ */
+static int do_recordElements (void *o, Tcl_Interp *interp,
+ int argc, char **argv)
+{
+ IrTcl_SetObj *obj = o;
+
+ if (argc == 0)
+ {
+ obj->recordElements = NULL;
+ return TCL_OK;
+ }
+ else if (argc == -1)
+ return ir_tcl_strdel (NULL, &obj->recordElements);
+ if (argc > 2)
+ {
+ sprintf (interp->result, "wrong # args");
+ return TCL_ERROR;
+ }
+ if (argc == 2)
+ return ir_tcl_strdup (NULL, &obj->recordElements,
+ (*argv[1] ? argv[1] : NULL));
+ Tcl_AppendResult (interp, obj->recordElements, NULL);
+ return TCL_OK;
+}
+
+/*
* ir_diagResult
*/
static int ir_diagResult (Tcl_Interp *interp, IrTcl_Diagnostic *list, int num)
if (argc <= 0)
return TCL_OK;
- if (argc < 3)
+ if (argc != 3)
{
sprintf (interp->result, "wrong # args");
return TCL_ERROR;
if (argc <= 0)
return TCL_OK;
- if (argc < 3)
+ if (argc != 3)
{
sprintf (interp->result, "wrong # args");
return TCL_ERROR;
if (argc <= 0)
return TCL_OK;
- if (argc < 3)
+ if (argc != 3)
{
interp->result = "wrong # args";
return TCL_ERROR;
{
IrTcl_RecordList *rl;
- rl = new_IR_record (setobj, no, Z_NamePlusRecord_databaseRecord);
+ rl = new_IR_record (setobj, no, Z_NamePlusRecord_databaseRecord, "F");
rl->u.dbrec.type = VAL_USMARC;
rl->u.dbrec.buf = buf;
rl->u.dbrec.size = size;
{ 0, "getSutrs", do_getSutrs },
{ 0, "getGrs", do_getGrs },
{ 0, "recordType", do_recordType },
+ { 0, "recordElements", do_recordElements },
{ 0, "diag", do_diag },
{ 0, "responseStatus", do_responseStatus },
{ 0, "loadFile", do_loadFile },
}
}
-static void ir_handleRecords (void *o, Z_Records *zrs, IrTcl_SetObj *setobj)
+static void ir_handleRecords (void *o, Z_Records *zrs, IrTcl_SetObj *setobj,
+ const char *elements)
{
IrTcl_Obj *p = o;
{
rl = new_IR_record (setobj, setobj->start + offset,
zrs->u.databaseOrSurDiagnostics->
- records[offset]->which);
+ records[offset]->which,
+ elements);
if (rl->which == Z_NamePlusRecord_surrogateDiagnostic)
{
ir_handleDiags (&rl->u.surrogateDiagnostics.list,
logf (LOG_DEBUG, "Search response %d, %d hits",
setobj->searchStatus, setobj->resultCount);
if (zrs)
- ir_handleRecords (o, zrs, setobj);
+ {
+ const char *es;
+ if (setobj->resultCount <= setobj->set_inher.smallSetUpperBound)
+ es = setobj->set_inher.smallSetElementSetNames;
+ else
+ es = setobj->set_inher.mediumSetElementSetNames;
+ ir_handleRecords (o, zrs, setobj, es);
+ }
else
setobj->recordFlag = 0;
}
get_referenceId (&setobj->set_inher.referenceId, presrs->referenceId);
setobj->nextResultSetPosition = *presrs->nextResultSetPosition;
if (zrs)
- ir_handleRecords (o, zrs, setobj);
+ ir_handleRecords (o, zrs, setobj, setobj->set_inher.elementSetNames);
else
{
setobj->recordFlag = 0;