summaryrefslogtreecommitdiff
path: root/src/libc/stdio/fprintf.c
blob: cd2851c0c063fa4a2d7bec0cdb52c6be4bd35ec7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <shared/printf.h>
#include <stdio.h>

static void backend_file(void *arg, const char *buf, size_t len) {
	fwrite(buf, 1, len, arg);
}

int fprintf(FILE *restrict f, const char *restrict fmt, ...) {
	int ret;
	va_list argp;
	va_start(argp, fmt);
	ret = vfprintf(f, fmt, argp);
	va_end(argp);
	return ret;
}

int vfprintf(FILE *restrict f, const char *restrict fmt, va_list ap) {
	return __printf_internal(fmt, ap, backend_file, f);
}

int printf(const char *restrict fmt, ...) {
	int ret;
	va_list argp;
	va_start(argp, fmt);
	ret = vprintf(fmt, argp);
	va_end(argp);
	return ret;
}

int vprintf(const char *restrict fmt, va_list ap) {
	return vfprintf(stdout, fmt, ap);
}