libc: io: implement (v)fprintf
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "file.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
extern int __libc_fctprintf(
|
||||
@@ -11,7 +11,7 @@ extern int __libc_fctprintf(
|
||||
va_list va);
|
||||
extern int __fputc(int c, struct __opaque_file *stream);
|
||||
|
||||
static inline int _out_file(char character, void *arg)
|
||||
static inline int _out_file(char character, void *arg)
|
||||
{
|
||||
FILE *fp = arg;
|
||||
return __fputc(character, fp);
|
||||
@@ -19,17 +19,5 @@ static inline int _out_file(char character, void *arg)
|
||||
|
||||
int vprintf(const char *format, va_list arg)
|
||||
{
|
||||
__libc_file_lock(stdout);
|
||||
|
||||
int ret = __libc_fctprintf(_out_file, stdout, format, arg);
|
||||
if (errno != SUCCESS) {
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
if (ferror(stdout)) {
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
__libc_file_unlock(stdout);
|
||||
return ret;
|
||||
return vfprintf(stdout, format, arg);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user