A damn mess, but now things work, I think.
authorSebastian Hammer <quinn@indexdata.com>
Tue, 7 Feb 1995 17:52:58 +0000 (17:52 +0000)
committerSebastian Hammer <quinn@indexdata.com>
Tue, 7 Feb 1995 17:52:58 +0000 (17:52 +0000)
odr/ber_int.c
odr/ber_tag.c
odr/odr_choice.c [new file with mode: 0644]
odr/odr_cons.c
odr/odr_seq.c

index d259da3..b262781 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: ber_int.c,v $
- * Revision 1.1  1995-02-02 16:21:52  quinn
+ * Revision 1.2  1995-02-07 17:52:58  quinn
+ * A damn mess, but now things work, I think.
+ *
+ * Revision 1.1  1995/02/02  16:21:52  quinn
  * First kick.
  *
  */
@@ -63,7 +66,7 @@ int ber_encinteger(unsigned char *buf, int val, int maxlen)
     b += len;
     if (ber_enclen(lenpos, len, 1, 1) != 1)
        return -1;
-    fprintf(stderr, "[val=%d]\n", val);
+    fprintf(stderr, "[val=%d]", val);
     return b - buf;
 }
 
@@ -92,6 +95,6 @@ int ber_decinteger(unsigned char *buf, int *val)
     *val = ntohl(tmp.i);
 
     b += len;
-    fprintf(stderr, "[val=%d]\n", *val);
+    fprintf(stderr, "[val=%d]", *val);
     return b - buf;
 }
index 21c3685..8c524c0 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: ber_tag.c,v $
- * Revision 1.1  1995-02-02 16:21:53  quinn
+ * Revision 1.2  1995-02-07 17:52:59  quinn
+ * A damn mess, but now things work, I think.
+ *
+ * Revision 1.1  1995/02/02  16:21:53  quinn
  * First kick.
  *
  */
@@ -37,7 +40,7 @@ int ber_tag(ODR o, const void *p, int class, int tag, int *constructed)
                return -1;
            o->bp += rd;
            o->left -= rd;
-           fprintf(stderr, "[class=%d,tag=%d,cons=%d]", class, tag,
+           fprintf(stderr, "\n[class=%d,tag=%d,cons=%d]", class, tag,
                *constructed);
            return 1;
        case ODR_DECODE:
@@ -45,7 +48,7 @@ int ber_tag(ODR o, const void *p, int class, int tag, int *constructed)
            {
                if ((br = ber_dectag(o->bp, &lclass, &ltag, &lcons)) <= 0)
                    return -1;
-               fprintf(stderr, "[class=%d,tag=%d,cons=%d]", lclass, ltag,
+               fprintf(stderr, "\n[class=%d,tag=%d,cons=%d]", lclass, ltag,
                    lcons);
            }
            if (class == lclass && tag == ltag)
diff --git a/odr/odr_choice.c b/odr/odr_choice.c
new file mode 100644 (file)
index 0000000..0866311
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 1994, Index Data I/S 
+ * All rights reserved.
+ * Sebastian Hammer, Adam Dickmeiss
+ *
+ * $Log: odr_choice.c,v $
+ * Revision 1.1  1995-02-07 17:52:59  quinn
+ * A damn mess, but now things work, I think.
+ *
+ */
+
+#include <odr.h>
+
+int odr_choice(ODR o, Odr_arm arm[], void *p, int *which)
+{
+    int i, cl = -1, tg, cn;
+
+    if (o->direction != ODR_DECODE && !*(char*)p)
+       return 0;
+    for (i = 0; arm[i].fun; i++)
+    {
+       if (o->direction == ODR_DECODE)
+           *which = arm[i].which;
+       else if (*which != arm[i].which)
+           continue;
+
+       if (arm[i].tagmode != ODR_NONE)
+       {
+           if (o->direction == ODR_DECODE && cl < 0)
+           {
+               if (ber_dectag(o->bp, &cl, &tg, &cn) <= 0)
+                   return 0;
+           }
+           else if (o->direction != ODR_DECODE)
+           {
+               cl = arm[i].class;
+               tg = arm[i].tag;
+           }
+           if (tg == arm[i].tag && cl == arm[i].class)
+           {
+               if (arm[i].tagmode == ODR_IMPLICIT)
+               {
+                   odr_implicit_settag(o, cl, tg);
+                   return (*arm[i].fun)(o, p, 0);
+               }
+               /* explicit */
+               if (!odr_constructed_begin(o, p, cl, tg))
+                   return 0;
+               return (*arm[i].fun)(o, p, 0) &&
+                   odr_constructed_end(o);
+           }
+       }
+       else  /* no tagging. Have to poll type */
+           if ((*arm[i].fun)(o, p, 0))
+               return 1;
+    }
+    *which = -1;
+    *(char*)p = 0;
+    return 0;
+}
index 043bb76..608ee65 100644 (file)
@@ -4,29 +4,30 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: odr_cons.c,v $
- * Revision 1.1  1995-02-02 16:21:53  quinn
+ * Revision 1.2  1995-02-07 17:52:59  quinn
+ * A damn mess, but now things work, I think.
+ *
+ * Revision 1.1  1995/02/02  16:21:53  quinn
  * First kick.
  *
  */
 
 #include <odr.h>
 
-int odr_constructed_begin(ODR o, void *p, int class, int tag, int opt)
+int odr_constructed_begin(ODR o, void *p, int class, int tag)
 {
     int res;
     int cons = 1;
 
-    if (o->direction == ODR_ENCODE && !*(char*)p)
-       return opt;
     if (o->t_class < 0)
     {
        o->t_class = class;
        o->t_tag = tag;
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons)) < 0)
+    if ((res = ber_tag(o, *(char**)p, o->t_class, o->t_tag, &cons)) < 0)
        return 0;
     if (!res || !cons)
-       return opt;
+       return 0;
 
     o->stack[++(o->stackp)].lenb = o->bp;
     if (o->direction == ODR_ENCODE || o->direction == ODR_PRINT)
index e2d0cbf..48e4298 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: odr_seq.c,v $
- * Revision 1.3  1995-02-07 14:13:46  quinn
+ * Revision 1.4  1995-02-07 17:53:00  quinn
+ * A damn mess, but now things work, I think.
+ *
+ * Revision 1.3  1995/02/07  14:13:46  quinn
  * Bug fixes.
  *
  * Revision 1.2  1995/02/06  16:45:03  quinn
@@ -27,7 +30,7 @@ int odr_sequence_begin(ODR o, void *p, int size)
        o->t_tag = ODR_SEQUENCE;
     }
 
-    if (odr_constructed_begin(o, p, o->t_class, o->t_tag, 0))
+    if (odr_constructed_begin(o, p, o->t_class, o->t_tag))
     {
        if (o->direction == ODR_DECODE && size)
            *pp = nalloc(o, size);
@@ -56,9 +59,10 @@ int odr_sequence_of(ODR o, Odr_fun type, void *p, int *num)
 {
     char ***pp = (char***) p;  /* for dereferencing */
     char **tmp;
+    char *dummy;
     int size = 0, i;
 
-    if (!odr_sequence_begin(o, p, 0))
+    if (!odr_sequence_begin(o, &dummy, 0))
        return 0;
 
     switch (o->direction)