2 * Copyright (C) 1994, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.6 1995-02-10 15:55:29 quinn
10 * Revision 1.5 1995/02/09 15:51:49 quinn
13 * Revision 1.4 1995/02/07 17:53:00 quinn
14 * A damn mess, but now things work, I think.
16 * Revision 1.3 1995/02/07 14:13:46 quinn
19 * Revision 1.2 1995/02/06 16:45:03 quinn
22 * Revision 1.1 1995/02/02 16:21:54 quinn
30 int odr_sequence_begin(ODR o, void *p, int size)
32 char **pp = (char**) p;
36 o->t_class = ODR_UNIVERSAL;
37 o->t_tag = ODR_SEQUENCE;
40 if (o->direction == ODR_DECODE)
42 if (odr_constructed_begin(o, p, o->t_class, o->t_tag))
44 if (o->direction == ODR_DECODE && size)
45 *pp = nalloc(o, size);
46 if (o->direction == ODR_PRINT)
48 fprintf(o->print, "%s{\n", odr_indent(o));
57 int odr_sequence_end(ODR o)
59 if (o->direction == ODR_PRINT)
61 assert(o->indent > 0);
63 fprintf(o->print, "%s}\n", odr_indent(o));
65 return odr_constructed_end(o);
68 int odr_sequence_more(ODR o)
70 return odr_constructed_more(o);
73 int odr_sequence_of(ODR o, Odr_fun type, void *p, int *num)
75 char ***pp = (char***) p; /* for dereferencing */
77 char *dummy = "Nothing";
80 if (!odr_sequence_begin(o, &dummy, 0))
87 while (odr_sequence_more(o))
90 if (*num * sizeof(void*) >= size)
92 /* double the buffer size */
93 tmp = nalloc(o, sizeof(void*) * (size += size ? size :
97 memcpy(tmp, *pp, *num * sizeof(void*));
99 * For now, we just throw the old *p away, since we use
100 * nibble memory anyway (disgusting, isn't it?).
105 if (!(*type)(o, (*pp) + *num, 0))
110 case ODR_ENCODE: case ODR_PRINT:
111 for (i = 0; i < *num; i++)
112 if (!(*type)(o, *pp + i, 0))
117 return odr_sequence_end(o);