2 * Copyright (c) 1995, Index Data.
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.3 1995-09-27 15:02:57 quinn
8 * Modified function heads & prototypes.
10 * Revision 1.2 1995/06/27 13:20:51 quinn
11 * Fixed sign-clash. Non-fatal warning
13 * Revision 1.1 1995/06/19 12:38:45 quinn
22 static int do_dumpBER(FILE *f, char *buf, int len, int level)
24 int res, ll, class, tag, cons;
29 if (!buf[0] && !buf[1])
31 if ((res = ber_dectag((unsigned char*)b, &class, &tag, &cons)) <= 0)
35 fprintf(stderr, "Unexpected end of buffer\n");
38 fprintf(stderr, "%*s", level * 4, "");
39 if (class == ODR_UNIVERSAL)
43 "Ugh", "BOOLEAN", "INTEGER", "BIT STRING", "OCTET STRING",
44 "NULL", "OID", "OBJECT DESCIPTOR", "EXTERNAL", "REAL",
45 "ENUM", "[UNIV 11]", "[UNIV 12]", "[UNIV 13]", "[UNIV 14]",
46 "[UNIV 15]", "SEQUENCE", "SET", "NUMERICSTRING", "PRINTABLESTRING",
47 "[UNIV 20]", "[UNIV 21]", "[UNIV 22]", "[UNIV 23]", "[UNIV 24]",
48 "GRAPHICSTRING", "VISIBLESTRING", "GENERALSTRING", "[UNIV 28]"
52 fprintf(stderr, "%s", nl[tag]);
54 fprintf(stderr, "[UNIV %d]", tag);
56 else if (class == ODR_CONTEXT)
57 fprintf(stderr, "[%d]", tag);
59 fprintf(stderr, "[%d:%d]", class, tag);
62 if ((res = ber_declen((unsigned char*)b, &ll)) <= 0)
64 fprintf(stderr, "bad length\n");
69 fprintf(stderr, "Unexpected end of buffer\n");
75 fprintf(stderr, " len=%d\n", ll);
77 fprintf(stderr, " len=?\n");
82 fprintf(stderr, "Bad length on primitive type.\n");
85 return ll + (b - buf);
89 /* constructed - cycle through children */
90 while ((ll == -1 && len >= 2) || (ll >= 0 && len))
92 if (ll == -1 && *b == 0 && *(b + 1) == 0)
94 if (!(res = do_dumpBER(f, b, len, level + 1)))
96 fprintf(stderr, "Dump of content element failed.\n");
106 fprintf(stderr, "Buffer too short in indefinite lenght.\n");
109 return (b - buf) + 2;
114 int MDF odr_dumpBER(FILE *f, char *buf, int len)
116 return do_dumpBER(f, buf, len, 0);