1 /* Copyright (C) 2009, 2010
2 Free Software Foundation, Inc.
3 Contributed by Janne Blomqvist
5 This file is part of the GNU Fortran runtime library (libgfortran).
7 Libgfortran is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 Libgfortran is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 Under Section 7 of GPL version 3, you are granted additional
18 permissions described in the GCC Runtime Library Exception, version
19 3.1, as published by the Free Software Foundation.
21 You should have received a copy of the GNU General Public License and
22 a copy of the GCC Runtime Library Exception along with this program;
23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 <http://www.gnu.org/licenses/>. */
34 ssize_t (*read) (struct stream *, void *, ssize_t);
35 ssize_t (*write) (struct stream *, const void *, ssize_t);
36 gfc_offset (*seek) (struct stream *, gfc_offset, int);
37 gfc_offset (*tell) (struct stream *);
38 /* Avoid keyword truncate due to AIX namespace collision. */
39 int (*trunc) (struct stream *, gfc_offset);
40 int (*flush) (struct stream *);
41 int (*close) (struct stream *);
45 /* Inline functions for doing file I/O given a stream. */
47 sread (stream * s, void * buf, ssize_t nbyte)
49 return s->read (s, buf, nbyte);
53 swrite (stream * s, const void * buf, ssize_t nbyte)
55 return s->write (s, buf, nbyte);
58 static inline gfc_offset
59 sseek (stream * s, gfc_offset offset, int whence)
61 return s->seek (s, offset, whence);
64 static inline gfc_offset
71 struncate (stream * s, gfc_offset length)
73 return s->trunc (s, length);
89 extern int compare_files (stream *, stream *);
90 internal_proto(compare_files);
92 extern stream *open_external (st_parameter_open *, unit_flags *);
93 internal_proto(open_external);
95 extern stream *open_internal (char *, int, gfc_offset);
96 internal_proto(open_internal);
98 extern stream *open_internal4 (char *, int, gfc_offset);
99 internal_proto(open_internal4);
101 extern char * mem_alloc_w (stream *, int *);
102 internal_proto(mem_alloc_w);
104 extern char * mem_alloc_r (stream *, int *);
105 internal_proto(mem_alloc_r);
107 extern gfc_char4_t * mem_alloc_w4 (stream *, int *);
108 internal_proto(mem_alloc_w4);
110 extern char * mem_alloc_r4 (stream *, int *);
111 internal_proto(mem_alloc_r4);
113 extern stream *input_stream (void);
114 internal_proto(input_stream);
116 extern stream *output_stream (void);
117 internal_proto(output_stream);
119 extern stream *error_stream (void);
120 internal_proto(error_stream);
122 extern int compare_file_filename (gfc_unit *, const char *, int);
123 internal_proto(compare_file_filename);
125 extern gfc_unit *find_file (const char *file, gfc_charlen_type file_len);
126 internal_proto(find_file);
128 extern int delete_file (gfc_unit *);
129 internal_proto(delete_file);
131 extern int file_exists (const char *file, gfc_charlen_type file_len);
132 internal_proto(file_exists);
134 extern GFC_IO_INT file_size (const char *file, gfc_charlen_type file_len);
135 internal_proto(file_size);
137 extern const char *inquire_sequential (const char *, int);
138 internal_proto(inquire_sequential);
140 extern const char *inquire_direct (const char *, int);
141 internal_proto(inquire_direct);
143 extern const char *inquire_formatted (const char *, int);
144 internal_proto(inquire_formatted);
146 extern const char *inquire_unformatted (const char *, int);
147 internal_proto(inquire_unformatted);
149 extern const char *inquire_read (const char *, int);
150 internal_proto(inquire_read);
152 extern const char *inquire_write (const char *, int);
153 internal_proto(inquire_write);
155 extern const char *inquire_readwrite (const char *, int);
156 internal_proto(inquire_readwrite);
158 extern gfc_offset file_length (stream *);
159 internal_proto(file_length);
161 extern int is_seekable (stream *);
162 internal_proto(is_seekable);
164 extern int is_special (stream *);
165 internal_proto(is_special);
167 extern void flush_if_preconnected (stream *);
168 internal_proto(flush_if_preconnected);
170 extern int stream_isatty (stream *);
171 internal_proto(stream_isatty);
174 #ifdef _POSIX_TTY_NAME_MAX
175 #define TTY_NAME_MAX _POSIX_TTY_NAME_MAX
177 /* sysconf(_SC_TTY_NAME_MAX) = 32 which should be enough. */
178 #define TTY_NAME_MAX 32
182 extern int stream_ttyname (stream *, char *, size_t);
183 internal_proto(stream_ttyname);
185 extern int unpack_filename (char *, const char *, int);
186 internal_proto(unpack_filename);