Procedure to change record syntax information added. Bug fixes.
[ir-tcl-moved-to-github.git] / ir-tcl.c
index ae10fcc..fc95e30 100644 (file)
--- a/ir-tcl.c
+++ b/ir-tcl.c
@@ -5,7 +5,14 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: ir-tcl.c,v $
- * Revision 1.105  1998-04-02 14:31:08  adam
+ * Revision 1.107  1998-06-10 13:00:46  adam
+ * Added ir-version command.
+ *
+ * Revision 1.106  1998/05/20 12:25:35  adam
+ * Fixed bug that occurred in rare cases when encoding of incoming
+ * records failed.
+ *
+ * Revision 1.105  1998/04/02 14:31:08  adam
  * This version works with compiled ASN.1 code.
  *
  * Revision 1.104  1998/02/27 14:26:07  adam
@@ -653,13 +660,14 @@ int ir_tcl_named_bits (struct ir_named_entry *tab, Odr_bitmask *ob,
         ODR_MASK_ZERO (ob);
         for (no = 0; no < argc; no++)
         {
+           int ok = 0;
             for (ti = tab; ti->name; ti++)
-                if (!strcmp (argv[no], ti->name))
+                if (!strcmp(argv[no], "@all") || !strcmp (argv[no], ti->name))
                 {
                     ODR_MASK_SET (ob, ti->pos);
-                    break;
+                    ok = 1;
                 }
-            if (!ti->name)
+            if (!ok)
             {
                 Tcl_AppendResult (interp, "bad bit mask ", argv[no], NULL);
                 return ir_tcl_error_exec (interp, argc, argv);
@@ -3485,6 +3493,18 @@ static int ir_log_proc (ClientData clientData, Tcl_Interp *interp,
 }
 
 
+/* 
+ * ir_version: log ir version
+ */
+static int ir_version (ClientData clientData, Tcl_Interp *interp,
+                        int argc, char **argv)
+{
+    Tcl_AppendElement (interp, IR_TCL_VERSION);
+    Tcl_AppendElement (interp, YAZ_VERSION);
+    return TCL_OK;
+}
+
+
 /* ------------------------------------------------------- */
 static void ir_initResponse (void *obj, Z_InitResponse *initrs)
 {
@@ -3591,7 +3611,8 @@ static void ir_handleDBRecord (IrTcl_Obj *p, IrTcl_RecordList *rl,
 {
     struct oident *ident;
     Z_ext_typeent *etype;
-                
+
+    logf (LOG_DEBUG, "handleDBRecord size=%d", oe->u.octet_aligned->len);
     rl->u.dbrec.size = oe->u.octet_aligned->len;
     rl->u.dbrec.buf = NULL;
     
@@ -3609,7 +3630,10 @@ static void ir_handleDBRecord (IrTcl_Obj *p, IrTcl_RecordList *rl,
         odr_setbuf (p->odr_in, (char*) oe->u.octet_aligned->buf,
                     oe->u.octet_aligned->len, 0);
         if (!(*etype->fun)(p->odr_in, (char **) &rr, 0))
+        {
+            rl->u.dbrec.type = VAL_NONE;
             return;
+        }
         switch (etype->what)
         {
         case Z_External_sutrs:
@@ -4195,6 +4219,8 @@ EXPORT (int,Irtcl_Init) (Tcl_Interp *interp)
                        (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
     Tcl_CreateCommand (interp, "ir-log", ir_log_proc,
                        (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
+    Tcl_CreateCommand (interp, "ir-version", ir_version, (ClientData) NULL,
+                       (Tcl_CmdDeleteProc *) NULL);
     nmem_init ();
     return TCL_OK;
 }