1 /* 2 ** Distributed under the terms of the OpenBeOS License. 3 */ 4 #ifndef _STDIO_H_ 5 #define _STDIO_H_ 6 7 8 #include <sys/types.h> 9 #include <null.h> 10 #include <stdarg.h> 11 12 13 /* Dodge gcc 2.95.3's fixincludes hack stdio_va_list by including this string: 14 * __gnuc_va_list */ 15 16 17 #define BUFSIZ 8192 18 #define _IOFBF 0 /* fully buffered */ 19 #define _IOLBF 1 /* line buffered */ 20 #define _IONBF 2 /* not buffered */ 21 22 /* 23 * FOPEN_MAX is a minimum maximum, and should be the number of descriptors 24 * that the kernel can provide without allocation of a resource that can 25 * fail without the process sleeping. Do not use this for anything 26 */ 27 #define FOPEN_MAX 128 28 #define STREAM_MAX FOPEN_MAX 29 #define FILENAME_MAX 256 30 #define TMP_MAX 32768 31 32 #define L_ctermid 32 33 #define L_cuserid 32 34 #define L_tmpnam 512 35 36 #define P_tmpdir "/tmp/" 37 38 #ifdef EOF 39 # undef EOF 40 #endif 41 #define EOF -1 42 43 #ifndef SEEK_SET 44 # define SEEK_SET 0 45 #endif 46 #ifndef SEEK_CUR 47 # define SEEK_CUR 1 48 #endif 49 #ifndef SEEK_END 50 # define SEEK_END 2 51 #endif 52 53 54 typedef off_t fpos_t; 55 56 #include <stdio_pre.h> 57 58 extern FILE *stdin; 59 extern FILE *stdout; 60 extern FILE *stderr; 61 62 63 #ifdef __cplusplus 64 extern "C" { 65 #endif 66 67 /* file operations */ 68 extern FILE *fopen(const char *name, const char *mode); 69 extern FILE *freopen(const char *name, const char *mode, FILE *stream); 70 extern FILE *fdopen(int fd, const char *mode); 71 extern int fclose(FILE *stream); 72 73 extern int fileno(FILE *stream); 74 extern int fileno_unlocked(FILE *stream); 75 76 extern int ferror(FILE *stream); 77 extern int ferror_unlocked(FILE *stream); 78 extern void clearerr(FILE *stream); 79 extern void clearerr_unlocked(FILE *stream); 80 81 extern int feof(FILE *stream); 82 extern int feof_unlocked(FILE *stream); 83 84 extern void flockfile(FILE *stream); 85 extern void funlockfile(FILE *stream); 86 extern int ftrylockfile(FILE *stream); 87 88 extern int remove(const char *name); 89 extern int rename(const char *from, const char *to); 90 91 /* pipes */ 92 extern FILE *popen(const char *command, const char *mode); 93 extern int pclose(FILE *stream); 94 extern void perror(const char *errorPrefix); 95 96 /* file I/O */ 97 extern int fflush(FILE *stream); 98 extern int fflush_unlocked(FILE *stream); 99 extern int fpurge(FILE *stream); 100 101 extern int fgetpos(FILE *stream, fpos_t *position); 102 extern int fsetpos(FILE *stream, const fpos_t *position); 103 extern int fseek(FILE *stream, long offset, int seekType); 104 extern int fseeko(FILE *stream, off_t offset, int seekType); 105 extern int _fseek(FILE *stream, fpos_t offset, int seekType); 106 extern long ftell(FILE *stream); 107 extern off_t ftello(FILE *stream); 108 extern fpos_t _ftell(FILE *stream); 109 110 extern void rewind(FILE *stream); 111 112 extern void setbuf (FILE *file, char *buff); 113 extern int setvbuf(FILE *file, char *buff, int mode, size_t size); 114 extern int setbuffer(FILE *stream, char *buf, size_t size); 115 extern int setlinebuf(FILE *stream); 116 117 extern size_t fwrite(const void *buffer, size_t size, size_t numItems, FILE *stream); 118 extern size_t fread(void *buffer, size_t size, size_t numItems, FILE *stream); 119 120 extern int putc(int c, FILE *stream); 121 extern int putchar(int c); 122 extern int putc_unlocked(int c, FILE *stream); 123 extern int putchar_unlocked(int c); 124 extern int fputc(int c, FILE *stream); 125 extern int fputc_unlocked(int c, FILE *stream); 126 extern int puts(const char *string); 127 extern int fputs(const char *string, FILE *stream); 128 129 extern int getc(FILE *stream); 130 extern int getc_unlocked(FILE *stream); 131 extern int ungetc(int c, FILE *stream); 132 extern int getchar(void); 133 extern int getchar_unlocked(void); 134 extern int fgetc(FILE *stream); 135 extern char *gets(char *buffer); 136 extern char *fgets(char *string, int stringLength, FILE *stream); 137 138 /* formatted I/O */ 139 extern int printf(char const *format, ...) __PRINTFLIKE(1,2); 140 extern int fprintf(FILE *stream, char const *format, ...) __PRINTFLIKE(2,3); 141 extern int sprintf(char *string, char const *format, ...) __PRINTFLIKE(2,3); 142 extern int snprintf(char *string, size_t size, char const *format, ...) __PRINTFLIKE(3,4); 143 extern int asprintf(char **ret, char const *format, ...) __PRINTFLIKE(2,3); 144 extern int vprintf(char const *format, va_list ap); 145 extern int vfprintf(FILE *stream, char const *format, va_list ap); 146 extern int vsprintf(char *string, char const *format, va_list ap); 147 extern int vsnprintf(char *string, size_t size, char const *format, va_list ap); 148 extern int vasprintf(char **ret, char const *format, va_list ap); 149 150 extern int scanf(char const *format, ...); 151 extern int fscanf(FILE *stream, char const *format, ...); 152 extern int sscanf(char const *str, char const *format, ...); 153 extern int vscanf(char const *format, va_list ap); 154 extern int vsscanf(char const *str, char const *format, va_list ap); 155 extern int vfscanf(FILE *stream, char const *format, va_list ap); 156 157 /* misc */ 158 extern char *ctermid(char *controllingTerminal); 159 extern char *cuserid(char *s); 160 161 /* temporary files */ 162 extern char *tempnam(char *path, char *prefix); 163 extern FILE *tmpfile(void); 164 extern char *tmpnam(char *nameBuffer); 165 extern char *tmpnam_r(char *nameBuffer); 166 167 #include <stdio_post.h> 168 169 #ifdef __cplusplus 170 } 171 #endif 172 173 #endif /* _STDIO_H_ */ 174