X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fodr_choice.c;h=3020e2d4b2ccb2be4292fcc1213b2a33238e04d8;hp=f91c589dbdb1aac39407e21a88311e643aea7dd4;hb=fb6d99a0c7e07d9cc4a315c447deaf6564a85505;hpb=67002f49611adb64993391b0cbf6c235f18080a4 diff --git a/src/odr_choice.c b/src/odr_choice.c index f91c589..3020e2d 100644 --- a/src/odr_choice.c +++ b/src/odr_choice.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2005, Index Data ApS * See the file LICENSE for details. * - * $Id: odr_choice.c,v 1.4 2005-01-15 19:47:14 adam Exp $ + * $Id: odr_choice.c,v 1.5 2005-06-25 15:46:04 adam Exp $ */ /** @@ -17,14 +17,14 @@ #include "odr-priv.h" int odr_choice(ODR o, Odr_arm arm[], void *p, void *whichp, - const char *name) + const char *name) { int i, cl = -1, tg, cn, *which = (int *)whichp, bias = o->choice_bias; if (o->error) - return 0; + return 0; if (o->direction != ODR_DECODE && !*(char**)p) - return 0; + return 0; if (o->direction == ODR_DECODE) { @@ -35,56 +35,56 @@ int odr_choice(ODR o, Odr_arm arm[], void *p, void *whichp, if (o->direction == ODR_PRINT) { - if (name) - { - odr_prname(o, name); - odr_printf(o, "choice\n"); - } + if (name) + { + odr_prname(o, name); + odr_printf(o, "choice\n"); + } } for (i = 0; arm[i].fun; i++) { - if (o->direction == ODR_DECODE) - { - if (bias >= 0 && bias != arm[i].which) - continue; - *which = arm[i].which; - } - else if (*which != arm[i].which) - continue; + if (o->direction == ODR_DECODE) + { + if (bias >= 0 && bias != arm[i].which) + continue; + *which = arm[i].which; + } + else if (*which != arm[i].which) + continue; - if (arm[i].tagmode != ODR_NONE) - { - if (o->direction == ODR_DECODE && cl < 0) - { - if (o->op->stackp > -1 && !odr_constructed_more(o)) - return 0; - if (ber_dectag(o->bp, &cl, &tg, &cn, odr_max(o)) <= 0) - return 0; - } - else if (o->direction != ODR_DECODE) - { - cl = arm[i].zclass; - tg = arm[i].tag; - } - if (tg == arm[i].tag && cl == arm[i].zclass) - { - if (arm[i].tagmode == ODR_IMPLICIT) - { - odr_implicit_settag(o, cl, tg); - return (*arm[i].fun)(o, (char **)p, 0, arm[i].name); - } - /* explicit */ - if (!odr_constructed_begin(o, p, cl, tg, 0)) - return 0; - return (*arm[i].fun)(o, (char **)p, 0, arm[i].name) && - odr_constructed_end(o); - } - } - else /* no tagging. Have to poll type */ - { - if ((*arm[i].fun)(o, (char **)p, 1, arm[i].name) && *(char**)p) - return 1; - } + if (arm[i].tagmode != ODR_NONE) + { + if (o->direction == ODR_DECODE && cl < 0) + { + if (o->op->stackp > -1 && !odr_constructed_more(o)) + return 0; + if (ber_dectag(o->bp, &cl, &tg, &cn, odr_max(o)) <= 0) + return 0; + } + else if (o->direction != ODR_DECODE) + { + cl = arm[i].zclass; + tg = arm[i].tag; + } + if (tg == arm[i].tag && cl == arm[i].zclass) + { + if (arm[i].tagmode == ODR_IMPLICIT) + { + odr_implicit_settag(o, cl, tg); + return (*arm[i].fun)(o, (char **)p, 0, arm[i].name); + } + /* explicit */ + if (!odr_constructed_begin(o, p, cl, tg, 0)) + return 0; + return (*arm[i].fun)(o, (char **)p, 0, arm[i].name) && + odr_constructed_end(o); + } + } + else /* no tagging. Have to poll type */ + { + if ((*arm[i].fun)(o, (char **)p, 1, arm[i].name) && *(char**)p) + return 1; + } } return 0; } @@ -99,3 +99,11 @@ void odr_choice_enable_bias (ODR o, int mode) { o->enable_bias = mode; } +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +