1 | // SPDX-License-Identifier: GPL-3.0-or-later |
2 | #pragma once |
3 | |
4 | #include <mos/mos_global.h> |
5 | #include <mos/moslib_global.h> |
6 | #include <stdarg.h> |
7 | #include <stddef.h> |
8 | |
9 | /** |
10 | * @defgroup libs_stdio libs.Stdio |
11 | * @ingroup libs |
12 | * @brief Standard input/output functions. |
13 | * @{ |
14 | */ |
15 | |
16 | // defined in stdio.c & stdio_impl.c |
17 | MOSAPI int __printf(2, 3) sprintf(char *__restrict str, const char *__restrict format, ...); |
18 | MOSAPI int __printf(3, 4) snprintf(char *__restrict str, size_t size, const char *__restrict format, ...); |
19 | MOSAPI int vsprintf(char *__restrict str, const char *__restrict format, va_list ap); |
20 | MOSAPI int vsnprintf(char *__restrict buf, size_t size, const char *__restrict format, va_list args); |
21 | |
22 | #ifndef __MOS_KERNEL__ // for userspace only |
23 | |
24 | typedef struct _FILE FILE; |
25 | MOSAPI FILE *stdin; |
26 | MOSAPI FILE *stdout; |
27 | MOSAPI FILE *stderr; |
28 | |
29 | // C standard says they are macros, make them happy. |
30 | #define stdin stdin |
31 | #define stdout stdout |
32 | #define stderr stderr |
33 | |
34 | MOSAPI int __printf(1, 2) printf(const char *__restrict format, ...); |
35 | MOSAPI int __printf(2, 3) fprintf(FILE *__restrict file, const char *__restrict format, ...); |
36 | MOSAPI int __printf(2, 3) dprintf(int fd, const char *__restrict format, ...); |
37 | MOSAPI int vprintf(const char *__restrict format, va_list ap); |
38 | MOSAPI int vfprintf(FILE *__restrict file, const char *__restrict format, va_list ap); |
39 | MOSAPI int vdprintf(int fd, const char *__restrict format, va_list ap); |
40 | |
41 | MOSAPI int getchar(void); |
42 | MOSAPI int putchar(int c); |
43 | MOSAPI int puts(const char *s); |
44 | |
45 | MOSAPI int fputs(const char *__restrict s, FILE *__restrict file); |
46 | MOSAPI int fputc(int c, FILE *file); |
47 | MOSAPI int fgetc(FILE *file); |
48 | |
49 | size_t fread(void *__restrict ptr, size_t size, size_t nmemb, FILE *__restrict stream); |
50 | size_t fwrite(const void *__restrict ptr, size_t size, size_t nmemb, FILE *__restrict stream); |
51 | int fseek(FILE *stream, long offset, io_seek_whence_t whence); |
52 | off_t ftell(FILE *stream); |
53 | FILE *fopen(const char *path, const char *mode); |
54 | int fclose(FILE *stream); |
55 | #endif |
56 | |
57 | /** @} */ |
58 | |