mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:57:35 +00:00
LibC: Implement vdprintf
and dprintf
These functions work just like `vfprintf` and `fprintf`, except that they take a file descriptor as their first argument instead of a FILE*.
This commit is contained in:
parent
daf3d4c6ef
commit
ad560cff0f
2 changed files with 19 additions and 0 deletions
|
@ -907,6 +907,23 @@ int fprintf(FILE* stream, char const* fmt, ...)
|
|||
return ret;
|
||||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/vdprintf.html
|
||||
int vdprintf(int fd, char const* fmt, va_list ap)
|
||||
{
|
||||
// FIXME: Implement buffering so that we don't issue one write syscall for every character.
|
||||
return printf_internal([fd](auto, char ch) { write(fd, &ch, 1); }, nullptr, fmt, ap);
|
||||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/dprintf.html
|
||||
int dprintf(int fd, char const* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
int ret = vdprintf(fd, fmt, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/vprintf.html
|
||||
int vprintf(char const* fmt, va_list ap)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue