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 size_t fwrite(const void *buffer, size_t size, size_t numItems, FILE *stream); 108 extern size_t fread(void *buffer, size_t size, size_t numItems, FILE *stream); 109 110 extern int putc(int c, FILE *stream); 111 extern int putchar(int c); 112 extern int putc_unlocked(int c, FILE *stream); 113 extern int putchar_unlocked(int c); 114 extern int fputc(int c, FILE *stream); 115 extern int fputc_unlocked(int c, FILE *stream); 116 extern int puts(const char *string); 117 extern int fputs(const char *string, FILE *stream); 118 119 extern int getc(FILE *stream); 120 extern int getc_unlocked(FILE *stream); 121 extern int ungetc(int c, FILE *stream); 122 extern int getchar(void); 123 extern int getchar_unlocked(void); 124 extern int fgetc(FILE *stream); 125 extern char *gets(char *buffer); 126 extern char *fgets(char *string, int stringLength, FILE *stream); 127 128 extern char *fgetln(FILE *stream, size_t *); 129 130 /* formatted I/O */ 131 extern int printf(char const *format, ...) __PRINTFLIKE(1,2); 132 extern int fprintf(FILE *stream, char const *format, ...) __PRINTFLIKE(2,3); 133 extern int sprintf(char *string, char const *format, ...) __PRINTFLIKE(2,3); 134 extern int snprintf(char *string, size_t size, char const *format, ...) __PRINTFLIKE(3,4); 135 extern int asprintf(char **ret, char const *format, ...) __PRINTFLIKE(2,3); 136 extern int vprintf(char const *format, va_list ap); 137 extern int vfprintf(FILE *stream, char const *format, va_list ap); 138 extern int vsprintf(char *string, char const *format, va_list ap); 139 extern int vsnprintf(char *string, size_t size, char const *format, va_list ap); 140 extern int vasprintf(char **ret, char const *format, va_list ap); 141 142 extern int scanf(char const *format, ...); 143 extern int fscanf(FILE *stream, char const *format, ...); 144 extern int sscanf(char const *str, char const *format, ...); 145 extern int vscanf(char const *format, va_list ap); 146 extern int vsscanf(char const *str, char const *format, va_list ap); 147 extern int vfscanf(FILE *stream, char const *format, va_list ap); 148 149 /* misc */ 150 extern char *ctermid(char *controllingTerminal); 151 152 /* temporary files */ 153 extern char *tempnam(char *path, char *prefix); 154 extern FILE *tmpfile(void); 155 extern char *tmpnam(char *nameBuffer); 156 extern char *tmpnam_r(char *nameBuffer); 157 158 #include <stdio_post.h> 159 160 #ifdef __cplusplus 161 } 162 #endif 163 164 #endif /* _STDIO_H_ */ 165