1
0
mirror of https://github.com/samba-team/samba.git synced 2025-11-28 12:23:49 +03:00

r10245: Get rid of XFILE in a few places.

Add fdprintf() and vfdprintf() helper functions.
This commit is contained in:
Jelmer Vernooij
2005-09-15 19:52:13 +00:00
committed by Gerald (Jerry) Carter
parent 8a0a8d259d
commit 6685009f6a
4 changed files with 47 additions and 27 deletions

View File

@@ -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;
}