5 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
8 Desc: ANSI-C header file stdio.h
11 #include <aros/system.h>
12 #include <sys/arosc.h>
14 #include <aros/types/null.h>
15 #include <aros/types/size_t.h>
16 #include <aros/types/off_t.h>
21 FIXME: We are supposed to declare it, without including the file.
22 This is too compiler specific to handle at the moment.
26 /* Need to protect against standard Amiga includes */
31 /* Buffering methods that can be specified with setvbuf() */
32 #define _IOFBF 0 /* Fully buffered. */
33 #define _IOLBF 1 /* Line buffered. */
34 #define _IONBF 2 /* Not buffered. */
39 #define FILENAME_MAX 256 /* Amiga files are 256 */
40 #define FOPEN_MAX 16 /* Must be > 8 */
41 #define TMP_MAX 10240 /* Must be > 10000 */
42 #define L_tmpnam FILENAME_MAX /* Max temporary filename */
44 #if !defined(_ANSI_SOURCE)
45 #define L_ctermid FILENAME_MAX /* Max filename for controlling tty */
48 #define P_tmpdir "T:" /* Default temporary path */
50 #ifndef __typedef_FILE
51 # define __typedef_FILE
53 /* I need a named struct for FILE, so that I can use it in wchar.h> */
54 typedef struct __sFILE
FILE;
56 # define _STDIO_EOF 0x0001L
57 # define _STDIO_ERROR 0x0002L
58 # define _STDIO_WRITE 0x0004L
59 # define _STDIO_READ 0x0008L
60 # define _STDIO_RDWR _STDIO_WRITE | _STDIO_READ
61 # define _STDIO_APPEND 0x0010L
64 #include <aros/types/seek.h> /* SEEK_SET, SEEK_CUR and SEEK_END */
66 #define stdin (__get_arosc_userdata()->acud_stdin)
67 #define stdout (__get_arosc_userdata()->acud_stdout)
68 #define stderr (__get_arosc_userdata()->acud_stderr)
73 int remove(const char *filename
);
74 int rename(const char *from
, const char *to
);
76 char *tmpnam(char *s
);
77 char *tempnam(const char *dir
, const char *pfx
);
78 int fclose(FILE *stream
);
79 int fflush(FILE *stream
);
80 FILE *fopen(const char * restrict filename
, const char * restrict mode
);
81 FILE *freopen(const char * restrict filename
, const char * restrict mode
,
82 FILE * restrict stream
);
83 void setbuf(FILE * restrict stream
, char * restrict buf
);
84 int setvbuf(FILE * restrict stream
, char * restrict buf
, int mode
,
86 int fprintf(FILE * restrict stream
, const char * restrict format
, ...);
87 int fscanf(FILE * restrict stream
, const char * restrict format
, ...);
88 int printf(const char * restrict format
, ...);
89 int scanf(const char * restrict format
, ...);
90 int snprintf(char * restrict s
, size_t n
, const char * restrict format
, ...);
91 int sprintf(char * restrict s
, const char * restrict format
, ...);
92 int sscanf(const char * restrict s
, const char * restrict format
, ...);
93 int vfprintf(FILE * restrict stream
, const char * restrict format
,
95 int vfscanf(FILE * restrict stream
, const char * restrict format
,
97 int vprintf(const char * restrict format
, va_list arg
);
98 int vscanf(const char * restrict format
, va_list arg
);
99 int vsnprintf(char * restrict s
, size_t n
, const char * restrict format
,
101 int vsprintf(char * restrict s
, const char * restrict format
,
103 int vsscanf(const char * restrict s
, const char * restrict format
,
105 int fgetc(FILE *stream
);
106 char *fgets(char * restrict s
, int n
, FILE * restrict stream
);
107 int fputc(int c
, FILE *stream
);
108 int fputs(const char * restrict s
, FILE * restrict stream
);
109 int getc(FILE *stream
);
112 int putc(int c
, FILE *stream
);
114 int puts(const char *s
);
115 int ungetc(int c
, FILE *stream
);
116 size_t fread(void * restrict ptr
, size_t size
, size_t nmemb
,
117 FILE * restrict stream
);
118 size_t fwrite(const void * restrict ptr
, size_t size
, size_t nmemb
,
119 FILE * restrict stream
);
120 int fgetpos(FILE * restrict stream
, fpos_t * restrict pos
);
121 int fseek(FILE *stream
, long int offset
, int whence
);
122 int fseeko(FILE *stream
, off_t offset
, int whence
);
123 int fsetpos(FILE *stream
, const fpos_t *pos
);
124 long int ftell(FILE *stream
);
125 off_t
ftello(FILE *stream
);
126 void rewind(FILE *stream
);
127 void clearerr(FILE *stream
);
128 int feof(FILE *stream
);
129 int ferror(FILE *stream
);
130 void perror(const char *s
);
132 /* Internal functions */
133 int __vcformat (void * data
, int (*outc
)(int, void *),
134 const char * format
, va_list args
);
135 int __vcscan (void * data
, int (*getc
)(void *),
136 int (*ungetc
)(int, void *),
137 const char * format
, va_list args
);
139 /* AROS specific function to synchronise to keep DOS Input and Output in sync
140 * with the C stdin, stdout and stderr
142 void updatestdio(void);
144 #ifndef _STDIO_H_NOMACRO
145 #define putc(c, stream) fputc(c, stream)
146 #define getc(stream) fgetc(stream)
147 #define getchar() getc(stdin)
150 #if !defined(_ANSI_SOURCE)
152 FILE *fdopen (int filedes
, const char *mode
);
155 FILE *popen(const char *, const char *);
157 char *tmpnam(char *);
158 #endif /* !_ANSI_SOURCE */
161 void setlinebuf(FILE *stream
);
164 /* NOTIMPL char *tempnam(const char *, const char *); */
166 /* NOTIMPL char *ctermid(char *); */
167 /* NOTIMPL char *ctermid_r(char *); */
169 /* NOTIMPL void flockfile(FILE *); */
170 /* NOTIMPL int ftrylockfile(FILE *); */
171 /* NOTIMPL void funlockfile(FILE *); */
173 /* NOTIMPL int getc_unlocked(FILE *); */
174 /* NOTIMPL int getchar_unlocked(void); */
175 /* NOTIMPL int putc_unlocked(int, FILE *); */
176 /* NOTIMPL int putchar_unlocked(int); */
178 int getw(FILE *stream
);
179 int putw(int word
, FILE *stream
);
183 #endif /* _STDIO_H_ */