1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2010 Index Data
3 * See the file LICENSE for details.
7 * \brief Implements ODR OID codec
13 #include <yaz/oid_util.h>
17 * Top level oid en/decoder.
18 * Returns 1 on success, 0 on error.
20 int odr_oid(ODR o, Odr_oid **p, int opt, const char *name)
26 if (o->op->t_class < 0)
28 o->op->t_class = ODR_UNIVERSAL;
29 o->op->t_tag = ODR_OID;
31 res = ber_tag(o, p, o->op->t_class, o->op->t_tag, &cons, opt, name);
35 return odr_missing(o, opt, name);
38 odr_seterror(o, OPROTO, 46);
41 if (o->direction == ODR_PRINT)
46 odr_printf(o, "OID:");
47 for (i = 0; (*p)[i] > -1; i++)
48 odr_printf(o, " %d", (*p)[i]);
52 if (o->direction == ODR_DECODE)
53 *p = (Odr_oid *)odr_malloc(o, OID_SIZE * sizeof(**p));
54 return ber_oidc(o, *p, OID_SIZE);
59 * c-file-style: "Stroustrup"
60 * indent-tabs-mode: nil
62 * vim: shiftwidth=4 tabstop=8 expandtab