Introduce dump_data_file
authorVolker Lendecke <vl@samba.org>
Wed, 25 Jan 2012 08:10:04 +0000 (09:10 +0100)
committerVolker Lendecke <vlendec@samba.org>
Wed, 25 Jan 2012 10:57:18 +0000 (11:57 +0100)
Autobuild-User: Volker Lendecke <vlendec@samba.org>
Autobuild-Date: Wed Jan 25 11:57:18 CET 2012 on sn-devel-104

lib/util/samba_util.h
lib/util/util.c
librpc/tools/ndrdump.c
source3/client/client.c

index 95bf7fd7430df96201b2bb4b61bb56b3e44d9bb2..9df3ddfcd0eba66fc779f765e606b56ce54117d6 100644 (file)
@@ -701,6 +701,12 @@ void dump_data_cb(const uint8_t *buf, int len,
                  void (*cb)(const char *buf, void *private_data),
                  void *private_data);
 
+/**
+ * Write dump of binary data to a FILE
+ */
+void dump_data_file(const uint8_t *buf, int len, bool omit_zero_bytes,
+                   FILE *f);
+
 /**
  * Write dump of binary data to the log file.
  *
index c7c37bc815201f6816ad186c5f1286e42047757f..c4fbd0b39fcab3ff864fa630ab8d71d407051c56 100644 (file)
@@ -462,6 +462,17 @@ _PUBLIC_ void dump_data_skip_zeros(int level, const uint8_t *buf, int len)
        dump_data_cb(buf, len, true, debugadd_cb, &level);
 }
 
+static void fprintf_cb(const char *buf, void *private_data)
+{
+       FILE *f = (FILE *)private_data;
+       fprintf(f, "%s", buf);
+}
+
+void dump_data_file(const uint8_t *buf, int len, bool omit_zero_bytes,
+                   FILE *f)
+{
+       dump_data_cb(buf, len, omit_zero_bytes, fprintf_cb, f);
+}
 
 /**
  malloc that aborts with smb_panic on fail or zero size.
index e33115ded840486c93f52209b5b282f9a9862ce3..91bf06fcd9aab03e461ab291b371586d34c08f4d 100644 (file)
@@ -125,14 +125,9 @@ static const struct ndr_interface_table *load_iface_from_plugin(const char *plug
        return p;
 }
 
-static void printf_cb(const char *buf, void *private_data)
-{
-       printf("%s", buf);
-}
-
 static void ndrdump_data(uint8_t *d, uint32_t l, bool force)
 {
-       dump_data_cb(d, l, !force, printf_cb, NULL);
+       dump_data_file(d, l, !force, stdout);
 }
 
 static NTSTATUS ndrdump_pull_and_print_pipes(const char *function,
index 47d44705d2d80d9758703168e68fad53af9e2727..4b7df92877de469845427894570fbeeae002a924 100644 (file)
@@ -3463,11 +3463,6 @@ static int cmd_getfacl(void)
        return 0;
 }
 
-static void printf_cb(const char *buf, void *private_data)
-{
-       printf("%s", buf);
-}
-
 /****************************************************************************
  Get the EA list of a file
 ****************************************************************************/
@@ -3511,8 +3506,8 @@ static int cmd_geteas(void)
 
        for (i=0; i<num_eas; i++) {
                d_printf("%s (%d) =\n", eas[i].name, (int)eas[i].flags);
-               dump_data_cb(eas[i].value.data, eas[i].value.length, false,
-                            printf_cb, NULL);
+               dump_data_file(eas[i].value.data, eas[i].value.length, false,
+                              stdout);
                d_printf("\n");
        }