1 /* Implementation of the FGET, FGETC, FPUT and FPUTC intrinsics.
2 Copyright (C) 2005 Free Software Foundation, Inc.
3 Contributed by François-Xavier Coudert <coudert@clipper.ens.fr>
5 This file is part of the GNU Fortran 95 runtime library (libgfortran).
7 Libgfortran is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 In addition to the permissions in the GNU General Public License, the
13 Free Software Foundation gives you unlimited permission to link the
14 compiled version of this file into combinations with other programs,
15 and to distribute those combinations without any restriction coming
16 from the use of this file. (The General Public License restrictions
17 do apply in other respects; for example, they cover modification of
18 the file, and distribution when not linked into a combine
21 Libgfortran is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 GNU General Public License for more details.
26 You should have received a copy of the GNU General Public
27 License along with libgfortran; see the file COPYING. If not,
28 write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
29 Boston, MA 02110-1301, USA. */
32 #include "libgfortran.h"
38 static const int five
= 5;
39 static const int six
= 6;
41 extern int PREFIX(fgetc
) (const int *, char *, gfc_charlen_type
);
42 export_proto_np(PREFIX(fgetc
));
45 PREFIX(fgetc
) (const int * unit
, char * c
, gfc_charlen_type c_len
)
49 gfc_unit
* u
= find_unit (*unit
);
55 memset (c
, ' ', c_len
);
56 ret
= sread (u
->s
, c
, &s
);
69 #define FGETC_SUB(kind) \
70 extern void fgetc_i ## kind ## _sub \
71 (const int *, char *, GFC_INTEGER_ ## kind *, gfc_charlen_type); \
72 export_proto(fgetc_i ## kind ## _sub); \
73 void fgetc_i ## kind ## _sub \
74 (const int * unit, char * c, GFC_INTEGER_ ## kind * st, gfc_charlen_type c_len) \
76 *st = PREFIX(fgetc) (unit, c, c_len); \
78 PREFIX(fgetc) (unit, c, c_len); }
86 extern int PREFIX(fget
) (char *, gfc_charlen_type
);
87 export_proto_np(PREFIX(fget
));
90 PREFIX(fget
) (char * c
, gfc_charlen_type c_len
)
92 return PREFIX(fgetc
) (&five
, c
, c_len
);
96 #define FGET_SUB(kind) \
97 extern void fget_i ## kind ## _sub \
98 (char *, GFC_INTEGER_ ## kind *, gfc_charlen_type); \
99 export_proto(fget_i ## kind ## _sub); \
100 void fget_i ## kind ## _sub \
101 (char * c, GFC_INTEGER_ ## kind * st, gfc_charlen_type c_len) \
103 *st = PREFIX(fgetc) (&five, c, c_len); \
105 PREFIX(fgetc) (&five, c, c_len); }
114 extern int PREFIX(fputc
) (const int *, char *, gfc_charlen_type
);
115 export_proto_np(PREFIX(fputc
));
118 PREFIX(fputc
) (const int * unit
, char * c
,
119 gfc_charlen_type c_len
__attribute__((unused
)))
123 gfc_unit
* u
= find_unit (*unit
);
129 ret
= swrite (u
->s
, c
, &s
);
135 #define FPUTC_SUB(kind) \
136 extern void fputc_i ## kind ## _sub \
137 (const int *, char *, GFC_INTEGER_ ## kind *, gfc_charlen_type); \
138 export_proto(fputc_i ## kind ## _sub); \
139 void fputc_i ## kind ## _sub \
140 (const int * unit, char * c, GFC_INTEGER_ ## kind * st, gfc_charlen_type c_len) \
142 *st = PREFIX(fputc) (unit, c, c_len); \
144 PREFIX(fputc) (unit, c, c_len); }
152 extern int PREFIX(fput
) (char *, gfc_charlen_type
);
153 export_proto_np(PREFIX(fput
));
156 PREFIX(fput
) (char * c
, gfc_charlen_type c_len
)
158 return PREFIX(fputc
) (&six
, c
, c_len
);
162 #define FPUT_SUB(kind) \
163 extern void fput_i ## kind ## _sub \
164 (char *, GFC_INTEGER_ ## kind *, gfc_charlen_type); \
165 export_proto(fput_i ## kind ## _sub); \
166 void fput_i ## kind ## _sub \
167 (char * c, GFC_INTEGER_ ## kind * st, gfc_charlen_type c_len) \
169 *st = PREFIX(fputc) (&six, c, c_len); \
171 PREFIX(fputc) (&six, c, c_len); }