diff options
author | Andrew Tridgell <tridge@samba.org> | 2000-04-16 09:40:02 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2000-04-16 09:40:02 +0000 |
commit | bd5cd502bf52164b95d7bfc026189e04988171db (patch) | |
tree | 763479e6a552046f0c936dc11bdf034543268371 /source/lib/slprintf.c | |
parent | 9f49d17d4cf904034ce3718626450dc25541b420 (diff) | |
download | samba-bd5cd502bf52164b95d7bfc026189e04988171db.tar.gz samba-bd5cd502bf52164b95d7bfc026189e04988171db.tar.xz samba-bd5cd502bf52164b95d7bfc026189e04988171db.zip |
added fdprintf()
this is like fprintf() but operates on a file descriptor
combined with file_load_lines() this makes it really easy to get rid
of the use of fopen() in Samba.
Diffstat (limited to 'source/lib/slprintf.c')
-rw-r--r-- | source/lib/slprintf.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/source/lib/slprintf.c b/source/lib/slprintf.c index a755bf1bc58..ed7113c8652 100644 --- a/source/lib/slprintf.c +++ b/source/lib/slprintf.c @@ -64,3 +64,33 @@ va_dcl va_end(ap); return ret; } + + /* this is rather line fprintf, except that it works on a file descriptor + and is limited to one pstring of output */ +#ifdef HAVE_STDARG_H + int fdprintf(int fd, char *format, ...) +{ +#else + int fdprintf(va_alist) +va_dcl +{ + int fd; + char *format; +#endif + va_list ap; + int ret; + pstring str; + +#ifdef HAVE_STDARG_H + va_start(ap, format); +#else + va_start(ap); + fd = va_arg(ap,int); + format = va_arg(ap,char *); +#endif + str[0] = 0; + + ret = vslprintf(str,sizeof(str),format,ap); + va_end(ap); + return write(fd, str, strlen(str)); +} |