blob: 37413a23730b424f78bf2eb65fc791dc66b16aec (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stddef.h>
#define EOF (-1)
#define BUFSIZ 8192
#define OPN_MAX 20
typedef struct {
int cnt;
char *ptr;
char *base;
int flag;
int fd;
} FILE;
extern FILE _iob[OPN_MAX];
#define stdin (_iob+0)
#define stdout (_iob+1)
#define stderr (_iob+2)
enum flags {
_READ = 1 << 0,
_WRITE = 1 << 2,
_UNBUF = 1 << 3,
_EOF = 1 << 4,
_ERR = 1 << 5
};
int _fillbuf(FILE *);
int _flushbuf(int, FILE *);
FILE *fopen(char *name, char *mode);
int fflush(FILE *fp);
int fseek(FILE *fp, ssize_t os, int whence);
int fclose(FILE *fp);
int puts(const char *);
#define feof(p) ((p)->flag & _EOF)
#define ferror(p) ((p)->flag & _ERR)
#define fileno(p) ((p)->fd)
#define getc(p) ((--(p)->cnt >= 0) \
? (unsigned char) *(p)->ptr++ : _fillbuf(p))
#define putc(x, p) ((--(p)->cnt >= 0) \
? *(p)->ptr++ = (x) : _flushbuf(x, p))
#define getchar() getc(stdin)
#define putchar(x) putc((x), stdout)
|