X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=ir-tcl.c;h=9b4ee5c20e39476407ab2f9d8f96457f6f809ebb;hb=d026c3e06f6e19e5ed4174ab1a504a4b5af79183;hp=881f428f41def022b41b9b92da030e9de9578229;hpb=4feb282a09768af26b52f81ce88e0016f33fe88c;p=ir-tcl-moved-to-github.git diff --git a/ir-tcl.c b/ir-tcl.c index 881f428..9b4ee5c 100644 --- a/ir-tcl.c +++ b/ir-tcl.c @@ -4,7 +4,19 @@ * See the file LICENSE for details. * * $Log: ir-tcl.c,v $ - * Revision 1.124 2003-03-05 22:02:47 adam + * Revision 1.128 2005-03-10 13:54:56 adam + * Remove CCL support for scan + * + * Revision 1.127 2004/05/10 08:38:45 adam + * Do not use obsolete YAZ defines + * + * Revision 1.126 2003/11/29 17:24:09 adam + * Added getXml method (Franck Falcoz) + * + * Revision 1.125 2003/04/29 10:51:23 adam + * Null terminate octet aligned records + * + * Revision 1.124 2003/03/05 22:02:47 adam * Add Tcl_InitStubs * * Revision 1.123 2003/03/05 21:21:41 adam @@ -1576,7 +1588,7 @@ static int do_triggerResourceControl (void *obj, Tcl_Interp *interp, } apdu = zget_APDU (p->odr_out, Z_APDU_triggerResourceControlRequest); req = apdu->u.triggerResourceControlRequest; - *req->requestedAction = Z_TriggerResourceCtrl_cancel; + *req->requestedAction = Z_TriggerResourceControlRequest_cancel; req->resultSetWanted = &is_false; return ir_tcl_send_APDU (interp, p, apdu, "triggerResourceControl", @@ -2430,16 +2442,16 @@ static int do_sortStatus (void *o, Tcl_Interp *interp, if (argc <= 0) { - obj->sortStatus = Z_SortStatus_failure; + obj->sortStatus = Z_SortResponse_failure; return TCL_OK; } switch (obj->sortStatus) { - case Z_SortStatus_success: + case Z_SortResponse_success: res = "success"; break; - case Z_SortStatus_partial_1: + case Z_SortResponse_partial_1: res = "partial"; break; - case Z_SortStatus_failure: + case Z_SortResponse_failure: res = "failure"; break; default: res = "unknown"; break; @@ -2753,6 +2765,41 @@ static int do_getSutrs (void *o, Tcl_Interp *interp, int argc, char **argv) return TCL_OK; } +/* + * do_getXml: Get XML Record + */ +static int do_getXml (void *o, Tcl_Interp *interp, int argc, char **argv) +{ + IrTcl_SetObj *obj = o; + int offset; + IrTcl_RecordList *rl; + + if (argc <= 0) + return TCL_OK; + if (argc != 3) + { + Tcl_AppendResult (interp, wrongArgs, *argv, " ", argv[1], + " position\"", NULL); + return TCL_ERROR; + } + if (Tcl_GetInt (interp, argv[2], &offset)==TCL_ERROR) + return TCL_ERROR; + rl = find_IR_record (obj, offset); + if (!rl) + { + Tcl_AppendResult (interp, "No record at #", argv[2], NULL); + return TCL_ERROR; + } + if (rl->which != Z_NamePlusRecord_databaseRecord) + { + Tcl_AppendResult (interp, "No DB record at #", argv[2], NULL); + return TCL_ERROR; + } + if (!rl->u.dbrec.buf || rl->u.dbrec.type != VAL_TEXT_XML) + return TCL_OK; + Tcl_AppendElement (interp, rl->u.dbrec.buf); + return TCL_OK; +} /* * do_getGrs: Get a GRS-1 Record @@ -3241,10 +3288,10 @@ static int do_sort (void *o, Tcl_Interp *interp, int argc, char **argv) } sks->sortRelation = (int *) odr_malloc (p->odr_out, sizeof(*sks->sortRelation)); - *sks->sortRelation = Z_SortRelation_ascending; + *sks->sortRelation = Z_SortKeySpec_ascending; sks->caseSensitivity = (int *) odr_malloc (p->odr_out, sizeof(*sks->caseSensitivity)); - *sks->caseSensitivity = Z_SortCase_caseSensitive; + *sks->caseSensitivity = Z_SortKeySpec_caseSensitive; #ifdef ASN_COMPILED sks->which = Z_SortKeySpec_null; @@ -3260,20 +3307,20 @@ static int do_sort (void *o, Tcl_Interp *interp, int argc, char **argv) case 'a': case 'A': case '>': - *sks->sortRelation = Z_SortRelation_descending; + *sks->sortRelation = Z_SortKeySpec_descending; break; case 'd': case 'D': case '<': - *sks->sortRelation = Z_SortRelation_ascending; + *sks->sortRelation = Z_SortKeySpec_ascending; break; case 'i': case 'I': - *sks->caseSensitivity = Z_SortCase_caseInsensitive; + *sks->caseSensitivity = Z_SortKeySpec_caseInsensitive; break; case 'S': case 's': - *sks->caseSensitivity = Z_SortCase_caseSensitive; + *sks->caseSensitivity = Z_SortKeySpec_caseSensitive; break; } } @@ -3300,6 +3347,7 @@ static IrTcl_Method ir_set_method_tab[] = { { "type", do_type, NULL}, { "getMarc", do_getMarc, NULL}, { "getSutrs", do_getSutrs, NULL}, + { "getXml", do_getXml, NULL}, { "getGrs", do_getGrs, NULL}, { "getExplain", do_getExplain, NULL}, { "recordType", do_recordType, NULL}, @@ -3543,8 +3591,6 @@ static int do_scan (void *o, Tcl_Interp *interp, int argc, char **argv) req->num_databaseNames = p->set_inher.num_databaseNames; req->databaseNames = p->set_inher.databaseNames; -#if 1 -/* !CCL2RPN */ if (!(req->termListAndStartPoint = p_query_scan (p->odr_out, p->protocol_type, &req->attributeSet, start_term))) @@ -3553,25 +3599,6 @@ static int do_scan (void *o, Tcl_Interp *interp, int argc, char **argv) code = ir_tcl_error_exec (interp, argc, argv); goto out; } -#else - rpn = ccl_find_str(p->bibset, start_term, &r, &pos); - if (r) - { - Tcl_AppendResult (interp, "ccl syntax error ", ccl_err_msg(r), NULL); - code = ir_tcl_error_exec (interp, argc, argv); - goto out; - } - bib1.proto = p->protocol_type; - bib1.oclass = CLASS_ATTSET; - bib1.value = VAL_BIB1; - - req->attributeSet = oid_getoidbyent (&bib1); - if (!(req->termListAndStartPoint = ccl_scan_query (p->odr_out, rpn))) - { - code = TCL_ERROR; - goto out; - } -#endif req->stepSize = &obj->stepSize; req->numberOfTermsRequested = &obj->numberOfTermsRequested; req->preferredPositionInResponse = &obj->preferredPositionInResponse; @@ -4075,8 +4102,11 @@ static void ir_handleDBRecord (IrTcl_Obj *p, IrTcl_RecordList *rl, if (oe->which == Z_External_octet && rl->u.dbrec.size > 0) { char *buf = (char*) oe->u.octet_aligned->buf; - if ((rl->u.dbrec.buf = ir_tcl_malloc (rl->u.dbrec.size))) + if ((rl->u.dbrec.buf = ir_tcl_malloc (rl->u.dbrec.size+1))) + { memcpy (rl->u.dbrec.buf, buf, rl->u.dbrec.size); + rl->u.dbrec.buf[rl->u.dbrec.size] = '\0'; + } } else if (rl->u.dbrec.type == VAL_SUTRS && oe->which == Z_External_sutrs) @@ -4254,7 +4284,7 @@ static void ir_searchResponse (void *o, Z_SearchResponse *searchrs, if (searchrs->presentStatus) setobj->presentStatus = *searchrs->presentStatus; else - setobj->presentStatus = Z_RES_NONE; + setobj->presentStatus = Z_SearchResponse_none; if (searchrs->nextResultSetPosition) setobj->nextResultSetPosition = *searchrs->nextResultSetPosition;