2 * Copyright (C) 1994, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.5 1995-02-09 15:51:49 quinn
10 * Revision 1.4 1995/02/07 17:53:00 quinn
11 * A damn mess, but now things work, I think.
13 * Revision 1.3 1995/02/07 14:13:46 quinn
16 * Revision 1.2 1995/02/06 16:45:03 quinn
19 * Revision 1.1 1995/02/02 16:21:54 quinn
27 int odr_sequence_begin(ODR o, void *p, int size)
29 char **pp = (char**) p;
33 o->t_class = ODR_UNIVERSAL;
34 o->t_tag = ODR_SEQUENCE;
37 if (o->direction == ODR_DECODE)
39 if (odr_constructed_begin(o, p, o->t_class, o->t_tag))
41 if (o->direction == ODR_DECODE && size)
42 *pp = nalloc(o, size);
43 if (o->direction == ODR_PRINT)
45 fprintf(o->print, "%s{\n", odr_indent(o));
54 int odr_sequence_end(ODR o)
56 if (o->direction == ODR_PRINT)
58 assert(o->indent > 0);
60 fprintf(o->print, "%s}\n", odr_indent(o));
62 return odr_constructed_end(o);
65 int odr_sequence_more(ODR o)
69 if (o->stack[o->stackp].len >= 0)
70 return o->bp - o->stack[o->stackp].base < o->stack[o->stackp].len;
72 return (!(*o->bp == 0 && *(o->bp + 1) == 0));
75 int odr_sequence_of(ODR o, Odr_fun type, void *p, int *num)
77 char ***pp = (char***) p; /* for dereferencing */
79 char *dummy = "Nothing";
82 if (!odr_sequence_begin(o, &dummy, 0))
89 while (odr_sequence_more(o))
92 if (*num * sizeof(void*) >= size)
94 /* double the buffer size */
95 tmp = nalloc(o, sizeof(void*) * (size += size ? size :
99 memcpy(tmp, *pp, *num * sizeof(void*));
101 * For now, we just throw the old *p away, since we use
102 * nibble memory anyway (disgusting, isn't it?).
107 if (!(*type)(o, (*pp) + *num, 0))
112 case ODR_ENCODE: case ODR_PRINT:
113 for (i = 0; i < *num; i++)
114 if (!(*type)(o, *pp + i, 0))
119 return odr_sequence_end(o);