]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgfortran/io/unix.h
Update copyright years.
[thirdparty/gcc.git] / libgfortran / io / unix.h
CommitLineData
fbd26352 1/* Copyright (C) 2009-2019 Free Software Foundation, Inc.
6e84b168 2 Contributed by Janne Blomqvist
3
4This file is part of the GNU Fortran runtime library (libgfortran).
5
6Libgfortran is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 3, or (at your option)
9any later version.
10
11Libgfortran is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16Under Section 7 of GPL version 3, you are granted additional
17permissions described in the GCC Runtime Library Exception, version
183.1, as published by the Free Software Foundation.
19
20You should have received a copy of the GNU General Public License and
21a copy of the GCC Runtime Library Exception along with this program;
22see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23<http://www.gnu.org/licenses/>. */
24
6e84b168 25#ifndef GFOR_UNIX_H
26#define GFOR_UNIX_H
27
6f576778 28#include "io.h"
29
292d5498 30struct stream_vtable
6e84b168 31{
292d5498 32 ssize_t (* const read) (struct stream *, void *, ssize_t);
33 ssize_t (* const write) (struct stream *, const void *, ssize_t);
34 gfc_offset (* const seek) (struct stream *, gfc_offset, int);
35 gfc_offset (* const tell) (struct stream *);
36 gfc_offset (* const size) (struct stream *);
6e84b168 37 /* Avoid keyword truncate due to AIX namespace collision. */
292d5498 38 int (* const trunc) (struct stream *, gfc_offset);
39 int (* const flush) (struct stream *);
40 int (* const close) (struct stream *);
155fbd31 41 int (* const markeor) (struct stream *);
6e84b168 42};
43
292d5498 44struct stream
45{
46 const struct stream_vtable *vptr;
47};
4cdcb18d 48
6e84b168 49/* Inline functions for doing file I/O given a stream. */
50static inline ssize_t
25a5ce27 51sread (stream *s, void *buf, ssize_t nbyte)
6e84b168 52{
292d5498 53 return s->vptr->read (s, buf, nbyte);
6e84b168 54}
55
56static inline ssize_t
25a5ce27 57swrite (stream *s, const void *buf, ssize_t nbyte)
6e84b168 58{
292d5498 59 return s->vptr->write (s, buf, nbyte);
6e84b168 60}
61
4dbc0658 62static inline gfc_offset
25a5ce27 63sseek (stream *s, gfc_offset offset, int whence)
6e84b168 64{
292d5498 65 return s->vptr->seek (s, offset, whence);
6e84b168 66}
67
4dbc0658 68static inline gfc_offset
25a5ce27 69stell (stream *s)
6e84b168 70{
292d5498 71 return s->vptr->tell (s);
6e84b168 72}
73
41178014 74static inline gfc_offset
25a5ce27 75ssize (stream *s)
41178014 76{
292d5498 77 return s->vptr->size (s);
41178014 78}
79
6e84b168 80static inline int
25a5ce27 81struncate (stream *s, gfc_offset length)
6e84b168 82{
292d5498 83 return s->vptr->trunc (s, length);
6e84b168 84}
85
86static inline int
25a5ce27 87sflush (stream *s)
6e84b168 88{
292d5498 89 return s->vptr->flush (s);
6e84b168 90}
91
92static inline int
25a5ce27 93sclose (stream *s)
6e84b168 94{
292d5498 95 return s->vptr->close (s);
6e84b168 96}
97
155fbd31 98static inline int
25a5ce27 99smarkeor (stream *s)
155fbd31 100{
101 return s->vptr->markeor (s);
102}
103
6e84b168 104
105extern int compare_files (stream *, stream *);
106internal_proto(compare_files);
107
108extern stream *open_external (st_parameter_open *, unit_flags *);
109internal_proto(open_external);
110
d683dd3a 111extern stream *open_internal (char *, size_t, gfc_offset);
6e84b168 112internal_proto(open_internal);
113
d683dd3a 114extern stream *open_internal4 (char *, size_t, gfc_offset);
e0aaacb7 115internal_proto(open_internal4);
116
d683dd3a 117extern char *mem_alloc_w (stream *, size_t *);
6e84b168 118internal_proto(mem_alloc_w);
119
d683dd3a 120extern char *mem_alloc_r (stream *, size_t *);
a83432d3 121internal_proto(mem_alloc_r);
6e84b168 122
d683dd3a 123extern gfc_char4_t *mem_alloc_w4 (stream *, size_t *);
e0aaacb7 124internal_proto(mem_alloc_w4);
125
d683dd3a 126extern char *mem_alloc_r4 (stream *, size_t *);
e0aaacb7 127internal_proto(mem_alloc_r4);
128
6e84b168 129extern stream *input_stream (void);
130internal_proto(input_stream);
131
132extern stream *output_stream (void);
133internal_proto(output_stream);
134
135extern stream *error_stream (void);
136internal_proto(error_stream);
137
35d5443a 138extern int compare_file_filename (gfc_unit *, const char *, gfc_charlen_type);
6e84b168 139internal_proto(compare_file_filename);
140
141extern gfc_unit *find_file (const char *file, gfc_charlen_type file_len);
142internal_proto(find_file);
143
b3db57e8 144extern int close_share (gfc_unit *);
145internal_proto(close_share);
146
6e84b168 147extern int file_exists (const char *file, gfc_charlen_type file_len);
148internal_proto(file_exists);
149
f4e9c676 150extern GFC_IO_INT file_size (const char *file, gfc_charlen_type file_len);
151internal_proto(file_size);
152
35d5443a 153extern const char *inquire_sequential (const char *, gfc_charlen_type);
6e84b168 154internal_proto(inquire_sequential);
155
35d5443a 156extern const char *inquire_direct (const char *, gfc_charlen_type);
6e84b168 157internal_proto(inquire_direct);
158
35d5443a 159extern const char *inquire_formatted (const char *, gfc_charlen_type);
6e84b168 160internal_proto(inquire_formatted);
161
35d5443a 162extern const char *inquire_unformatted (const char *, gfc_charlen_type);
6e84b168 163internal_proto(inquire_unformatted);
164
35d5443a 165extern const char *inquire_read (const char *, gfc_charlen_type);
6e84b168 166internal_proto(inquire_read);
167
35d5443a 168extern const char *inquire_write (const char *, gfc_charlen_type);
6e84b168 169internal_proto(inquire_write);
170
35d5443a 171extern const char *inquire_readwrite (const char *, gfc_charlen_type);
6e84b168 172internal_proto(inquire_readwrite);
173
6e84b168 174extern void flush_if_preconnected (stream *);
175internal_proto(flush_if_preconnected);
176
6e84b168 177extern int stream_isatty (stream *);
178internal_proto(stream_isatty);
179
57f34837 180#ifndef TTY_NAME_MAX
181#ifdef _POSIX_TTY_NAME_MAX
182#define TTY_NAME_MAX _POSIX_TTY_NAME_MAX
183#else
184/* sysconf(_SC_TTY_NAME_MAX) = 32 which should be enough. */
185#define TTY_NAME_MAX 32
186#endif
187#endif
188
189extern int stream_ttyname (stream *, char *, size_t);
6e84b168 190internal_proto(stream_ttyname);
191
6e84b168 192#endif