2 * Copyright (c) 1995, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
6 * $Log: odr_choice.c,v $
7 * Revision 1.6 1995-05-16 08:50:53 quinn
8 * License, documentation, and memory fixes
10 * Revision 1.5 1995/03/18 12:16:31 quinn
13 * Revision 1.4 1995/03/14 16:59:38 quinn
14 * Added odr_constructed_more check
16 * Revision 1.3 1995/03/08 12:12:22 quinn
17 * Added better error checking.
19 * Revision 1.2 1995/02/09 15:51:48 quinn
22 * Revision 1.1 1995/02/07 17:52:59 quinn
23 * A damn mess, but now things work, I think.
29 int odr_choice(ODR o, Odr_arm arm[], void *p, void *whichp)
31 int i, cl = -1, tg, cn, *which = whichp;
35 if (o->direction != ODR_DECODE && !*(char**)p)
37 for (i = 0; arm[i].fun; i++)
39 if (o->direction == ODR_DECODE)
40 *which = arm[i].which;
41 else if (*which != arm[i].which)
44 if (arm[i].tagmode != ODR_NONE)
46 if (o->direction == ODR_DECODE && cl < 0)
48 if (o->stackp > -1 && !odr_constructed_more(o))
50 if (ber_dectag(o->bp, &cl, &tg, &cn) <= 0)
53 else if (o->direction != ODR_DECODE)
58 if (tg == arm[i].tag && cl == arm[i].class)
60 if (arm[i].tagmode == ODR_IMPLICIT)
62 odr_implicit_settag(o, cl, tg);
63 return (*arm[i].fun)(o, p, 0);
66 if (!odr_constructed_begin(o, p, cl, tg))
68 return (*arm[i].fun)(o, p, 0) &&
69 odr_constructed_end(o);
72 else /* no tagging. Have to poll type */
73 if ((*arm[i].fun)(o, p, 0))