HALF ECHO LEARN / REFERENCE COLLECTION

v262.2

src/libc/musl/stdio.c

1,453 bytesGit mode 100644Download original fileLGPL-2.1-or-later

Git blob: cfe35b09f9908f9caa59ccfded7cfbe07086a4a2

Lines 1–40 of 40

/* SPDX-License-Identifier: LGPL-2.1-or-later */
 
#include <errno.h>
#include <stdio.h>
#include <stdio_ext.h>
 
#define DEFINE_PUT(func)                                         \
        int func##_check_writable(int c, FILE *stream) {         \
                if (!__fwritable(stream)) {                      \
                        errno = EBADF;                           \
                        return EOF;                              \
                }                                                \
                                                                 \
                return func(c, stream);                          \
        }
 
#define DEFINE_FPUTS(func)                                       \
        int func##_check_writable(const char *s, FILE *stream) { \
                if (!__fwritable(stream)) {                      \
                        errno = EBADF;                           \
                        return EOF;                              \
                }                                                \
                                                                 \
                return func(s, stream);                          \
        }
 
#undef putc
#undef putc_unlocked
#undef fputc
#undef fputc_unlocked
#undef fputs
#undef fputs_unlocked
 
DEFINE_PUT(putc);
DEFINE_PUT(putc_unlocked);
DEFINE_PUT(fputc);
DEFINE_PUT(fputc_unlocked);
DEFINE_FPUTS(fputs);
DEFINE_FPUTS(fputs_unlocked);