2 * Copyright (C) 1994, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.6 1995-02-10 18:57:26 quinn
8 * More in the way of error-checking.
10 * Revision 1.5 1995/02/09 15:51:49 quinn
13 * Revision 1.4 1995/02/07 14:13:46 quinn
16 * Revision 1.3 1995/02/03 17:04:38 quinn
17 * *** empty log message ***
19 * Revision 1.2 1995/02/02 20:38:51 quinn
22 * Revision 1.1 1995/02/02 16:21:54 quinn
30 * Top level octet string en/decoder.
31 * Returns 1 on success, 0 on error.
33 int odr_octetstring(ODR o, Odr_oct **p, int opt)
39 o->t_class = ODR_UNIVERSAL;
40 o->t_tag = ODR_OCTETSTRING;
42 if ((res = ber_tag(o, p, o->t_class, o->t_tag, &cons)) < 0)
46 if (o->direction == ODR_PRINT)
48 fprintf(o->print, "%sOCTETSTRING(len=%d)\n", odr_indent(o), (*p)->len);
51 if (o->direction == ODR_DECODE)
53 *p = nalloc(o, sizeof(Odr_oct));
58 if (ber_octetstring(o, *p, cons))
65 * Friendlier interface to octetstring.
67 int odr_cstring(ODR o, char **p, int opt)
74 o->t_class = ODR_UNIVERSAL;
75 o->t_tag = ODR_OCTETSTRING;
77 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'%s'\n", odr_indent(o), *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 */