2 * Copyright (C) 1994, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.3 1995-02-03 17:04:38 quinn
8 * *** empty log message ***
10 * Revision 1.2 1995/02/02 20:38:51 quinn
13 * Revision 1.1 1995/02/02 16:21:54 quinn
21 * Top level octet string en/decoder.
22 * Returns 1 on success, 0 on error.
24 int odr_octetstring(ODR o, Odr_oct **p, int opt)
30 o->t_class = ODR_UNIVERSAL;
31 o->t_tag = ODR_OCTETSTRING;
33 if ((res = ber_tag(o, *p, o->t_class, o->t_tag, &cons)) < 0)
40 if (o->direction == ODR_PRINT)
42 fprintf(o->print, "OCTETSTRING(len=%d)\n", (*p)->len);
45 if (o->direction == ODR_DECODE && !*p)
47 *p = nalloc(o, sizeof(Odr_oct));
52 return ber_octetstring(o, *p, cons);
56 * Friendlier interface to octetstring.
58 int odr_cstring(ODR o, char **p, int opt)
65 o->t_class = ODR_UNIVERSAL;
66 o->t_tag = ODR_OCTETSTRING;
68 if ((res = ber_tag(o, *p, o->t_class, o->t_tag, &cons)) < 0)
75 if (o->direction == ODR_PRINT)
77 fprintf(o->print, "'%s'\n", *p);
80 t = nalloc(o, sizeof(Odr_oct)); /* wrapper for octstring */
81 if (o->direction == ODR_ENCODE)
83 t->buf = (unsigned char *) *p;
84 t->size = t->len = strlen(*p);
92 if (!ber_octetstring(o, t, cons))
94 if (o->direction == ODR_DECODE)
97 *(*p + t->len) = '\0'; /* ber_octs reserves space for this */