r10678: Add debug helper
authorJelmer Vernooij <jelmer@samba.org>
Sun, 2 Oct 2005 14:29:08 +0000 (14:29 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:39:17 +0000 (13:39 -0500)
Fix push for non-fixed length strings
(This used to be commit 821b0bb56f6d6b9df7bbdeeddc206505f3f0a7c2)

source4/lib/tdr/tdr.c

index 34611683e2847da2ea23542d14f1aed6c39f7ce1..4a8d05a8abc94ac6b919dd3d2ddfd6a560c1ea0c 100644 (file)
@@ -170,6 +170,10 @@ NTSTATUS tdr_push_charset(struct tdr_push *tdr, const char **v, uint32_t length,
 {
        ssize_t ret, required;
 
 {
        ssize_t ret, required;
 
+       if (length == -1) {
+               length = strlen(*v) + 1; /* Extra element for null character */
+       }
+
        required = el_size * length;
        TDR_PUSH_NEED_BYTES(tdr, required);
 
        required = el_size * length;
        TDR_PUSH_NEED_BYTES(tdr, required);
 
@@ -392,3 +396,21 @@ NTSTATUS tdr_push_to_fd(int fd, tdr_push_fn_t push_fn, const void *p)
 
        return NT_STATUS_OK;
 }
 
        return NT_STATUS_OK;
 }
+
+void tdr_print_debug_helper(struct tdr_print *tdr, const char *format, ...) _PRINTF_ATTRIBUTE(2,3)
+{
+       va_list ap;
+       char *s = NULL;
+       int i;
+
+       va_start(ap, format);
+       vasprintf(&s, format, ap);
+       va_end(ap);
+
+       for (i=0;i<tdr->level;i++) {
+               DEBUG(0,("    "));
+       }
+
+       DEBUG(0,("%s\n", s));
+       free(s);
+}