1 /**
2  * D header file for POSIX.
3  *
4  * Copyright: Public Domain
5  * License:   Public Domain
6  * Authors:   Sean Kelly
7  * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
8  */
9 module tango.stdc.posix.stdio;
10 
11 private import tango.stdc.posix.config;
12 public import tango.stdc.stdio;
13 public import tango.stdc.posix.sys.types; // for off_t
14 
15 extern (C):
16 
17 //
18 // Required (defined in tango.stdc.stdio)
19 //
20 /*
21 BUFSIZ
22 _IOFBF
23 _IOLBF
24 _IONBF
25 L_tmpnam
26 SEEK_CUR
27 SEEK_END
28 SEEK_SET
29 FILENAME_MAX
30 FOPEN_MAX
31 TMP_MAX
32 EOF
33 NULL
34 stderr
35 stdin
36 stdout
37 FILE
38 fpos_t
39 size_t
40 
41 void   clearerr(FILE*);
42 int    fclose(FILE*);
43 int    feof(FILE*);
44 int    ferror(FILE*);
45 int    fflush(FILE*);
46 int    fgetc(FILE*);
47 int    fgetpos(FILE*, fpos_t *);
48 char*  fgets(char*, int, FILE*);
49 FILE*  fopen(in char*, in char*);
50 int    fprintf(FILE*, in char*, ...);
51 int    fputc(int, FILE*);
52 int    fputs(in char*, FILE*);
53 size_t fread(void *, size_t, size_t, FILE*);
54 FILE*  freopen(in char*, in char*, FILE*);
55 int    fscanf(FILE*, in char*, ...);
56 int    fseek(FILE*, c_long, int);
57 int    fsetpos(FILE*, in fpos_t*);
58 c_long ftell(FILE*);
59 size_t fwrite(in void *, size_t, size_t, FILE*);
60 int    getc(FILE*);
61 int    getchar();
62 char*  gets(char*);
63 void   perror(in char*);
64 int    printf(in char*, ...);
65 int    putc(int, FILE*);
66 int    putchar(int);
67 int    puts(in char*);
68 int    remove(in char*);
69 int    rename(in char*, in char*);
70 void   rewind(FILE*);
71 int    scanf(in char*, ...);
72 void   setbuf(FILE*, char*);
73 int    setvbuf(FILE*, char*, int, size_t);
74 int    snprintf(char*, size_t, in char*, ...);
75 int    sprintf(char*, in char*, ...);
76 int    sscanf(in char*, in char*, int ...);
77 FILE*  tmpfile();
78 char*  tmpnam(char*);
79 int    ungetc(int, FILE*);
80 int    vfprintf(FILE*, in char*, va_list);
81 int    vfscanf(FILE*, in char*, va_list);
82 int    vprintf(in char*, va_list);
83 int    vscanf(in char*, va_list);
84 int    vsnprintf(char*, size_t, in char*, va_list);
85 int    vsprintf(char*, in char*, va_list);
86 int    vsscanf(in char*, in char*, va_list arg);
87 */
88 
89 version( linux )
90 {
91     static if( __USE_LARGEFILE64 )
92     {
93         int   fgetpos64(FILE*, fpos_t *);
94         alias fgetpos64 fgetpos;
95 
96         FILE* fopen64(in char*, in char*);
97         alias fopen64 fopen;
98 
99         FILE* freopen64(in char*, in char*, FILE*);
100         alias freopen64 freopen;
101 
102         int   fseek64(FILE*, c_long, int);
103         alias fseek64 fseek;
104 
105         int   fsetpos64(FILE*, in fpos_t*);
106         alias fsetpos64 fsetpos;
107 
108         FILE* tmpfile64();
109         alias tmpfile64 tmpfile;
110     }
111     else
112     {
113         int   fgetpos(FILE*, fpos_t *);
114         FILE* fopen(in char*, in char*);
115         FILE* freopen(in char*, in char*, FILE*);
116         int   fseek(FILE*, c_long, int);
117         int   fsetpos(FILE*, in fpos_t*);
118         FILE* tmpfile();
119     }
120 }
121 else version( solaris )
122 {
123     static if( __USE_LARGEFILE64 )
124     {
125         int   fgetpos64(FILE*, fpos_t *);
126         alias fgetpos64 fgetpos;
127 
128         FILE* fopen64(in char*, in char*);
129         alias fopen64 fopen;
130 
131         FILE* freopen64(in char*, in char*, FILE*);
132         alias freopen64 freopen;
133 
134         int   fseek64(FILE*, c_long, int);
135         alias fseek64 fseek;
136 
137         int   fsetpos64(FILE*, in fpos_t*);
138         alias fsetpos64 fsetpos;
139 
140         FILE* tmpfile64();
141         alias tmpfile64 tmpfile;
142     }
143     else
144     {
145         int   fgetpos(FILE*, fpos_t *);
146         FILE* fopen(in char*, in char*);
147         FILE* freopen(in char*, in char*, FILE*);
148         int   fseek(FILE*, c_long, int);
149         int   fsetpos(FILE*, in fpos_t*);
150         FILE* tmpfile();
151     }
152 }
153 
154 //
155 // C Extension (CX)
156 //
157 /*
158 L_ctermid
159 
160 char*  ctermid(char*);
161 FILE*  fdopen(int, in char*);
162 int    fileno(FILE*);
163 int    fseeko(FILE*, off_t, int);
164 off_t  ftello(FILE*);
165 char*  gets(char*);
166 FILE*  popen(in char*, in char*);
167 */
168 
169 version( linux )
170 {
171     const L_ctermid = 9;
172 }
173 
174 static if( __USE_LARGEFILE64 )
175 {
176     int   fseeko64(FILE*, off_t, int);
177     alias fseeko64 fseeko;
178 }
179 else
180 {
181     int   fseeko(FILE*, off_t, int);
182 }
183 
184 static if( __USE_LARGEFILE64 ){
185     off_t ftello64(FILE*);
186     alias ftello64 ftello;
187 } else {
188     off_t ftello(FILE*);
189 }
190 
191 char*  ctermid(char*);
192 FILE*  fdopen(int, in char*);
193 int    fileno(FILE*);
194 //int    fseeko(FILE*, off_t, int);
195 //off_t  ftello(FILE*);
196 char*  gets(char*);
197 FILE*  popen(in char*, in char*);
198 
199 //
200 // Thread-Safe Functions (TSF)
201 //
202 /*
203 void   flockfile(FILE*);
204 int    ftrylockfile(FILE*);
205 void   funlockfile(FILE*);
206 int    getc_unlocked(FILE*);
207 int    getchar_unlocked();
208 int    putc_unlocked(int, FILE*);
209 int    putchar_unlocked(int);
210 */
211 
212 version( linux )
213 {
214     void   flockfile(FILE*);
215     int    ftrylockfile(FILE*);
216     void   funlockfile(FILE*);
217     int    getc_unlocked(FILE*);
218     int    getchar_unlocked();
219     int    putc_unlocked(int, FILE*);
220     int    putchar_unlocked(int);
221 }
222 else version( solaris )
223 {
224     void   flockfile(FILE*);
225     int    ftrylockfile(FILE*);
226     void   funlockfile(FILE*);
227     int    getc_unlocked(FILE*);
228     int    getchar_unlocked();
229     int    putc_unlocked(int, FILE*);
230     int    putchar_unlocked(int);
231 }
232 
233 //
234 // XOpen (XSI)
235 //
236 /*
237 P_tmpdir
238 va_list (defined in tango.stdc.stdarg)
239 
240 char*  tempnam(in char*, in char*);
241 */
242 
243 version( linux )
244 {
245     const P_tmpdir  = "/tmp";
246 
247     char*  tempnam(in char*, in char*);
248 }
249 else version( solaris )
250 {
251     const P_tmpdir  = "/tmp";
252 
253     char*  tempnam(in char*, in char*);
254 }