mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:54:58 +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)
|
||||
{
|
||||
|
|
|
@ -79,6 +79,8 @@ int vfprintf(FILE*, char const* fmt, va_list) __attribute__((format(printf, 2, 0
|
|||
int vasprintf(char** strp, char const* fmt, va_list) __attribute__((format(printf, 2, 0)));
|
||||
int vsprintf(char* buffer, char const* fmt, va_list) __attribute__((format(printf, 2, 0)));
|
||||
int vsnprintf(char* buffer, size_t, char const* fmt, va_list) __attribute__((format(printf, 3, 0)));
|
||||
int vdprintf(int, char const* fmt, va_list) __attribute__((format(printf, 2, 0)));
|
||||
int dprintf(int, char const* fmt, ...) __attribute__((format(printf, 2, 3)));
|
||||
int fprintf(FILE*, char const* fmt, ...) __attribute__((format(printf, 2, 3)));
|
||||
int printf(char const* fmt, ...) __attribute__((format(printf, 1, 2)));
|
||||
void dbgputstr(char const*, size_t);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue