Rev 4537 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 4537 | Rev 4668 | ||
|---|---|---|---|
| Line 35... | Line 35... | ||
| 35 | #ifndef LIBC_STDIO_H_ |
35 | #ifndef LIBC_STDIO_H_ |
| 36 | #define LIBC_STDIO_H_ |
36 | #define LIBC_STDIO_H_ |
| 37 | 37 | ||
| 38 | #include <sys/types.h> |
38 | #include <sys/types.h> |
| 39 | #include <stdarg.h> |
39 | #include <stdarg.h> |
| - | 40 | #include <string.h> |
|
| 40 | #include <adt/list.h> |
41 | #include <adt/list.h> |
| 41 | 42 | ||
| 42 | #define EOF (-1) |
43 | #define EOF (-1) |
| 43 | 44 | ||
| - | 45 | /** Default size for stream I/O buffers */ |
|
| - | 46 | #define BUFSIZ 4096 |
|
| - | 47 | ||
| 44 | #define DEBUG(fmt, ...) \ |
48 | #define DEBUG(fmt, ...) \ |
| 45 | { \ |
49 | { \ |
| 46 | char buf[256]; \ |
50 | char _buf[256]; \ |
| 47 | int n = snprintf(buf, sizeof(buf), fmt, ##__VA_ARGS__); \ |
51 | int _n = snprintf(_buf, sizeof(_buf), fmt, ##__VA_ARGS__); \ |
| 48 | if (n > 0) \ |
52 | if (_n > 0) \ |
| 49 | (void) __SYSCALL3(SYS_KLOG, 1, (sysarg_t) buf, str_size(buf)); \ |
53 | (void) __SYSCALL3(SYS_KLOG, 1, (sysarg_t) _buf, str_size(_buf)); \ |
| 50 | } |
54 | } |
| 51 | 55 | ||
| 52 | #ifndef SEEK_SET |
56 | #ifndef SEEK_SET |
| 53 | #define SEEK_SET 0 |
57 | #define SEEK_SET 0 |
| 54 | #define SEEK_CUR 1 |
58 | #define SEEK_CUR 1 |
| 55 | #define SEEK_END 2 |
59 | #define SEEK_END 2 |
| 56 | #endif |
60 | #endif |
| 57 | 61 | ||
| - | 62 | enum _buffer_type { |
|
| - | 63 | /** No buffering */ |
|
| - | 64 | _IONBF, |
|
| - | 65 | /** Line buffering */ |
|
| - | 66 | _IOLBF, |
|
| - | 67 | /** Full buffering */ |
|
| - | 68 | _IOFBF |
|
| - | 69 | }; |
|
| - | 70 | ||
| 58 | typedef struct { |
71 | typedef struct { |
| 59 | /** Linked list pointer. */ |
72 | /** Linked list pointer. */ |
| 60 | link_t link; |
73 | link_t link; |
| 61 | 74 | ||
| 62 | /** Underlying file descriptor. */ |
75 | /** Underlying file descriptor. */ |
| Line 71... | Line 84... | ||
| 71 | /** Klog indicator */ |
84 | /** Klog indicator */ |
| 72 | int klog; |
85 | int klog; |
| 73 | 86 | ||
| 74 | /** Phone to the file provider */ |
87 | /** Phone to the file provider */ |
| 75 | int phone; |
88 | int phone; |
| - | 89 | ||
| - | 90 | /** Buffering type */ |
|
| - | 91 | enum _buffer_type btype; |
|
| - | 92 | /** Buffer */ |
|
| - | 93 | uint8_t *buf; |
|
| - | 94 | /** Buffer size */ |
|
| - | 95 | size_t buf_size; |
|
| - | 96 | /** Buffer I/O pointer */ |
|
| - | 97 | uint8_t *buf_head; |
|
| 76 | } FILE; |
98 | } FILE; |
| 77 | 99 | ||
| 78 | extern FILE *stdin; |
100 | extern FILE *stdin; |
| 79 | extern FILE *stdout; |
101 | extern FILE *stdout; |
| 80 | extern FILE *stderr; |
102 | extern FILE *stderr; |
| Line 119... | Line 141... | ||
| 119 | 141 | ||
| 120 | extern int fflush(FILE *); |
142 | extern int fflush(FILE *); |
| 121 | extern int ferror(FILE *); |
143 | extern int ferror(FILE *); |
| 122 | extern void clearerr(FILE *); |
144 | extern void clearerr(FILE *); |
| 123 | 145 | ||
| - | 146 | extern void setvbuf(FILE *, void *, int, size_t); |
|
| - | 147 | ||
| 124 | /* Misc file functions */ |
148 | /* Misc file functions */ |
| 125 | extern int rename(const char *, const char *); |
149 | extern int rename(const char *, const char *); |
| 126 | 150 | ||
| 127 | #endif |
151 | #endif |
| 128 | 152 | ||