summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2010-10-24 15:23:41 +0200
committerVolker Lendecke <vlendec@samba.org>2010-10-24 20:46:28 +0000
commit611bcfcb49f3a17ac7a1b866b2ea04806c7c1b40 (patch)
tree2a0a7f5003be6e954542e93ba6e1ab119765e096 /lib
parent9e7bcaab2dc9a73c8251431fa4573d1d1ba32561 (diff)
downloadsamba-611bcfcb49f3a17ac7a1b866b2ea04806c7c1b40.tar.gz
samba-611bcfcb49f3a17ac7a1b866b2ea04806c7c1b40.tar.bz2
samba-611bcfcb49f3a17ac7a1b866b2ea04806c7c1b40.zip
Add print_asc_cb()
Diffstat (limited to 'lib')
-rw-r--r--lib/util/util.c24
-rw-r--r--lib/util/util.h3
2 files changed, 24 insertions, 3 deletions
diff --git a/lib/util/util.c b/lib/util/util.c
index 11bb315176..a01b47da15 100644
--- a/lib/util/util.c
+++ b/lib/util/util.c
@@ -300,11 +300,29 @@ _PUBLIC_ bool fcntl_lock(int fd, int op, off_t offset, off_t count, int type)
return true;
}
-void print_asc(int level, const uint8_t *buf,int len)
+static void debugadd_cb(const char *buf, void *private_data)
+{
+ int *plevel = (int *)private_data;
+ DEBUGADD(*plevel, ("%s", buf));
+}
+
+void print_asc_cb(const uint8_t *buf, int len,
+ void (*cb)(const char *buf, void *private_data),
+ void *private_data)
{
int i;
- for (i=0;i<len;i++)
- DEBUGADD(level,("%c", isprint(buf[i])?buf[i]:'.'));
+ char s[2];
+ s[1] = 0;
+
+ for (i=0; i<len; i++) {
+ s[0] = isprint(buf[i]) ? buf[i] : '.';
+ cb(s, private_data);
+ }
+}
+
+void print_asc(int level, const uint8_t *buf,int len)
+{
+ print_asc_cb(buf, len, debugadd_cb, &level);
}
/**
diff --git a/lib/util/util.h b/lib/util/util.h
index c613e65adf..261acea88c 100644
--- a/lib/util/util.h
+++ b/lib/util/util.h
@@ -840,6 +840,9 @@ bool pm_process( const char *fileName,
bool unmap_file(void *start, size_t size);
void print_asc(int level, const uint8_t *buf,int len);
+void print_asc_cb(const uint8_t *buf, int len,
+ void (*cb)(const char *buf, void *private_data),
+ void *private_data);
/**
* Add an id to an array of ids.