Better ODR diagnostics for missing elements which includes additional
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 20 May 2003 19:55:29 +0000 (19:55 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 20 May 2003 19:55:29 +0000 (19:55 +0000)
info with name of element. New ODR function odr_missing.
Removed depricated macros odr_implicit and odr_explicit.

22 files changed:
client/admin.h
client/client.c
doc/odr.xml
include/yaz/odr.h
odr/Makefile.am
odr/ber_tag.c
odr/odr-priv.h
odr/odr.c
odr/odr_any.c
odr/odr_bit.c
odr/odr_bool.c
odr/odr_cons.c
odr/odr_enum.c
odr/odr_int.c
odr/odr_null.c
odr/odr_oct.c
odr/odr_oid.c
odr/odr_use.c
odr/odr_util.c
odr/tstodr.c
util/yaz-comp
z39.50/z.tcl

index c44f70d..f692cf4 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1995-2003, Index Data
  * See the file LICENSE for details.
  *
  * Copyright (c) 1995-2003, Index Data
  * See the file LICENSE for details.
  *
- * $Id: admin.h,v 1.6 2003-03-11 11:07:47 adam Exp $
+ * $Id: admin.h,v 1.7 2003-05-20 19:55:29 adam Exp $
  */
 
 int cmd_adm_reindex(const char* arg);
  */
 
 int cmd_adm_reindex(const char* arg);
@@ -15,7 +15,7 @@ int cmd_adm_commit(const char* arg);
 int cmd_adm_shutdown(const char* arg);
 int cmd_adm_startup(const char* arg);
 
 int cmd_adm_shutdown(const char* arg);
 int cmd_adm_startup(const char* arg);
 
-void send_apdu(Z_APDU *a);
+int send_apdu(Z_APDU *a);
 /*
  * Local variables:
  * tab-width: 8
 /*
  * Local variables:
  * tab-width: 8
index 5aeb19e..2b314f5 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1995-2003, Index Data
  * See the file LICENSE for details.
  *
  * Copyright (c) 1995-2003, Index Data
  * See the file LICENSE for details.
  *
- * $Id: client.c,v 1.193 2003-05-19 20:44:33 adam Exp $
+ * $Id: client.c,v 1.194 2003-05-20 19:55:29 adam Exp $
  */
 
 #include <stdio.h>
  */
 
 #include <stdio.h>
@@ -183,7 +183,7 @@ void add_otherInfos(Z_APDU *a)
     }   
 }
 
     }   
 }
 
-void send_apdu(Z_APDU *a)
+int send_apdu(Z_APDU *a)
 {
     char *buf;
     int len;
 {
     char *buf;
     int len;
@@ -199,7 +199,7 @@ void send_apdu(Z_APDU *a)
     {
         odr_perror(out, "Encoding APDU");
         close_session();
     {
         odr_perror(out, "Encoding APDU");
         close_session();
-        return;
+        return 0;
     }
     buf = odr_getbuf(out, &len, 0);
     if (ber_file)
     }
     buf = odr_getbuf(out, &len, 0);
     if (ber_file)
@@ -209,10 +209,11 @@ void send_apdu(Z_APDU *a)
     {
         fprintf(stderr, "cs_put: %s", cs_errmsg(cs_errno(conn)));
         close_session();
     {
         fprintf(stderr, "cs_put: %s", cs_errmsg(cs_errno(conn)));
         close_session();
-        return;
+        return 0;
     }
     do_hex_dump(buf,len);
     odr_reset(out); /* release the APDU structure  */
     }
     do_hex_dump(buf,len);
     odr_reset(out); /* release the APDU structure  */
+    return 1;
 }
 
 static void print_stringn(const unsigned char *buf, size_t len)
 }
 
 static void print_stringn(const unsigned char *buf, size_t len)
@@ -297,8 +298,8 @@ static void send_initRequest(const char* type_and_host)
        }
     }
     
        }
     }
     
-    send_apdu(apdu);
-    printf("Sent initrequest.\n");
+    if (send_apdu(apdu))
+        printf("Sent initrequest.\n");
 }
 
 static int process_initResponse(Z_InitResponse *res)
 }
 
 static int process_initResponse(Z_InitResponse *res)
@@ -1138,9 +1139,9 @@ static int send_searchRequest(const char *arg)
         printf ("Unsupported query type\n");
         return 0;
     }
         printf ("Unsupported query type\n");
         return 0;
     }
-    send_apdu(apdu);
+    if (send_apdu(apdu))
+        printf("Sent searchRequest.\n");
     setno = 1;
     setno = 1;
-    printf("Sent searchRequest.\n");
     return 2;
 }
 
     return 2;
 }
 
index 820fa26..8b1cc4f 100644 (file)
@@ -1,4 +1,4 @@
-<!-- $Id: odr.xml,v 1.8 2002-09-03 09:50:34 adam Exp $ -->
+<!-- $Id: odr.xml,v 1.9 2003-05-20 19:55:29 adam Exp $ -->
  <chapter id="odr"><title>The ODR Module</title>
   
   <sect1 id="odr.introduction"><title>Introduction</title>
  <chapter id="odr"><title>The ODR Module</title>
   
   <sect1 id="odr.introduction"><title>Introduction</title>
@@ -744,8 +744,8 @@ int myInt(ODR o, int **p, int optional, const char *name)
     <para>
      The function <function>myInt()</function> can then be used like any of
      the primitive functions provided by &odr;. Note that the behavior of
     <para>
      The function <function>myInt()</function> can then be used like any of
      the primitive functions provided by &odr;. Note that the behavior of
-     <function>odr_explicit()</function>
-     and <function>odr_implicit()</function> macros
+     <function>odr_explicit_tag()</function>
+     and <function>odr_implicit_tag()</function> macros
      act exactly the same as the functions they are applied to - they
      respond to error conditions, etc, in the same manner - they
      simply have three extra parameters. The class parameter may
      act exactly the same as the functions they are applied to - they
      respond to error conditions, etc, in the same manner - they
      simply have three extra parameters. The class parameter may
@@ -826,7 +826,8 @@ int mySequence(ODR o, MySequence **p, int optional, const char *name)
      Note the 1 in the call to <function>odr_bool()</function>, to mark
      that the sequence member is optional.
      If either of the member types had been tagged, the macros
      Note the 1 in the call to <function>odr_bool()</function>, to mark
      that the sequence member is optional.
      If either of the member types had been tagged, the macros
-     <function>odr_implicit()</function> or <function>odr_explicit()</function>
+     <function>odr_implicit_tag()</function> or
+     <function>odr_explicit_tag()</function>
      could have been used.
      The new function can be used exactly like the standard functions provided
      with &odr;. It will encode, decode or pretty-print a data value of the
      could have been used.
      The new function can be used exactly like the standard functions provided
      with &odr;. It will encode, decode or pretty-print a data value of the
@@ -874,7 +875,7 @@ int odr_implicit_settag(ODR o, int class, int tag);
 
      <para>
       which overrides the tag of the type immediately following it. The
 
      <para>
       which overrides the tag of the type immediately following it. The
-      macro <function>odr_implicit()</function> works by calling
+      macro <function>odr_implicit_tag()</function> works by calling
       <function>odr_implicit_settag()</function> immediately
       before calling the function pointer argument.
       Your type function could look like this:
       <function>odr_implicit_settag()</function> immediately
       before calling the function pointer argument.
       Your type function could look like this:
@@ -964,7 +965,7 @@ int mySequence(ODR o, MySequence **p, int optional, const char *name)
       interface) is less than the time that would be required to develop a
       better interface. Nevertheless, it is far from satisfying, and it's a
       point that will be worked on in the future. One option for you would
       interface) is less than the time that would be required to develop a
       better interface. Nevertheless, it is far from satisfying, and it's a
       point that will be worked on in the future. One option for you would
-      be to simply apply the <function>odr_explicit()</function> macro to
+      be to simply apply the <function>odr_explicit_tag()</function> macro to
       the first function, and not
       have to worry about <function>odr_constructed_*</function> yourself.
       Incidentally, as you might have guessed, the
       the first function, and not
       have to worry about <function>odr_constructed_*</function> yourself.
       Incidentally, as you might have guessed, the
index bfd4d35..f4a0c26 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: odr.h,v 1.10 2003-03-18 13:34:35 adam Exp $
+ * $Id: odr.h,v 1.11 2003-05-20 19:55:29 adam Exp $
  */
 
 #ifndef ODR_H
  */
 
 #ifndef ODR_H
@@ -185,6 +185,8 @@ extern char *odr_errlist[];
 YAZ_EXPORT int odr_geterror(ODR o);
 YAZ_EXPORT int odr_geterrorx(ODR o, int *x);
 YAZ_EXPORT void odr_seterror(ODR o, int errorno, int errorid);
 YAZ_EXPORT int odr_geterror(ODR o);
 YAZ_EXPORT int odr_geterrorx(ODR o, int *x);
 YAZ_EXPORT void odr_seterror(ODR o, int errorno, int errorid);
+YAZ_EXPORT void odr_setaddinfo(ODR o, const char *addinfo);
+YAZ_EXPORT char *odr_getaddinfo(ODR o);
 YAZ_EXPORT void odr_perror(ODR o, char *message);
 YAZ_EXPORT void odr_setprint(ODR o, FILE *file);
 YAZ_EXPORT ODR odr_createmem(int direction);
 YAZ_EXPORT void odr_perror(ODR o, char *message);
 YAZ_EXPORT void odr_setprint(ODR o, FILE *file);
 YAZ_EXPORT ODR odr_createmem(int direction);
@@ -201,21 +203,13 @@ YAZ_EXPORT Odr_null *odr_nullval(void);
 #define odr_release_mem(m) nmem_destroy(m)
 #define ODR_MEM NMEM
 
 #define odr_release_mem(m) nmem_destroy(m)
 #define ODR_MEM NMEM
 
-#define odr_implicit(o, t, p, cl, tg, opt)\
-        (odr_implicit_settag((o), cl, tg), t ((o), (p), (opt), 0) )
-
 #define odr_implicit_tag(o, t, p, cl, tg, opt, name)\
         (odr_implicit_settag((o), cl, tg), t ((o), (p), (opt), name) )
 
 #define odr_implicit_tag(o, t, p, cl, tg, opt, name)\
         (odr_implicit_settag((o), cl, tg), t ((o), (p), (opt), name) )
 
-#define odr_explicit(o, t, p, cl, tg, opt)\
-        ((int) (odr_constructed_begin((o), (p), (cl), (tg), 0) ? \
-        t ((o), (p), (opt), 0) &&\
-        odr_constructed_end(o) : opt))
-
 #define odr_explicit_tag(o, t, p, cl, tg, opt, name)\
         ((int) (odr_constructed_begin((o), (p), (cl), (tg), 0) ? \
         t ((o), (p), (opt), name) &&\
 #define odr_explicit_tag(o, t, p, cl, tg, opt, name)\
         ((int) (odr_constructed_begin((o), (p), (cl), (tg), 0) ? \
         t ((o), (p), (opt), name) &&\
-        odr_constructed_end(o) : opt))
+        odr_constructed_end(o) : odr_missing((o), opt, name)))
 
 #define ODR_MASK_ZERO(mask)\
     ((void) (memset((mask)->bits, 0, ODR_BITMASK_SIZE),\
 
 #define ODR_MASK_ZERO(mask)\
     ((void) (memset((mask)->bits, 0, ODR_BITMASK_SIZE),\
@@ -242,7 +236,7 @@ YAZ_EXPORT Odr_null *odr_nullval(void);
 
 YAZ_EXPORT int ber_boolean(ODR o, int *val);
 YAZ_EXPORT int ber_tag(ODR o, void *p, int zclass, int tag,
 
 YAZ_EXPORT int ber_boolean(ODR o, int *val);
 YAZ_EXPORT int ber_tag(ODR o, void *p, int zclass, int tag,
-                      int *constructed, int opt);
+                      int *constructed, int opt, const char *name);
 YAZ_EXPORT int ber_enctag(ODR o, int zclass, int tag, int constructed);
 YAZ_EXPORT int ber_dectag(const unsigned char *buf, int *zclass,
                          int *tag, int *constructed, int max);
 YAZ_EXPORT int ber_enctag(ODR o, int zclass, int tag, int constructed);
 YAZ_EXPORT int ber_dectag(const unsigned char *buf, int *zclass,
                          int *tag, int *constructed, int max);
@@ -302,6 +296,7 @@ YAZ_EXPORT Odr_oid *odr_getoidbystr_nmem(NMEM o, const char *str);
 YAZ_EXPORT int odr_initmember(ODR o, void *p, int size);
 YAZ_EXPORT int odr_peektag(ODR o, int *zclass, int *tag, int *cons);
 YAZ_EXPORT void odr_setlenlen(ODR o, int len);
 YAZ_EXPORT int odr_initmember(ODR o, void *p, int size);
 YAZ_EXPORT int odr_peektag(ODR o, int *zclass, int *tag, int *cons);
 YAZ_EXPORT void odr_setlenlen(ODR o, int len);
+YAZ_EXPORT int odr_missing(ODR o, int opt, const char *name);
 
 typedef struct Odr_external
 {
 
 typedef struct Odr_external
 {
index 47d8321..eb074bc 100644 (file)
@@ -1,4 +1,4 @@
-## $Id: Makefile.am,v 1.8 2003-05-06 10:08:30 adam Exp $
+## $Id: Makefile.am,v 1.9 2003-05-20 19:55:29 adam Exp $
 
 noinst_LTLIBRARIES = libodr.la
 
 
 noinst_LTLIBRARIES = libodr.la
 
@@ -14,7 +14,7 @@ tstodr_LDADD = libodr.la ../util/libutil.la
 tstodr_SOURCES = tstodr.c tstodrcodec.c tstodrcodec.h 
 
 # Rule for generating codecs for our small ASN.1 spec
 tstodr_SOURCES = tstodr.c tstodrcodec.c tstodrcodec.h 
 
 # Rule for generating codecs for our small ASN.1 spec
-tstodrcodec.c tstodrcodec.h: $(srcdir)/tstodr.asn
+tstodrcodec.c tstodrcodec.h: $(srcdir)/tstodr.asn $(top_srcdir)/util/yaz-comp
        cd $(srcdir); $(top_srcdir)/util/yaz-comp tstodr.asn
 
 libodr_la_SOURCES = odr_bool.c ber_bool.c ber_len.c ber_tag.c odr_util.c \
        cd $(srcdir); $(top_srcdir)/util/yaz-comp tstodr.asn
 
 libodr_la_SOURCES = odr_bool.c ber_bool.c ber_len.c ber_tag.c odr_util.c \
index 0df6014..8c3e186 100644 (file)
@@ -3,7 +3,7 @@
  * See the file LICENSE for details.
  * Sebastian Hammer, Adam Dickmeiss
  *
  * See the file LICENSE for details.
  * Sebastian Hammer, Adam Dickmeiss
  *
- * $Id: ber_tag.c,v 1.25 2003-03-11 11:03:31 adam Exp $
+ * $Id: ber_tag.c,v 1.26 2003-05-20 19:55:29 adam Exp $
  */
 #if HAVE_CONFIG_H
 #include <config.h>
  */
 #if HAVE_CONFIG_H
 #include <config.h>
@@ -22,7 +22,8 @@
  *
  * Should perhaps be odr_tag?
  */
  *
  * Should perhaps be odr_tag?
  */
-int ber_tag(ODR o, void *p, int zclass, int tag, int *constructed, int opt)
+int ber_tag(ODR o, void *p, int zclass, int tag, int *constructed, int opt,
+            const char *name)
 {
     struct Odr_ber_tag *odr_ber_tag = &o->op->odr_ber_tag;
     int rd;
 {
     struct Odr_ber_tag *odr_ber_tag = &o->op->odr_ber_tag;
     int rd;
@@ -44,7 +45,10 @@ int ber_tag(ODR o, void *p, int zclass, int tag, int *constructed, int opt)
         if (!*pp)
         {
             if (!opt)
         if (!*pp)
         {
             if (!opt)
+            {
                 odr_seterror(o, OREQUIRED, 24);
                 odr_seterror(o, OREQUIRED, 24);
+                odr_setaddinfo (o, name);
+            }
             return 0;
         }
         if ((rd = ber_enctag(o, zclass, tag, *constructed)) < 0)
             return 0;
         }
         if ((rd = ber_enctag(o, zclass, tag, *constructed)) < 0)
@@ -59,7 +63,10 @@ int ber_tag(ODR o, void *p, int zclass, int tag, int *constructed, int opt)
         if (o->op->stackp > -1 && !odr_constructed_more(o))
         {
             if (!opt)
         if (o->op->stackp > -1 && !odr_constructed_more(o))
         {
             if (!opt)
+            {
                 odr_seterror(o, OREQUIRED, 25);
                 odr_seterror(o, OREQUIRED, 25);
+                odr_setaddinfo(o, name);
+            }
             return 0;
         }
         if (odr_ber_tag->lclass < 0)
             return 0;
         }
         if (odr_ber_tag->lclass < 0)
@@ -70,6 +77,7 @@ int ber_tag(ODR o, void *p, int zclass, int tag, int *constructed, int opt)
                             odr_max(o))) <= 0)
             {
                 odr_seterror(o, OPROTO, 26);
                             odr_max(o))) <= 0)
             {
                 odr_seterror(o, OPROTO, 26);
+                odr_setaddinfo(o, name);
                 return 0;
             }
 #ifdef ODR_DEBUG
                 return 0;
             }
 #ifdef ODR_DEBUG
@@ -89,15 +97,22 @@ int ber_tag(ODR o, void *p, int zclass, int tag, int *constructed, int opt)
         else
         {
             if (!opt)
         else
         {
             if (!opt)
+            {
                 odr_seterror(o, OREQUIRED, 27);
                 odr_seterror(o, OREQUIRED, 27);
+                odr_setaddinfo(o, name);
+            }
             return 0;
         }
     case ODR_PRINT:
         if (!*pp && !opt)
             return 0;
         }
     case ODR_PRINT:
         if (!*pp && !opt)
+        {
             odr_seterror(o,OREQUIRED, 28);
             odr_seterror(o,OREQUIRED, 28);
+            odr_setaddinfo(o, name);
+        }
         return *pp != 0;
     default:
         odr_seterror(o, OOTHER, 29);
         return *pp != 0;
     default:
         odr_seterror(o, OOTHER, 29);
+        odr_setaddinfo(o, name);
         return 0;
     }
 }
         return 0;
     }
 }
index 01b1a4f..fef7455 100644 (file)
@@ -23,7 +23,7 @@
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  *
- * $Id: odr-priv.h,v 1.4 2003-03-11 11:03:31 adam Exp $
+ * $Id: odr-priv.h,v 1.5 2003-05-20 19:55:29 adam Exp $
  */
 
 #ifndef ODR_PRIV_H
  */
 
 #ifndef ODR_PRIV_H
@@ -52,6 +52,7 @@ struct Odr_private {
     struct Odr_ber_tag odr_ber_tag;
     yaz_iconv_t iconv_handle;
     int error_id;
     struct Odr_ber_tag odr_ber_tag;
     yaz_iconv_t iconv_handle;
     int error_id;
+    char addinfo[80];
 };
 
 /* Private macro.
 };
 
 /* Private macro.
index 948043c..a29f720 100644 (file)
--- a/odr/odr.c
+++ b/odr/odr.c
@@ -2,7 +2,7 @@
  * Copyright (c) 1995-2003, Index Data
  * See the file LICENSE for details.
  *
  * Copyright (c) 1995-2003, Index Data
  * See the file LICENSE for details.
  *
- * $Id: odr.c,v 1.42 2003-05-19 14:37:38 adam Exp $
+ * $Id: odr.c,v 1.43 2003-05-20 19:55:29 adam Exp $
  *
  */
 #if HAVE_CONFIG_H
  *
  */
 #if HAVE_CONFIG_H
@@ -36,7 +36,7 @@ char *odr_errlist[] =
     "Stack overflow",
     "Length of constructed type different from sum of members",
     "Overflow writing definite length of constructed type",
     "Stack overflow",
     "Length of constructed type different from sum of members",
     "Overflow writing definite length of constructed type",
-    "HTTP Bad Request"
+    "Bad HTTP Request"
 };
 
 char *odr_errmsg(int n)
 };
 
 char *odr_errmsg(int n)
@@ -46,7 +46,8 @@ char *odr_errmsg(int n)
 
 void odr_perror(ODR o, char *message)
 {
 
 void odr_perror(ODR o, char *message)
 {
-    fprintf(stderr, "%s: %s\n", message, odr_errlist[o->error]);
+    fprintf(stderr, "%s: %s: %s\n", message, odr_errlist[o->error],
+            odr_getaddinfo(o));
 }
 
 int odr_geterror(ODR o)
 }
 
 int odr_geterror(ODR o)
@@ -61,10 +62,25 @@ int odr_geterrorx(ODR o, int *x)
     return o->error;
 }
 
     return o->error;
 }
 
+char *odr_getaddinfo(ODR o)
+{
+    return o->op->addinfo;
+}
+
 void odr_seterror(ODR o, int error, int id)
 {
     o->error = error;
     o->op->error_id = id;
 void odr_seterror(ODR o, int error, int id)
 {
     o->error = error;
     o->op->error_id = id;
+    o->op->addinfo[0] = '\0';
+}
+
+void odr_setaddinfo(ODR o, const char *addinfo)
+{
+    if (addinfo)
+    {
+        strncpy(o->op->addinfo, addinfo, sizeof(o->op->addinfo)-1);
+        o->op->addinfo[sizeof(o->op->addinfo)-1] = '\0';
+    }
 }
 
 void odr_setprint(ODR o, FILE *file)
 }
 
 void odr_setprint(ODR o, FILE *file)
index 0def5ee..e464872 100644 (file)
@@ -3,7 +3,7 @@
  * See the file LICENSE for details.
  * Sebastian Hammer, Adam Dickmeiss
  *
  * See the file LICENSE for details.
  * Sebastian Hammer, Adam Dickmeiss
  *
- * $Id: odr_any.c,v 1.13 2003-03-11 11:03:31 adam Exp $
+ * $Id: odr_any.c,v 1.14 2003-05-20 19:55:30 adam Exp $
  */
 #if HAVE_CONFIG_H
 #include <config.h>
  */
 #if HAVE_CONFIG_H
 #include <config.h>
@@ -32,7 +32,5 @@ int odr_any(ODR o, Odr_any **p, int opt, const char *name)
     if (ber_any(o, p))
        return 1;
     *p = 0;
     if (ber_any(o, p))
        return 1;
     *p = 0;
-    if (!opt)
-        odr_seterror(o, OREQUIRED, 53);
-    return opt;
-}    
+    return odr_missing(o, opt, name);
+}
index 5cae833..07d0647 100644 (file)
@@ -3,7 +3,7 @@
  * See the file LICENSE for details.
  * Sebastian Hammer, Adam Dickmeiss
  *
  * See the file LICENSE for details.
  * Sebastian Hammer, Adam Dickmeiss
  *
- * $Id: odr_bit.c,v 1.17 2003-04-24 12:48:47 adam Exp $
+ * $Id: odr_bit.c,v 1.18 2003-05-20 19:55:30 adam Exp $
  */
 #if HAVE_CONFIG_H
 #include <config.h>
  */
 #if HAVE_CONFIG_H
 #include <config.h>
@@ -27,10 +27,10 @@ int odr_bitstring(ODR o, Odr_bitmask **p, int opt, const char *name)
        o->t_class = ODR_UNIVERSAL;
        o->t_tag = ODR_BITSTRING;
     }
        o->t_class = ODR_UNIVERSAL;
        o->t_tag = ODR_BITSTRING;
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt)) < 0)
+    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt, name)) < 0)
        return 0;
     if (!res)
        return 0;
     if (!res)
-       return opt;
+       return odr_missing(o, opt, name);
     if (o->direction == ODR_PRINT)
     {
        odr_prname(o, name);
     if (o->direction == ODR_PRINT)
     {
        odr_prname(o, name);
index f1cb60a..9ad56a8 100644 (file)
@@ -3,7 +3,7 @@
  * See the file LICENSE for details.
  * Sebastian Hammer, Adam Dickmeiss
  *
  * See the file LICENSE for details.
  * Sebastian Hammer, Adam Dickmeiss
  *
- * $Id: odr_bool.c,v 1.14 2003-01-06 08:20:27 adam Exp $
+ * $Id: odr_bool.c,v 1.15 2003-05-20 19:55:30 adam Exp $
  */
 #if HAVE_CONFIG_H
 #include <config.h>
  */
 #if HAVE_CONFIG_H
 #include <config.h>
@@ -27,10 +27,10 @@ int odr_bool(ODR o, int **p, int opt, const char *name)
        o->t_class = ODR_UNIVERSAL;
        o->t_tag = ODR_BOOLEAN;
     }
        o->t_class = ODR_UNIVERSAL;
        o->t_tag = ODR_BOOLEAN;
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt)) < 0)
+    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt, name)) < 0)
        return 0;
     if (!res)
        return 0;
     if (!res)
-       return opt;
+       return odr_missing(o, opt, name);
     if (o->direction == ODR_PRINT)
     {
        odr_prname(o, name);
     if (o->direction == ODR_PRINT)
     {
        odr_prname(o, name);
index 806e38c..1521343 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1995-2003, Index Data
  * See the file LICENSE for details.
  *
  * Copyright (c) 1995-2003, Index Data
  * See the file LICENSE for details.
  *
- * $Id: odr_cons.c,v 1.25 2003-03-11 11:03:31 adam Exp $
+ * $Id: odr_cons.c,v 1.26 2003-05-20 19:55:30 adam Exp $
  *
  */
 #if HAVE_CONFIG_H
  *
  */
 #if HAVE_CONFIG_H
@@ -31,7 +31,7 @@ int odr_constructed_begin(ODR o, void *p, int zclass, int tag,
        o->t_class = zclass;
        o->t_tag = tag;
     }
        o->t_class = zclass;
        o->t_tag = tag;
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, 1)) < 0)
+    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, 1, name)) < 0)
        return 0;
     if (!res || !cons)
        return 0;
        return 0;
     if (!res || !cons)
        return 0;
index 0dda8bb..22c20d8 100644 (file)
@@ -3,7 +3,7 @@
  * See the file LICENSE for details.
  * Sebastian Hammer, Adam Dickmeiss
  *
  * See the file LICENSE for details.
  * Sebastian Hammer, Adam Dickmeiss
  *
- * $Id: odr_enum.c,v 1.8 2003-03-11 11:03:31 adam Exp $
+ * $Id: odr_enum.c,v 1.9 2003-05-20 19:55:30 adam Exp $
  */
 #if HAVE_CONFIG_H
 #include <config.h>
  */
 #if HAVE_CONFIG_H
 #include <config.h>
@@ -26,10 +26,10 @@ int odr_enum(ODR o, int **p, int opt, const char *name)
         o->t_class = ODR_UNIVERSAL;
         o->t_tag = ODR_ENUM;
     }
         o->t_class = ODR_UNIVERSAL;
         o->t_tag = ODR_ENUM;
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt)) < 0)
+    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt, name)) < 0)
         return 0;
     if (!res)
         return 0;
     if (!res)
-        return opt;
+        return odr_missing(o, opt, name);
     if (o->direction == ODR_PRINT)
     {
        odr_prname(o, name);
     if (o->direction == ODR_PRINT)
     {
        odr_prname(o, name);
index f5a3b33..a685761 100644 (file)
@@ -3,7 +3,7 @@
  * See the file LICENSE for details.
  * Sebastian Hammer, Adam Dickmeiss
  *
  * See the file LICENSE for details.
  * Sebastian Hammer, Adam Dickmeiss
  *
- * $Id: odr_int.c,v 1.18 2003-03-11 11:03:31 adam Exp $
+ * $Id: odr_int.c,v 1.19 2003-05-20 19:55:30 adam Exp $
  */
 #if HAVE_CONFIG_H
 #include <config.h>
  */
 #if HAVE_CONFIG_H
 #include <config.h>
@@ -26,10 +26,10 @@ int odr_integer(ODR o, int **p, int opt, const char *name)
         o->t_class = ODR_UNIVERSAL;
         o->t_tag = ODR_INTEGER;
     }
         o->t_class = ODR_UNIVERSAL;
         o->t_tag = ODR_INTEGER;
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt)) < 0)
+    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt, name)) < 0)
         return 0;
     if (!res)
         return 0;
     if (!res)
-        return opt;
+        return odr_missing(o, opt, name);
     if (o->direction == ODR_PRINT)
     {
        odr_prname(o, name);
     if (o->direction == ODR_PRINT)
     {
        odr_prname(o, name);
index 8524f8f..8e7d85d 100644 (file)
@@ -3,7 +3,7 @@
  * See the file LICENSE for details.
  * Sebastian Hammer, Adam Dickmeiss
  *
  * See the file LICENSE for details.
  * Sebastian Hammer, Adam Dickmeiss
  *
- * $Id: odr_null.c,v 1.16 2003-03-11 11:03:31 adam Exp $
+ * $Id: odr_null.c,v 1.17 2003-05-20 19:55:30 adam Exp $
  */
 #if HAVE_CONFIG_H
 #include <config.h>
  */
 #if HAVE_CONFIG_H
 #include <config.h>
@@ -26,10 +26,10 @@ int odr_null(ODR o, Odr_null **p, int opt, const char *name)
        o->t_class = ODR_UNIVERSAL;
        o->t_tag = ODR_NULL;
     }
        o->t_class = ODR_UNIVERSAL;
        o->t_tag = ODR_NULL;
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt)) < 0)
+    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt, name)) < 0)
        return 0;
     if (!res)
        return 0;
     if (!res)
-       return opt;
+       return odr_missing(o, opt, name);
     if (o->direction == ODR_PRINT)
     {
        odr_prname(o, name);
     if (o->direction == ODR_PRINT)
     {
        odr_prname(o, name);
index dee25a7..c0458dd 100644 (file)
@@ -3,7 +3,7 @@
  * See the file LICENSE for details.
  * Sebastian Hammer, Adam Dickmeiss
  *
  * See the file LICENSE for details.
  * Sebastian Hammer, Adam Dickmeiss
  *
- * $Id: odr_oct.c,v 1.21 2003-03-11 11:03:31 adam Exp $
+ * $Id: odr_oct.c,v 1.22 2003-05-20 19:55:30 adam Exp $
  */
 #if HAVE_CONFIG_H
 #include <config.h>
  */
 #if HAVE_CONFIG_H
 #include <config.h>
@@ -27,10 +27,10 @@ int odr_octetstring(ODR o, Odr_oct **p, int opt, const char *name)
        o->t_class = ODR_UNIVERSAL;
        o->t_tag = ODR_OCTETSTRING;
     }
        o->t_class = ODR_UNIVERSAL;
        o->t_tag = ODR_OCTETSTRING;
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt)) < 0)
+    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt, name)) < 0)
        return 0;
     if (!res)
        return 0;
     if (!res)
-       return opt;
+       return odr_missing(o, opt, name);
     if (o->direction == ODR_PRINT)
     {
         int i;
     if (o->direction == ODR_PRINT)
     {
         int i;
@@ -76,10 +76,10 @@ int odr_cstring(ODR o, char **p, int opt, const char *name)
        o->t_class = ODR_UNIVERSAL;
        o->t_tag = ODR_OCTETSTRING;
     }
        o->t_class = ODR_UNIVERSAL;
        o->t_tag = ODR_OCTETSTRING;
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt)) < 0)
+    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt, name)) < 0)
        return 0;
     if (!res)
        return 0;
     if (!res)
-       return opt;
+       return odr_missing(o, opt, name);
     if (o->direction == ODR_PRINT)
     {
        odr_prname(o, name);
     if (o->direction == ODR_PRINT)
     {
        odr_prname(o, name);
@@ -123,10 +123,10 @@ int odr_iconv_string(ODR o, char **p, int opt, const char *name)
        o->t_class = ODR_UNIVERSAL;
        o->t_tag = ODR_OCTETSTRING;
     }
        o->t_class = ODR_UNIVERSAL;
        o->t_tag = ODR_OCTETSTRING;
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt)) < 0)
+    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt, name)) < 0)
        return 0;
     if (!res)
        return 0;
     if (!res)
-       return opt;
+       return odr_missing(o, opt, name);
     if (o->direction == ODR_PRINT)
     {
        odr_prname(o, name);
     if (o->direction == ODR_PRINT)
     {
        odr_prname(o, name);
index 6d575d1..4077f36 100644 (file)
@@ -3,7 +3,7 @@
  * See the file LICENSE for details.
  * Sebastian Hammer, Adam Dickmeiss
  *
  * See the file LICENSE for details.
  * Sebastian Hammer, Adam Dickmeiss
  *
- * $Id: odr_oid.c,v 1.19 2003-03-11 11:03:31 adam Exp $
+ * $Id: odr_oid.c,v 1.20 2003-05-20 19:55:30 adam Exp $
  */
 #if HAVE_CONFIG_H
 #include <config.h>
  */
 #if HAVE_CONFIG_H
 #include <config.h>
@@ -27,10 +27,10 @@ int odr_oid(ODR o, Odr_oid **p, int opt, const char *name)
        o->t_class = ODR_UNIVERSAL;
        o->t_tag = ODR_OID;
     }
        o->t_class = ODR_UNIVERSAL;
        o->t_tag = ODR_OID;
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt)) < 0)
+    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt, name)) < 0)
        return 0;
     if (!res)
        return 0;
     if (!res)
-       return opt;
+       return odr_missing(o, opt, name);
     if (cons)
     {
         odr_seterror(o, OPROTO, 46);
     if (cons)
     {
         odr_seterror(o, OPROTO, 46);
index 5ae1e9c..918d69d 100644 (file)
@@ -3,7 +3,7 @@
  * See the file LICENSE for details.
  * Sebastian Hammer, Adam Dickmeiss
  *
  * See the file LICENSE for details.
  * Sebastian Hammer, Adam Dickmeiss
  *
- * $Id: odr_use.c,v 1.13 2003-01-06 08:20:28 adam Exp $
+ * $Id: odr_use.c,v 1.14 2003-05-20 19:55:30 adam Exp $
  */
 #if HAVE_CONFIG_H
 #include <config.h>
  */
 #if HAVE_CONFIG_H
 #include <config.h>
@@ -27,7 +27,7 @@ int odr_external(ODR o, Odr_external **p, int opt, const char *name)
 
     odr_implicit_settag(o, ODR_UNIVERSAL, ODR_EXTERNAL);
     if (!odr_sequence_begin(o, p, sizeof(Odr_external), name))
 
     odr_implicit_settag(o, ODR_UNIVERSAL, ODR_EXTERNAL);
     if (!odr_sequence_begin(o, p, sizeof(Odr_external), name))
-       return opt;
+       return odr_missing(o, opt, name);
     pp = *p;
     return
        odr_oid(o, &pp->direct_reference, 1, "direct") &&
     pp = *p;
     return
        odr_oid(o, &pp->direct_reference, 1, "direct") &&
index 3f450ca..26a672c 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (c) 1995-2003, Index Data
  * See the file LICENSE for details.
  *
  * Copyright (c) 1995-2003, Index Data
  * See the file LICENSE for details.
  *
- * $Id: odr_util.c,v 1.22 2003-01-06 08:20:28 adam Exp $
+ * $Id: odr_util.c,v 1.23 2003-05-20 19:55:30 adam Exp $
  */
 #if HAVE_CONFIG_H
 #include <config.h>
  */
 #if HAVE_CONFIG_H
 #include <config.h>
@@ -81,4 +81,15 @@ Odr_oid *odr_getoidbystr(ODR o, const char *str)
     return odr_getoidbystr_nmem (o->mem, str);
 }
 
     return odr_getoidbystr_nmem (o->mem, str);
 }
 
-
+int odr_missing(ODR o, int opt, const char *name)
+{
+    if (o->error)
+        return 0;
+    if (!opt)
+    {
+        printf ("odr_missing set error : %s\n", name);
+        odr_seterror(o, OREQUIRED, 55);
+        odr_setaddinfo(o, name);
+    }
+    return opt;
+}
index 1b36a5e..4d681a1 100644 (file)
@@ -2,14 +2,14 @@
  * Copyright (c) 1995-2003, Index Data
  * See the file LICENSE for details.
  *
  * Copyright (c) 1995-2003, Index Data
  * See the file LICENSE for details.
  *
- * $Id: tstodr.c,v 1.2 2003-05-06 13:09:15 adam Exp $
+ * $Id: tstodr.c,v 1.3 2003-05-20 19:55:30 adam Exp $
  *
  */
 #include <stdio.h>
 #include <yaz/odr.h>
 #include "tstodrcodec.h"
 
  *
  */
 #include <stdio.h>
 #include <yaz/odr.h>
 #include "tstodrcodec.h"
 
-void tst_MySequence(ODR encode, ODR decode)
+void tst_MySequence1(ODR encode, ODR decode)
 {
     char *ber_buf;
     int ber_len;
 {
     char *ber_buf;
     int ber_len;
@@ -48,12 +48,43 @@ void tst_MySequence(ODR encode, ODR decode)
         exit(8);
 }
 
         exit(8);
 }
 
+void tst_MySequence2(ODR encode, ODR decode)
+{
+    char *ber_buf;
+    int ber_len;
+    Yc_MySequence *s = odr_malloc(encode, sizeof(*s));
+    Yc_MySequence *t;
+
+    s->first = 0;  /* deliberately miss this .. */
+    s->second = odr_malloc(encode, sizeof(*s->second));
+    s->second->buf = "hello";
+    s->second->len = 5;
+    s->second->size = 0;
+    s->third = odr_intdup(encode, 1);
+    s->fourth = odr_nullval();
+    s->fifth = odr_intdup(encode, YC_MySequence_enum1);
+
+    if (yc_MySequence(encode, &s, 0, 0)) /* should fail */
+        exit(9);
+    if (odr_geterror(encode) != OREQUIRED)
+        exit(10);
+    if (strcmp(odr_getaddinfo(encode), "first"))
+        exit(11);
+    odr_reset(encode);
+
+    if (odr_geterror(encode) != ONONE)
+        exit(12);
+    if (strcmp(odr_getaddinfo(encode), ""))
+        exit(13);
+}
+
 int main(int argc, char **argv)
 {
     ODR odr_encode = odr_createmem(ODR_ENCODE);
     ODR odr_decode = odr_createmem(ODR_DECODE);
 
 int main(int argc, char **argv)
 {
     ODR odr_encode = odr_createmem(ODR_ENCODE);
     ODR odr_decode = odr_createmem(ODR_DECODE);
 
-    tst_MySequence(odr_encode, odr_decode);
+    tst_MySequence1(odr_encode, odr_decode);
+    tst_MySequence2(odr_encode, odr_decode);
 
     odr_destroy(odr_encode);
     odr_destroy(odr_decode);
 
     odr_destroy(odr_encode);
     odr_destroy(odr_decode);
index f7a1c06..247b607 100755 (executable)
@@ -6,7 +6,7 @@ exec tclsh "$0" "$@"
 # (c) Index Data 1996-2003
 # See the file LICENSE for details.
 #
 # (c) Index Data 1996-2003
 # See the file LICENSE for details.
 #
-# $Id: yaz-comp,v 1.5 2003-05-06 10:06:43 adam Exp $
+# $Id: yaz-comp,v 1.6 2003-05-20 19:55:30 adam Exp $
 #
 
 set yc_version 0.3
 #
 
 set yc_version 0.3
@@ -510,14 +510,14 @@ proc asnSequence {name tag implicit tagtype} {
     set nchoice 0
     if {![string length $tag]} {
         lappend l "\tif (!odr_sequence_begin (o, p, sizeof(**p), name))"
     set nchoice 0
     if {![string length $tag]} {
         lappend l "\tif (!odr_sequence_begin (o, p, sizeof(**p), name))"
-        lappend l "\t\treturn opt && odr_ok (o);"
+        lappend l "\t\treturn odr_missing(o, opt, name) && odr_ok (o);"
     } elseif {$implicit} {
         lappend l "\tif (!odr_implicit_settag (o, $tagtype, $tag) ||"
         lappend l "\t\t!odr_sequence_begin (o, p, sizeof(**p), name))"
     } elseif {$implicit} {
         lappend l "\tif (!odr_implicit_settag (o, $tagtype, $tag) ||"
         lappend l "\t\t!odr_sequence_begin (o, p, sizeof(**p), name))"
-        lappend l "\t\treturn opt && odr_ok(o);"
+        lappend l "\t\treturn odr_missing(o, opt, name);"
     } else {
         lappend l "\tif (!odr_constructed_begin (o, p, $tagtype, $tag, name))"
     } else {
         lappend l "\tif (!odr_constructed_begin (o, p, $tagtype, $tag, name))"
-        lappend l "\t\treturn opt && odr_ok(o);"
+        lappend l "\t\treturn odr_missing(o, opt, name);"
         lappend l "\tif (o->direction == ODR_DECODE)"
         lappend l "\t\t*p = ($inf(vprefix)$name *) odr_malloc (o, sizeof(**p));"
 
         lappend l "\tif (o->direction == ODR_DECODE)"
         lappend l "\t\t*p = ($inf(vprefix)$name *) odr_malloc (o, sizeof(**p));"
 
@@ -709,7 +709,7 @@ proc asnOf {name tag implicit tagtype isset} {
     lappend j "\tint [lindex $numName 0];"
 
     lappend l "\tif (!odr_initmember (o, p, sizeof(**p)))"
     lappend j "\tint [lindex $numName 0];"
 
     lappend l "\tif (!odr_initmember (o, p, sizeof(**p)))"
-    lappend l "\t\treturn opt && odr_ok(o);"
+    lappend l "\t\treturn odr_missing(o, opt, name);"
     if {[string length $tag]} {
         if {$implicit} {
             lappend l "\todr_implicit_settag (o, $tagtype, $tag);"
     if {[string length $tag]} {
         if {$implicit} {
             lappend l "\todr_implicit_settag (o, $tagtype, $tag);"
@@ -736,7 +736,7 @@ proc asnOf {name tag implicit tagtype isset} {
     lappend j "\}"
     lappend l "\t\treturn 1;"
     lappend l "\t*p = 0;"
     lappend j "\}"
     lappend l "\t\treturn 1;"
     lappend l "\t*p = 0;"
-    lappend l "\treturn opt && odr_ok(o);"
+    lappend l "\treturn odr_missing(o, opt, name);"
     return [list [join $l \n] [join $j \n]]
 }
 
     return [list [join $l \n] [join $j \n]]
 }
 
@@ -832,26 +832,26 @@ proc asnChoice {name tag implicit tagtype} {
     lappend l "\t\};"
     if {![string length $tag]} {
        lappend l "\tif (!odr_initmember(o, p, sizeof(**p)))"
     lappend l "\t\};"
     if {![string length $tag]} {
        lappend l "\tif (!odr_initmember(o, p, sizeof(**p)))"
-       lappend l "\t\treturn opt && odr_ok(o);"
+       lappend l "\t\treturn odr_missing(o, opt, name);"
        lappend l "\tif (odr_choice(o, arm, &(*p)->[lindex $uName 1], &(*p)->[lindex $uName 0], name))"
     } elseif {$implicit} {
        lappend l "\tif (!odr_initmember(o, p, sizeof(**p)))"
        lappend l "\tif (odr_choice(o, arm, &(*p)->[lindex $uName 1], &(*p)->[lindex $uName 0], name))"
     } elseif {$implicit} {
        lappend l "\tif (!odr_initmember(o, p, sizeof(**p)))"
-       lappend l "\t\treturn opt && odr_ok(o);"
+       lappend l "\t\treturn odr_missing(o, opt, name);"
        lappend l "\todr_implicit_settag(o, $tagtype, $tag);"
        lappend l "\tif (odr_choice(o, arm, &(*p)->[lindex $uName 1], &(*p)->[lindex $uName 0], name))"
     } else {
        lappend l "\tif (!*p && o->direction != ODR_DECODE)"
        lappend l "\t\treturn opt;"
        lappend l "\tif (!odr_constructed_begin(o, p, $tagtype, $tag, 0))"
        lappend l "\todr_implicit_settag(o, $tagtype, $tag);"
        lappend l "\tif (odr_choice(o, arm, &(*p)->[lindex $uName 1], &(*p)->[lindex $uName 0], name))"
     } else {
        lappend l "\tif (!*p && o->direction != ODR_DECODE)"
        lappend l "\t\treturn opt;"
        lappend l "\tif (!odr_constructed_begin(o, p, $tagtype, $tag, 0))"
-       lappend l "\t\treturn opt && odr_ok(o);"
+       lappend l "\t\treturn odr_missing(o, opt, name);"
        lappend l "\tif (!odr_initmember(o, p, sizeof(**p)))"
        lappend l "\tif (!odr_initmember(o, p, sizeof(**p)))"
-       lappend l "\t\treturn opt && odr_ok(o);"
+       lappend l "\t\treturn odr_missing(o, opt, name);"
        lappend l "\tif (odr_choice(o, arm, &(*p)->[lindex $uName 1], &(*p)->[lindex $uName 0], name) &&"
        lappend l "\t\todr_constructed_end(o))"
     }
     lappend l "\t\treturn 1;"
     lappend l "\t*p = 0;"
        lappend l "\tif (odr_choice(o, arm, &(*p)->[lindex $uName 1], &(*p)->[lindex $uName 0], name) &&"
        lappend l "\t\todr_constructed_end(o))"
     }
     lappend l "\t\treturn 1;"
     lappend l "\t*p = 0;"
-    lappend l "\treturn opt && odr_ok(o);"
+    lappend l "\treturn odr_missing(o, opt, name);"
     return [list [join $l \n] [join $j \n]]
 }
 
     return [list [join $l \n] [join $j \n]]
 }
 
index 47bb1c3..c0855a6 100644 (file)
@@ -1,5 +1,5 @@
 # YC Sample Config File for Z39.50
 # YC Sample Config File for Z39.50
-# $Id: z.tcl,v 1.10 2003-02-17 21:23:31 adam Exp $
+# $Id: z.tcl,v 1.11 2003-05-20 19:55:30 adam Exp $
 # ----------------------------------------------------------
 # Prefix Specifications
 #  
 # ----------------------------------------------------------
 # Prefix Specifications
 #  
@@ -208,8 +208,8 @@ set filename($m) z-sutrs
 set body($m,c) {
 int z_SUTRS (ODR o, Odr_oct **p, int opt, const char *name)
 {
 set body($m,c) {
 int z_SUTRS (ODR o, Odr_oct **p, int opt, const char *name)
 {
-    return odr_implicit(o, odr_octetstring, p, ODR_UNIVERSAL,
-        ODR_GENERALSTRING, opt);
+    return odr_implicit_tag(o, odr_octetstring, p, ODR_UNIVERSAL,
+        ODR_GENERALSTRING, opt, name);
 }
 }
 
 }
 }