2 * Copyright (C) 1994, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.10 1995-04-18 08:15:20 quinn
8 * Added dynamic memory allocation on encoding (whew). Code is now somewhat
9 * neater. We'll make the same change for decoding one day.
11 * Revision 1.9 1995/04/10 10:23:11 quinn
14 * Revision 1.8 1995/03/17 10:17:43 quinn
15 * Added memory management.
17 * Revision 1.7 1995/03/10 11:44:41 quinn
18 * Fixed serious stack-bug in odr_cons_begin
20 * Revision 1.6 1995/03/08 12:12:15 quinn
21 * Added better error checking.
23 * Revision 1.5 1995/03/07 13:28:57 quinn
24 * *** empty log message ***
26 * Revision 1.4 1995/03/07 13:16:13 quinn
27 * Fixed bug in odr_reset
29 * Revision 1.3 1995/03/07 10:21:31 quinn
30 * odr_errno-->odr_error
32 * Revision 1.2 1995/03/07 10:19:05 quinn
33 * Addded some method functions to the ODR type.
35 * Revision 1.1 1995/03/07 09:23:15 quinn
36 * Installing top-level API and documentation.
49 "Memory allocation failed",
52 "Required data element missing",
60 void odr_perror(ODR o, char *message)
62 fprintf(stderr, "%s: %s\n", message, odr_errlist[o->error]);
65 int odr_geterror(ODR o)
70 void odr_setprint(ODR o, FILE *file)
75 ODR odr_createmem(int direction)
79 if (!(r = malloc(sizeof(*r))))
81 r->direction = direction;
85 r->ecb.size = r->ecb.pos = r->ecb.top = 0;
97 odr_seek(o, ODR_S_SET, 0);
104 odr_release_mem(o->mem);
108 void odr_destroy(ODR o)
110 odr_release_mem(o->mem);
111 if (o->ecb.buf && o->ecb.can_grow)
113 if (o->print != stderr)
118 void odr_setbuf(ODR o, char *buf, int len)
120 o->buf = o->bp = (unsigned char *) buf;
121 o->buflen = o->left = len;
123 o->ecb.buf = (unsigned char *) buf;
125 o->ecb.top = o->ecb.pos = 0;
129 char *odr_getbuf(ODR o, int *len)
132 return (char*) o->ecb.buf;