2 * Copyright (C) 1994, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.5 1995-02-09 15:51:49 quinn
10 * Revision 1.4 1995/02/07 14:13:46 quinn
13 * Revision 1.3 1995/02/03 17:04:38 quinn
14 * *** empty log message ***
16 * Revision 1.2 1995/02/02 20:38:51 quinn
19 * Revision 1.1 1995/02/02 16:21:54 quinn
27 * Top level octet string en/decoder.
28 * Returns 1 on success, 0 on error.
30 int odr_octetstring(ODR o, Odr_oct **p, int opt)
36 o->t_class = ODR_UNIVERSAL;
37 o->t_tag = ODR_OCTETSTRING;
39 if (o->direction == ODR_DECODE)
41 if ((res = ber_tag(o, *p, o->t_class, o->t_tag, &cons)) < 0)
51 if (o->direction == ODR_PRINT)
53 fprintf(o->print, "%sOCTETSTRING(len=%d)\n", odr_indent(o), (*p)->len);
56 if (o->direction == ODR_DECODE)
58 *p = nalloc(o, sizeof(Odr_oct));
63 if (ber_octetstring(o, *p, cons))
70 * Friendlier interface to octetstring.
72 int odr_cstring(ODR o, char **p, int opt)
79 o->t_class = ODR_UNIVERSAL;
80 o->t_tag = ODR_OCTETSTRING;
82 if (o->direction == ODR_DECODE)
84 if ((res = ber_tag(o, *p, o->t_class, o->t_tag, &cons)) < 0)
91 if (o->direction == ODR_PRINT)
93 fprintf(o->print, "%s'%s'\n", odr_indent(o), *p);
96 t = nalloc(o, sizeof(Odr_oct)); /* wrapper for octstring */
97 if (o->direction == ODR_ENCODE)
99 t->buf = (unsigned char *) *p;
100 t->size = t->len = strlen(*p);
108 if (!ber_octetstring(o, t, cons))
110 if (o->direction == ODR_DECODE)
112 *p = (char *) t->buf;
113 *(*p + t->len) = '\0'; /* ber_octs reserves space for this */