+/* Private macro.
+ * write a single character at the current position - grow buffer if
+ * necessary.
+ * (no, we're not usually this anal about our macros, but this baby is
+ * next to unreadable without some indentation :)
+ */
+#define odr_putc(o, c) \
+( \
+ ( \
+ (o)->ecb.pos < (o)->ecb.size ? \
+ ( \
+ (o)->ecb.buf[(o)->ecb.pos++] = (c), \
+ 0 \
+ ) : \
+ ( \
+ odr_grow_block(&(o)->ecb, 1) == 0 ? \
+ ( \
+ (o)->ecb.buf[(o)->ecb.pos++] = (c), \
+ 0 \
+ ) : \
+ ( \
+ (o)->error = OSPACE, \
+ -1 \
+ ) \
+ ) \
+ ) == 0 ? \
+ ( \
+ (o)->ecb.pos > (o)->ecb.top ? \
+ ( \
+ (o)->ecb.top = (o)->ecb.pos, \
+ 0 \
+ ) : \
+ 0 \
+ ) : \
+ -1 \
+) \
+
+#define odr_tell(o) ((o)->ecb.pos)
+#define odr_offset(o) ((o)->bp - (o)->buf)
+#define odr_ok(o) (!(o)->error)
+#define odr_getmem(o) ((o)->mem)
+#define odr_setmem(o, v) ((o)->mem = (v))
+
+#define ODR_MAXNAME 256
+
+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);
+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);
+YAZ_EXPORT int odr_bool(ODR o, int **p, int opt, const char *name);
+YAZ_EXPORT int odr_integer(ODR o, int **p, int opt, const char *name);
+YAZ_EXPORT int odr_enum(ODR o, int **p, int opt, const char *name);
+YAZ_EXPORT int odr_implicit_settag(ODR o, int zclass, int tag);
+YAZ_EXPORT int ber_enclen(ODR o, int len, int lenlen, int exact);
+YAZ_EXPORT int ber_declen(const unsigned char *buf, int *len);
+YAZ_EXPORT void odr_prname(ODR o, const char *name);
+YAZ_EXPORT int ber_null(ODR o);
+YAZ_EXPORT int odr_null(ODR o, Odr_null **p, int opt, const char *name);
+YAZ_EXPORT int ber_integer(ODR o, int *val);
+YAZ_EXPORT int odr_constructed_begin(ODR o, void *p, int zclass, int tag,
+ const char *name);
+YAZ_EXPORT int odr_constructed_end(ODR o);
+YAZ_EXPORT int odr_sequence_begin(ODR o, void *p, int size, const char *name);
+YAZ_EXPORT int odr_set_begin(ODR o, void *p, int size, const char *name);
+YAZ_EXPORT int odr_sequence_end(ODR o);
+YAZ_EXPORT int odr_set_end(ODR o);
+YAZ_EXPORT int ber_octetstring(ODR o, Odr_oct *p, int cons);
+YAZ_EXPORT int odr_octetstring(ODR o, Odr_oct **p, int opt, const char *name);
+YAZ_EXPORT int odp_more_chunks(ODR o, const unsigned char *base, int len);
+YAZ_EXPORT int odr_constructed_more(ODR o);
+YAZ_EXPORT int odr_bitstring(ODR o, Odr_bitmask **p, int opt,
+ const char *name);
+YAZ_EXPORT int ber_bitstring(ODR o, Odr_bitmask *p, int cons);
+YAZ_EXPORT int odr_generalstring(ODR o, char **p, int opt, const char *name);
+YAZ_EXPORT int ber_oidc(ODR o, Odr_oid *p);
+YAZ_EXPORT int odr_oid(ODR o, Odr_oid **p, int opt, const char *name);
+YAZ_EXPORT int odr_choice(ODR o, Odr_arm arm[], void *p, void *whichp,
+ const char *name);
+YAZ_EXPORT int odr_cstring(ODR o, char **p, int opt, const char *name);
+YAZ_EXPORT int odr_sequence_of(ODR o, Odr_fun type, void *p, int *num,
+ const char *name);
+YAZ_EXPORT int odr_set_of(ODR o, Odr_fun type, void *p, int *num,
+ const char *name);
+YAZ_EXPORT int odr_any(ODR o, Odr_any **p, int opt, const char *name);
+YAZ_EXPORT int ber_any(ODR o, Odr_any **p);
+YAZ_EXPORT int completeBER(const unsigned char *buf, int len);
+YAZ_EXPORT void odr_begin(ODR o);
+YAZ_EXPORT void odr_end(ODR o);
+YAZ_EXPORT Odr_oid *odr_oiddup(ODR odr, Odr_oid *o);
+YAZ_EXPORT Odr_oid *odr_oiddup_nmem(NMEM nmem, Odr_oid *o);
+YAZ_EXPORT int odr_grow_block(odr_ecblock *b, int min_bytes);
+YAZ_EXPORT int odr_write(ODR o, unsigned char *buf, int bytes);
+YAZ_EXPORT int odr_seek(ODR o, int whence, int offset);
+YAZ_EXPORT int odr_dumpBER(FILE *f, const char *buf, int len);
+YAZ_EXPORT void odr_choice_bias(ODR o, int what);
+YAZ_EXPORT void odr_choice_enable_bias(ODR o, int mode);
+YAZ_EXPORT int odr_total(ODR o);
+YAZ_EXPORT char *odr_errmsg(int n);
+YAZ_EXPORT Odr_oid *odr_getoidbystr(ODR o, char *str);
+YAZ_EXPORT Odr_oid *odr_getoidbystr_nmem(NMEM o, 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);
+
+#ifdef __cplusplus
+}
+#endif
+
+#include <odr_use.h>
+
+#include <xmalloc.h>