Directive s=pw sets structure to phrase if term includes blank(s).
[yaz-moved-to-github.git] / odr / dumpber.c
index 47ca851..2ba5a70 100644 (file)
@@ -1,10 +1,22 @@
 /*
- * Copyright (c) 1995, Index Data.
+ * Copyright (c) 1995-2000, 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
+ * Revision 1.12  2000-02-29 13:44:55  adam
+ * Check for config.h (currently not generated).
+ *
+ * Revision 1.11  1999/11/30 13:47:11  adam
+ * Improved installation. Moved header files to include/yaz.
+ *
+ * Revision 1.10  1999/01/08 11:23:26  adam
+ * Added const modifier to some of the BER/ODR encoding routines.
+ *
+ * Revision 1.9  1998/01/14 09:53:26  quinn
+ * Added a bit more info to dump.
+ *
+ * Revision 1.8  1997/05/14 06:53:57  adam
  * C++ support.
  *
  * Revision 1.7  1996/03/08 14:38:41  quinn
  *
  *
  */
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
 
-#include <odr.h>
 #include <stdio.h>
+#include <yaz/odr.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 +88,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 +101,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 +145,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);
 }