Debian Codegraph @

src/libc/musl/stdio.c

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 #include <errno.h>
4 #include <stdio.h>
5 #include <stdio_ext.h>
6
7 #define DEFINE_PUT(func) \
8 int func##_check_writable(int c, FILE *stream) { \
9 if (!__fwritable(stream)) { \
10 errno = EBADF; \
11 return EOF; \
12 } \
13 \
14 return func(c, stream); \
15 }
16
17 #define DEFINE_FPUTS(func) \
18 int func##_check_writable(const char *s, FILE *stream) { \
19 if (!__fwritable(stream)) { \
20 errno = EBADF; \
21 return EOF; \
22 } \
23 \
24 return func(s, stream); \
25 }
26
27 #undef putc
28 #undef putc_unlocked
29 #undef fputc
30 #undef fputc_unlocked
31 #undef fputs
32 #undef fputs_unlocked
33
34 DEFINE_PUT(putc);
35 DEFINE_PUT(putc_unlocked);
36 DEFINE_PUT(fputc);
37 DEFINE_PUT(fputc_unlocked);
38 DEFINE_FPUTS(fputs);
39 DEFINE_FPUTS(fputs_unlocked);