* Sebastian Hammer, Adam Dickmeiss
*
* $Log: ir-tcl.c,v $
- * Revision 1.30 1995-05-26 08:54:11 adam
+ * Revision 1.31 1995-05-26 11:44:10 adam
+ * Bugs fixed. More work on MARC utilities and queries. Test
+ * client is up-to-date again.
+ *
+ * Revision 1.30 1995/05/26 08:54:11 adam
* New MARC utilities. Uses prefix query.
*
* Revision 1.29 1995/05/24 14:10:22 adam
int (*method) (void *obj, Tcl_Interp *interp, int argc, char **argv);
} IRMethod;
+typedef struct {
+ void *obj;
+ IRMethod *tab;
+} IRMethods;
static int do_disconnect (void *obj,Tcl_Interp *interp, int argc, char **argv);
/*
* ir_method: Search for method in table and invoke method handler
*/
-int ir_method (void *obj, Tcl_Interp *interp, int argc, char **argv,
- IRMethod *tab, int sigerr)
+int ir_method (Tcl_Interp *interp, int argc, char **argv, IRMethods *tab)
{
+ IRMethods *tab_i = tab;
IRMethod *t;
- for (t = tab; t->name; t++)
- if (!strcmp (t->name, argv[1]))
- return (*t->method)(obj, interp, argc, argv);
- if (sigerr)
- return TCL_ERROR;
- Tcl_AppendResult (interp, "Bad method. Possible values:", NULL);
- for (t = tab; t->name; t++)
- Tcl_AppendResult (interp, " ", t->name, NULL);
+
+ for (tab_i = tab; tab_i->tab; tab_i++)
+ for (t = tab_i->tab; t->name; t++)
+ if (!strcmp (t->name, argv[1]))
+ return (*t->method)(tab_i->obj, interp, argc, argv);
+
+ Tcl_AppendResult (interp, "Bad method. Possible methods:", NULL);
+ for (tab_i = tab; tab_i->tab; tab_i++)
+ for (t = tab_i->tab; t->name; t++)
+ Tcl_AppendResult (interp, " ", t->name, NULL);
return TCL_ERROR;
+
}
/*
interp->result = "not connected";
return TCL_ERROR;
}
+ odr_reset (p->odr_out);
+
req.referenceId = 0;
req.options = &p->options;
req.protocolVersion = &p->protocolVersion;
auth->which = Z_IdAuthentication_idPass;
auth->u.idPass = pass;
if (p->idAuthenticationGroupId && *p->idAuthenticationGroupId)
- {
- printf ("i");
pass->groupId = p->idAuthenticationGroupId;
- }
else
pass->groupId = NULL;
if (p->idAuthenticationUserId && *p->idAuthenticationUserId)
- {
- printf ("u");
pass->userId = p->idAuthenticationUserId;
- }
else
pass->userId = NULL;
if (p->idAuthenticationPassword && *p->idAuthenticationPassword)
- {
- printf ("p");
pass->password = p->idAuthenticationPassword;
- }
else
pass->password = NULL;
req.idAuthentication = auth;
else if (r == 1)
{
ir_select_add_write (cs_fileno(p->cs_link), p);
- printf("Sent part of initializeRequest (%d bytes).\n", p->slen);
+ logf (LOG_DEBUG, "Sent part of initializeRequest (%d bytes)", p->slen);
}
else
- printf("Sent whole initializeRequest (%d bytes).\n", p->slen);
+ logf (LOG_DEBUG, "Sent whole initializeRequest (%d bytes)", p->slen);
return TCL_OK;
}
interp->result = "tcpip_strtoaddr fail";
return TCL_ERROR;
}
- printf ("tcp/ip connect %s\n", argv[2]);
+ logf (LOG_DEBUG, "tcp/ip connect %s", argv[2]);
}
#if MOSI
else if (!strcmp (p->cs_type, "mosi"))
interp->result = "mosi_strtoaddr fail";
return TCL_ERROR;
}
- printf ("mosi connect %s\n", argv[2]);
+ logf (LOG_DEBUG, "mosi connect %s", argv[2]);
}
#endif
else
};
static IRMethod ir_set_c_method_tab[] = {
-{ 0, "databaseNames", do_databaseNames},
-{ 0, "replaceIndicator", do_replaceIndicator},
-{ 0, "queryType", do_queryType },
-{ 0, "smallSetUpperBound", do_smallSetUpperBound},
-{ 0, "largeSetLowerBound", do_largeSetLowerBound},
-{ 0, "mediumSetPresentNumber", do_mediumSetPresentNumber},
+{ 0, "databaseNames", do_databaseNames},
+{ 0, "replaceIndicator", do_replaceIndicator},
+{ 0, "queryType", do_queryType },
+{ 0, "smallSetUpperBound", do_smallSetUpperBound},
+{ 0, "largeSetLowerBound", do_largeSetLowerBound},
+{ 0, "mediumSetPresentNumber", do_mediumSetPresentNumber},
{ 0, NULL, NULL}
};
static int ir_obj_method (ClientData clientData, Tcl_Interp *interp,
int argc, char **argv)
{
+ IRMethods tab[3];
+ IRObj *p = clientData;
+
if (argc < 2)
return ir_method_r (clientData, interp, argc, argv, ir_method_tab);
- if (ir_method (clientData, interp, argc, argv,
- ir_method_tab, 1) == TCL_OK)
- return TCL_OK;
- return ir_method (&((IRObj*) clientData)->set_inher, interp,
- argc, argv, ir_set_c_method_tab, 0);
+
+ tab[0].tab = ir_method_tab;
+ tab[0].obj = p;
+ tab[1].tab = ir_set_c_method_tab;
+ tab[1].obj = &p->set_inher;
+ tab[2].tab = NULL;
+
+ return ir_method (interp, argc, argv, tab);
}
/*
interp->result = "not connected";
return TCL_ERROR;
}
+ odr_reset (p->odr_out);
apdu.which = Z_APDU_searchRequest;
apdu.u.searchRequest = &req;
req.mediumSetPresentNumber = &p->set_inher.mediumSetPresentNumber;
req.replaceIndicator = &p->set_inher.replaceIndicator;
req.resultSetName = obj->setName ? obj->setName : "Default";
+ logf (LOG_DEBUG, "Search, resultSetName %s", req.resultSetName);
req.num_databaseNames = p->set_inher.num_databaseNames;
req.databaseNames = p->set_inher.databaseNames;
- printf ("Search:");
for (r=0; r < p->set_inher.num_databaseNames; r++)
- printf (" %s", p->set_inher.databaseNames[r]);
+ logf (LOG_DEBUG, " Database %s", p->set_inher.databaseNames[r]);
req.smallSetElementSetNames = 0;
req.mediumSetElementSetNames = 0;
req.preferredRecordSyntax = 0;
RPNquery->attributeSetId = oid_getoidbyent (&p->bib1);
query.which = Z_Query_type_1;
query.u.type_1 = RPNquery;
- printf ("- RPN\n");
+ logf (LOG_DEBUG, "RPN");
}
#if CCL2RPN
else if (!strcmp (p->set_inher.queryType, "cclrpn"))
RPNquery->attributeSetId = oid_getoidbyent (&p->bib1);
query.which = Z_Query_type_1;
query.u.type_1 = RPNquery;
- printf ("- CCLRPN\n");
+ logf (LOG_DEBUG, "CCLRPN");
}
#endif
else if (!strcmp (p->set_inher.queryType, "ccl"))
query.u.type_2 = &ccl_query;
ccl_query.buf = (unsigned char *) argv[2];
ccl_query.len = strlen (argv[2]);
- printf ("- CCL\n");
+ logf (LOG_DEBUG, "CCL");
}
else
{
else if (r == 1)
{
ir_select_add_write (cs_fileno(p->cs_link), p);
- printf("Sent part of searchRequest (%d bytes).\n", p->slen);
+ logf (LOG_DEBUG, "Sent part of searchRequest (%d bytes)", p->slen);
}
else
{
- printf ("Whole search request\n");
+ logf (LOG_DEBUG, "Whole search request (%d bytes)", p->slen);
}
return TCL_OK;
}
}
/*
+ * do_presentStatus: Get search status (after search/present response)
+ */
+static int do_presentStatus (void *o, Tcl_Interp *interp,
+ int argc, char **argv)
+{
+ IRSetObj *obj = o;
+
+ return get_set_int (&obj->presentStatus, interp, argc, argv);
+}
+
+/*
+ * do_nextResultSetPosition: Get next result set position
+ * (after search/present response)
+ */
+static int do_nextResultSetPosition (void *o, Tcl_Interp *interp,
+ int argc, char **argv)
+{
+ IRSetObj *obj = o;
+
+ return get_set_int (&obj->nextResultSetPosition, interp, argc, argv);
+}
+
+/*
* do_setName: Set result Set name
*/
static int do_setName (void *o, Tcl_Interp *interp,
return get_set_int (&obj->numberOfRecordsReturned, interp, argc, argv);
}
-#if 0
-static int get_marc_fields(Tcl_Interp *interp, Iso2709Rec rec,
- int argc, char **argv)
-{
- Iso2709Anchor a;
- char *data;
-
- if (!rec)
- return TCL_OK;
- a = iso2709_a_mk (rec);
- while (iso2709_a_search (a, argv[4], argv[5], argv[6]))
- {
- if (!(iso2709_a_info_field (a, NULL, NULL, NULL, &data)))
- break;
- Tcl_AppendElement (interp, data);
- iso2709_a_next (a);
- }
-
- iso2709_a_rm (a);
- return TCL_OK;
-}
-#endif
-
-#if 0
-static int get_marc_lines(Tcl_Interp *interp, Iso2709Rec rec,
- int argc, char **argv)
-{
- Iso2709Anchor a;
- char *tag;
- char *indicator;
- char *identifier;
- char *data;
- char *ptag = "";
-
- if (!rec)
- return TCL_OK;
- a = iso2709_a_mk (rec);
- while (iso2709_a_search (a, argv[4], argv[5], argv[6]))
- {
- if (!(iso2709_a_info_field (a, &tag, &indicator, &identifier, &data)))
- break;
- if (strcmp (tag, ptag))
- {
- if (*ptag)
- Tcl_AppendResult (interp, "}} ", NULL);
- if (!indicator)
- Tcl_AppendResult (interp, "{", tag, " {} {", NULL);
- else
- Tcl_AppendResult (interp, "{", tag, " {", indicator,
- "} {", NULL);
- ptag = tag;
- }
- if (!identifier)
- Tcl_AppendResult (interp, "{{}", NULL);
- else
- Tcl_AppendResult (interp, "{", identifier, NULL);
- Tcl_AppendElement (interp, data);
- Tcl_AppendResult (interp, "} ", NULL);
- iso2709_a_next (a);
- }
- if (*ptag)
- Tcl_AppendResult (interp, "}} ", NULL);
- iso2709_a_rm (a);
- return TCL_OK;
-}
-#endif
-
/*
* do_recordType: Return record type (if any) at position.
*/
interp->result = "not connected";
return TCL_ERROR;
}
+ odr_reset (p->odr_out);
obj->start = start;
obj->number = number;
else if (r == 1)
{
ir_select_add_write (cs_fileno(p->cs_link), p);
- printf ("Part of present request, start=%d, num=%d (%d bytes)\n",
- start, number, p->slen);
+ logf (LOG_DEBUG, "Part of present request, start=%d, num=%d"
+ " (%d bytes)", start, number, p->slen);
}
else
{
- printf ("Whole present request, start=%d, num=%d (%d bytes)\n",
- start, number, p->slen);
+ logf (LOG_DEBUG, "Whole present request, start=%d, num=%d"
+ " (%d bytes)", start, number, p->slen);
}
return TCL_OK;
}
static IRMethod tab[] = {
{ 0, "search", do_search },
{ 0, "searchStatus", do_searchStatus },
+ { 0, "presentStatus", do_presentStatus },
+ { 0, "nextResultSetPosition", do_nextResultSetPosition },
{ 0, "setName", do_setName },
{ 0, "resultCount", do_resultCount },
{ 0, "numberOfRecordsReturned", do_numberOfRecordsReturned },
{ 0, "present", do_present },
{ 0, "recordType", do_recordType },
{ 0, "getMarc", do_getMarc },
- { 0, "recordDiag", do_recordDiag },
+ { 0, "Diag", do_recordDiag },
{ 0, "responseStatus", do_responseStatus },
{ 0, "loadFile", do_loadFile },
{ 0, NULL, NULL}
};
+ IRMethods tabs[3];
+ IRSetObj *p = clientData;
if (argc < 2)
{
interp->result = "wrong # args";
return TCL_ERROR;
}
- if (ir_method (clientData, interp, argc, argv, tab, 1) == TCL_OK)
- return TCL_OK;
- return ir_method (&((IRSetObj *)clientData)->set_inher, interp, argc,
- argv, ir_set_c_method_tab, 0);
+ tabs[0].tab = tab;
+ tabs[0].obj = p;
+ tabs[1].tab = ir_set_c_method_tab;
+ tabs[1].obj = &p->set_inher;
+ tabs[2].tab = NULL;
+
+ return ir_method (interp, argc, argv, tabs);
}
/*
return TCL_ERROR;
for (i = 0; i < dst->num_databaseNames; i++)
{
- printf ("database %i %s\n", i, src->databaseNames[i]);
if (ir_strdup (interp, &dst->databaseNames[i],
src->databaseNames[i]) == TCL_ERROR)
return TCL_ERROR;
dst->smallSetUpperBound = src->smallSetUpperBound;
dst->largeSetLowerBound = src->largeSetLowerBound;
dst->mediumSetPresentNumber = src->mediumSetPresentNumber;
- printf ("ssu lsl msp %d %d %d\n", dst->smallSetUpperBound,
- dst->largeSetLowerBound, dst->mediumSetPresentNumber);
}
else
obj->parent = NULL;
interp->result = "not connected";
return TCL_ERROR;
}
+ odr_reset (p->odr_out);
apdu.which = Z_APDU_scanRequest;
apdu.u.scanRequest = &req;
req.referenceId = NULL;
req.stepSize = &obj->stepSize;
req.numberOfTermsRequested = &obj->numberOfTermsRequested;
req.preferredPositionInResponse = &obj->preferredPositionInResponse;
- printf ("stepSize=%d\n", *req.stepSize);
- printf ("numberOfTermsRequested=%d\n", *req.numberOfTermsRequested);
- printf ("preferredPositionInResponse=%d\n",
- *req.preferredPositionInResponse);
+ logf (LOG_DEBUG, "stepSize=%d", *req.stepSize);
+ logf (LOG_DEBUG, "numberOfTermsRequested=%d",
+ *req.numberOfTermsRequested);
+ logf (LOG_DEBUG, "preferredPositionInResponse=%d",
+ *req.preferredPositionInResponse);
if (!z_APDU (p->odr_out, &apdup, 0))
{
else if (r == 1)
{
ir_select_add_write (cs_fileno(p->cs_link), p);
- printf("Sent part of scanRequest (%d bytes).\n", p->slen);
+ logf (LOG_DEBUG, "Sent part of scanRequest (%d bytes)", p->slen);
}
else
{
- printf ("Whole scan request\n");
+ logf (LOG_DEBUG, "Whole scan request (%d bytes)", p->slen);
}
return TCL_OK;
}
{ 0, "scanLine", do_scanLine },
{ 0, NULL, NULL}
};
+ IRMethods tabs[3];
if (argc < 2)
{
interp->result = "wrong # args";
return TCL_ERROR;
}
- return ir_method (clientData, interp, argc, argv, tab, 0);
+
+ tabs[0].tab = tab;
+ tabs[0].obj = clientData;
+ tabs[1].tab = NULL;
+
+ return ir_method (interp, argc, argv, tabs);
}
/*
p->initResult = *initrs->result ? 1 : 0;
if (!*initrs->result)
- printf("Connection rejected by target.\n");
+ logf (LOG_DEBUG, "Connection rejected by target");
else
- printf("Connection accepted by target.\n");
+ logf (LOG_DEBUG, "Connection accepted by target");
free (p->targetImplementationId);
ir_strdup (p->interp, &p->targetImplementationId,
addinfo = zrs->u.nonSurrogateDiagnostic->addinfo;
if (addinfo && (setobj->addinfo = malloc (strlen(addinfo) + 1)))
strcpy (setobj->addinfo, addinfo);
- printf ("Diagnostic response. %s (%d): %s\n",
- diagbib1_str (setobj->condition),
- setobj->condition,
- setobj->addinfo ? setobj->addinfo : "");
+ logf (LOG_DEBUG, "Diagnostic response. %s (%d): %s",
+ diagbib1_str (setobj->condition),
+ setobj->condition,
+ setobj->addinfo ? setobj->addinfo : "");
}
else
{
setobj->numberOfRecordsReturned =
zrs->u.databaseOrSurDiagnostics->num_records;
- printf ("Got %d records\n", setobj->numberOfRecordsReturned);
+ logf (LOG_DEBUG, "Got %d records", setobj->numberOfRecordsReturned);
for (offset = 0; offset<setobj->numberOfRecordsReturned; offset++)
{
rl = new_IR_record (setobj, setobj->start + offset,
{
setobj->searchStatus = searchrs->searchStatus ? 1 : 0;
setobj->resultCount = *searchrs->resultCount;
- printf ("Search response %d, %d hits\n",
- setobj->searchStatus, setobj->resultCount);
+ if (searchrs->presentStatus)
+ setobj->presentStatus = *searchrs->presentStatus;
+ if (searchrs->nextResultSetPosition)
+ setobj->nextResultSetPosition = *searchrs->nextResultSetPosition;
+
+ logf (LOG_DEBUG, "Search response %d, %d hits",
+ setobj->searchStatus, setobj->resultCount);
if (zrs)
ir_handleRecords (o, zrs);
else
setobj->recordFlag = 0;
}
else
- printf ("Search response, no object!\n");
+ logf (LOG_DEBUG, "Search response, no object!");
}
IRSetObj *setobj = p->set_child;
Z_Records *zrs = presrs->records;
- printf ("Received presentResponse\n");
+ logf (LOG_DEBUG, "Received presentResponse");
+ setobj->presentStatus = *presrs->presentStatus;
+ setobj->nextResultSetPosition = *presrs->nextResultSetPosition;
if (zrs)
ir_handleRecords (o, zrs);
else
{
setobj->recordFlag = 0;
- printf ("No records!\n");
+ logf (LOG_DEBUG, "No records!");
}
}
IRObj *p = o;
IRScanObj *scanobj = p->scan_child;
- printf ("Received scanResponse\n");
+ logf (LOG_DEBUG, "Received scanResponse");
scanobj->scanStatus = *scanrs->scanStatus;
- printf ("scanStatus=%d\n", scanobj->scanStatus);
+ logf (LOG_DEBUG, "scanStatus=%d", scanobj->scanStatus);
if (scanrs->stepSize)
scanobj->stepSize = *scanrs->stepSize;
- printf ("stepSize=%d\n", scanobj->stepSize);
+ logf (LOG_DEBUG, "stepSize=%d", scanobj->stepSize);
scanobj->numberOfEntriesReturned = *scanrs->numberOfEntriesReturned;
- printf ("numberOfEntriesReturned=%d\n", scanobj->numberOfEntriesReturned);
+ logf (LOG_DEBUG, "numberOfEntriesReturned=%d",
+ scanobj->numberOfEntriesReturned);
if (scanrs->positionOfTerm)
scanobj->positionOfTerm = *scanrs->positionOfTerm;
else
scanobj->positionOfTerm = -1;
- printf ("positionOfTerm=%d\n", scanobj->positionOfTerm);
+ logf (LOG_DEBUG, "positionOfTerm=%d", scanobj->positionOfTerm);
free (scanobj->entries);
scanobj->entries = NULL;
ir_select_remove_write (cs_fileno (p->cs_link), p);
if (r < 0)
{
- printf ("cs_rcvconnect error\n");
+ logf (LOG_DEBUG, "cs_rcvconnect error");
if (p->failback)
Tcl_Eval (p->interp, p->failback);
do_disconnect (p, NULL, 0, NULL);
}
do
{
- if ((r=cs_get (p->cs_link, &p->buf_in, &p->len_in)) <= 0)
+ if ((r=cs_get (p->cs_link, &p->buf_in, &p->len_in)) <= 0)
{
- printf ("cs_get failed\n");
+ logf (LOG_DEBUG, "cs_get failed, code %d", r);
ir_select_remove (cs_fileno (p->cs_link), p);
if (p->failback)
Tcl_Eval (p->interp, p->failback);
if (r == 1)
return ;
odr_setbuf (p->odr_in, p->buf_in, r, 0);
- printf ("cs_get ok, got %d\n", r);
+ logf (LOG_DEBUG, "cs_get ok, got %d", r);
if (!z_APDU (p->odr_in, &apdu, 0))
{
- printf ("%s\n", odr_errlist [odr_geterror (p->odr_in)]);
+ logf (LOG_DEBUG, "%s", odr_errlist [odr_geterror (p->odr_in)]);
if (p->failback)
Tcl_Eval (p->interp, p->failback);
do_disconnect (p, NULL, 0, NULL);
ir_scanResponse (p, apdu->u.scanResponse);
break;
default:
- printf("Received unknown APDU type (%d).\n",
- apdu->which);
+ logf (LOG_WARN, "Received unknown APDU type (%d)", apdu->which);
if (p->failback)
Tcl_Eval (p->interp, p->failback);
do_disconnect (p, NULL, 0, NULL);
}
+ odr_reset (p->odr_in);
if (p->callback)
Tcl_Eval (p->interp, p->callback);
- } while (cs_more (p->cs_link));
+ } while (p->cs_link && cs_more (p->cs_link));
}
/*
IRObj *p = clientData;
int r;
- printf ("In write handler.....\n");
+ logf (LOG_DEBUG, "In write handler");
if (p->connectFlag)
{
r = cs_rcvconnect (p->cs_link);
p->connectFlag = 0;
if (r < 0)
{
- printf ("cs_rcvconnect error\n");
+ logf (LOG_DEBUG, "cs_rcvconnect error");
ir_select_remove_write (cs_fileno (p->cs_link), p);
if (p->failback)
Tcl_Eval (p->interp, p->failback);
}
if ((r=cs_put (p->cs_link, p->sbuf, p->slen)) < 0)
{
- printf ("select write fail\n");
+ logf (LOG_DEBUG, "select write fail");
if (p->failback)
Tcl_Eval (p->interp, p->failback);
do_disconnect (p, NULL, 0, NULL);
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: marc.c,v $
- * Revision 1.1 1995-05-26 08:54:19 adam
+ * Revision 1.2 1995-05-26 11:44:11 adam
+ * Bugs fixed. More work on MARC utilities and queries. Test
+ * client is up-to-date again.
+ *
+ * Revision 1.1 1995/05/26 08:54:19 adam
* New MARC utilities. Uses prefix query.
*
*/
int length_data_entry;
int length_starting;
int length_implementation;
+ char ptag[4];
int mode = 0;
+ *ptag = '\0';
if (!strcmp (argv[3], "field"))
mode = 'f';
- else if (!strcmp (argv[3], "lines"))
+ else if (!strcmp (argv[3], "lines") || !strcmp (argv[3], "list"))
mode = 'l';
else
{
continue;
while (buf[i] != ISO2709_RS && buf[i] != ISO2709_FS && i < end_offset)
{
+ int i0;
+
if (memcmp (tag, "00", 2) && identifier_length)
{
- int i0;
i++;
for (j = 1; j<identifier_length; j++)
identifier[j-1] = buf[i++];
buf[i] != ISO2709_FS && i < end_offset;
i++)
;
- if (marc_compare (identifier, argv[6])==0)
- {
- char *data = malloc (i-i0+1);
-
- memcpy (data, buf+i0, i-i0);
- data[i-i0] = '\0';
- Tcl_AppendElement (interp, data);
- free (data);
- }
}
else
{
- int i0;
-
for (i0 = i; buf[i] != ISO2709_RS &&
buf[i] != ISO2709_FS && i < end_offset;
i++)
;
- if (marc_compare (NULL, argv[6])==0)
- {
- char *data = malloc (i-i0+1);
-
- memcpy (data, buf+i0, i-i0);
- data[i-i0] = '\0';
- Tcl_AppendElement (interp, data);
- free (data);
- }
-
+ *identifier = '\0';
}
+ if (marc_compare (identifier, argv[6])==0)
+ {
+ char *data = malloc (i-i0+1);
+
+ memcpy (data, buf+i0, i-i0);
+ data[i-i0] = '\0';
+ if (mode == 'l')
+ {
+ if (strcmp (tag, ptag))
+ {
+ if (*ptag)
+ Tcl_AppendResult (interp, "}} ", NULL);
+ if (!*indicator)
+ Tcl_AppendResult (interp, "{", tag, " {} {", NULL);
+ else
+ Tcl_AppendResult (interp, "{", tag, " {",
+ indicator, "} {", NULL);
+ strcpy (ptag, tag);
+ }
+ if (!*identifier)
+ Tcl_AppendResult (interp, "{{}", NULL);
+ else
+ Tcl_AppendResult (interp, "{", identifier, NULL);
+ Tcl_AppendElement (interp, data);
+ Tcl_AppendResult (interp, "} ", NULL);
+ }
+ else
+ Tcl_AppendElement (interp, data);
+ free (data);
+ }
}
if (i < end_offset)
- fprintf (outf, "-- separator but not at end of field\n");
+ logf (LOG_WARN, "MARC: separator but not at end of field");
if (buf[i] != ISO2709_RS && buf[i] != ISO2709_FS)
- fprintf (outf, "-- no separator at end of field\n");
+ logf (LOG_WARN, "MARC: no separator at end of field");
}
+ if (mode == 'l' && *ptag)
+ Tcl_AppendResult (interp, "}} ", NULL);
return TCL_OK;
}
-#if 0
-int ir_tcl_get_marc_fields(Tcl_Interp *interp, const char *buf,
- size_t size, int argc, char **argv)
-{
- Iso2709Anchor a;
- char *data;
- if (!rec)
- return TCL_OK;
- a = iso2709_a_mk (rec);
- while (iso2709_a_search (a, argv[4], argv[5], argv[6]))
- {
- if (!(iso2709_a_info_field (a, NULL, NULL, NULL, &data)))
- break;
- Tcl_AppendElement (interp, data);
- iso2709_a_next (a);
- }
- iso2709_a_rm (a);
- return TCL_OK;
-}
-int ir_tcl_get_marc_lines(Tcl_Interp *interp, const char *buf,
- size_t size, int argc, char **argv)
-{
- Iso2709Anchor a;
- char *tag;
- char *indicator;
- char *identifier;
- char *data;
- char *ptag = "";
-
- if (!rec)
- return TCL_OK;
- a = iso2709_a_mk (rec);
- while (iso2709_a_search (a, argv[4], argv[5], argv[6]))
- {
- if (!(iso2709_a_info_field (a, &tag, &indicator, &identifier, &data)))
- break;
- if (strcmp (tag, ptag))
- {
- if (*ptag)
- Tcl_AppendResult (interp, "}} ", NULL);
- if (!indicator)
- Tcl_AppendResult (interp, "{", tag, " {} {", NULL);
- else
- Tcl_AppendResult (interp, "{", tag, " {", indicator,
- "} {", NULL);
- ptag = tag;
- }
- if (!identifier)
- Tcl_AppendResult (interp, "{{}", NULL);
- else
- Tcl_AppendResult (interp, "{", identifier, NULL);
- Tcl_AppendElement (interp, data);
- Tcl_AppendResult (interp, "} ", NULL);
- iso2709_a_next (a);
- }
- if (*ptag)
- Tcl_AppendResult (interp, "}} ", NULL);
- iso2709_a_rm (a);
- return TCL_OK;
-}
-#endif