From fd619b4fb3a9a5c05df765d2cf57a042a4d5da2d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 15 Sep 2005 19:52:13 +0000 Subject: r10245: Get rid of XFILE in a few places. Add fdprintf() and vfdprintf() helper functions. (This used to be commit 6685009f6af94b088084d69a43bcea5f8335ae57) --- source4/lib/util_file.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'source4/lib/util_file.c') diff --git a/source4/lib/util_file.c b/source4/lib/util_file.c index 1330b0a70d..338b9547a5 100644 --- a/source4/lib/util_file.c +++ b/source4/lib/util_file.c @@ -397,3 +397,29 @@ BOOL file_exists(const char *path) struct stat st; return (stat(path, &st) == 0); } + +int vfdprintf(int fd, const char *format, va_list ap) +{ + char *p; + int len, ret; + va_list ap2; + + VA_COPY(ap2, ap); + + len = vasprintf(&p, format, ap2); + if (len <= 0) return len; + ret = write(fd, p, len); + SAFE_FREE(p); + return ret; +} + +int fdprintf(int fd, const char *format, ...) _PRINTF_ATTRIBUTE(2,3) +{ + va_list ap; + int ret; + + va_start(ap, format); + ret = vfdprintf(fd, format, ap); + va_end(ap); + return ret; +} -- cgit