[1] | 1 | #ifndef _STDIO_H |
---|
| 2 | #define _STDIO_H |
---|
| 3 | |
---|
| 4 | #include <stdarg.h> |
---|
| 5 | #include <sys/types.h> |
---|
| 6 | #include <endian.h> |
---|
| 7 | |
---|
| 8 | struct __stdio_file; |
---|
| 9 | typedef struct __stdio_file FILE; |
---|
| 10 | |
---|
| 11 | extern FILE *stdin, *stdout, *stderr; |
---|
| 12 | |
---|
| 13 | FILE *fopen (const char *path, const char *mode) ; |
---|
| 14 | FILE *fdopen (int fildes, const char *mode) ; |
---|
| 15 | FILE *freopen (const char *path, const char *mode, FILE *stream) ; |
---|
| 16 | |
---|
| 17 | int printf(const char *format, ...) __attribute__((__format__(__printf__,1,2))); |
---|
| 18 | int fprintf(FILE *stream, const char *format, ...) __attribute__((__format__(__printf__,2,3))); |
---|
| 19 | int sprintf(char *str, const char *format, ...) __attribute__((__format__(__printf__,2,3))); |
---|
| 20 | int snprintf(char *str, size_t size, const char *format, ...) __attribute__((__format__(__printf__,3,4))); |
---|
| 21 | int asprintf(char **ptr, const char* format, ...) __attribute__((__format__(__printf__,2,3))); |
---|
| 22 | |
---|
| 23 | int scanf(const char *format, ...) __attribute__((__format__(__scanf__,1,2))); |
---|
| 24 | int fscanf(FILE *stream, const char *format, ...) __attribute__((__format__(__scanf__,2,3))); |
---|
| 25 | int sscanf(const char *str, const char *format, ...) __attribute__((__format__(__scanf__,2,3))); |
---|
| 26 | |
---|
| 27 | int vprintf(const char *format, va_list ap) __attribute__((__format__(__printf__,1,0))); |
---|
| 28 | int vfprintf(FILE *stream, const char *format, va_list ap) __attribute__((__format__(__printf__,2,0))); |
---|
| 29 | int vsprintf(char *str, const char *format, va_list ap) __attribute__((__format__(__printf__,2,0))); |
---|
| 30 | int vsnprintf(char *str, size_t size, const char *format, va_list ap) __attribute__((__format__(__printf__,3,0))); |
---|
| 31 | |
---|
| 32 | int fdprintf(int fd, const char *format, ...) __attribute__((__format__(__printf__,2,3))); |
---|
| 33 | int vfdprintf(int fd, const char *format, va_list ap) __attribute__((__format__(__printf__,2,0))); |
---|
| 34 | |
---|
| 35 | int vscanf(const char *format, va_list ap) __attribute__((__format__(__scanf__,1,0))); |
---|
| 36 | int vsscanf(const char *str, const char *format, va_list ap) __attribute__((__format__(__scanf__,2,0))); |
---|
| 37 | int vfscanf(FILE *stream, const char *format, va_list ap) __attribute__((__format__(__scanf__,2,0))); |
---|
| 38 | |
---|
| 39 | int fgetc(FILE *stream) ; |
---|
| 40 | int fgetc_unlocked(FILE *stream) ; |
---|
| 41 | char *fgets(char *s, int size, FILE *stream) ; |
---|
| 42 | char *fgets_unlocked(char *s, int size, FILE *stream) ; |
---|
| 43 | |
---|
| 44 | char *gets(char *s) ; |
---|
| 45 | int ungetc(int c, FILE *stream) ; |
---|
| 46 | int ungetc_unlocked(int c, FILE *stream) ; |
---|
| 47 | |
---|
| 48 | int fputc(int c, FILE *stream) ; |
---|
| 49 | int fputc_unlocked(int c, FILE *stream) ; |
---|
| 50 | int fputs(const char *s, FILE *stream) ; |
---|
| 51 | int fputs_unlocked(const char *s, FILE *stream) ; |
---|
| 52 | |
---|
| 53 | int getc(FILE *stream) ; |
---|
| 54 | int getchar(void) ; |
---|
| 55 | int putchar(int c) ; |
---|
| 56 | int putchar_unlocked(int c) ; |
---|
| 57 | |
---|
| 58 | #if !defined(__cplusplus) |
---|
| 59 | #define putc(c,stream) fputc(c,stream) |
---|
| 60 | #define putchar(c) fputc(c,stdout) |
---|
| 61 | #define putc_unlocked(c,stream) fputc_unlocked(c,stream) |
---|
| 62 | #define putchar_unlocked(c) fputc_unlocked(c,stdout) |
---|
| 63 | #else |
---|
| 64 | inline int putc(int c, FILE *stream) { return fputc(c,stream); } |
---|
| 65 | inline int putc_unlocked(int c, FILE *stream) { return fputc_unlocked(c,stream); } |
---|
| 66 | #endif |
---|
| 67 | |
---|
| 68 | #if !defined(__cplusplus) |
---|
| 69 | #define getc(stream) fgetc(stream) |
---|
| 70 | #define getchar() fgetc(stdin) |
---|
| 71 | #define getc_unlocked(stream) fgetc_unlocked(stream) |
---|
| 72 | #define getchar_unlocked() fgetc_unlocked(stdin) |
---|
| 73 | #else |
---|
| 74 | inline int getc_unlocked(FILE *stream) { return fgetc_unlocked(stream); } |
---|
| 75 | inline int getchar_unlocked(void) { return fgetc_unlocked(stdin); } |
---|
| 76 | #endif |
---|
| 77 | |
---|
| 78 | int puts(const char *s) ; |
---|
| 79 | |
---|
| 80 | int fseek(FILE *stream, long offset, int whence) ; |
---|
| 81 | int fseek_unlocked(FILE *stream, long offset, int whence) ; |
---|
| 82 | long ftell(FILE *stream) ; |
---|
| 83 | long ftell_unlocked(FILE *stream) ; |
---|
| 84 | int fseeko(FILE *stream, off_t offset, int whence) ; |
---|
| 85 | int fseeko_unlocked(FILE *stream, off_t offset, int whence) ; |
---|
| 86 | off_t ftello(FILE *stream) ; |
---|
| 87 | off_t ftello_unlocked(FILE *stream) ; |
---|
| 88 | |
---|
| 89 | #if __WORDSIZE == 32 |
---|
| 90 | |
---|
| 91 | #if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64 |
---|
| 92 | #define off_t loff_t |
---|
| 93 | #define fseeko(foo,bar,baz) fseeko64(foo,bar,baz) |
---|
| 94 | #define ftello(foo) ftello64(foo) |
---|
| 95 | #endif |
---|
| 96 | |
---|
| 97 | #endif |
---|
| 98 | |
---|
| 99 | void rewind(FILE *stream) ; |
---|
| 100 | int fgetpos(FILE *stream, fpos_t *pos) ; |
---|
| 101 | int fsetpos(FILE *stream, fpos_t *pos) ; |
---|
| 102 | |
---|
| 103 | size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream) ; |
---|
| 104 | size_t fread_unlocked(void *ptr, size_t size, size_t nmemb, FILE *stream) ; |
---|
| 105 | |
---|
| 106 | size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) ; |
---|
| 107 | size_t fwrite_unlocked(const void *ptr, size_t size, size_t nmemb, FILE *stream) ; |
---|
| 108 | |
---|
| 109 | int fflush(FILE *stream) ; |
---|
| 110 | int fflush_unlocked(FILE *stream) ; |
---|
| 111 | |
---|
| 112 | int fclose(FILE *stream) ; |
---|
| 113 | int fclose_unlocked(FILE *stream) ; |
---|
| 114 | |
---|
| 115 | int feof(FILE *stream) ; |
---|
| 116 | int feof_unlocked(FILE *stream) ; |
---|
| 117 | int ferror(FILE *stream) ; |
---|
| 118 | int ferror_unlocked(FILE *stream) ; |
---|
| 119 | int fileno(FILE *stream) ; |
---|
| 120 | int fileno_unlocked(FILE *stream) ; |
---|
| 121 | void clearerr(FILE *stream) ; |
---|
| 122 | void clearerr_unlocked(FILE *stream) ; |
---|
| 123 | |
---|
| 124 | int remove(const char *pathname) ; |
---|
| 125 | int rename(const char *oldpath, const char *newpath) ; |
---|
| 126 | |
---|
| 127 | void perror(const char *s) ; |
---|
| 128 | |
---|
| 129 | #define EOF (-1) |
---|
| 130 | |
---|
| 131 | #define BUFSIZ 128 |
---|
| 132 | |
---|
| 133 | #define _IONBF 0 |
---|
| 134 | #define _IOLBF 1 |
---|
| 135 | #define _IOFBF 2 |
---|
| 136 | |
---|
| 137 | int setvbuf(FILE *stream, char *buf, int mode , size_t size) ; |
---|
| 138 | int setvbuf_unlocked(FILE *stream, char *buf, int mode , size_t size) ; |
---|
| 139 | |
---|
| 140 | #if !defined(__cplusplus) |
---|
| 141 | #define setbuf(stream,buf) setvbuf(stream,buf,buf?_IOFBF:_IONBF,BUFSIZ) |
---|
| 142 | #define setbuffer(stream,buf,size) setvbuf(stream,buf,buf?_IOFBF:_IONBF,size) |
---|
| 143 | #define setlinebuf(stream) setvbuf(stream,0,_IOLBF,BUFSIZ) |
---|
| 144 | #else |
---|
| 145 | inline int setbuf(FILE *stream, char *buf) |
---|
| 146 | { return setvbuf(stream,buf,buf?_IOFBF:_IONBF,BUFSIZ); } |
---|
| 147 | inline int setbuffer(FILE *stream, char *buf, size_t size) |
---|
| 148 | { return setvbuf(stream,buf,buf?_IOFBF:_IONBF,size); } |
---|
| 149 | inline int setlinebuf(FILE *stream) |
---|
| 150 | { return setvbuf(stream,0,_IOLBF,BUFSIZ); } |
---|
| 151 | #endif |
---|
| 152 | |
---|
| 153 | FILE *popen(const char *command, const char *type) ; |
---|
| 154 | int pclose(FILE *stream) ; |
---|
| 155 | |
---|
| 156 | |
---|
| 157 | #define L_tmpnam 128 |
---|
| 158 | #define P_tmpdir "/tmp" |
---|
| 159 | char* tmpnam(char *s) ; /* DO NOT USE!!! Use mkstemp instead! */ |
---|
| 160 | char* tempnam(char* dir,char* _template); /* dito */ |
---|
| 161 | FILE* tmpfile(void) ; |
---|
| 162 | FILE* tmpfile_unlocked(void) ; |
---|
| 163 | |
---|
| 164 | #define FILENAME_MAX NAME_MAX |
---|
| 165 | #define FOPEN_MAX 16 |
---|
| 166 | |
---|
| 167 | #define TMP_MAX 10000 |
---|
| 168 | |
---|
| 169 | /* this is so bad, we moved it to -lcompat */ |
---|
| 170 | #define L_ctermid 9 |
---|
| 171 | char* ctermid(char* s); /* returns "/dev/tty" */ |
---|
| 172 | |
---|
| 173 | void flockfile(FILE* f) ; |
---|
| 174 | void funlockfile(FILE* f) ; |
---|
| 175 | int ftrylockfile (FILE *__stream) ; |
---|
| 176 | |
---|
| 177 | #ifdef _GNU_SOURCE |
---|
| 178 | int vasprintf(char **strp, const char *fmt, va_list ap); |
---|
| 179 | ssize_t getline(char **lineptr, size_t *n, FILE *stream); |
---|
| 180 | ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream); |
---|
| 181 | #endif |
---|
| 182 | |
---|
| 183 | #endif |
---|