2 * IR toolkit for tcl/tk
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.27 1995-05-11 15:34:47 adam
8 * Scan request changed a bit. This version works with RLG.
10 * Revision 1.26 1995/04/18 16:11:51 adam
11 * First version of graphical Scan. Some work on query-by-form.
13 * Revision 1.25 1995/04/17 09:37:17 adam
14 * Further development of scan.
16 * Revision 1.24 1995/04/11 14:16:42 adam
17 * Further work on scan. Response works. Entries aren't saved yet.
19 * Revision 1.23 1995/04/10 10:50:27 adam
20 * Result-set name defaults to suffix of ir-set name.
21 * Started working on scan. Not finished at this point.
23 * Revision 1.22 1995/03/31 10:43:03 adam
24 * More robust when getting bad MARC records.
26 * Revision 1.21 1995/03/31 08:56:37 adam
27 * New button "Search".
29 * Revision 1.20 1995/03/29 16:07:09 adam
30 * Bug fix: Didn't use setName in present request.
32 * Revision 1.19 1995/03/28 12:45:23 adam
33 * New ir method failback: called on disconnect/protocol error.
34 * New ir set/get method: protocol: SR / Z3950.
35 * Simple popup and disconnect when failback is invoked.
37 * Revision 1.18 1995/03/21 15:50:12 adam
40 * Revision 1.17 1995/03/21 13:41:03 adam
41 * Comstack cs_create not used too often. Non-blocking connect.
43 * Revision 1.16 1995/03/21 08:26:06 adam
44 * New method, setName, to specify the result set name (other than Default).
45 * New method, responseStatus, which returns diagnostic info, if any, after
46 * present response / search response.
48 * Revision 1.15 1995/03/20 15:24:07 adam
49 * Diagnostic records saved on searchResponse.
51 * Revision 1.14 1995/03/20 08:53:22 adam
52 * Event loop in tclmain.c rewritten. New method searchStatus.
54 * Revision 1.13 1995/03/17 18:26:17 adam
55 * Non-blocking i/o used now. Database names popup as cascade items.
57 * Revision 1.12 1995/03/17 15:45:00 adam
58 * Improved target/database setup.
60 * Revision 1.11 1995/03/16 17:54:03 adam
61 * Minor changes really.
63 * Revision 1.10 1995/03/15 16:14:50 adam
64 * Blocking arg in cs_create changed.
66 * Revision 1.9 1995/03/15 13:59:24 adam
69 * Revision 1.8 1995/03/15 08:25:16 adam
70 * New method presentStatus to check for error on present. Misc. cleanup
71 * of IRRecordList manipulations. Full MARC record presentation in
74 * Revision 1.7 1995/03/14 17:32:29 adam
75 * Presentation of full Marc record in popup window.
77 * Revision 1.6 1995/03/12 19:31:55 adam
78 * Pattern matching implemented when retrieving MARC records. More
79 * diagnostic functions.
81 * Revision 1.5 1995/03/10 18:00:15 adam
82 * Actual presentation in line-by-line format. RPN query support.
84 * Revision 1.4 1995/03/09 16:15:08 adam
85 * First presentRequest attempts. Hot-target list.
108 #include <diagbib1.h>
120 int preferredMessageSize;
121 int maximumRecordSize;
123 Odr_bitmask protocolVersion;
124 char *idAuthentication;
125 char *implementationName;
126 char *implementationId;
147 int smallSetUpperBound;
148 int largeSetLowerBound;
149 int mediumSetPresentNumber;
150 int replaceIndicator;
151 char **databaseNames;
152 int num_databaseNames;
158 struct IRSetObj_ *set_child;
159 struct IRScanObj_ *scan_child;
162 typedef struct IRRecordList_ {
174 struct IRRecordList_ *next;
177 typedef struct IRSetObj_ {
183 int numberOfRecordsReturned;
189 IRRecordList *record_list;
192 typedef struct IRScanEntry_ {
197 int globalOccurrences;
206 typedef struct IRScanDiag_ {
210 typedef struct IRScanObj_ {
213 int numberOfTermsRequested;
214 int preferredPositionInResponse;
217 int numberOfEntriesReturned;
226 IRScanEntry *entries;
227 IRScanDiag *nonSurrogateDiagnostics;
233 int (*method) (void *obj, Tcl_Interp *interp, int argc, char **argv);
236 static int do_disconnect (void *obj,Tcl_Interp *interp, int argc, char **argv);
238 static IRRecordList *new_IR_record (IRSetObj *setobj, int no, int which)
242 for (rl = setobj->record_list; rl; rl = rl->next)
248 case Z_NamePlusRecord_databaseRecord:
249 iso2709_rm (rl->u.marc.rec);
251 case Z_NamePlusRecord_surrogateDiagnostic:
252 free (rl->u.diag.addinfo);
253 rl->u.diag.addinfo = NULL;
261 rl = malloc (sizeof(*rl));
263 rl->next = setobj->record_list;
265 setobj->record_list = rl;
271 static IRRecordList *find_IR_record (IRSetObj *setobj, int no)
275 for (rl = setobj->record_list; rl; rl = rl->next)
282 * getsetint: Set/get integer value
284 static int get_set_int (int *val, Tcl_Interp *interp, int argc, char **argv)
290 if (Tcl_GetInt (interp, argv[2], val)==TCL_ERROR)
293 sprintf (buf, "%d", *val);
294 Tcl_AppendResult (interp, buf, NULL);
299 * mk_nonSurrogateDiagnostics: Make Tcl result with diagnostic info
301 static int mk_nonSurrogateDiagnostics (Tcl_Interp *interp,
308 Tcl_AppendElement (interp, "NSD");
309 sprintf (buf, "%d", condition);
310 Tcl_AppendElement (interp, buf);
311 cp = diagbib1_str (condition);
313 Tcl_AppendElement (interp, (char*) cp);
315 Tcl_AppendElement (interp, "");
317 Tcl_AppendElement (interp, (char*) addinfo);
319 Tcl_AppendElement (interp, "");
324 * get_parent_info: Returns information about parent object.
326 static int get_parent_info (Tcl_Interp *interp, const char *name,
327 Tcl_CmdInfo *parent_info,
330 char parent_name[128];
331 const char *csep = strrchr (name, '.');
336 interp->result = "missing .";
344 memcpy (parent_name, name, pos);
345 parent_name[pos] = '\0';
346 if (!Tcl_GetCommandInfo (interp, parent_name, parent_info))
348 interp->result = "No parent";
355 * ir_method: Search for method in table and invoke method handler
357 int ir_method (void *obj, Tcl_Interp *interp, int argc, char **argv,
361 for (t = tab; t->name; t++)
362 if (!strcmp (t->name, argv[1]))
363 return (*t->method)(obj, interp, argc, argv);
364 Tcl_AppendResult (interp, "Bad method. Possible values:", NULL);
365 for (t = tab; t->name; t++)
366 Tcl_AppendResult (interp, " ", t->name, NULL);
371 * ir_method_r: Get status for all readable elements
373 int ir_method_r (void *obj, Tcl_Interp *interp, int argc, char **argv,
381 for (; tab->name; tab++)
384 argv_n[1] = tab->name;
385 Tcl_AppendResult (interp, "{", NULL);
386 (*tab->method)(obj, interp, argc_n, argv_n);
387 Tcl_AppendResult (interp, "} ", NULL);
393 * ir_asc2bitmask: Ascii to ODR bitmask conversion
395 int ir_asc2bitmask (const char *asc, Odr_bitmask *ob)
397 const char *cp = asc + strlen(asc);
404 ODR_MASK_SET (ob, bitno);
411 * ir_strdup: Duplicate string
413 int ir_strdup (Tcl_Interp *interp, char** p, const char *s)
415 *p = malloc (strlen(s)+1);
418 interp->result = "strdup fail";
426 * ir_malloc: Malloc function
428 void *ir_malloc (Tcl_Interp *interp, size_t size)
430 static char buf[128];
431 void *p = malloc (size);
435 sprintf (buf, "Malloc fail. %ld bytes requested", (long) size);
436 interp->result = buf;
442 /* ------------------------------------------------------- */
445 * do_init_request: init method on IR object
447 static int do_init_request (void *obj, Tcl_Interp *interp,
448 int argc, char **argv)
450 Z_APDU apdu, *apdup = &apdu;
457 interp->result = "not connected";
461 req.options = &p->options;
462 req.protocolVersion = &p->protocolVersion;
463 req.preferredMessageSize = &p->preferredMessageSize;
464 req.maximumRecordSize = &p->maximumRecordSize;
466 req.idAuthentication = p->idAuthentication;
467 req.implementationId = p->implementationId;
468 req.implementationName = p->implementationName;
469 req.implementationVersion = "0.1";
470 req.userInformationField = 0;
472 apdu.u.initRequest = &req;
473 apdu.which = Z_APDU_initRequest;
475 if (!z_APDU (p->odr_out, &apdup, 0))
477 Tcl_AppendResult (interp, odr_errlist [odr_geterror (p->odr_out)],
479 odr_reset (p->odr_out);
482 p->sbuf = odr_getbuf (p->odr_out, &p->slen);
483 if ((r=cs_put (p->cs_link, p->sbuf, p->slen)) < 0)
485 interp->result = "cs_put failed in init";
486 do_disconnect (p, NULL, 0, NULL);
491 ir_select_add_write (cs_fileno(p->cs_link), p);
492 printf("Sent part of initializeRequest (%d bytes).\n", p->slen);
495 printf("Sent whole initializeRequest (%d bytes).\n", p->slen);
500 * do_protocolVersion: Set protocol Version
502 static int do_protocolVersion (void *obj, Tcl_Interp *interp,
503 int argc, char **argv)
506 ir_asc2bitmask (argv[2], &((IRObj *) obj)->protocolVersion);
511 * do_options: Set options
513 static int do_options (void *obj, Tcl_Interp *interp,
514 int argc, char **argv)
517 ir_asc2bitmask (argv[2], &((IRObj *) obj)->options);
522 * do_preferredMessageSize: Set/get preferred message size
524 static int do_preferredMessageSize (void *obj, Tcl_Interp *interp,
525 int argc, char **argv)
528 return get_set_int (&p->preferredMessageSize, interp, argc, argv);
532 * do_maximumRecordSize: Set/get maximum record size
534 static int do_maximumRecordSize (void *obj, Tcl_Interp *interp,
535 int argc, char **argv)
538 return get_set_int (&p->maximumRecordSize, interp, argc, argv);
543 * do_implementationName: Set/get Implementation Name.
545 static int do_implementationName (void *obj, Tcl_Interp *interp,
546 int argc, char **argv)
550 free (((IRObj*)obj)->implementationName);
551 if (ir_strdup (interp, &((IRObj*) obj)->implementationName, argv[2])
555 Tcl_AppendResult (interp, ((IRObj*)obj)->implementationName,
561 * do_implementationId: Set/get Implementation Id.
563 static int do_implementationId (void *obj, Tcl_Interp *interp,
564 int argc, char **argv)
568 free (((IRObj*)obj)->implementationId);
569 if (ir_strdup (interp, &((IRObj*) obj)->implementationId, argv[2])
573 Tcl_AppendResult (interp, ((IRObj*)obj)->implementationId,
579 * do_idAuthentication: Set/get id Authentication
581 static int do_idAuthentication (void *obj, Tcl_Interp *interp,
582 int argc, char **argv)
586 free (((IRObj*)obj)->idAuthentication);
587 if (ir_strdup (interp, &((IRObj*) obj)->idAuthentication, argv[2])
591 Tcl_AppendResult (interp, ((IRObj*)obj)->idAuthentication,
597 * do_connect: connect method on IR object
599 static int do_connect (void *obj, Tcl_Interp *interp,
600 int argc, char **argv)
605 int protocol_type = CS_Z3950;
611 interp->result = "already connected";
614 if (!strcmp (p->protocol_type, "Z3950"))
615 protocol_type = CS_Z3950;
616 else if (!strcmp (p->protocol_type, "SR"))
617 protocol_type = CS_SR;
620 interp->result = "bad protocol type";
623 if (!strcmp (p->cs_type, "tcpip"))
625 p->cs_link = cs_create (tcpip_type, CS_BLOCK, protocol_type);
626 addr = tcpip_strtoaddr (argv[2]);
629 interp->result = "tcpip_strtoaddr fail";
632 printf ("tcp/ip connect %s\n", argv[2]);
635 else if (!strcmp (p->cs_type, "mosi"))
637 p->cs_link = cs_create (mosi_type, CS_BLOCK, protocol_type);
638 addr = mosi_strtoaddr (argv[2]);
641 interp->result = "mosi_strtoaddr fail";
644 printf ("mosi connect %s\n", argv[2]);
649 interp->result = "unknown comstack type";
652 if (ir_strdup (interp, &p->hostname, argv[2]) == TCL_ERROR)
654 if ((r=cs_connect (p->cs_link, addr)) < 0)
656 interp->result = "cs_connect fail";
657 do_disconnect (p, NULL, 0, NULL);
660 ir_select_add (cs_fileno (p->cs_link), p);
663 ir_select_add_write (cs_fileno (p->cs_link), p);
670 Tcl_Eval (p->interp, p->callback);
674 Tcl_AppendElement (interp, p->hostname);
679 * do_disconnect: disconnect method on IR object
681 static int do_disconnect (void *obj, Tcl_Interp *interp,
682 int argc, char **argv)
690 ir_select_remove_write (cs_fileno (p->cs_link), p);
691 ir_select_remove (cs_fileno (p->cs_link), p);
694 cs_close (p->cs_link);
697 assert (!p->cs_link);
702 * do_comstack: Set/get comstack method on IR object
704 static int do_comstack (void *o, Tcl_Interp *interp,
705 int argc, char **argv)
712 if (ir_strdup (interp, &obj->cs_type, argv[2]) == TCL_ERROR)
715 Tcl_AppendElement (interp, obj->cs_type);
720 * do_protocol: Set/get protocol method on IR object
722 static int do_protocol (void *o, Tcl_Interp *interp,
723 int argc, char **argv)
729 free (obj->protocol_type);
730 if (ir_strdup (interp, &obj->protocol_type, argv[2]) == TCL_ERROR)
733 Tcl_AppendElement (interp, obj->protocol_type);
738 * do_callback: add callback
740 static int do_callback (void *obj, Tcl_Interp *interp,
741 int argc, char **argv)
748 if (ir_strdup (interp, &p->callback, argv[2]) == TCL_ERROR)
756 * do_failback: add error handle callback
758 static int do_failback (void *obj, Tcl_Interp *interp,
759 int argc, char **argv)
766 if (ir_strdup (interp, &p->failback, argv[2]) == TCL_ERROR)
774 * do_databaseNames: specify database names
776 static int do_databaseNames (void *obj, Tcl_Interp *interp,
777 int argc, char **argv)
784 for (i=0; i<p->num_databaseNames; i++)
785 Tcl_AppendElement (interp, p->databaseNames[i]);
788 if (p->databaseNames)
790 for (i=0; i<p->num_databaseNames; i++)
791 free (p->databaseNames[i]);
792 free (p->databaseNames);
794 p->num_databaseNames = argc - 2;
795 if (!(p->databaseNames = ir_malloc (interp,
796 sizeof(*p->databaseNames) * p->num_databaseNames)))
798 for (i=0; i<p->num_databaseNames; i++)
800 if (ir_strdup (interp, &p->databaseNames[i], argv[2+i])
808 * do_query: Set/Get query mothod
810 static int do_query (void *obj, Tcl_Interp *interp,
811 int argc, char **argv)
816 free (p->query_method);
817 if (ir_strdup (interp, &p->query_method, argv[2]) == TCL_ERROR)
820 Tcl_AppendResult (interp, p->query_method, NULL);
825 * do_replaceIndicator: Set/get replace Set indicator
827 static int do_replaceIndicator (void *obj, Tcl_Interp *interp,
828 int argc, char **argv)
831 return get_set_int (&p->replaceIndicator, interp, argc, argv);
835 * ir_obj_method: IR Object methods
837 static int ir_obj_method (ClientData clientData, Tcl_Interp *interp,
838 int argc, char **argv)
840 static IRMethod tab[] = {
841 { 1, "comstack", do_comstack },
842 { 1, "protocol", do_protocol },
843 { 1, "connect", do_connect },
844 { 0, "protocolVersion", do_protocolVersion },
845 { 0, "options", do_options },
846 { 1, "preferredMessageSize", do_preferredMessageSize },
847 { 1, "maximumRecordSize", do_maximumRecordSize },
848 { 1, "implementationName", do_implementationName },
849 { 1, "implementationId", do_implementationId },
850 { 1, "idAuthentication", do_idAuthentication },
851 { 0, "init", do_init_request },
852 { 0, "disconnect", do_disconnect },
853 { 0, "callback", do_callback },
854 { 0, "failback", do_failback },
855 { 1, "databaseNames", do_databaseNames},
856 { 1, "replaceIndicator", do_replaceIndicator},
857 { 1, "query", do_query },
861 return ir_method_r (clientData, interp, argc, argv, tab);
862 return ir_method (clientData, interp, argc, argv, tab);
866 * ir_obj_delete: IR Object disposal
868 static void ir_obj_delete (ClientData clientData)
870 free ( (void*) clientData);
874 * ir_obj_mk: IR Object creation
876 static int ir_obj_mk (ClientData clientData, Tcl_Interp *interp,
877 int argc, char **argv)
884 interp->result = "wrong # args";
887 if (!(obj = ir_malloc (interp, sizeof(*obj))))
889 if (ir_strdup (interp, &obj->cs_type, "tcpip") == TCL_ERROR)
891 if (ir_strdup (interp, &obj->protocol_type, "Z3950") == TCL_ERROR)
894 obj->bib1.proto = PROTO_Z3950;
895 obj->bib1.class = CLASS_ATTSET;
896 obj->bib1.value = VAL_BIB1;
898 obj->maximumRecordSize = 32768;
899 obj->preferredMessageSize = 4096;
900 obj->connectFlag = 0;
902 obj->idAuthentication = NULL;
904 if (ir_strdup (interp, &obj->implementationName, "TCL/TK on YAZ")
908 if (ir_strdup (interp, &obj->implementationId, "TCL/TK/YAZ")
912 obj->smallSetUpperBound = 0;
913 obj->largeSetLowerBound = 2;
914 obj->mediumSetPresentNumber = 0;
915 obj->replaceIndicator = 1;
917 obj->databaseNames = NULL;
918 obj->num_databaseNames = 0;
920 obj->num_databaseNames = 1;
921 if (!(obj->databaseNames = ir_malloc (interp,
922 sizeof(*obj->databaseNames))))
924 if (ir_strdup (interp, &obj->databaseNames[0], "Default") == TCL_ERROR)
928 obj->hostname = NULL;
930 if (ir_strdup (interp, &obj->query_method, "rpn") == TCL_ERROR)
932 obj->bibset = ccl_qual_mk ();
933 if ((inf = fopen ("default.bib", "r")))
935 ccl_qual_file (obj->bibset, inf);
938 ODR_MASK_ZERO (&obj->protocolVersion);
939 ODR_MASK_SET (&obj->protocolVersion, 0);
940 ODR_MASK_SET (&obj->protocolVersion, 1);
942 ODR_MASK_ZERO (&obj->options);
943 ODR_MASK_SET (&obj->options, 0);
945 obj->odr_in = odr_createmem (ODR_DECODE);
946 obj->odr_out = odr_createmem (ODR_ENCODE);
947 obj->odr_pr = odr_createmem (ODR_PRINT);
949 obj->len_out = 10000;
950 if (!(obj->buf_out = ir_malloc (interp, obj->len_out)))
952 odr_setbuf (obj->odr_out, obj->buf_out, obj->len_out);
957 obj->callback = NULL;
958 obj->failback = NULL;
959 Tcl_CreateCommand (interp, argv[1], ir_obj_method,
960 (ClientData) obj, ir_obj_delete);
964 /* ------------------------------------------------------- */
966 * do_search: Do search request
968 static int do_search (void *o, Tcl_Interp *interp,
969 int argc, char **argv)
973 Z_APDU apdu, *apdup = &apdu;
976 IRObj *p = obj->parent;
982 interp->result = "wrong # args";
985 if (!p->num_databaseNames)
987 interp->result = "no databaseNames";
992 interp->result = "not connected";
995 apdu.which = Z_APDU_searchRequest;
996 apdu.u.searchRequest = &req;
999 req.smallSetUpperBound = &p->smallSetUpperBound;
1000 req.largeSetLowerBound = &p->largeSetLowerBound;
1001 req.mediumSetPresentNumber = &p->mediumSetPresentNumber;
1002 req.replaceIndicator = &p->replaceIndicator;
1003 req.resultSetName = obj->setName ? obj->setName : "Default";
1004 req.num_databaseNames = p->num_databaseNames;
1005 req.databaseNames = p->databaseNames;
1007 for (r=0; r<p->num_databaseNames; r++)
1009 printf (" %s", p->databaseNames[r]);
1011 req.smallSetElementSetNames = 0;
1012 req.mediumSetElementSetNames = 0;
1013 req.preferredRecordSyntax = 0;
1016 if (!strcmp (p->query_method, "rpn"))
1020 struct ccl_rpn_node *rpn;
1021 Z_RPNQuery *RPNquery;
1023 rpn = ccl_find_str(p->bibset, argv[2], &error, &pos);
1026 Tcl_AppendResult (interp, "CCL error: ", ccl_err_msg(error),NULL);
1029 ccl_pr_tree (rpn, stderr);
1030 fprintf (stderr, "\n");
1031 query.which = Z_Query_type_1;
1032 assert((RPNquery = ccl_rpn_query(rpn)));
1033 RPNquery->attributeSetId = oid_getoidbyent (&p->bib1);
1034 query.u.type_1 = RPNquery;
1037 else if (!strcmp (p->query_method, "ccl"))
1039 query.which = Z_Query_type_2;
1040 query.u.type_2 = &ccl_query;
1041 ccl_query.buf = (unsigned char *) argv[2];
1042 ccl_query.len = strlen (argv[2]);
1047 interp->result = "unknown query method";
1050 if (!z_APDU (p->odr_out, &apdup, 0))
1052 interp->result = odr_errlist [odr_geterror (p->odr_out)];
1053 odr_reset (p->odr_out);
1056 p->sbuf = odr_getbuf (p->odr_out, &p->slen);
1057 if ((r=cs_put (p->cs_link, p->sbuf, p->slen)) < 0)
1059 interp->result = "cs_put failed in search";
1064 ir_select_add_write (cs_fileno(p->cs_link), p);
1065 printf("Sent part of searchRequest (%d bytes).\n", p->slen);
1069 printf ("Whole search request\n");
1075 * do_resultCount: Get number of hits
1077 static int do_resultCount (void *o, Tcl_Interp *interp,
1078 int argc, char **argv)
1082 return get_set_int (&obj->resultCount, interp, argc, argv);
1086 * do_searchStatus: Get search status (after search response)
1088 static int do_searchStatus (void *o, Tcl_Interp *interp,
1089 int argc, char **argv)
1093 return get_set_int (&obj->searchStatus, interp, argc, argv);
1097 * do_setName: Set result Set name
1099 static int do_setName (void *o, Tcl_Interp *interp,
1100 int argc, char **argv)
1106 free (obj->setName);
1107 if (ir_strdup (interp, &obj->setName, argv[2])
1111 Tcl_AppendElement (interp, obj->setName);
1116 * do_numberOfRecordsReturned: Get number of records returned
1118 static int do_numberOfRecordsReturned (void *o, Tcl_Interp *interp,
1119 int argc, char **argv)
1123 return get_set_int (&obj->numberOfRecordsReturned, interp, argc, argv);
1126 static int get_marc_fields(Tcl_Interp *interp, Iso2709Rec rec,
1127 int argc, char **argv)
1134 a = iso2709_a_mk (rec);
1135 while (iso2709_a_search (a, argv[4], argv[5], argv[6]))
1137 if (!(iso2709_a_info_field (a, NULL, NULL, NULL, &data)))
1139 Tcl_AppendElement (interp, data);
1147 static int get_marc_lines(Tcl_Interp *interp, Iso2709Rec rec,
1148 int argc, char **argv)
1159 a = iso2709_a_mk (rec);
1160 while (iso2709_a_search (a, argv[4], argv[5], argv[6]))
1162 if (!(iso2709_a_info_field (a, &tag, &indicator, &identifier, &data)))
1164 if (strcmp (tag, ptag))
1167 Tcl_AppendResult (interp, "}} ", NULL);
1169 Tcl_AppendResult (interp, "{", tag, " {} {", NULL);
1171 Tcl_AppendResult (interp, "{", tag, " {", indicator,
1176 Tcl_AppendResult (interp, "{{}", NULL);
1178 Tcl_AppendResult (interp, "{", identifier, NULL);
1179 Tcl_AppendElement (interp, data);
1180 Tcl_AppendResult (interp, "} ", NULL);
1184 Tcl_AppendResult (interp, "}} ", NULL);
1190 * do_recordType: Return record type (if any) at position.
1192 static int do_recordType (void *o, Tcl_Interp *interp, int argc, char **argv)
1200 sprintf (interp->result, "wrong # args");
1203 if (Tcl_GetInt (interp, argv[2], &offset)==TCL_ERROR)
1205 rl = find_IR_record (obj, offset);
1210 case Z_NamePlusRecord_databaseRecord:
1211 interp->result = "databaseRecord";
1213 case Z_NamePlusRecord_surrogateDiagnostic:
1214 interp->result = "surrogateDiagnostic";
1221 * do_recordDiag: Return diagnostic record info
1223 static int do_recordDiag (void *o, Tcl_Interp *interp, int argc, char **argv)
1232 sprintf (interp->result, "wrong # args");
1235 if (Tcl_GetInt (interp, argv[2], &offset)==TCL_ERROR)
1237 rl = find_IR_record (obj, offset);
1240 Tcl_AppendResult (interp, "No record at #", argv[2], NULL);
1243 if (rl->which != Z_NamePlusRecord_surrogateDiagnostic)
1245 Tcl_AppendResult (interp, "No Diagnostic record at #", argv[2], NULL);
1248 sprintf (buf, "%d", rl->u.diag.condition);
1249 Tcl_AppendResult (interp, buf, " {",
1250 (rl->u.diag.addinfo ? rl->u.diag.addinfo : ""),
1256 * do_recordMarc: Get ISO2709 Record lines/fields
1258 static int do_recordMarc (void *o, Tcl_Interp *interp, int argc, char **argv)
1266 sprintf (interp->result, "wrong # args");
1269 if (Tcl_GetInt (interp, argv[2], &offset)==TCL_ERROR)
1271 rl = find_IR_record (obj, offset);
1274 Tcl_AppendResult (interp, "No record at #", argv[2], NULL);
1277 if (rl->which != Z_NamePlusRecord_databaseRecord)
1279 Tcl_AppendResult (interp, "No MARC record at #", argv[2], NULL);
1282 if (!strcmp (argv[3], "field"))
1283 return get_marc_fields (interp, rl->u.marc.rec, argc, argv);
1284 else if (!strcmp (argv[3], "line"))
1285 return get_marc_lines (interp, rl->u.marc.rec, argc, argv);
1288 Tcl_AppendResult (interp, "field/line expected", NULL);
1295 * do_responseStatus: Return response status (present or search)
1297 static int do_responseStatus (void *o, Tcl_Interp *interp,
1298 int argc, char **argv)
1302 if (!obj->recordFlag)
1306 case Z_Records_DBOSD:
1307 Tcl_AppendElement (interp, "DBOSD");
1310 return mk_nonSurrogateDiagnostics (interp, obj->condition,
1317 * do_present: Perform Present Request
1320 static int do_present (void *o, Tcl_Interp *interp,
1321 int argc, char **argv)
1324 IRObj *p = obj->parent;
1325 Z_APDU apdu, *apdup = &apdu;
1326 Z_PresentRequest req;
1333 if (Tcl_GetInt (interp, argv[2], &start) == TCL_ERROR)
1340 if (Tcl_GetInt (interp, argv[3], &number) == TCL_ERROR)
1347 interp->result = "not connected";
1351 obj->number = number;
1353 apdu.which = Z_APDU_presentRequest;
1354 apdu.u.presentRequest = &req;
1355 req.referenceId = 0;
1356 /* sprintf(setstring, "%d", setnumber); */
1358 req.resultSetId = obj->setName ? obj->setName : "Default";
1360 req.resultSetStartPoint = &start;
1361 req.numberOfRecordsRequested = &number;
1362 req.elementSetNames = 0;
1363 req.preferredRecordSyntax = 0;
1365 if (!z_APDU (p->odr_out, &apdup, 0))
1367 interp->result = odr_errlist [odr_geterror (p->odr_out)];
1368 odr_reset (p->odr_out);
1371 p->sbuf = odr_getbuf (p->odr_out, &p->slen);
1372 if ((r=cs_put (p->cs_link, p->sbuf, p->slen)) < 0)
1374 interp->result = "cs_put failed in present";
1379 ir_select_add_write (cs_fileno(p->cs_link), p);
1380 printf ("Part of present request, start=%d, num=%d (%d bytes)\n",
1381 start, number, p->slen);
1385 printf ("Whole present request, start=%d, num=%d (%d bytes)\n",
1386 start, number, p->slen);
1392 * do_loadFile: Load result set from file
1395 static int do_loadFile (void *o, Tcl_Interp *interp,
1396 int argc, char **argv)
1398 IRSetObj *setobj = o;
1405 interp->result = "wrong # args";
1408 inf = fopen (argv[2], "r");
1411 Tcl_AppendResult (interp, "Cannot open ", argv[2], NULL);
1414 while ((buf = iso2709_read (inf)))
1419 rec = iso2709_cvt (buf);
1422 rl = new_IR_record (setobj, no, Z_NamePlusRecord_databaseRecord);
1423 rl->u.marc.rec = rec;
1426 setobj->numberOfRecordsReturned = no-1;
1432 * ir_set_obj_method: IR Set Object methods
1434 static int ir_set_obj_method (ClientData clientData, Tcl_Interp *interp,
1435 int argc, char **argv)
1437 static IRMethod tab[] = {
1438 { 0, "search", do_search },
1439 { 0, "searchStatus", do_searchStatus },
1440 { 0, "setName", do_setName },
1441 { 0, "resultCount", do_resultCount },
1442 { 0, "numberOfRecordsReturned", do_numberOfRecordsReturned },
1443 { 0, "present", do_present },
1444 { 0, "recordType", do_recordType },
1445 { 0, "recordMarc", do_recordMarc },
1446 { 0, "recordDiag", do_recordDiag },
1447 { 0, "responseStatus", do_responseStatus },
1448 { 0, "loadFile", do_loadFile },
1454 interp->result = "wrong # args";
1457 return ir_method (clientData, interp, argc, argv, tab);
1461 * ir_set_obj_delete: IR Set Object disposal
1463 static void ir_set_obj_delete (ClientData clientData)
1465 free ( (void*) clientData);
1469 * ir_set_obj_mk: IR Set Object creation
1471 static int ir_set_obj_mk (ClientData clientData, Tcl_Interp *interp,
1472 int argc, char **argv)
1474 Tcl_CmdInfo parent_info;
1480 interp->result = "wrong # args";
1483 if (get_parent_info (interp, argv[1], &parent_info, &suffix) == TCL_ERROR)
1485 if (!(obj = ir_malloc (interp, sizeof(*obj))))
1487 if (ir_strdup (interp, &obj->setName, suffix) == TCL_ERROR)
1489 obj->record_list = NULL;
1490 obj->addinfo = NULL;
1491 obj->parent = (IRObj *) parent_info.clientData;
1492 Tcl_CreateCommand (interp, argv[1], ir_set_obj_method,
1493 (ClientData) obj, ir_set_obj_delete);
1497 /* ------------------------------------------------------- */
1500 * do_scan: Perform scan
1502 static int do_scan (void *o, Tcl_Interp *interp, int argc, char **argv)
1505 Z_APDU apdu, *apdup = &apdu;
1507 IRObj *p = obj->parent;
1509 struct ccl_rpn_node *rpn;
1514 interp->result = "wrong # args";
1517 if (!p->num_databaseNames)
1519 interp->result = "no databaseNames";
1524 interp->result = "not connected";
1527 apdu.which = Z_APDU_scanRequest;
1528 apdu.u.scanRequest = &req;
1529 req.referenceId = NULL;
1530 req.num_databaseNames = p->num_databaseNames;
1531 req.databaseNames = p->databaseNames;
1532 req.attributeSet = oid_getoidbyent (&p->bib1);
1535 if (!(req.termListAndStartPoint =
1536 ir_malloc (interp, sizeof(*req.termListAndStartPoint))))
1538 req.termListAndStartPoint->num_attributes = 0;
1539 req.termListAndStartPoint->attributeList = NULL;
1540 if (!(req.termListAndStartPoint->term = ir_malloc (interp,
1543 req.termListAndStartPoint->term->which = Z_Term_general;
1544 if (!(req.termListAndStartPoint->term->u.general =
1545 ir_malloc (interp, sizeof(*req.termListAndStartPoint->
1548 if (ir_strdup (interp, &req.termListAndStartPoint->term->u.general->buf,
1549 argv[2]) == TCL_ERROR)
1551 req.termListAndStartPoint->term->u.general->len =
1552 req.termListAndStartPoint->term->u.general->size = strlen(argv[2]);
1554 rpn = ccl_find_str(p->bibset, argv[2], &r, &pos);
1557 Tcl_AppendResult (interp, "CCL error: ", ccl_err_msg (r), NULL);
1560 ccl_pr_tree (rpn, stderr);
1561 fprintf (stderr, "\n");
1562 if (!(req.termListAndStartPoint = ccl_scan_query (rpn)))
1565 req.stepSize = &obj->stepSize;
1566 req.numberOfTermsRequested = &obj->numberOfTermsRequested;
1567 req.preferredPositionInResponse = &obj->preferredPositionInResponse;
1568 printf ("stepSize=%d\n", *req.stepSize);
1569 printf ("numberOfTermsRequested=%d\n", *req.numberOfTermsRequested);
1570 printf ("preferredPositionInResponse=%d\n",
1571 *req.preferredPositionInResponse);
1573 if (!z_APDU (p->odr_out, &apdup, 0))
1575 interp->result = odr_errlist [odr_geterror (p->odr_out)];
1576 odr_reset (p->odr_out);
1579 p->sbuf = odr_getbuf (p->odr_out, &p->slen);
1580 if ((r=cs_put (p->cs_link, p->sbuf, p->slen)) < 0)
1582 interp->result = "cs_put failed in scan";
1587 ir_select_add_write (cs_fileno(p->cs_link), p);
1588 printf("Sent part of scanRequest (%d bytes).\n", p->slen);
1592 printf ("Whole scan request\n");
1598 * do_stepSize: Set/get replace Step Size
1600 static int do_stepSize (void *obj, Tcl_Interp *interp,
1601 int argc, char **argv)
1604 return get_set_int (&p->stepSize, interp, argc, argv);
1608 * do_numberOfTermsRequested: Set/get Number of Terms requested
1610 static int do_numberOfTermsRequested (void *obj, Tcl_Interp *interp,
1611 int argc, char **argv)
1614 return get_set_int (&p->numberOfTermsRequested, interp, argc, argv);
1619 * do_preferredPositionInResponse: Set/get preferred Position
1621 static int do_preferredPositionInResponse (void *obj, Tcl_Interp *interp,
1622 int argc, char **argv)
1625 return get_set_int (&p->preferredPositionInResponse, interp, argc, argv);
1629 * do_scanStatus: Get scan status
1631 static int do_scanStatus (void *obj, Tcl_Interp *interp,
1632 int argc, char **argv)
1635 return get_set_int (&p->scanStatus, interp, argc, argv);
1639 * do_numberOfEntriesReturned: Get number of Entries returned
1641 static int do_numberOfEntriesReturned (void *obj, Tcl_Interp *interp,
1642 int argc, char **argv)
1645 return get_set_int (&p->numberOfEntriesReturned, interp, argc, argv);
1649 * do_positionOfTerm: Get position of Term
1651 static int do_positionOfTerm (void *obj, Tcl_Interp *interp,
1652 int argc, char **argv)
1655 return get_set_int (&p->positionOfTerm, interp, argc, argv);
1659 * do_scanLine: get Scan Line (surrogate or normal) after response
1661 static int do_scanLine (void *obj, Tcl_Interp *interp, int argc, char **argv)
1669 interp->result = "wrong # args";
1672 if (Tcl_GetInt (interp, argv[2], &i) == TCL_ERROR)
1674 if (!p->entries_flag || p->which != Z_ListEntries_entries || !p->entries
1675 || i >= p->num_entries || i < 0)
1677 switch (p->entries[i].which)
1679 case Z_Entry_termInfo:
1680 Tcl_AppendElement (interp, "T");
1681 if (p->entries[i].u.term.buf)
1682 Tcl_AppendElement (interp, p->entries[i].u.term.buf);
1684 Tcl_AppendElement (interp, "");
1685 sprintf (numstr, "%d", p->entries[i].u.term.globalOccurrences);
1686 Tcl_AppendElement (interp, numstr);
1688 case Z_Entry_surrogateDiagnostic:
1690 mk_nonSurrogateDiagnostics (interp, p->entries[i].u.diag.condition,
1691 p->entries[i].u.diag.addinfo);
1698 * ir_scan_obj_method: IR Scan Object methods
1700 static int ir_scan_obj_method (ClientData clientData, Tcl_Interp *interp,
1701 int argc, char **argv)
1703 static IRMethod tab[] = {
1704 { 0, "scan", do_scan },
1705 { 0, "stepSize", do_stepSize },
1706 { 0, "numberOfTermsRequested", do_numberOfTermsRequested },
1707 { 0, "preferredPositionInResponse", do_preferredPositionInResponse },
1708 { 0, "scanStatus", do_scanStatus },
1709 { 0, "numberOfEntriesReturned", do_numberOfEntriesReturned },
1710 { 0, "positionOfTerm", do_positionOfTerm },
1711 { 0, "scanLine", do_scanLine },
1717 interp->result = "wrong # args";
1720 return ir_method (clientData, interp, argc, argv, tab);
1724 * ir_scan_obj_delete: IR Scan Object disposal
1726 static void ir_scan_obj_delete (ClientData clientData)
1728 free ( (void*) clientData);
1732 * ir_scan_obj_mk: IR Scan Object creation
1734 static int ir_scan_obj_mk (ClientData clientData, Tcl_Interp *interp,
1735 int argc, char **argv)
1737 Tcl_CmdInfo parent_info;
1742 interp->result = "wrong # args";
1745 if (get_parent_info (interp, argv[1], &parent_info, NULL) == TCL_ERROR)
1747 if (!(obj = ir_malloc (interp, sizeof(*obj))))
1751 obj->numberOfTermsRequested = 20;
1752 obj->preferredPositionInResponse = 1;
1754 obj->entries = NULL;
1755 obj->nonSurrogateDiagnostics = NULL;
1757 obj->parent = (IRObj *) parent_info.clientData;
1758 Tcl_CreateCommand (interp, argv[1], ir_scan_obj_method,
1759 (ClientData) obj, ir_scan_obj_delete);
1763 /* ------------------------------------------------------- */
1765 static void ir_initResponse (void *obj, Z_InitResponse *initrs)
1767 if (!*initrs->result)
1768 printf("Connection rejected by target.\n");
1770 printf("Connection accepted by target.\n");
1771 if (initrs->implementationId)
1772 printf("ID : %s\n", initrs->implementationId);
1773 if (initrs->implementationName)
1774 printf("Name : %s\n", initrs->implementationName);
1775 if (initrs->implementationVersion)
1776 printf("Version: %s\n", initrs->implementationVersion);
1777 if (initrs->maximumRecordSize)
1778 printf ("MaximumRecordSize=%d\n", *initrs->maximumRecordSize);
1779 if (initrs->preferredMessageSize)
1780 printf ("PreferredMessageSize=%d\n", *initrs->preferredMessageSize);
1782 if (initrs->userInformationField)
1784 printf("UserInformationfield:\n");
1785 odr_external(&print, (Odr_external**)&initrs->
1786 userInformationField, 0);
1791 static void ir_handleRecords (void *o, Z_Records *zrs)
1794 IRSetObj *setobj = p->set_child;
1796 setobj->which = zrs->which;
1797 setobj->recordFlag = 1;
1798 if (zrs->which == Z_Records_NSD)
1800 const char *addinfo;
1802 setobj->numberOfRecordsReturned = 0;
1803 setobj->condition = *zrs->u.nonSurrogateDiagnostic->condition;
1804 free (setobj->addinfo);
1805 setobj->addinfo = NULL;
1806 addinfo = zrs->u.nonSurrogateDiagnostic->addinfo;
1807 if (addinfo && (setobj->addinfo = malloc (strlen(addinfo) + 1)))
1808 strcpy (setobj->addinfo, addinfo);
1809 printf ("Diagnostic response. %s (%d): %s\n",
1810 diagbib1_str (setobj->condition),
1812 setobj->addinfo ? setobj->addinfo : "");
1819 setobj->numberOfRecordsReturned =
1820 zrs->u.databaseOrSurDiagnostics->num_records;
1821 printf ("Got %d records\n", setobj->numberOfRecordsReturned);
1822 for (offset = 0; offset<setobj->numberOfRecordsReturned; offset++)
1824 rl = new_IR_record (setobj, setobj->start + offset,
1825 zrs->u.databaseOrSurDiagnostics->
1826 records[offset]->which);
1827 if (rl->which == Z_NamePlusRecord_surrogateDiagnostic)
1831 diagrec = zrs->u.databaseOrSurDiagnostics->
1832 records[offset]->u.surrogateDiagnostic;
1834 rl->u.diag.condition = *diagrec->condition;
1835 if (diagrec->addinfo && (rl->u.diag.addinfo =
1836 malloc (strlen (diagrec->addinfo)+1)))
1837 strcpy (rl->u.diag.addinfo, diagrec->addinfo);
1841 Z_DatabaseRecord *zr;
1844 zr = zrs->u.databaseOrSurDiagnostics->records[offset]
1846 oe = (Odr_external*) zr;
1847 if (oe->which == ODR_EXTERNAL_octet
1848 && zr->u.octet_aligned->len)
1850 const char *buf = (char*) zr->u.octet_aligned->buf;
1851 rl->u.marc.rec = iso2709_cvt (buf);
1854 rl->u.marc.rec = NULL;
1860 static void ir_searchResponse (void *o, Z_SearchResponse *searchrs)
1863 IRSetObj *setobj = p->set_child;
1864 Z_Records *zrs = searchrs->records;
1868 setobj->searchStatus = searchrs->searchStatus ? 1 : 0;
1869 setobj->resultCount = *searchrs->resultCount;
1870 printf ("Search response %d, %d hits\n",
1871 setobj->searchStatus, setobj->resultCount);
1873 ir_handleRecords (o, zrs);
1875 setobj->recordFlag = 0;
1878 printf ("Search response, no object!\n");
1882 static void ir_presentResponse (void *o, Z_PresentResponse *presrs)
1885 IRSetObj *setobj = p->set_child;
1886 Z_Records *zrs = presrs->records;
1888 printf ("Received presentResponse\n");
1890 ir_handleRecords (o, zrs);
1893 setobj->recordFlag = 0;
1894 printf ("No records!\n");
1898 static void ir_scanResponse (void *o, Z_ScanResponse *scanrs)
1901 IRScanObj *scanobj = p->scan_child;
1903 printf ("Received scanResponse\n");
1905 scanobj->scanStatus = *scanrs->scanStatus;
1906 printf ("scanStatus=%d\n", scanobj->scanStatus);
1908 if (scanrs->stepSize)
1909 scanobj->stepSize = *scanrs->stepSize;
1910 printf ("stepSize=%d\n", scanobj->stepSize);
1912 scanobj->numberOfEntriesReturned = *scanrs->numberOfEntriesReturned;
1913 printf ("numberOfEntriesReturned=%d\n", scanobj->numberOfEntriesReturned);
1915 if (scanrs->positionOfTerm)
1916 scanobj->positionOfTerm = *scanrs->positionOfTerm;
1918 scanobj->positionOfTerm = -1;
1919 printf ("positionOfTerm=%d\n", scanobj->positionOfTerm);
1921 free (scanobj->entries);
1922 scanobj->entries = NULL;
1923 free (scanobj->nonSurrogateDiagnostics);
1924 scanobj->nonSurrogateDiagnostics = NULL;
1926 if (scanrs->entries)
1931 scanobj->entries_flag = 1;
1932 scanobj->which = scanrs->entries->which;
1933 switch (scanobj->which)
1935 case Z_ListEntries_entries:
1936 scanobj->num_entries = scanrs->entries->u.entries->num_entries;
1937 scanobj->entries = malloc (scanobj->num_entries *
1938 sizeof(*scanobj->entries));
1939 for (i=0; i<scanobj->num_entries; i++)
1941 ze = scanrs->entries->u.entries->entries[i];
1942 scanobj->entries[i].which = ze->which;
1945 case Z_Entry_termInfo:
1946 if (ze->u.termInfo->term->which == Z_Term_general)
1948 int l = ze->u.termInfo->term->u.general->len;
1949 scanobj->entries[i].u.term.buf = malloc (1+l);
1950 memcpy (scanobj->entries[i].u.term.buf,
1951 ze->u.termInfo->term->u.general->buf,
1953 scanobj->entries[i].u.term.buf[l] = '\0';
1956 scanobj->entries[i].u.term.buf = NULL;
1957 if (ze->u.termInfo->globalOccurrences)
1958 scanobj->entries[i].u.term.globalOccurrences =
1959 *ze->u.termInfo->globalOccurrences;
1961 scanobj->entries[i].u.term.globalOccurrences = 0;
1963 case Z_Entry_surrogateDiagnostic:
1964 scanobj->entries[i].u.diag.addinfo =
1965 malloc (1+strlen(ze->u.surrogateDiagnostic->
1967 strcpy (scanobj->entries[i].u.diag.addinfo,
1968 ze->u.surrogateDiagnostic->addinfo);
1969 scanobj->entries[i].u.diag.condition =
1970 *ze->u.surrogateDiagnostic->condition;
1975 case Z_ListEntries_nonSurrogateDiagnostics:
1976 scanobj->num_diagRecs = scanrs->entries->
1977 u.nonSurrogateDiagnostics->num_diagRecs;
1978 scanobj->nonSurrogateDiagnostics = malloc (scanobj->num_diagRecs *
1979 sizeof(*scanobj->nonSurrogateDiagnostics));
1984 scanobj->entries_flag = 0;
1988 * ir_select_read: handle incoming packages
1990 void ir_select_read (ClientData clientData)
1992 IRObj *p = clientData;
1998 r = cs_rcvconnect (p->cs_link);
2002 ir_select_remove_write (cs_fileno (p->cs_link), p);
2005 printf ("cs_rcvconnect error\n");
2007 Tcl_Eval (p->interp, p->failback);
2008 do_disconnect (p, NULL, 0, NULL);
2012 Tcl_Eval (p->interp, p->callback);
2017 if ((r=cs_get (p->cs_link, &p->buf_in, &p->len_in)) <= 0)
2019 printf ("cs_get failed\n");
2020 ir_select_remove (cs_fileno (p->cs_link), p);
2022 Tcl_Eval (p->interp, p->failback);
2023 do_disconnect (p, NULL, 0, NULL);
2028 odr_setbuf (p->odr_in, p->buf_in, r);
2029 printf ("cs_get ok, got %d\n", r);
2030 if (!z_APDU (p->odr_in, &apdu, 0))
2032 printf ("%s\n", odr_errlist [odr_geterror (p->odr_in)]);
2034 Tcl_Eval (p->interp, p->failback);
2035 do_disconnect (p, NULL, 0, NULL);
2040 case Z_APDU_initResponse:
2041 ir_initResponse (p, apdu->u.initResponse);
2043 case Z_APDU_searchResponse:
2044 ir_searchResponse (p, apdu->u.searchResponse);
2046 case Z_APDU_presentResponse:
2047 ir_presentResponse (p, apdu->u.presentResponse);
2049 case Z_APDU_scanResponse:
2050 ir_scanResponse (p, apdu->u.scanResponse);
2053 printf("Received unknown APDU type (%d).\n",
2056 Tcl_Eval (p->interp, p->failback);
2057 do_disconnect (p, NULL, 0, NULL);
2060 Tcl_Eval (p->interp, p->callback);
2061 } while (cs_more (p->cs_link));
2065 * ir_select_write: handle outgoing packages - not yet written.
2067 void ir_select_write (ClientData clientData)
2069 IRObj *p = clientData;
2072 printf ("In write handler.....\n");
2075 r = cs_rcvconnect (p->cs_link);
2081 printf ("cs_rcvconnect error\n");
2082 ir_select_remove_write (cs_fileno (p->cs_link), p);
2084 Tcl_Eval (p->interp, p->failback);
2085 do_disconnect (p, NULL, 0, NULL);
2088 ir_select_remove_write (cs_fileno (p->cs_link), p);
2090 Tcl_Eval (p->interp, p->callback);
2093 if ((r=cs_put (p->cs_link, p->sbuf, p->slen)) < 0)
2095 printf ("select write fail\n");
2097 Tcl_Eval (p->interp, p->failback);
2098 do_disconnect (p, NULL, 0, NULL);
2100 else if (r == 0) /* remove select bit */
2102 ir_select_remove_write (cs_fileno (p->cs_link), p);
2106 /* ------------------------------------------------------- */
2109 * ir_tcl_init: Registration of TCL commands.
2111 int ir_tcl_init (Tcl_Interp *interp)
2113 Tcl_CreateCommand (interp, "ir", ir_obj_mk, (ClientData) NULL,
2114 (Tcl_CmdDeleteProc *) NULL);
2115 Tcl_CreateCommand (interp, "ir-set", ir_set_obj_mk,
2116 (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
2117 Tcl_CreateCommand (interp, "ir-scan", ir_scan_obj_mk,
2118 (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);