Add Zthes tag-set -- where was it?!
[yaz-moved-to-github.git] / odr / dumpber.c
index 47ca851..1fbdecf 100644 (file)
@@ -1,43 +1,21 @@
 /*
- * Copyright (c) 1995, Index Data.
+ * Copyright (c) 1995-2002, Index Data.
  * See the file LICENSE for details.
  * Sebastian Hammer, Adam Dickmeiss
  *
- * $Log: dumpber.c,v $
- * Revision 1.8  1997-05-14 06:53:57  adam
- * C++ support.
- *
- * Revision 1.7  1996/03/08 14:38:41  quinn
- * Fixed output.
- *
- * Revision 1.6  1996/01/19  15:41:34  quinn
- * dumpber was ignoring the file argument.
- *
- * Revision 1.5  1995/10/18  16:12:55  quinn
- * Better diagnostics. Added special case in NULL to handle WAIS server.
- *
- * Revision 1.4  1995/09/29  17:12:21  quinn
- * Smallish
- *
- * Revision 1.3  1995/09/27  15:02:57  quinn
- * Modified function heads & prototypes.
- *
- * Revision 1.2  1995/06/27  13:20:51  quinn
- * Fixed sign-clash. Non-fatal warning
- *
- * Revision 1.1  1995/06/19  12:38:45  quinn
- * Added BER dumper.
- *
- *
+ * $Id: dumpber.c,v 1.13 2002-07-25 12:51:08 adam Exp $
  */
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
 
-#include <odr.h>
 #include <stdio.h>
+#include "odr-priv.h"
 
-static int do_dumpBER(FILE *f, char *buf, int len, int level, int offset)
+static int do_dumpBER(FILE *f, const char *buf, int len, int level, int offset)
 {
-    int res, ll, zclass, tag, cons;
-    char *b = buf;
+    int res, ll, zclass, tag, cons, lenlen, taglen;
+    const char *b = buf, *bp = buf;
     
     if (!len)
        return 0;
@@ -73,7 +51,9 @@ static int do_dumpBER(FILE *f, char *buf, int len, int level, int offset)
     else
        fprintf(f, "[%d:%d]", zclass, tag);
     b += res;
+    taglen = res;
     len -= res;
+    bp = b;
     if ((res = ber_declen((unsigned char*)b, &ll)) <= 0)
     {
        fprintf(f, "bad length\n");
@@ -84,12 +64,14 @@ static int do_dumpBER(FILE *f, char *buf, int len, int level, int offset)
        fprintf(f, "Unexpected end of buffer\n");
        return 0;
     }
+    lenlen = res;
     b += res;
     len -= res;
     if (ll >= 0)
-       fprintf(f, " len=%d\n", ll);
+       fprintf(f, " len=%d", ll);
     else
-       fprintf(f, " len=?\n");
+       fprintf(f, " len=?");
+    fprintf(f, "       tl=%d, ll=%d\n", taglen, lenlen);
     if (!cons)
     {
        if (ll < 0)
@@ -126,7 +108,7 @@ static int do_dumpBER(FILE *f, char *buf, int len, int level, int offset)
     return b - buf;
 }
 
-int odr_dumpBER(FILE *f, char *buf, int len)
+int odr_dumpBER(FILE *f, const char *buf, int len)
 {
     return do_dumpBER(f, buf, len, 0, 0);
 }