summaryrefslogtreecommitdiff
path: root/lib/util
diff options
context:
space:
mode:
Diffstat (limited to 'lib/util')
-rw-r--r--lib/util/samba_util.h6
-rw-r--r--lib/util/util.c11
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h
index 95bf7fd743..9df3ddfcd0 100644
--- a/lib/util/samba_util.h
+++ b/lib/util/samba_util.h
@@ -702,6 +702,12 @@ void dump_data_cb(const uint8_t *buf, int len,
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.
*
* The data is only written if the log level is at least level.
diff --git a/lib/util/util.c b/lib/util/util.c
index c7c37bc815..c4fbd0b39f 100644
--- a/lib/util/util.c
+++ b/lib/util/util.c
@@ -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.