2 Copyright © 2010-2013, The AROS Development Team. All rights reserved.
5 C99 function freopen().
7 #include <proto/exec.h>
13 /*****************************************************************************
21 const char * restrict path
,
22 const char * restrict mode
,
23 FILE * restrict stream
27 Opens the file whose name is the string pointed to by path and
28 associates the stream pointed to by stream with it.
31 path - the file to open, NULL to only change the mode of the stream.
32 mode - Mode to open file, see fopen for description of the string.
33 When path is NULL end-of-file and error indicator will be
34 cleared and indication if stream is read and/or write.
35 No change to position in file or no truncation will be
37 stream - the stream to wich the file will be associated.
40 NULL on error or stream. When NULL is returned input stream is
54 ******************************************************************************/
61 if (!(stream
->flags
& __STDCIO_STDIO_DONTCLOSE
))
63 FILE *stream2
= fopen(path
, mode
);
64 int dontfree
= stream
->flags
& __STDCIO_STDIO_DONTFREE
;
66 stream
->flags
|= dontfree
;
67 Remove((struct Node
*)stream2
);
75 if (l2
== 'b') l2
= mode
[2];
76 hasplus
= (l2
== '+');
78 /* Keep some flags; clear the rest */
79 stream
->flags
&= ~(__STDCIO_STDIO_TMP
| __STDCIO_STDIO_DONTCLOSE
| __STDCIO_STDIO_DONTFREE
);
83 stream
->flags
|= __STDCIO_STDIO_RDWR
;
88 stream
->flags
|= __STDCIO_STDIO_READ
;
92 stream
->flags
|= __STDCIO_STDIO_WRITE
;