1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2013 Index Data
3 * See the file LICENSE for details.
8 * \brief Implements ber_octetstring
10 * This source file implements BER encoding and decoding of
11 * the OCTETSTRING type.
22 int ber_octetstring(ODR o, Odr_oct *p, int cons)
30 if ((res = ber_declen(o->op->bp, &len, odr_max(o))) < 0)
32 odr_seterror(o, OPROTO, 14);
36 if (cons) /* fetch component strings */
39 while (odp_more_chunks(o, base, len))
40 if (!odr_octetstring(o, &p, 0, 0))
44 /* primitive octetstring */
47 odr_seterror(o, OOTHER, 15);
52 odr_seterror(o, OOTHER, 16);
56 p->buf = odr_strdupn(o, o->op->bp, len);
60 if ((res = ber_enclen(o, p->len, 5, 0)) < 0)
64 if (odr_write(o, p->buf, p->len) < 0)
70 odr_seterror(o, OOTHER, 17);
77 * c-file-style: "Stroustrup"
78 * indent-tabs-mode: nil
80 * vim: shiftwidth=4 tabstop=8 expandtab