-
Notifications
You must be signed in to change notification settings - Fork 0
/
file.h
62 lines (44 loc) · 1.19 KB
/
file.h
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
51
52
53
54
55
56
57
58
59
60
61
62
#define BUFSIZE 1024
#define OPEN_MAX 20
#define myEOF -1
typedef struct myFILE {
int myfd; //file descriptor
int mycnt; //characters left
char *myptr; //next character position
char *mybase; //location of buffer
int myflag;
int count; //mode of file access
}myFILE;
typedef struct fpos {
int p;
}fpos;
myFILE file_no[OPEN_MAX];
#define mystdin (&file_no[0])
#define mystdout (&file_no[1])
#define mystderr (&file_no[2])
enum _flags {
READ = 01,
WRITE = 02,
UNBUF = 04,
Eof = 010,
ERR = 020
};
myFILE file_no[OPEN_MAX] ={ /* stdin, stdout, stderr:*/
{0, 0, (char *)0, (char *)0, READ},
{1, 0, (char *)0, (char *)0, WRITE},
{2, 0, (char *)0, (char *)0, WRITE | UNBUF}
};
#define mySEEK_SET 0
#define mySEEK_CUR 1
#define mySEEK_END 2
myFILE *myfopen(char *filename, char *mode);
int myfread(char *, int size, int nmemb, myFILE *fp);
int myfwrite(char *, int size, int nmemb, myFILE *fp);
int myfclose(myFILE *fp);
int myfillbuf(myFILE *fp);
int myflushbuf(int c, myFILE *fp);
int myfgetpos(myFILE *fp, fpos *pos);
int myfsetpos(myFILE *fp, fpos *pos);
int myfeof(myFILE *fp);
long myftell(myFILE *fp);
int myfseek(myFILE *fp, long offset, int whence);