1 /* Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
2 Ported to standalone by Joel Sherrill jsherril@redstone-emh2.army.mil,
3 On-Line Applications Research Corporation.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public
17 License along with the GNU C Library; see the file COPYING.LIB. If not,
18 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
27 #include <bits/stdio_lim.h>
30 #define __DECLARE_FILE_DESCRIPTORS__
34 /* Open FILE with access OFLAG. If OFLAG includes O_CREAT,
35 a third argument is the file protection. */
55 mode
= va_arg(arg
, int);
65 for ( index
=0 ; index
< FOPEN_MAX
; index
++ )
66 if ( !__FD_Table
[ index
].in_use
) {
77 * Initialize the open slot
80 __FD_Table
[ newfd
].in_use
= 1;
81 __FD_Table
[ newfd
].flags
= oflag
;
86 /* Initialization Code for Console I/O */
92 __NONE_init_console_io (argc
, argv
, envp
)
99 for ( index
=0 ; index
< FOPEN_MAX
; index
++ )
100 __FD_Table
[ index
].in_use
= 0;
102 stdin
= fopen( "", "r" );
104 stdout
= fopen( "", "w" );
106 stderr
= fopen( "", "w" );
109 * Line buffer the standard input and output and use no buffering for
113 setvbuf( stdin
, NULL
, _IOLBF
, BUFSIZ
);
114 setvbuf( stdout
, NULL
, _IOLBF
, BUFSIZ
);
115 setvbuf( stderr
, NULL
, _IONBF
, BUFSIZ
);
117 (void) &__NONE_init_console_io
; /* Avoid "defined but not used" warning. */
121 text_set_element (__libc_subinit
, __NONE_init_console_io
);
124 weak_alias (__open
, open
)