From: Adam Dickmeiss Date: Wed, 29 May 1996 06:37:40 +0000 (+0000) Subject: Function ir_tcl_get_grs_r enhanced so that specific elements can be X-Git-Tag: IRTCL.1.4~125 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=bc6bd3345159c5d9619098bb96327f2d87fad667;p=ir-tcl-moved-to-github.git Function ir_tcl_get_grs_r enhanced so that specific elements can be extracted. --- diff --git a/CHANGELOG b/CHANGELOG index d9ae8fa..3bd8b44 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -$Id: CHANGELOG,v 1.15 1996-02-05 17:58:02 adam Exp $ +$Id: CHANGELOG,v 1.16 1996-05-29 06:37:40 adam Exp $ 06/19/95 Release of ir-tcl-1.0b ------------------------------------------------------ @@ -80,4 +80,10 @@ $Id: CHANGELOG,v 1.15 1996-02-05 17:58:02 adam Exp $ 05/02/96 Ported ir-tcl to Tcl7.5b1/tk4.1b1. Ir-tcl is now incompatible with the alpha versions of tcl7.5/tk4.1. +20/02/96 Identification of record syntaxes, etc. are handled by the YAZ + oid utilities. + +29/05/96 Set function getGrs enhanced so that specific elements can be + extracted by . - pairs. + diff --git a/grs.c b/grs.c index a85ebb7..c58d7c6 100644 --- a/grs.c +++ b/grs.c @@ -5,7 +5,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: grs.c,v $ - * Revision 1.3 1996-03-05 09:21:01 adam + * Revision 1.4 1996-05-29 06:37:42 adam + * Function ir_tcl_get_grs_r enhanced so that specific elements can be + * extracted. + * + * Revision 1.3 1996/03/05 09:21:01 adam * Bug fix: memory used by GRS records wasn't freed. * Rewrote some of the error handling code - the connection is always * closed before failback is called. @@ -159,74 +163,101 @@ static int ir_tcl_get_grs_r (Tcl_Interp *interp, IrTcl_GRS_Record *grs_record, int i; struct GRS_Record_entry *e = grs_record->entries; - if (argno >= argc) + for (i = 0; inoTags; i++, e++) { - for (i = 0; inoTags; i++, e++) + int yes = 0; + if (argno >= argc) + yes = 1; + else { + const char *cp0 = argv[argno]; + const char *cp1 = strchr (cp0, '.'); - Tcl_AppendResult (interp, "{ ", NULL); - sprintf (tmpbuf, "%d", e->tagType); - Tcl_AppendElement (interp, tmpbuf); - - if (e->tagWhich == Z_StringOrNumeric_numeric) - { - Tcl_AppendResult (interp, " numeric ", NULL); - sprintf (tmpbuf, "%d", e->tagVal.num); - Tcl_AppendElement (interp, tmpbuf); - } + if (!cp1 || cp1-cp0 < 1) + yes = 1; else { - Tcl_AppendResult (interp, " string ", NULL); - Tcl_AppendElement (interp, e->tagVal.str); - } - switch (e->dataWhich) - { - case Z_ElementData_octets: - Tcl_AppendResult (interp, " octets {} ", NULL); - break; - case Z_ElementData_numeric: - Tcl_AppendResult (interp, " numeric {} ", NULL); - break; - case Z_ElementData_date: - Tcl_AppendResult (interp, " date {} ", NULL); - break; - case Z_ElementData_ext: - Tcl_AppendResult (interp, " ext {} ", NULL); - break; - case Z_ElementData_string: - Tcl_AppendResult (interp, " string ", NULL); - Tcl_AppendElement (interp, e->tagData.str ); - break; - case Z_ElementData_trueOrFalse: - Tcl_AppendResult (interp, " bool ", - e->tagData.bool ? "1" : "0", " ", NULL); - break; - case Z_ElementData_oid: - Tcl_AppendResult (interp, " oid {} ", NULL); - break; - case Z_ElementData_intUnit: - Tcl_AppendResult (interp, " intUnit {} ", NULL); - break; - case Z_ElementData_elementNotThere: - Tcl_AppendResult (interp, " notThere {} ", NULL); - break; - case Z_ElementData_elementEmpty: - Tcl_AppendResult (interp, " empty {} ", NULL); - break; - case Z_ElementData_noDataRequested: - Tcl_AppendResult (interp, " notRequested {} ", NULL); - break; - case Z_ElementData_diagnostic: - Tcl_AppendResult (interp, " diagnostic {} ", NULL); - break; - case Z_ElementData_subtree: - Tcl_AppendResult (interp, " subtree { ", NULL); - ir_tcl_get_grs_r (interp, e->tagData.sub, argc, argv, argno+1); - Tcl_AppendResult (interp, " } ", NULL); - break; + if (atoi(cp0) == e->tagType) + { + if (e->tagWhich == Z_StringOrNumeric_numeric) + { + if (atoi (cp1+1) == e->tagVal.num) + yes = 1; + } + else + { + if (!strcmp (cp1+1, e->tagVal.str)) + yes = 1; + } + } } + } + if (!yes) + continue; + Tcl_AppendResult (interp, "{ ", NULL); + sprintf (tmpbuf, "%d", e->tagType); + Tcl_AppendElement (interp, tmpbuf); + + if (e->tagWhich == Z_StringOrNumeric_numeric) + { + Tcl_AppendResult (interp, " numeric ", NULL); + sprintf (tmpbuf, "%d", e->tagVal.num); + Tcl_AppendElement (interp, tmpbuf); + } + else + { + Tcl_AppendResult (interp, " string ", NULL); + Tcl_AppendElement (interp, e->tagVal.str); + } + switch (e->dataWhich) + { + case Z_ElementData_octets: + Tcl_AppendResult (interp, " octets {} ", NULL); + break; + case Z_ElementData_numeric: + Tcl_AppendResult (interp, " numeric ", NULL); + sprintf (tmpbuf, "%d", e->tagData.num); + Tcl_AppendElement (interp, tmpbuf); + break; + case Z_ElementData_date: + Tcl_AppendResult (interp, " date {} ", NULL); + break; + case Z_ElementData_ext: + Tcl_AppendResult (interp, " ext {} ", NULL); + break; + case Z_ElementData_string: + Tcl_AppendResult (interp, " string ", NULL); + Tcl_AppendElement (interp, e->tagData.str); + break; + case Z_ElementData_trueOrFalse: + Tcl_AppendResult (interp, " bool ", + e->tagData.bool ? "1" : "0", " ", NULL); + break; + case Z_ElementData_oid: + Tcl_AppendResult (interp, " oid {} ", NULL); + break; + case Z_ElementData_intUnit: + Tcl_AppendResult (interp, " intUnit {} ", NULL); + break; + case Z_ElementData_elementNotThere: + Tcl_AppendResult (interp, " notThere {} ", NULL); + break; + case Z_ElementData_elementEmpty: + Tcl_AppendResult (interp, " empty {} ", NULL); + break; + case Z_ElementData_noDataRequested: + Tcl_AppendResult (interp, " notRequested {} ", NULL); + break; + case Z_ElementData_diagnostic: + Tcl_AppendResult (interp, " diagnostic {} ", NULL); + break; + case Z_ElementData_subtree: + Tcl_AppendResult (interp, " subtree { ", NULL); + ir_tcl_get_grs_r (interp, e->tagData.sub, argc, argv, argno+1); Tcl_AppendResult (interp, " } ", NULL); + break; } + Tcl_AppendResult (interp, " } ", NULL); } return TCL_OK; } @@ -234,6 +265,6 @@ static int ir_tcl_get_grs_r (Tcl_Interp *interp, IrTcl_GRS_Record *grs_record, int ir_tcl_get_grs (Tcl_Interp *interp, IrTcl_GRS_Record *grs_record, int argc, char **argv) { - return ir_tcl_get_grs_r (interp, grs_record, argc, argv, 4); + return ir_tcl_get_grs_r (interp, grs_record, argc, argv, 3); } diff --git a/ir-tcl.c b/ir-tcl.c index 2ac5a47..58ed23d 100644 --- a/ir-tcl.c +++ b/ir-tcl.c @@ -5,7 +5,11 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: ir-tcl.c,v $ - * Revision 1.86 1996-03-20 13:54:04 adam + * Revision 1.87 1996-05-29 06:37:51 adam + * Function ir_tcl_get_grs_r enhanced so that specific elements can be + * extracted. + * + * Revision 1.86 1996/03/20 13:54:04 adam * The Tcl_File structure is only manipulated in the Tk-event interface * in tkinit.c. * @@ -407,8 +411,10 @@ int ir_tcl_eval (Tcl_Interp *interp, const char *command) strcpy (tmp, command); r = Tcl_Eval (interp, tmp); if (r == TCL_ERROR) + { logf (LOG_WARN, "Tcl error in line %d: %s", interp->errorLine, interp->result); + } Tcl_FreeResult (interp); free (tmp); return r;