| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
#pragma once |
| 3 |
|
| 4 |
#include_next <stdio.h> |
| 5 |
|
| 6 |
/* When a stream is opened read-only under glibc, fputs() and friends fail with EBADF. However, they |
| 7 |
* succeed under musl. We rely on the glibc behavior in the code base. The following _check_writable() |
| 8 |
* functions first check if the passed stream is writable, and refuse to write with EBADF if not. */ |
| 9 |
|
| 10 |
int putc_check_writable(int c, FILE *stream); |
| 11 |
int putc_unlocked_check_writable(int c, FILE *stream); |
| 12 |
int fputc_check_writable(int c, FILE *stream); |
| 13 |
int fputc_unlocked_check_writable(int c, FILE *stream); |
| 14 |
int fputs_check_writable(const char *s, FILE *stream); |
| 15 |
int fputs_unlocked_check_writable(const char *s, FILE *stream); |
| 16 |
|
| 17 |
#define putc putc_check_writable |
| 18 |
#define putc_unlocked putc_unlocked_check_writable |
| 19 |
#define fputc fputc_check_writable |
| 20 |
#define fputc_unlocked fputc_unlocked_check_writable |
| 21 |
#define fputs fputs_check_writable |
| 22 |
#define fputs_unlocked fputs_unlocked_check_writable |