aboutsummaryrefslogtreecommitdiff
path: root/ch8/8-02_syscalls.h
diff options
context:
space:
mode:
Diffstat (limited to 'ch8/8-02_syscalls.h')
-rw-r--r--ch8/8-02_syscalls.h47
1 files changed, 0 insertions, 47 deletions
diff --git a/ch8/8-02_syscalls.h b/ch8/8-02_syscalls.h
deleted file mode 100644
index 728c5af..0000000
--- a/ch8/8-02_syscalls.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* 8-02_syscalls.h
- *
- * A simpler stdio.h to aid in exercises 8-2
- */
-
-long lseek(int fd, long offset, int origin);
-
-struct _flags {
- unsigned int _READ : 1;
- unsigned int _WRITE : 1;
- unsigned int _UNBUF : 1;
- unsigned int _EOF : 1;
- unsigned int _ERR : 1;
-} flags;
-
-typedef struct _iobuf {
- int cnt;
- char *ptr;
- char *base;
- struct _flags flags;
- int fd;
-} my_FILE;
-
-my_FILE _iob[FOPEN_MAX] = {
- /* stdin is read-only */
- { 0, (char *) 0, (char *) 0, {1, 0, 0, 0, 0}, 0 },
- /* stdout is write only */
- { 0, (char *) 0, (char *) 0, {0, 1, 0, 0, 0}, 1 },
- /* stderr is written AND not buffered */
- { 0, (char *) 0, (char *) 0, {0, 1, 1, 0, 0}, 2 }
-};
-
-#define feof(p) (((p)->flags._EOF) != 0)
-#define ferror(p) (((p)->flags._ERR) != 0)
-#define fileno(p) ((p)->fd)
-#define my_getc(p) (--(p)->cnt >= 0 ? (unsigned char) *(p)->ptr++ : my__fillbuf(p))
-#define getchar() getc(stdin)
-
-int my_fempty(struct _flags flags) {
- if (!flags._READ && !flags._WRITE && !flags._UNBUF && !flags._EOF && !flags._ERR) {
- return 1;
- } else {
- return 0;
- }
-}
-
-int my_fclose(my_FILE*);