2 * Copyright (C) 1994, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.4 1995-02-07 14:13:46 quinn
10 * Revision 1.3 1995/02/03 17:04:38 quinn
11 * *** empty log message ***
13 * Revision 1.2 1995/02/02 20:38:51 quinn
16 * Revision 1.1 1995/02/02 16:21:54 quinn
24 * Top level octet string en/decoder.
25 * Returns 1 on success, 0 on error.
27 int odr_octetstring(ODR o, Odr_oct **p, int opt)
33 o->t_class = ODR_UNIVERSAL;
34 o->t_tag = ODR_OCTETSTRING;
36 if ((res = ber_tag(o, *p, o->t_class, o->t_tag, &cons)) < 0)
46 if (o->direction == ODR_PRINT)
48 fprintf(o->print, "OCTETSTRING(len=%d)\n", (*p)->len);
51 if (o->direction == ODR_DECODE)
53 *p = nalloc(o, sizeof(Odr_oct));
58 return ber_octetstring(o, *p, cons);
62 * Friendlier interface to octetstring.
64 int odr_cstring(ODR o, char **p, int opt)
71 o->t_class = ODR_UNIVERSAL;
72 o->t_tag = ODR_OCTETSTRING;
74 if ((res = ber_tag(o, *p, o->t_class, o->t_tag, &cons)) < 0)
81 if (o->direction == ODR_PRINT)
83 fprintf(o->print, "'%s'\n", *p);
86 t = nalloc(o, sizeof(Odr_oct)); /* wrapper for octstring */
87 if (o->direction == ODR_ENCODE)
89 t->buf = (unsigned char *) *p;
90 t->size = t->len = strlen(*p);
98 if (!ber_octetstring(o, t, cons))
100 if (o->direction == ODR_DECODE)
102 *p = (char *) t->buf;
103 *(*p + t->len) = '\0'; /* ber_octs reserves space for this */