Share ndrdump implementation.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 13 Oct 2008 13:58:45 +0000 (15:58 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 13 Oct 2008 13:58:45 +0000 (15:58 +0200)
librpc/tools/ndrdump.1.xml [moved from source4/librpc/tools/ndrdump.1.xml with 100% similarity]
librpc/tools/ndrdump.c [moved from source4/librpc/tools/ndrdump.c with 99% similarity]
source3/Makefile.in
source3/include/proto.h
source3/lib/util.c
source3/librpc/ndr/libndr.h
source3/librpc/ndr/util.c
source4/librpc/config.mk

similarity index 99%
rename from source4/librpc/tools/ndrdump.c
rename to librpc/tools/ndrdump.c
index b24868eaced3a9c8b79aa040cef207d648b27d9b..3ecf10a167bd53edff17e0e98856a6bf8c6ac90f 100644 (file)
@@ -26,6 +26,8 @@
 #include "librpc/ndr/libndr.h"
 #include "librpc/ndr/ndr_table.h"
 #include "param/param.h"
+#else
+#define _NORETURN_
 #endif
 
 static const struct ndr_interface_call *find_function(
index d6c548652899dd980d3780450c727383d7aa0071..1685bf141debd558554ae0a527299c6bb629e917 100644 (file)
@@ -968,7 +968,7 @@ REPLACETORT_OBJ = @libreplacedir@/test/testsuite.o \
                @libreplacedir@/test/main.o \
                $(LIBREPLACE_OBJ)
 
-NDRDUMP_OBJ = librpc/tools/ndrdump.o \
+NDRDUMP_OBJ = ../librpc/tools/ndrdump.o \
              $(PARAM_OBJ) $(LIBNDR_GEN_OBJ) \
              $(LIBSAMBA_OBJ) $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ) \
              librpc/gen_ndr/ndr_svcctl.o
index fb6d45befdab3cfe19a72987f382f678e76472b7..7dc0319e7d317c72e673d7b173f3eb3c6bfaf84e 100644 (file)
@@ -1291,6 +1291,7 @@ enum remote_arch_types get_remote_arch(void);
 void print_asc(int level, const unsigned char *buf,int len);
 void dump_data(int level, const unsigned char *buf1,int len);
 void dump_data_pw(const char *msg, const uchar * data, size_t len);
+void dump_data_skip_zeros(int level, const uint8_t *buf, int len);
 const char *tab_depth(int level, int depth);
 int str_checksum(const char *s);
 void zero_free(void *p, size_t size);
index ec43ea7037dc73aa05e0c81447b89906992f9a10..418ae41392b2d83ef1e262a064bf360f2efc5a90 100644 (file)
@@ -2217,25 +2217,60 @@ void print_asc(int level, const unsigned char *buf,int len)
                DEBUG(level,("%c", isprint(buf[i])?buf[i]:'.'));
 }
 
-void dump_data(int level, const unsigned char *buf1,int len)
+/**
+ * Write dump of binary data to the log file.
+ *
+ * The data is only written if the log level is at least level.
+ */
+static void _dump_data(int level, const uint8_t *buf, int len,
+                      bool omit_zero_bytes)
 {
-       const unsigned char *buf = (const unsigned char *)buf1;
        int i=0;
+       const uint8_t empty[16];
+       bool skipped = false;
+
        if (len<=0) return;
 
        if (!DEBUGLVL(level)) return;
-       
-       DEBUGADD(level,("[%03X] ",i));
+
+       memset(&empty, '\0', 16);
+
        for (i=0;i<len;) {
+
+               if (i%16 == 0) {
+                       if ((omit_zero_bytes == true) &&
+                           (i > 0) &&
+                           (len > i+16) &&
+                           (memcmp(&buf[i], &empty, 16) == 0))
+                       {
+                               i +=16;
+                               continue;
+                       }
+
+                       if (i<len)  {
+                               DEBUGADD(level,("[%04X] ",i));
+                       }
+               }
+
                DEBUGADD(level,("%02X ",(int)buf[i]));
                i++;
-               if (i%8 == 0) DEBUGADD(level,(" "));
-               if (i%16 == 0) {      
+               if (i%8 == 0) DEBUGADD(level,("  "));
+               if (i%16 == 0) {
+
                        print_asc(level,&buf[i-16],8); DEBUGADD(level,(" "));
                        print_asc(level,&buf[i-8],8); DEBUGADD(level,("\n"));
-                       if (i<len) DEBUGADD(level,("[%03X] ",i));
+
+                       if ((omit_zero_bytes == true) &&
+                           (len > i+16) &&
+                           (memcmp(&buf[i], &empty, 16) == 0)) {
+                               if (!skipped) {
+                                       DEBUGADD(level,("skipping zero buffer bytes\n"));
+                                       skipped = true;
+                               }
+                       }
                }
        }
+
        if (i%16) {
                int n;
                n = 16 - (i%16);
@@ -2248,8 +2283,32 @@ void dump_data(int level, const unsigned char *buf1,int len)
                if (n>0) print_asc(level,&buf[i-n],n);
                DEBUGADD(level,("\n"));
        }
+
+}
+
+/**
+ * Write dump of binary data to the log file.
+ *
+ * The data is only written if the log level is at least level.
+ */
+_PUBLIC_ void dump_data(int level, const uint8_t *buf, int len)
+{
+       _dump_data(level, buf, len, false);
 }
 
+/**
+ * Write dump of binary data to the log file.
+ *
+ * The data is only written if the log level is at least level.
+ * 16 zero bytes in a row are ommited
+ */
+_PUBLIC_ void dump_data_skip_zeros(int level, const uint8_t *buf, int len)
+{
+       _dump_data(level, buf, len, true);
+}
+
+
+
 void dump_data_pw(const char *msg, const uchar * data, size_t len)
 {
 #ifdef DEBUG_PASSWORD
index a860f35998fd0134572e881c68b50019f55176a3..e25a7b8abd2055e2f9d28c0a96178ea1d749922f 100644 (file)
 #include "librpc/gen_ndr/misc.h"
 #include "librpc/gen_ndr/security.h"
 
+/* Samba 3 doesn't use iconv_convenience: */
+extern void *global_loadparm;
+extern void *cmdline_lp_ctx;
+struct smb_iconv_convenience *lp_iconv_convenience(void *lp_ctx);
+
 /*
   this provides definitions for the libcli/rpc/ MSRPC library
 */
index b85739df69a318d634b7fadd568c198fb3539705..427292ac7019819220ad3a7fe64d7c1b77e3cc51 100644 (file)
@@ -180,3 +180,9 @@ _PUBLIC_ void ndr_print_sockaddr_storage(struct ndr_print *ndr, const char *name
        ndr->print(ndr, "%-25s: %s", name, print_sockaddr(addr, sizeof(addr), ss));
 }
 
+void *global_loadparm;
+void *cmdline_lp_ctx;
+struct smb_iconv_convenience *lp_iconv_convenience(void *lp_ctx)
+{
+       return NULL;
+}
index 4e1ccbb1a748e096626c9e2823d8cba6a5fff8e3..a481b97a1110aba3f84dbf3d83585571a146967e 100644 (file)
@@ -36,9 +36,9 @@ PRIVATE_DEPENDENCIES = \
 # End BINARY ndrdump
 #################################
 
-ndrdump_OBJ_FILES = $(librpcsrcdir)/tools/ndrdump.o
+ndrdump_OBJ_FILES = ../librpc/tools/ndrdump.o
 
-MANPAGES += $(librpcsrcdir)/tools/ndrdump.1
+MANPAGES += ../librpc/tools/ndrdump.1
 
 ################################################
 # Start SUBSYSTEM NDR_COMPRESSION