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