2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
9 #include "__posixc_intbase.h"
17 #include <exec/lists.h>
19 #include <proto/exec.h>
20 #include <proto/dos.h>
21 #include <aros/symbolsets.h>
22 #include <aros/debug.h>
25 int __smode2oflags(const char *mode
)
37 ret
= O_WRONLY
| O_CREAT
| O_TRUNC
;
41 ret
= O_WRONLY
| O_CREAT
| O_APPEND
;
54 else if (*mode
== 't')
56 // Silently ignore 't' (=text).
57 // It's deprecated, but it's still in some sources,
58 // and on other platforms they can compiled without problems.
64 ret
= O_RDWR
| (ret
& ~O_ACCMODE
);
68 if (*mode
== 'b' && !theresb
)
82 int __oflags2sflags(int omode
)
86 switch (omode
& O_ACCMODE
)
89 ret
= __POSIXC_STDIO_READ
;
93 ret
= __POSIXC_STDIO_WRITE
;
97 ret
= __POSIXC_STDIO_READ
| __POSIXC_STDIO_WRITE
;
105 if (omode
& O_APPEND
)
106 ret
|= __POSIXC_STDIO_APPEND
;
111 int __init_stdio(struct PosixCIntBase
*PosixCIntBase
)
113 struct PosixCBase
*PosixCBase
= (struct PosixCBase
*)PosixCIntBase
;
114 NEWLIST(&PosixCIntBase
->stdio_files
);
118 !(PosixCBase
->_stdin
= fdopen(STDIN_FILENO
, NULL
)) ||
119 !(PosixCBase
->_stdout
= fdopen(STDOUT_FILENO
, NULL
)) ||
120 !(PosixCBase
->_stderr
= fdopen(STDERR_FILENO
, NULL
))
123 SetIoErr(ERROR_NO_FREE_STORE
);
130 ADD2OPENLIB(__init_stdio
, 5);