s4/torture: Remove already existing test_dir
[samba.git] / lib / util / dprintf.c
index a77eed84f5b776a218af0fe2fbac6d0c6923c827..9d1573f671f71f3928f79c2a5d73d6e3a851aa77 100644 (file)
   conversion
 */
 
-#include "includes.h"
+#include "replace.h"
 #include "system/locale.h"
+#include "lib/util/samba_util.h"
+
+static int d_vfprintf(FILE *f, const char *format, va_list ap)
+                     PRINTF_ATTRIBUTE(2,0);
 
 static int d_vfprintf(FILE *f, const char *format, va_list ap) 
 {
-       char *p, *p2;
-       int ret;
-       size_t clen;
-       bool cret;
-       va_list ap2;
-
-       va_copy(ap2, ap);
-       ret = vasprintf(&p, format, ap2);
-       va_end(ap2);
-
-       if (ret <= 0) return ret;
-
-       cret = convert_string_talloc(NULL, CH_UTF8, CH_DISPLAY, p, ret, (void **)&p2, &clen);
-        if (!cret) {
-               /* the string can't be converted - do the best we can,
-                  filling in non-printing chars with '?' */
-               int i;
-               for (i=0;i<ret;i++) {
-                       if (isprint(p[i]) || isspace(p[i])) {
-                               fwrite(p+i, 1, 1, f);
-                       } else {
-                               fwrite("?", 1, 1, f);
-                       }
-               }
-               SAFE_FREE(p);
-               return ret;
-        }
-
-       /* good, its converted OK */
-       SAFE_FREE(p);
-       ret = fwrite(p2, 1, clen, f);
-       talloc_free(p2);
-
-       return ret;
+       return vfprintf(f, format, ap);
 }