Moved more members of public struct odr (ODR*) to struct Odr_private.
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 19 Mar 2007 21:08:13 +0000 (21:08 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 19 Mar 2007 21:08:13 +0000 (21:08 +0000)
17 files changed:
include/yaz/odr.h
src/ber_tag.c
src/odr-priv.h
src/odr.c
src/odr_bit.c
src/odr_bool.c
src/odr_choice.c
src/odr_cons.c
src/odr_enum.c
src/odr_int.c
src/odr_mem.c
src/odr_null.c
src/odr_oct.c
src/odr_oid.c
src/odr_seq.c
src/odr_tag.c
src/odr_util.c

index a25ad20..78cc834 100644 (file)
@@ -24,7 +24,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-/* $Id: odr.h,v 1.25 2007-01-03 08:42:14 adam Exp $ */
+/* $Id: odr.h,v 1.26 2007-03-19 21:08:13 adam Exp $ */
 
 /**
  * \file odr.h
 
 /**
  * \file odr.h
@@ -115,35 +115,27 @@ typedef int Odr_oid;   /* terminate by -1 */
 #define ODR_S_CUR     1
 #define ODR_S_END     2
 
 #define ODR_S_CUR     1
 #define ODR_S_END     2
 
-typedef struct odr
+typedef struct odr *ODR;
+
+/** ODR handle and the public structs */
+struct odr
 {
     int direction;       /* the direction of this stream */
 
 {
     int direction;       /* the direction of this stream */
 
-    int error;           /* current error state (0==OK) */
+    int error;            /* current error state (0==OK) */
 
 
-    int can_grow;         /* are we allowed to reallocate */
     unsigned char *buf;            /* memory handle */
     unsigned char *buf;            /* memory handle */
+    int top;              /* top of buffer (max pos when encoding) */
     int size;             /* current buffer size (encoding+decoding) */
 
     int pos;              /* current position (encoding) */
     int size;             /* current buffer size (encoding+decoding) */
 
     int pos;              /* current position (encoding) */
-    int top;              /* top of buffer (max pos when encoding) */
 
     const unsigned char *bp; /* position in buffer (decoding) */
 
 
     const unsigned char *bp; /* position in buffer (decoding) */
 
-    int t_class;         /* implicit tagging (-1==default tag) */
-    int t_tag;
-
-    int enable_bias;     /* force choice enable flag */
-    int choice_bias;     /* force choice */
-    int lenlen;          /* force length-of-lenght (odr_setlen()) */
-
-    FILE *print;         /* output file handler for direction print */
-    int indent;          /* current indent level for printing */
-
     NMEM mem;            /* memory handle for decoding (primarily) */
 
     struct Odr_private *op;
     NMEM mem;            /* memory handle for decoding (primarily) */
 
     struct Odr_private *op;
-} *ODR;
+};
 
 typedef int (*Odr_fun)(ODR, char **, int, const char *);
 
 
 typedef int (*Odr_fun)(ODR, char **, int, const char *);
 
index cdf4dd9..a6b6ae8 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: ber_tag.c,v 1.7 2007-01-03 08:42:15 adam Exp $
+ * $Id: ber_tag.c,v 1.8 2007-03-19 21:08:13 adam Exp $
  */
 
 /** 
  */
 
 /** 
@@ -42,7 +42,7 @@ int ber_tag(ODR o, void *p, int zclass, int tag, int *constructed, int opt,
 
     if (o->direction == ODR_DECODE)
         *pp = 0;
 
     if (o->direction == ODR_DECODE)
         *pp = 0;
-    o->t_class = -1;
+    o->op->t_class = -1;
     if (ODR_STACK_EMPTY(o))
     {
         odr_seek(o, ODR_S_SET, 0);
     if (ODR_STACK_EMPTY(o))
     {
         odr_seek(o, ODR_S_SET, 0);
index 135c187..d7133c0 100644 (file)
@@ -60,7 +60,6 @@ struct Odr_private {
     struct odr_constack *stack_first; /** first member of allocated stack */
     struct odr_constack *stack_top;   /** top of stack */
 
     struct odr_constack *stack_first; /** first member of allocated stack */
     struct odr_constack *stack_top;   /** top of stack */
 
-
     const char **tmp_names_buf;   /** array returned by odr_get_element_path */
     int tmp_names_sz;                 /** size of tmp_names_buf */
 
     const char **tmp_names_buf;   /** array returned by odr_get_element_path */
     int tmp_names_sz;                 /** size of tmp_names_buf */
 
@@ -72,6 +71,16 @@ struct Odr_private {
     void (*stream_write)(ODR o, void *handle, int type,
                          const char *buf, int len);
     void (*stream_close)(void *handle);
     void (*stream_write)(ODR o, void *handle, int type,
                          const char *buf, int len);
     void (*stream_close)(void *handle);
+
+    int can_grow;        /* are we allowed to reallocate */
+    int t_class;         /* implicit tagging (-1==default tag) */
+    int t_tag;
+
+    int enable_bias;     /* force choice enable flag */
+    int choice_bias;     /* force choice */
+    int lenlen;          /* force length-of-lenght (odr_setlen()) */
+    FILE *print;         /* output file handler for direction print */
+    int indent;          /* current indent level for printing */
 };
 
 #define ODR_STACK_POP(x) (x)->op->stack_top = (x)->op->stack_top->prev
 };
 
 #define ODR_STACK_POP(x) (x)->op->stack_top = (x)->op->stack_top->prev
index 645317e..beb2986 100644 (file)
--- a/src/odr.c
+++ b/src/odr.c
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr.c,v 1.15 2007-02-23 10:15:01 adam Exp $
+ * $Id: odr.c,v 1.16 2007-03-19 21:08:13 adam Exp $
  *
  */
 
  *
  */
 
@@ -184,7 +184,7 @@ void odr_set_stream(ODR o, void *handle,
                                          const char *buf, int len),
                     void (*stream_close)(void *handle))
 {
                                          const char *buf, int len),
                     void (*stream_close)(void *handle))
 {
-    o->print = (FILE*) handle;
+    o->op->print = (FILE*) handle;
     o->op->stream_write = stream_write;
     o->op->stream_close = stream_close;
 }
     o->op->stream_write = stream_write;
     o->op->stream_close = stream_close;
 }
@@ -215,13 +215,13 @@ ODR odr_createmem(int direction)
 
     if (!(o = (ODR)xmalloc(sizeof(*o))))
         return 0;
 
     if (!(o = (ODR)xmalloc(sizeof(*o))))
         return 0;
+    o->op = (struct Odr_private *) xmalloc (sizeof(*o->op));
     o->direction = direction;
     o->buf = 0;
     o->size = o->pos = o->top = 0;
     o->direction = direction;
     o->buf = 0;
     o->size = o->pos = o->top = 0;
-    o->can_grow = 1;
+    o->op->can_grow = 1;
     o->mem = nmem_create();
     o->mem = nmem_create();
-    o->enable_bias = 1;
-    o->op = (struct Odr_private *) xmalloc (sizeof(*o->op));
+    o->op->enable_bias = 1;
     o->op->odr_ber_tag.lclass = -1;
     o->op->iconv_handle = 0;
     odr_setprint(o, stderr);
     o->op->odr_ber_tag.lclass = -1;
     o->op->iconv_handle = 0;
     odr_setprint(o, stderr);
@@ -242,16 +242,16 @@ void odr_reset(ODR o)
     o->bp = o->buf;
     odr_seek(o, ODR_S_SET, 0);
     o->top = 0;
     o->bp = o->buf;
     odr_seek(o, ODR_S_SET, 0);
     o->top = 0;
-    o->t_class = -1;
-    o->t_tag = -1;
-    o->indent = 0;
+    o->op->t_class = -1;
+    o->op->t_tag = -1;
+    o->op->indent = 0;
     o->op->stack_first = 0;
     o->op->stack_top = 0;
     o->op->tmp_names_sz = 0;
     o->op->tmp_names_buf = 0;
     nmem_reset(o->mem);
     o->op->stack_first = 0;
     o->op->stack_top = 0;
     o->op->tmp_names_sz = 0;
     o->op->tmp_names_buf = 0;
     nmem_reset(o->mem);
-    o->choice_bias = -1;
-    o->lenlen = 1;
+    o->op->choice_bias = -1;
+    o->op->lenlen = 1;
     if (o->op->iconv_handle != 0)
         yaz_iconv(o->op->iconv_handle, 0, 0, 0, 0);
     yaz_log (log_level, "odr_reset o=%p", o);
     if (o->op->iconv_handle != 0)
         yaz_iconv(o->op->iconv_handle, 0, 0, 0, 0);
     yaz_log (log_level, "odr_reset o=%p", o);
@@ -260,10 +260,10 @@ void odr_reset(ODR o)
 void odr_destroy(ODR o)
 {
     nmem_destroy(o->mem);
 void odr_destroy(ODR o)
 {
     nmem_destroy(o->mem);
-    if (o->buf && o->can_grow)
+    if (o->buf && o->op->can_grow)
        xfree(o->buf);
     if (o->op->stream_close)
        xfree(o->buf);
     if (o->op->stream_close)
-        o->op->stream_close(o->print);
+        o->op->stream_close(o->op->print);
     if (o->op->iconv_handle != 0)
         yaz_iconv_close (o->op->iconv_handle);
     xfree(o->op);
     if (o->op->iconv_handle != 0)
         yaz_iconv_close (o->op->iconv_handle);
     xfree(o->op);
@@ -277,7 +277,7 @@ void odr_setbuf(ODR o, char *buf, int len, int can_grow)
     o->bp = (unsigned char *) buf;
 
     o->buf = (unsigned char *) buf;
     o->bp = (unsigned char *) buf;
 
     o->buf = (unsigned char *) buf;
-    o->can_grow = can_grow;
+    o->op->can_grow = can_grow;
     o->top = o->pos = 0;
     o->size = len;
 }
     o->top = o->pos = 0;
     o->size = len;
 }
@@ -297,7 +297,7 @@ void odr_printf(ODR o, const char *fmt, ...)
 
     va_start(ap, fmt);
     yaz_vsnprintf(buf, sizeof(buf), fmt, ap);
 
     va_start(ap, fmt);
     yaz_vsnprintf(buf, sizeof(buf), fmt, ap);
-    o->op->stream_write(o, o->print, ODR_VISIBLESTRING, buf, strlen(buf));
+    o->op->stream_write(o, o->op->print, ODR_VISIBLESTRING, buf, strlen(buf));
     va_end(ap);
 }
 /*
     va_end(ap);
 }
 /*
index 5addedc..2622281 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_bit.c,v 1.6 2007-01-03 08:42:15 adam Exp $
+ * $Id: odr_bit.c,v 1.7 2007-03-19 21:08:13 adam Exp $
  */
 
 /**
  */
 
 /**
@@ -27,12 +27,13 @@ int odr_bitstring(ODR o, Odr_bitmask **p, int opt, const char *name)
 
     if (o->error)
         return 0;
 
     if (o->error)
         return 0;
-    if (o->t_class < 0)
+    if (o->op->t_class < 0)
     {
     {
-        o->t_class = ODR_UNIVERSAL;
-        o->t_tag = ODR_BITSTRING;
+        o->op->t_class = ODR_UNIVERSAL;
+        o->op->t_tag = ODR_BITSTRING;
     }
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt, name)) < 0)
+    res = ber_tag(o, p, o->op->t_class, o->op->t_tag, &cons, opt, name);
+    if (res < 0)
         return 0;
     if (!res)
         return odr_missing(o, opt, name);
         return 0;
     if (!res)
         return odr_missing(o, opt, name);
index 6a77716..7c9279e 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_bool.c,v 1.6 2007-01-03 08:42:15 adam Exp $
+ * $Id: odr_bool.c,v 1.7 2007-03-19 21:08:13 adam Exp $
  */
 
 /**
  */
 
 /**
@@ -26,12 +26,13 @@ int odr_bool(ODR o, int **p, int opt, const char *name)
 
     if (o->error)
         return 0;
 
     if (o->error)
         return 0;
-    if (o->t_class < 0)
+    if (o->op->t_class < 0)
     {
     {
-        o->t_class = ODR_UNIVERSAL;
-        o->t_tag = ODR_BOOLEAN;
+        o->op->t_class = ODR_UNIVERSAL;
+        o->op->t_tag = ODR_BOOLEAN;
     }
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt, name)) < 0)
+    res = ber_tag(o, p, o->op->t_class, o->op->t_tag, &cons, opt, name);
+    if (res < 0)
         return 0;
     if (!res)
         return odr_missing(o, opt, name);
         return 0;
     if (!res)
         return odr_missing(o, opt, name);
index 082dbda..b3744ca 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_choice.c,v 1.7 2007-01-03 08:42:15 adam Exp $
+ * $Id: odr_choice.c,v 1.8 2007-03-19 21:08:13 adam Exp $
  */
 
 /**
  */
 
 /**
@@ -19,7 +19,7 @@
 int odr_choice(ODR o, Odr_arm arm[], void *p, void *whichp,
                const char *name)
 {
 int odr_choice(ODR o, Odr_arm arm[], void *p, void *whichp,
                const char *name)
 {
-    int i, cl = -1, tg, cn, *which = (int *)whichp, bias = o->choice_bias;
+    int i, cl = -1, tg, cn, *which = (int *)whichp, bias = o->op->choice_bias;
 
     if (o->error)
         return 0;
 
     if (o->error)
         return 0;
@@ -31,7 +31,7 @@ int odr_choice(ODR o, Odr_arm arm[], void *p, void *whichp,
         *which = -1;
         *(char**)p = 0;
     }
         *which = -1;
         *(char**)p = 0;
     }
-    o->choice_bias = -1;
+    o->op->choice_bias = -1;
 
     if (o->direction == ODR_PRINT)
     {
 
     if (o->direction == ODR_PRINT)
     {
@@ -91,13 +91,13 @@ int odr_choice(ODR o, Odr_arm arm[], void *p, void *whichp,
 
 void odr_choice_bias(ODR o, int what)
 {
 
 void odr_choice_bias(ODR o, int what)
 {
-    if (o->enable_bias)
-        o->choice_bias = what;
+    if (o->op->enable_bias)
+        o->op->choice_bias = what;
 }
 
 void odr_choice_enable_bias (ODR o, int mode)
 {
 }
 
 void odr_choice_enable_bias (ODR o, int mode)
 {
-    o->enable_bias = mode;
+    o->op->enable_bias = mode;
 }
 /*
  * Local variables:
 }
 /*
  * Local variables:
index c6d092c..2f88087 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_cons.c,v 1.8 2007-01-03 08:42:15 adam Exp $
+ * $Id: odr_cons.c,v 1.9 2007-03-19 21:08:13 adam Exp $
  *
  */
 
  *
  */
 
@@ -21,7 +21,7 @@
 
 void odr_setlenlen(ODR o, int len)
 {
 
 void odr_setlenlen(ODR o, int len)
 {
-    o->lenlen = len;
+    o->op->lenlen = len;
 }
 
 int odr_constructed_begin(ODR o, void *xxp, int zclass, int tag,
 }
 
 int odr_constructed_begin(ODR o, void *xxp, int zclass, int tag,
@@ -29,17 +29,18 @@ int odr_constructed_begin(ODR o, void *xxp, int zclass, int tag,
 {
     int res;
     int cons = 1;
 {
     int res;
     int cons = 1;
-    int lenlen = o->lenlen;
+    int lenlen = o->op->lenlen;
 
     if (o->error)
         return 0;
 
     if (o->error)
         return 0;
-    o->lenlen = 1; /* reset lenlen */
-    if (o->t_class < 0)
+    o->op->lenlen = 1; /* reset lenlen */
+    if (o->op->t_class < 0)
     {
     {
-        o->t_class = zclass;
-        o->t_tag = tag;
+        o->op->t_class = zclass;
+        o->op->t_tag = tag;
     }
     }
-    if ((res = ber_tag(o, xxp, o->t_class, o->t_tag, &cons, 1, name)) < 0)
+    res = ber_tag(o, xxp, o->op->t_class, o->op->t_tag, &cons, 1, name);
+    if (res < 0)
         return 0;
     if (!res || !cons)
         return 0;
         return 0;
     if (!res || !cons)
         return 0;
@@ -122,7 +123,7 @@ int odr_constructed_begin(ODR o, void *xxp, int zclass, int tag,
     {
         odr_prname(o, name);
         odr_printf(o, "{\n");
     {
         odr_prname(o, name);
         odr_printf(o, "{\n");
-        o->indent++;
+        o->op->indent++;
     }
     else
     {
     }
     else
     {
@@ -202,7 +203,7 @@ int odr_constructed_end(ODR o)
         return 1;
     case ODR_PRINT:
         ODR_STACK_POP(o);
         return 1;
     case ODR_PRINT:
         ODR_STACK_POP(o);
-        o->indent--;
+        o->op->indent--;
         odr_prname(o, 0);
         odr_printf(o, "}\n");
         return 1;
         odr_prname(o, 0);
         odr_printf(o, "}\n");
         return 1;
index 214cdb3..d994c70 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_enum.c,v 1.6 2007-01-03 08:42:15 adam Exp $
+ * $Id: odr_enum.c,v 1.7 2007-03-19 21:08:13 adam Exp $
  */
 /**
  * \file odr_enum.c
  */
 /**
  * \file odr_enum.c
@@ -24,12 +24,13 @@ int odr_enum(ODR o, int **p, int opt, const char *name)
 
     if (o->error)
         return 0;
 
     if (o->error)
         return 0;
-    if (o->t_class < 0)
+    if (o->op->t_class < 0)
     {
     {
-        o->t_class = ODR_UNIVERSAL;
-        o->t_tag = ODR_ENUM;
+        o->op->t_class = ODR_UNIVERSAL;
+        o->op->t_tag = ODR_ENUM;
     }
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt, name)) < 0)
+    res = ber_tag(o, p, o->op->t_class, o->op->t_tag, &cons, opt, name);
+    if (res < 0)
         return 0;
     if (!res)
         return odr_missing(o, opt, name);
         return 0;
     if (!res)
         return odr_missing(o, opt, name);
index cb9645f..8c4b158 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_int.c,v 1.6 2007-01-03 08:42:15 adam Exp $
+ * $Id: odr_int.c,v 1.7 2007-03-19 21:08:13 adam Exp $
  */
 /**
  * \file odr_int.c
  */
 /**
  * \file odr_int.c
@@ -24,12 +24,13 @@ int odr_integer(ODR o, int **p, int opt, const char *name)
 
     if (o->error)
         return 0;
 
     if (o->error)
         return 0;
-    if (o->t_class < 0)
+    if (o->op->t_class < 0)
     {
     {
-        o->t_class = ODR_UNIVERSAL;
-        o->t_tag = ODR_INTEGER;
+        o->op->t_class = ODR_UNIVERSAL;
+        o->op->t_tag = ODR_INTEGER;
     }
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt, name)) < 0)
+    res = ber_tag(o, p, o->op->t_class, o->op->t_tag, &cons, opt, name);
+    if (res < 0)
         return 0;
     if (!res)
         return odr_missing(o, opt, name);
         return 0;
     if (!res)
         return odr_missing(o, opt, name);
index c994c23..d9e4025 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_mem.c,v 1.8 2007-01-03 08:42:15 adam Exp $
+ * $Id: odr_mem.c,v 1.9 2007-03-19 21:08:13 adam Exp $
  */
 /**
  * \file odr_mem.c
  */
 /**
  * \file odr_mem.c
@@ -77,7 +77,7 @@ int odr_grow_block(ODR b, int min_bytes)
 {
     int togrow;
 
 {
     int togrow;
 
-    if (!b->can_grow)
+    if (!b->op->can_grow)
         return -1;
     if (!b->size)
         togrow = 1024;
         return -1;
     if (!b->size)
         togrow = 1024;
index bf6df75..e3a8ab8 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_null.c,v 1.7 2007-01-03 08:42:15 adam Exp $
+ * $Id: odr_null.c,v 1.8 2007-03-19 21:08:13 adam Exp $
  */
 /**
  * \file odr_null.c
  */
 /**
  * \file odr_null.c
@@ -24,12 +24,13 @@ int odr_null(ODR o, Odr_null **p, int opt, const char *name)
 
     if (o->error)
         return 0;
 
     if (o->error)
         return 0;
-    if (o->t_class < 0)
+    if (o->op->t_class < 0)
     {
     {
-        o->t_class = ODR_UNIVERSAL;
-        o->t_tag = ODR_NULL;
+        o->op->t_class = ODR_UNIVERSAL;
+        o->op->t_tag = ODR_NULL;
     }
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt, name)) < 0)
+    res = ber_tag(o, p, o->op->t_class, o->op->t_tag, &cons, opt, name);
+    if (res < 0)
         return 0;
     if (!res)
         return odr_missing(o, opt, name);
         return 0;
     if (!res)
         return odr_missing(o, opt, name);
index 5d2603f..b21125a 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_oct.c,v 1.10 2007-01-03 08:42:15 adam Exp $
+ * $Id: odr_oct.c,v 1.11 2007-03-19 21:08:13 adam Exp $
  */
 /**
  * \file odr_oct.c
  */
 /**
  * \file odr_oct.c
@@ -24,12 +24,13 @@ int odr_octetstring(ODR o, Odr_oct **p, int opt, const char *name)
 
     if (o->error)
         return 0;
 
     if (o->error)
         return 0;
-    if (o->t_class < 0)
+    if (o->op->t_class < 0)
     {
     {
-        o->t_class = ODR_UNIVERSAL;
-        o->t_tag = ODR_OCTETSTRING;
+        o->op->t_class = ODR_UNIVERSAL;
+        o->op->t_tag = ODR_OCTETSTRING;
     }
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt, name)) < 0)
+    res = ber_tag(o, p, o->op->t_class, o->op->t_tag, &cons, opt, name);
+    if (res < 0)
         return 0;
     if (!res)
         return odr_missing(o, opt, name);
         return 0;
     if (!res)
         return odr_missing(o, opt, name);
@@ -38,7 +39,7 @@ int odr_octetstring(ODR o, Odr_oct **p, int opt, const char *name)
         odr_prname(o, name);
         odr_printf(o, "OCTETSTRING(len=%d) ", (*p)->len);
 
         odr_prname(o, name);
         odr_printf(o, "OCTETSTRING(len=%d) ", (*p)->len);
 
-        o->op->stream_write(o, o->print, ODR_OCTETSTRING,
+        o->op->stream_write(o, o->op->print, ODR_OCTETSTRING,
                             (char*) (*p)->buf, (*p)->len);
         odr_printf(o, "\n");
         return 1;
                             (char*) (*p)->buf, (*p)->len);
         odr_printf(o, "\n");
         return 1;
@@ -66,12 +67,13 @@ int odr_cstring(ODR o, char **p, int opt, const char *name)
 
     if (o->error)
         return 0;
 
     if (o->error)
         return 0;
-    if (o->t_class < 0)
+    if (o->op->t_class < 0)
     {
     {
-        o->t_class = ODR_UNIVERSAL;
-        o->t_tag = ODR_OCTETSTRING;
+        o->op->t_class = ODR_UNIVERSAL;
+        o->op->t_tag = ODR_OCTETSTRING;
     }
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt, name)) < 0)
+    res = ber_tag(o, p, o->op->t_class, o->op->t_tag, &cons, opt, name);
+    if (res < 0)
         return 0;
     if (!res)
         return odr_missing(o, opt, name);
         return 0;
     if (!res)
         return odr_missing(o, opt, name);
@@ -113,12 +115,13 @@ int odr_iconv_string(ODR o, char **p, int opt, const char *name)
 
     if (o->error)
         return 0;
 
     if (o->error)
         return 0;
-    if (o->t_class < 0)
+    if (o->op->t_class < 0)
     {
     {
-        o->t_class = ODR_UNIVERSAL;
-        o->t_tag = ODR_OCTETSTRING;
+        o->op->t_class = ODR_UNIVERSAL;
+        o->op->t_tag = ODR_OCTETSTRING;
     }
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt, name)) < 0)
+    res = ber_tag(o, p, o->op->t_class, o->op->t_tag, &cons, opt, name);
+    if (res < 0)
         return 0;
     if (!res)
         return odr_missing(o, opt, name);
         return 0;
     if (!res)
         return odr_missing(o, opt, name);
index 1034a7b..be45098 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_oid.c,v 1.8 2007-01-03 08:42:15 adam Exp $
+ * $Id: odr_oid.c,v 1.9 2007-03-19 21:08:13 adam Exp $
  */
 /**
  * \file odr_oid.c
  */
 /**
  * \file odr_oid.c
@@ -25,12 +25,13 @@ int odr_oid(ODR o, Odr_oid **p, int opt, const char *name)
 
     if (o->error)
         return 0;
 
     if (o->error)
         return 0;
-    if (o->t_class < 0)
+    if (o->op->t_class < 0)
     {
     {
-        o->t_class = ODR_UNIVERSAL;
-        o->t_tag = ODR_OID;
+        o->op->t_class = ODR_UNIVERSAL;
+        o->op->t_tag = ODR_OID;
     }
     }
-    if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons, opt, name)) < 0)
+    res = ber_tag(o, p, o->op->t_class, o->op->t_tag, &cons, opt, name);
+    if (res < 0)
         return 0;
     if (!res)
         return odr_missing(o, opt, name);
         return 0;
     if (!res)
         return odr_missing(o, opt, name);
index b73d1fd..b9413e7 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_seq.c,v 1.6 2007-01-03 08:42:15 adam Exp $
+ * $Id: odr_seq.c,v 1.7 2007-03-19 21:08:13 adam Exp $
  */
 /**
  * \file odr_seq.c
  */
 /**
  * \file odr_seq.c
@@ -20,14 +20,14 @@ int odr_sequence_begin(ODR o, void *p, int size, const char *name)
 
     if (o->error)
         return 0;
 
     if (o->error)
         return 0;
-    if (o->t_class < 0)
+    if (o->op->t_class < 0)
     {
     {
-        o->t_class = ODR_UNIVERSAL;
-        o->t_tag = ODR_SEQUENCE;
+        o->op->t_class = ODR_UNIVERSAL;
+        o->op->t_tag = ODR_SEQUENCE;
     }
     if (o->direction == ODR_DECODE)
         *pp = 0;
     }
     if (o->direction == ODR_DECODE)
         *pp = 0;
-    if (odr_constructed_begin(o, p, o->t_class, o->t_tag, name))
+    if (odr_constructed_begin(o, p, o->op->t_class, o->op->t_tag, name))
     {
         if (o->direction == ODR_DECODE && size)
             *pp = (char *)odr_malloc(o, size);
     {
         if (o->direction == ODR_DECODE && size)
             *pp = (char *)odr_malloc(o, size);
@@ -43,14 +43,14 @@ int odr_set_begin(ODR o, void *p, int size, const char *name)
 
     if (o->error)
         return 0;
 
     if (o->error)
         return 0;
-    if (o->t_class < 0)
+    if (o->op->t_class < 0)
     {
     {
-        o->t_class = ODR_UNIVERSAL;
-        o->t_tag = ODR_SET;
+        o->op->t_class = ODR_UNIVERSAL;
+        o->op->t_tag = ODR_SET;
     }
     if (o->direction == ODR_DECODE)
         *pp = 0;
     }
     if (o->direction == ODR_DECODE)
         *pp = 0;
-    if (odr_constructed_begin(o, p, o->t_class, o->t_tag, name))
+    if (odr_constructed_begin(o, p, o->op->t_class, o->op->t_tag, name))
     {
         if (o->direction == ODR_DECODE && size)
             *pp = (char *)odr_malloc(o, size);
     {
         if (o->direction == ODR_DECODE && size)
             *pp = (char *)odr_malloc(o, size);
index 3fe167b..ba83507 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_tag.c,v 1.6 2007-01-03 08:42:15 adam Exp $
+ * $Id: odr_tag.c,v 1.7 2007-03-19 21:08:13 adam Exp $
  */
 /**
  * \file odr_tag.c
  */
 /**
  * \file odr_tag.c
@@ -35,10 +35,10 @@ int odr_implicit_settag(ODR o, int zclass, int tag)
 {
     if (o->error)
         return 0;
 {
     if (o->error)
         return 0;
-    if (o->t_class < 0)
+    if (o->op->t_class < 0)
     {
     {
-        o->t_class = zclass;
-        o->t_tag = tag;
+        o->op->t_class = zclass;
+        o->op->t_tag = tag;
     }
     return 1;
 }
     }
     return 1;
 }
@@ -53,7 +53,7 @@ int odr_initmember(ODR o, void *p, int size)
         *pp = (char *)odr_malloc(o, size);
     else if (!*pp)
     {
         *pp = (char *)odr_malloc(o, size);
     else if (!*pp)
     {
-        o->t_class = -1;
+        o->op->t_class = -1;
         return 0;
     }
     return 1;
         return 0;
     }
     return 1;
index 370132f..9a9f445 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
  * Copyright (C) 1995-2007, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: odr_util.c,v 1.9 2007-01-03 08:42:15 adam Exp $
+ * $Id: odr_util.c,v 1.10 2007-03-19 21:08:13 adam Exp $
  */
 /**
  * \file odr_util.c
  */
 /**
  * \file odr_util.c
@@ -21,9 +21,9 @@
 void odr_prname(ODR o, const char *name)
 {
     if (name)
 void odr_prname(ODR o, const char *name)
 {
     if (name)
-        odr_printf(o, "%*s%s ", o->indent*4, "", name);
+        odr_printf(o, "%*s%s ", o->op->indent*4, "", name);
     else
     else
-        odr_printf(o, "%*s", o->indent*4, "");
+        odr_printf(o, "%*s", o->op->indent*4, "");
 }
 
 int odp_more_chunks(ODR o, const unsigned char *base, int len)
 }
 
 int odp_more_chunks(ODR o, const unsigned char *base, int len)