blob: 5d0dcf2114536b63ba45a2b8cfe513f08f44c3d0 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001/*
2 * Copyright (c) 2008-2013 Travis Geiselbrecht
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files
6 * (the "Software"), to deal in the Software without restriction,
7 * including without limitation the rights to use, copy, modify, merge,
8 * publish, distribute, sublicense, and/or sell copies of the Software,
9 * and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23#ifndef __STDIO_H
24#define __STDIO_H
25
26#include <compiler.h>
27#include <printf.h>
28#include <sys/types.h>
29
30__BEGIN_CDECLS
31
32typedef struct FILE {
33 void *ctx;
34 int (*fputc)(void *ctx, int c);
35 int (*fputs)(void *ctx, const char *s);
36 int (*fgetc)(void *ctx);
37 int (*vfprintf)(void *ctx, const char *fmt, va_list ap);
38} FILE;
39
40extern FILE __stdio_FILEs[];
41
42#define stdin (&__stdio_FILEs[0])
43#define stdout (&__stdio_FILEs[1])
44#define stderr (&__stdio_FILEs[2])
45
46FILE *fopen(const char *filename, const char *mode);
47int fclose(FILE *stream);
48size_t fread(void *ptr, size_t size, size_t count, FILE *stream);
49size_t fwrite(const void *ptr, size_t size, size_t count, FILE *stream);
50int fflush(FILE *stream);
51int feof(FILE *stream);
52
53#define SEEK_SET 0
54#define SEEK_CUR 1
55#define SEEK_END 2
56
57int fseek(FILE *stream, long offset, int whence);
58long ftell(FILE *stream);
59
60int fputc(int c, FILE *fp);
61#define putc(c, fp) fputc(c, fp)
62int putchar(int c);
63
64int fputs(const char *s, FILE *fp);
65int puts(const char *str);
66
67int getc(FILE *fp);
68int getchar(void);
69
70int fprintf(FILE *fp, const char *fmt, ...);
71int vfprintf(FILE *fp, const char *fmt, va_list ap);
72
73int sscanf(const char *buf, const char *fmt, ...);
74
75__END_CDECLS
76
77#endif
78