2 * Copyright (C) 1995-2007, Index Data ApS
3 * See the file LICENSE for details.
5 * $Id: odr_oid.c,v 1.11 2007-05-08 08:22:36 adam Exp $
9 * \brief Implements ODR OID codec
15 #include <yaz/oid_util.h>
19 * Top level oid en/decoder.
20 * Returns 1 on success, 0 on error.
22 int odr_oid(ODR o, Odr_oid **p, int opt, const char *name)
28 if (o->op->t_class < 0)
30 o->op->t_class = ODR_UNIVERSAL;
31 o->op->t_tag = ODR_OID;
33 res = ber_tag(o, p, o->op->t_class, o->op->t_tag, &cons, opt, name);
37 return odr_missing(o, opt, name);
40 odr_seterror(o, OPROTO, 46);
43 if (o->direction == ODR_PRINT)
48 odr_printf(o, "OID:");
49 for (i = 0; (*p)[i] > -1; i++)
50 odr_printf(o, " %d", (*p)[i]);
54 if (o->direction == ODR_DECODE)
55 *p = (Odr_oid *)odr_malloc(o, OID_SIZE * sizeof(**p));
56 return ber_oidc(o, *p, OID_SIZE);
61 * indent-tabs-mode: nil
63 * vim: shiftwidth=4 tabstop=8 expandtab