~ubuntu-branches/ubuntu/utopic/gettext/utopic

« back to all changes in this revision

Viewing changes to gettext-tools/libgettextpo/stdio.in.h

  • Committer: Colin Watson
  • Date: 2010-08-01 21:36:08 UTC
  • mfrom: (2.1.10 sid)
  • Revision ID: cjwatson@canonical.com-20100801213608-yy7vkm8lpatep3ci
merge from Debian 0.18.1.1-1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* A GNU-like <stdio.h>.
2
2
 
3
 
   Copyright (C) 2004, 2007 Free Software Foundation, Inc.
 
3
   Copyright (C) 2004, 2007-2010 Free Software Foundation, Inc.
4
4
 
5
5
   This program is free software; you can redistribute it and/or modify
6
6
   it under the terms of the GNU General Public License as published by
7
 
   the Free Software Foundation; either version 2, or (at your option)
 
7
   the Free Software Foundation; either version 3, or (at your option)
8
8
   any later version.
9
9
 
10
10
   This program is distributed in the hope that it will be useful,
16
16
   along with this program; if not, write to the Free Software Foundation,
17
17
   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
18
18
 
 
19
#if __GNUC__ >= 3
 
20
@PRAGMA_SYSTEM_HEADER@
 
21
#endif
 
22
 
19
23
#if defined __need_FILE || defined __need___FILE
20
24
/* Special invocation convention inside glibc header files.  */
21
25
 
32
36
#ifndef _GL_STDIO_H
33
37
#define _GL_STDIO_H
34
38
 
 
39
/* Get va_list.  Needed on many systems, including glibc 2.8.  */
35
40
#include <stdarg.h>
 
41
 
36
42
#include <stddef.h>
37
43
 
38
 
#if (@GNULIB_FSEEKO@ && @REPLACE_FSEEKO@) \
39
 
  || (@GNULIB_FTELLO@ && @REPLACE_FTELLO@) \
40
 
  || (@GNULIB_GETDELIM@ && !@HAVE_DECL_GETDELIM@) \
41
 
  || (@GNULIB_GETLINE@ && (!@HAVE_DECL_GETLINE@ || @REPLACE_GETLINE@))
42
 
/* Get off_t and ssize_t.  */
43
 
# include <sys/types.h>
44
 
#endif
 
44
/* Get off_t and ssize_t.  Needed on many systems, including glibc 2.8.  */
 
45
#include <sys/types.h>
45
46
 
46
47
#ifndef __attribute__
47
 
/* This feature is available in gcc versions 2.5 and later.  */
48
 
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
49
 
#  define __attribute__(Spec) /* empty */
50
 
# endif
51
 
/* The __-protected variants of `format' and `printf' attributes
52
 
   are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
 
48
/* The __attribute__ feature is available in gcc versions 2.5 and later.
 
49
   The __-protected variants of the attributes 'format' and 'printf' are
 
50
   accepted by gcc versions 2.6.4 (effectively 2.7) and later.
 
51
   We enable __attribute__ only if these are supported too, because
 
52
   gnulib and libintl do '#define printf __printf__' when they override
 
53
   the 'printf' function.  */
53
54
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
54
 
#  define __format__ format
55
 
#  define __printf__ printf
56
 
# endif
57
 
#endif
58
 
 
59
 
 
60
 
/* The definition of GL_LINK_WARNING is copied here.  */
61
 
 
62
 
 
63
 
#ifdef __cplusplus
64
 
extern "C" {
65
 
#endif
66
 
 
67
 
 
68
 
#if @GNULIB_FPRINTF_POSIX@
69
 
# if @REPLACE_FPRINTF@
70
 
#  define fprintf rpl_fprintf
71
 
extern int fprintf (FILE *fp, const char *format, ...)
72
 
       __attribute__ ((__format__ (__printf__, 2, 3)));
73
 
# endif
74
 
#elif defined GNULIB_POSIXCHECK
75
 
# undef fprintf
76
 
# define fprintf \
77
 
    (GL_LINK_WARNING ("fprintf is not always POSIX compliant - " \
78
 
                      "use gnulib module fprintf-posix for portable " \
79
 
                      "POSIX compliance"), \
80
 
     fprintf)
81
 
#endif
82
 
 
83
 
#if @GNULIB_VFPRINTF_POSIX@
84
 
# if @REPLACE_VFPRINTF@
85
 
#  define vfprintf rpl_vfprintf
86
 
extern int vfprintf (FILE *fp, const char *format, va_list args)
87
 
       __attribute__ ((__format__ (__printf__, 2, 0)));
88
 
# endif
89
 
#elif defined GNULIB_POSIXCHECK
90
 
# undef vfprintf
91
 
# define vfprintf(s,f,a) \
92
 
    (GL_LINK_WARNING ("vfprintf is not always POSIX compliant - " \
93
 
                      "use gnulib module vfprintf-posix for portable " \
94
 
                      "POSIX compliance"), \
95
 
     vfprintf (s, f, a))
96
 
#endif
97
 
 
98
 
#if @GNULIB_PRINTF_POSIX@
99
 
# if @REPLACE_PRINTF@
100
 
/* Don't break __attribute__((format(printf,M,N))).  */
101
 
#  define printf __printf__
102
 
extern int printf (const char *format, ...)
103
 
       __attribute__ ((__format__ (__printf__, 1, 2)));
104
 
# endif
105
 
#elif defined GNULIB_POSIXCHECK
106
 
# undef printf
107
 
# define printf \
108
 
    (GL_LINK_WARNING ("printf is not always POSIX compliant - " \
109
 
                      "use gnulib module printf-posix for portable " \
110
 
                      "POSIX compliance"), \
111
 
     printf)
112
 
/* Don't break __attribute__((format(printf,M,N))).  */
113
 
# define format(kind,m,n) format (__##kind##__, m, n)
114
 
# define __format__(kind,m,n) __format__ (__##kind##__, m, n)
115
 
# define ____printf____ __printf__
116
 
# define ____scanf____ __scanf__
117
 
# define ____strftime____ __strftime__
118
 
# define ____strfmon____ __strfmon__
119
 
#endif
120
 
 
121
 
#if @GNULIB_VPRINTF_POSIX@
122
 
# if @REPLACE_VPRINTF@
123
 
#  define vprintf rpl_vprintf
124
 
extern int vprintf (const char *format, va_list args)
125
 
       __attribute__ ((__format__ (__printf__, 1, 0)));
126
 
# endif
127
 
#elif defined GNULIB_POSIXCHECK
128
 
# undef vprintf
129
 
# define vprintf(f,a) \
130
 
    (GL_LINK_WARNING ("vprintf is not always POSIX compliant - " \
131
 
                      "use gnulib module vprintf-posix for portable " \
132
 
                      "POSIX compliance"), \
133
 
     vprintf (f, a))
134
 
#endif
135
 
 
136
 
#if @GNULIB_SNPRINTF@
137
 
# if @REPLACE_SNPRINTF@
138
 
#  define snprintf rpl_snprintf
139
 
# endif
140
 
# if @REPLACE_SNPRINTF@ || !@HAVE_DECL_SNPRINTF@
141
 
extern int snprintf (char *str, size_t size, const char *format, ...)
142
 
       __attribute__ ((__format__ (__printf__, 3, 4)));
143
 
# endif
144
 
#elif defined GNULIB_POSIXCHECK
145
 
# undef snprintf
146
 
# define snprintf \
147
 
    (GL_LINK_WARNING ("snprintf is unportable - " \
148
 
                      "use gnulib module snprintf for portability"), \
149
 
     snprintf)
150
 
#endif
151
 
 
152
 
#if @GNULIB_VSNPRINTF@
153
 
# if @REPLACE_VSNPRINTF@
154
 
#  define vsnprintf rpl_vsnprintf
155
 
# endif
156
 
# if @REPLACE_VSNPRINTF@ || !@HAVE_DECL_VSNPRINTF@
157
 
extern int vsnprintf (char *str, size_t size, const char *format, va_list args)
158
 
       __attribute__ ((__format__ (__printf__, 3, 0)));
159
 
# endif
160
 
#elif defined GNULIB_POSIXCHECK
161
 
# undef vsnprintf
162
 
# define vsnprintf(b,s,f,a) \
163
 
    (GL_LINK_WARNING ("vsnprintf is unportable - " \
164
 
                      "use gnulib module vsnprintf for portability"), \
165
 
     vsnprintf (b, s, f, a))
166
 
#endif
167
 
 
168
 
#if @GNULIB_SPRINTF_POSIX@
169
 
# if @REPLACE_SPRINTF@
170
 
#  define sprintf rpl_sprintf
171
 
extern int sprintf (char *str, const char *format, ...)
172
 
       __attribute__ ((__format__ (__printf__, 2, 3)));
173
 
# endif
174
 
#elif defined GNULIB_POSIXCHECK
175
 
# undef sprintf
176
 
# define sprintf \
177
 
    (GL_LINK_WARNING ("sprintf is not always POSIX compliant - " \
178
 
                      "use gnulib module sprintf-posix for portable " \
179
 
                      "POSIX compliance"), \
180
 
     sprintf)
181
 
#endif
182
 
 
183
 
#if @GNULIB_VSPRINTF_POSIX@
184
 
# if @REPLACE_VSPRINTF@
185
 
#  define vsprintf rpl_vsprintf
186
 
extern int vsprintf (char *str, const char *format, va_list args)
187
 
       __attribute__ ((__format__ (__printf__, 2, 0)));
188
 
# endif
189
 
#elif defined GNULIB_POSIXCHECK
190
 
# undef vsprintf
191
 
# define vsprintf(b,f,a) \
192
 
    (GL_LINK_WARNING ("vsprintf is not always POSIX compliant - " \
193
 
                      "use gnulib module vsprintf-posix for portable " \
194
 
                      "POSIX compliance"), \
195
 
     vsprintf (b, f, a))
196
 
#endif
197
 
 
198
 
#if @GNULIB_VASPRINTF@
199
 
# if @REPLACE_VASPRINTF@
200
 
#  define asprintf rpl_asprintf
201
 
#  define vasprintf rpl_vasprintf
202
 
# endif
203
 
# if @REPLACE_VASPRINTF@ || !@HAVE_VASPRINTF@
204
 
  /* Write formatted output to a string dynamically allocated with malloc().
205
 
     If the memory allocation succeeds, store the address of the string in
206
 
     *RESULT and return the number of resulting bytes, excluding the trailing
207
 
     NUL.  Upon memory allocation error, or some other error, return -1.  */
208
 
  extern int asprintf (char **result, const char *format, ...)
209
 
    __attribute__ ((__format__ (__printf__, 2, 3)));
210
 
  extern int vasprintf (char **result, const char *format, va_list args)
211
 
    __attribute__ ((__format__ (__printf__, 2, 0)));
212
 
# endif
213
 
#endif
 
55
#  define __attribute__(Spec)   /* empty */
 
56
# endif
 
57
#endif
 
58
 
 
59
 
 
60
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
61
 
 
62
/* The definition of _GL_ARG_NONNULL is copied here.  */
 
63
 
 
64
/* The definition of _GL_WARN_ON_USE is copied here.  */
 
65
 
 
66
/* Macros for stringification.  */
 
67
#define _GL_STDIO_STRINGIZE(token) #token
 
68
#define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token)
 
69
 
 
70
 
 
71
#if @GNULIB_DPRINTF@
 
72
# if @REPLACE_DPRINTF@
 
73
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
74
#   define dprintf rpl_dprintf
 
75
#  endif
 
76
_GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *format, ...)
 
77
                                __attribute__ ((__format__ (__printf__, 2, 3)))
 
78
                                _GL_ARG_NONNULL ((2)));
 
79
_GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *format, ...));
 
80
# else
 
81
#  if !@HAVE_DPRINTF@
 
82
_GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *format, ...)
 
83
                                __attribute__ ((__format__ (__printf__, 2, 3)))
 
84
                                _GL_ARG_NONNULL ((2)));
 
85
#  endif
 
86
_GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *format, ...));
 
87
# endif
 
88
_GL_CXXALIASWARN (dprintf);
 
89
#elif defined GNULIB_POSIXCHECK
 
90
# undef dprintf
 
91
# if HAVE_RAW_DECL_DPRINTF
 
92
_GL_WARN_ON_USE (dprintf, "dprintf is unportable - "
 
93
                 "use gnulib module dprintf for portability");
 
94
# endif
 
95
#endif
 
96
 
 
97
#if @GNULIB_FCLOSE@
 
98
/* Close STREAM and its underlying file descriptor.  */
 
99
# if @REPLACE_FCLOSE@
 
100
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
101
#   define fclose rpl_fclose
 
102
#  endif
 
103
_GL_FUNCDECL_RPL (fclose, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
 
104
_GL_CXXALIAS_RPL (fclose, int, (FILE *stream));
 
105
# else
 
106
_GL_CXXALIAS_SYS (fclose, int, (FILE *stream));
 
107
# endif
 
108
_GL_CXXALIASWARN (fclose);
 
109
#elif defined GNULIB_POSIXCHECK
 
110
# undef fclose
 
111
/* Assume fclose is always declared.  */
 
112
_GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - "
 
113
                 "use gnulib module fclose for portable POSIX compliance");
 
114
#endif
 
115
 
 
116
#if @GNULIB_FFLUSH@
 
117
/* Flush all pending data on STREAM according to POSIX rules.  Both
 
118
   output and seekable input streams are supported.
 
119
   Note! LOSS OF DATA can occur if fflush is applied on an input stream
 
120
   that is _not_seekable_ or on an update stream that is _not_seekable_
 
121
   and in which the most recent operation was input.  Seekability can
 
122
   be tested with lseek(fileno(fp),0,SEEK_CUR).  */
 
123
# if @REPLACE_FFLUSH@
 
124
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
125
#   define fflush rpl_fflush
 
126
#  endif
 
127
_GL_FUNCDECL_RPL (fflush, int, (FILE *gl_stream));
 
128
_GL_CXXALIAS_RPL (fflush, int, (FILE *gl_stream));
 
129
# else
 
130
_GL_CXXALIAS_SYS (fflush, int, (FILE *gl_stream));
 
131
# endif
 
132
_GL_CXXALIASWARN (fflush);
 
133
#elif defined GNULIB_POSIXCHECK
 
134
# undef fflush
 
135
/* Assume fflush is always declared.  */
 
136
_GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - "
 
137
                 "use gnulib module fflush for portable POSIX compliance");
 
138
#endif
 
139
 
 
140
/* It is very rare that the developer ever has full control of stdin,
 
141
   so any use of gets warrants an unconditional warning.  Assume it is
 
142
   always declared, since it is required by C89.  */
 
143
#undef gets
 
144
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
214
145
 
215
146
#if @GNULIB_FOPEN@
216
147
# if @REPLACE_FOPEN@
217
 
#  define fopen rpl_fopen
218
 
extern FILE * fopen (const char *filename, const char *mode);
 
148
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
149
#   undef fopen
 
150
#   define fopen rpl_fopen
 
151
#  endif
 
152
_GL_FUNCDECL_RPL (fopen, FILE *, (const char *filename, const char *mode)
 
153
                                 _GL_ARG_NONNULL ((1, 2)));
 
154
_GL_CXXALIAS_RPL (fopen, FILE *, (const char *filename, const char *mode));
 
155
# else
 
156
_GL_CXXALIAS_SYS (fopen, FILE *, (const char *filename, const char *mode));
219
157
# endif
 
158
_GL_CXXALIASWARN (fopen);
220
159
#elif defined GNULIB_POSIXCHECK
221
160
# undef fopen
222
 
# define fopen(f,m) \
223
 
   (GL_LINK_WARNING ("fopen on Win32 platforms is not POSIX compatible - " \
224
 
                     "use gnulib module fopen for portability"), \
225
 
    fopen (f, m))
 
161
/* Assume fopen is always declared.  */
 
162
_GL_WARN_ON_USE (fopen, "fopen on Win32 platforms is not POSIX compatible - "
 
163
                 "use gnulib module fopen for portability");
 
164
#endif
 
165
 
 
166
#if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@
 
167
# if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \
 
168
     || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@)
 
169
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
170
#   define fprintf rpl_fprintf
 
171
#  endif
 
172
#  define GNULIB_overrides_fprintf 1
 
173
_GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...)
 
174
                                __attribute__ ((__format__ (__printf__, 2, 3)))
 
175
                                _GL_ARG_NONNULL ((1, 2)));
 
176
_GL_CXXALIAS_RPL (fprintf, int, (FILE *fp, const char *format, ...));
 
177
# else
 
178
_GL_CXXALIAS_SYS (fprintf, int, (FILE *fp, const char *format, ...));
 
179
# endif
 
180
_GL_CXXALIASWARN (fprintf);
 
181
#endif
 
182
#if !@GNULIB_FPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
 
183
# if !GNULIB_overrides_fprintf
 
184
#  undef fprintf
 
185
# endif
 
186
/* Assume fprintf is always declared.  */
 
187
_GL_WARN_ON_USE (fprintf, "fprintf is not always POSIX compliant - "
 
188
                 "use gnulib module fprintf-posix for portable "
 
189
                 "POSIX compliance");
 
190
#endif
 
191
 
 
192
#if @GNULIB_FPURGE@
 
193
/* Discard all pending buffered I/O data on STREAM.
 
194
   STREAM must not be wide-character oriented.
 
195
   When discarding pending output, the file position is set back to where it
 
196
   was before the write calls.  When discarding pending input, the file
 
197
   position is advanced to match the end of the previously read input.
 
198
   Return 0 if successful.  Upon error, return -1 and set errno.  */
 
199
# if @REPLACE_FPURGE@
 
200
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
201
#   define fpurge rpl_fpurge
 
202
#  endif
 
203
_GL_FUNCDECL_RPL (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1)));
 
204
_GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream));
 
205
# else
 
206
#  if !@HAVE_DECL_FPURGE@
 
207
_GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream) _GL_ARG_NONNULL ((1)));
 
208
#  endif
 
209
_GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream));
 
210
# endif
 
211
_GL_CXXALIASWARN (fpurge);
 
212
#elif defined GNULIB_POSIXCHECK
 
213
# undef fpurge
 
214
# if HAVE_RAW_DECL_FPURGE
 
215
_GL_WARN_ON_USE (fpurge, "fpurge is not always present - "
 
216
                 "use gnulib module fpurge for portability");
 
217
# endif
 
218
#endif
 
219
 
 
220
#if @GNULIB_FPUTC@
 
221
# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
 
222
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
223
#   undef fputc
 
224
#   define fputc rpl_fputc
 
225
#  endif
 
226
_GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2)));
 
227
_GL_CXXALIAS_RPL (fputc, int, (int c, FILE *stream));
 
228
# else
 
229
_GL_CXXALIAS_SYS (fputc, int, (int c, FILE *stream));
 
230
# endif
 
231
_GL_CXXALIASWARN (fputc);
 
232
#endif
 
233
 
 
234
#if @GNULIB_FPUTS@
 
235
# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
 
236
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
237
#   undef fputs
 
238
#   define fputs rpl_fputs
 
239
#  endif
 
240
_GL_FUNCDECL_RPL (fputs, int, (const char *string, FILE *stream)
 
241
                              _GL_ARG_NONNULL ((1, 2)));
 
242
_GL_CXXALIAS_RPL (fputs, int, (const char *string, FILE *stream));
 
243
# else
 
244
_GL_CXXALIAS_SYS (fputs, int, (const char *string, FILE *stream));
 
245
# endif
 
246
_GL_CXXALIASWARN (fputs);
226
247
#endif
227
248
 
228
249
#if @GNULIB_FREOPEN@
229
250
# if @REPLACE_FREOPEN@
230
 
#  define freopen rpl_freopen
231
 
extern FILE * freopen (const char *filename, const char *mode, FILE *stream);
 
251
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
252
#   undef freopen
 
253
#   define freopen rpl_freopen
 
254
#  endif
 
255
_GL_FUNCDECL_RPL (freopen, FILE *,
 
256
                  (const char *filename, const char *mode, FILE *stream)
 
257
                  _GL_ARG_NONNULL ((2, 3)));
 
258
_GL_CXXALIAS_RPL (freopen, FILE *,
 
259
                  (const char *filename, const char *mode, FILE *stream));
 
260
# else
 
261
_GL_CXXALIAS_SYS (freopen, FILE *,
 
262
                  (const char *filename, const char *mode, FILE *stream));
232
263
# endif
 
264
_GL_CXXALIASWARN (freopen);
233
265
#elif defined GNULIB_POSIXCHECK
234
266
# undef freopen
235
 
# define freopen(f,m,s) \
236
 
   (GL_LINK_WARNING ("freopen on Win32 platforms is not POSIX compatible - " \
237
 
                     "use gnulib module freopen for portability"), \
238
 
    freopen (f, m, s))
 
267
/* Assume freopen is always declared.  */
 
268
_GL_WARN_ON_USE (freopen, "freopen on Win32 platforms is not POSIX compatible - "
 
269
                 "use gnulib module freopen for portability");
 
270
#endif
 
271
 
 
272
 
 
273
/* Set up the following warnings, based on which modules are in use.
 
274
   GNU Coding Standards discourage the use of fseek, since it imposes
 
275
   an arbitrary limitation on some 32-bit hosts.  Remember that the
 
276
   fseek module depends on the fseeko module, so we only have three
 
277
   cases to consider:
 
278
 
 
279
   1. The developer is not using either module.  Issue a warning under
 
280
   GNULIB_POSIXCHECK for both functions, to remind them that both
 
281
   functions have bugs on some systems.  _GL_NO_LARGE_FILES has no
 
282
   impact on this warning.
 
283
 
 
284
   2. The developer is using both modules.  They may be unaware of the
 
285
   arbitrary limitations of fseek, so issue a warning under
 
286
   GNULIB_POSIXCHECK.  On the other hand, they may be using both
 
287
   modules intentionally, so the developer can define
 
288
   _GL_NO_LARGE_FILES in the compilation units where the use of fseek
 
289
   is safe, to silence the warning.
 
290
 
 
291
   3. The developer is using the fseeko module, but not fseek.  Gnulib
 
292
   guarantees that fseek will still work around platform bugs in that
 
293
   case, but we presume that the developer is aware of the pitfalls of
 
294
   fseek and was trying to avoid it, so issue a warning even when
 
295
   GNULIB_POSIXCHECK is undefined.  Again, _GL_NO_LARGE_FILES can be
 
296
   defined to silence the warning in particular compilation units.
 
297
   In C++ compilations with GNULIB_NAMESPACE, in order to avoid that
 
298
   fseek gets defined as a macro, it is recommended that the developer
 
299
   uses the fseek module, even if he is not calling the fseek function.
 
300
 
 
301
   Most gnulib clients that perform stream operations should fall into
 
302
   category 3.  */
 
303
 
 
304
#if @GNULIB_FSEEK@
 
305
# if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
 
306
#  define _GL_FSEEK_WARN /* Category 2, above.  */
 
307
#  undef fseek
 
308
# endif
 
309
# if @REPLACE_FSEEK@
 
310
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
311
#   undef fseek
 
312
#   define fseek rpl_fseek
 
313
#  endif
 
314
_GL_FUNCDECL_RPL (fseek, int, (FILE *fp, long offset, int whence)
 
315
                              _GL_ARG_NONNULL ((1)));
 
316
_GL_CXXALIAS_RPL (fseek, int, (FILE *fp, long offset, int whence));
 
317
# else
 
318
_GL_CXXALIAS_SYS (fseek, int, (FILE *fp, long offset, int whence));
 
319
# endif
 
320
_GL_CXXALIASWARN (fseek);
239
321
#endif
240
322
 
241
323
#if @GNULIB_FSEEKO@
 
324
# if !@GNULIB_FSEEK@ && !defined _GL_NO_LARGE_FILES
 
325
#  define _GL_FSEEK_WARN /* Category 3, above.  */
 
326
#  undef fseek
 
327
# endif
242
328
# if @REPLACE_FSEEKO@
243
 
/* Provide fseek, fseeko functions that are aware of a preceding
244
 
   fflush(), and which detect pipes.  */
245
 
#  define fseeko rpl_fseeko
246
 
extern int fseeko (FILE *fp, off_t offset, int whence);
247
 
#  define fseek(fp, offset, whence) fseeko (fp, (off_t)(offset), whence)
 
329
/* Provide an fseeko function that is aware of a preceding fflush(), and which
 
330
   detects pipes.  */
 
331
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
332
#   undef fseeko
 
333
#   define fseeko rpl_fseeko
 
334
#  endif
 
335
_GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)
 
336
                               _GL_ARG_NONNULL ((1)));
 
337
_GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence));
 
338
# else
 
339
#  if ! @HAVE_FSEEKO@
 
340
_GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)
 
341
                               _GL_ARG_NONNULL ((1)));
 
342
#  endif
 
343
_GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence));
 
344
# endif
 
345
_GL_CXXALIASWARN (fseeko);
 
346
# if (@REPLACE_FSEEKO@ || !@HAVE_FSEEKO@) && !@GNULIB_FSEEK@
 
347
   /* Provide an fseek function that is consistent with fseeko.  */
 
348
   /* In order to avoid that fseek gets defined as a macro here, the
 
349
      developer can request the 'fseek' module.  */
 
350
#  undef fseek
 
351
#  define fseek rpl_fseek
 
352
static inline int _GL_ARG_NONNULL ((1))
 
353
rpl_fseek (FILE *fp, long offset, int whence)
 
354
{
 
355
#  if @REPLACE_FSEEKO@
 
356
  return rpl_fseeko (fp, offset, whence);
 
357
#  else
 
358
  return fseeko (fp, offset, whence);
 
359
#  endif
 
360
}
248
361
# endif
249
362
#elif defined GNULIB_POSIXCHECK
 
363
# define _GL_FSEEK_WARN /* Category 1, above.  */
 
364
# undef fseek
250
365
# undef fseeko
251
 
# define fseeko(f,o,w) \
252
 
   (GL_LINK_WARNING ("fseeko is unportable - " \
253
 
                     "use gnulib module fseeko for portability"), \
254
 
    fseeko (f, o, w))
255
 
#endif
256
 
 
257
 
#if @GNULIB_FSEEK@ && @REPLACE_FSEEK@
258
 
extern int rpl_fseek (FILE *fp, long offset, int whence);
259
 
# undef fseek
260
 
# if defined GNULIB_POSIXCHECK
261
 
#  define fseek(f,o,w) \
262
 
     (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \
263
 
                       "on 32-bit platforms - " \
264
 
                       "use fseeko function for handling of large files"), \
265
 
      rpl_fseek (f, o, w))
 
366
# if HAVE_RAW_DECL_FSEEKO
 
367
_GL_WARN_ON_USE (fseeko, "fseeko is unportable - "
 
368
                 "use gnulib module fseeko for portability");
 
369
# endif
 
370
#endif
 
371
 
 
372
#ifdef _GL_FSEEK_WARN
 
373
# undef _GL_FSEEK_WARN
 
374
/* Here, either fseek is undefined (but C89 guarantees that it is
 
375
   declared), or it is defined as rpl_fseek (declared above).  */
 
376
_GL_WARN_ON_USE (fseek, "fseek cannot handle files larger than 4 GB "
 
377
                 "on 32-bit platforms - "
 
378
                 "use fseeko function for handling of large files");
 
379
#endif
 
380
 
 
381
 
 
382
/* ftell, ftello.  See the comments on fseek/fseeko.  */
 
383
 
 
384
#if @GNULIB_FTELL@
 
385
# if defined GNULIB_POSIXCHECK && !defined _GL_NO_LARGE_FILES
 
386
#  define _GL_FTELL_WARN /* Category 2, above.  */
 
387
#  undef ftell
 
388
# endif
 
389
# if @REPLACE_FTELL@
 
390
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
391
#   undef ftell
 
392
#   define ftell rpl_ftell
 
393
#  endif
 
394
_GL_FUNCDECL_RPL (ftell, long, (FILE *fp) _GL_ARG_NONNULL ((1)));
 
395
_GL_CXXALIAS_RPL (ftell, long, (FILE *fp));
266
396
# else
267
 
#  define fseek rpl_fseek
268
 
# endif
269
 
#elif defined GNULIB_POSIXCHECK
270
 
# ifndef fseek
271
 
#  define fseek(f,o,w) \
272
 
     (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \
273
 
                       "on 32-bit platforms - " \
274
 
                       "use fseeko function for handling of large files"), \
275
 
      fseek (f, o, w))
276
 
# endif
 
397
_GL_CXXALIAS_SYS (ftell, long, (FILE *fp));
 
398
# endif
 
399
_GL_CXXALIASWARN (ftell);
277
400
#endif
278
401
 
279
402
#if @GNULIB_FTELLO@
 
403
# if !@GNULIB_FTELL@ && !defined _GL_NO_LARGE_FILES
 
404
#  define _GL_FTELL_WARN /* Category 3, above.  */
 
405
#  undef ftell
 
406
# endif
280
407
# if @REPLACE_FTELLO@
281
 
#  define ftello rpl_ftello
282
 
extern off_t ftello (FILE *fp);
283
 
#  define ftell(fp) ftello (fp)
 
408
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
409
#   undef ftello
 
410
#   define ftello rpl_ftello
 
411
#  endif
 
412
_GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
 
413
_GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp));
 
414
# else
 
415
#  if ! @HAVE_FTELLO@
 
416
_GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
 
417
#  endif
 
418
_GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp));
 
419
# endif
 
420
_GL_CXXALIASWARN (ftello);
 
421
# if (@REPLACE_FTELLO@ || !@HAVE_FTELLO@) && !@GNULIB_FTELL@
 
422
   /* Provide an ftell function that is consistent with ftello.  */
 
423
   /* In order to avoid that ftell gets defined as a macro here, the
 
424
      developer can request the 'ftell' module.  */
 
425
#  undef ftell
 
426
#  define ftell rpl_ftell
 
427
static inline long _GL_ARG_NONNULL ((1))
 
428
rpl_ftell (FILE *f)
 
429
{
 
430
#  if @REPLACE_FTELLO@
 
431
  return rpl_ftello (f);
 
432
#  else
 
433
  return ftello (f);
 
434
#  endif
 
435
}
284
436
# endif
285
437
#elif defined GNULIB_POSIXCHECK
 
438
# define _GL_FTELL_WARN /* Category 1, above.  */
 
439
# undef ftell
286
440
# undef ftello
287
 
# define ftello(f) \
288
 
   (GL_LINK_WARNING ("ftello is unportable - " \
289
 
                     "use gnulib module ftello for portability"), \
290
 
    ftello (f))
291
 
#endif
292
 
 
293
 
#if @GNULIB_FTELL@ && @REPLACE_FTELL@
294
 
extern long rpl_ftell (FILE *fp);
295
 
# undef ftell
296
 
# if GNULIB_POSIXCHECK
297
 
#  define ftell(f) \
298
 
     (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \
299
 
                       "on 32-bit platforms - " \
300
 
                       "use ftello function for handling of large files"), \
301
 
      rpl_ftell (f))
 
441
# if HAVE_RAW_DECL_FTELLO
 
442
_GL_WARN_ON_USE (ftello, "ftello is unportable - "
 
443
                 "use gnulib module ftello for portability");
 
444
# endif
 
445
#endif
 
446
 
 
447
#ifdef _GL_FTELL_WARN
 
448
# undef _GL_FTELL_WARN
 
449
/* Here, either ftell is undefined (but C89 guarantees that it is
 
450
   declared), or it is defined as rpl_ftell (declared above).  */
 
451
_GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB "
 
452
                 "on 32-bit platforms - "
 
453
                 "use ftello function for handling of large files");
 
454
#endif
 
455
 
 
456
 
 
457
#if @GNULIB_FWRITE@
 
458
# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
 
459
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
460
#   undef fwrite
 
461
#   define fwrite rpl_fwrite
 
462
#  endif
 
463
_GL_FUNCDECL_RPL (fwrite, size_t,
 
464
                  (const void *ptr, size_t s, size_t n, FILE *stream)
 
465
                  _GL_ARG_NONNULL ((1, 4)));
 
466
_GL_CXXALIAS_RPL (fwrite, size_t,
 
467
                  (const void *ptr, size_t s, size_t n, FILE *stream));
302
468
# else
303
 
#  define ftell rpl_ftell
304
 
# endif
305
 
#elif defined GNULIB_POSIXCHECK
306
 
# ifndef ftell
307
 
#  define ftell(f) \
308
 
     (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \
309
 
                       "on 32-bit platforms - " \
310
 
                       "use ftello function for handling of large files"), \
311
 
      ftell (f))
312
 
# endif
313
 
#endif
314
 
 
315
 
#if @GNULIB_FFLUSH@
316
 
# if @REPLACE_FFLUSH@
317
 
#  define fflush rpl_fflush
318
 
  /* Flush all pending data on STREAM according to POSIX rules.  Both
319
 
     output and seekable input streams are supported.
320
 
     Note! LOSS OF DATA can occur if fflush is applied on an input stream
321
 
     that is _not_seekable_ or on an update stream that is _not_seekable_
322
 
     and in which the most recent operation was input.  Seekability can
323
 
     be tested with lseek(fileno(fp),0,SEEK_CUR).  */
324
 
  extern int fflush (FILE *gl_stream);
325
 
# endif
326
 
#elif defined GNULIB_POSIXCHECK
327
 
# undef fflush
328
 
# define fflush(f) \
329
 
   (GL_LINK_WARNING ("fflush is not always POSIX compliant - " \
330
 
                     "use gnulib module fflush for portable " \
331
 
                     "POSIX compliance"), \
332
 
    fflush (f))
 
469
_GL_CXXALIAS_SYS (fwrite, size_t,
 
470
                  (const void *ptr, size_t s, size_t n, FILE *stream));
 
471
# endif
 
472
_GL_CXXALIASWARN (fwrite);
333
473
#endif
334
474
 
335
475
#if @GNULIB_GETDELIM@
336
 
# if !@HAVE_DECL_GETDELIM@
337
476
/* Read input, up to (and including) the next occurrence of DELIMITER, from
338
477
   STREAM, store it in *LINEPTR (and NUL-terminate it).
339
478
   *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
340
479
   bytes of space.  It is realloc'd as necessary.
341
480
   Return the number of bytes read and stored at *LINEPTR (not including the
342
481
   NUL terminator), or -1 on error or EOF.  */
343
 
extern ssize_t getdelim (char **lineptr, size_t *linesize, int delimiter,
344
 
                         FILE *stream);
 
482
# if @REPLACE_GETDELIM@
 
483
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
484
#   undef getdelim
 
485
#   define getdelim rpl_getdelim
 
486
#  endif
 
487
_GL_FUNCDECL_RPL (getdelim, ssize_t,
 
488
                  (char **lineptr, size_t *linesize, int delimiter,
 
489
                   FILE *stream)
 
490
                  _GL_ARG_NONNULL ((1, 2, 4)));
 
491
_GL_CXXALIAS_RPL (getdelim, ssize_t,
 
492
                  (char **lineptr, size_t *linesize, int delimiter,
 
493
                   FILE *stream));
 
494
# else
 
495
#  if !@HAVE_DECL_GETDELIM@
 
496
_GL_FUNCDECL_SYS (getdelim, ssize_t,
 
497
                  (char **lineptr, size_t *linesize, int delimiter,
 
498
                   FILE *stream)
 
499
                  _GL_ARG_NONNULL ((1, 2, 4)));
 
500
#  endif
 
501
_GL_CXXALIAS_SYS (getdelim, ssize_t,
 
502
                  (char **lineptr, size_t *linesize, int delimiter,
 
503
                   FILE *stream));
345
504
# endif
 
505
_GL_CXXALIASWARN (getdelim);
346
506
#elif defined GNULIB_POSIXCHECK
347
507
# undef getdelim
348
 
# define getdelim(l, s, d, f)                                       \
349
 
  (GL_LINK_WARNING ("getdelim is unportable - "                     \
350
 
                    "use gnulib module getdelim for portability"),  \
351
 
   getdelim (l, s, d, f))
 
508
# if HAVE_RAW_DECL_GETDELIM
 
509
_GL_WARN_ON_USE (getdelim, "getdelim is unportable - "
 
510
                 "use gnulib module getdelim for portability");
 
511
# endif
352
512
#endif
353
513
 
354
514
#if @GNULIB_GETLINE@
355
 
# if @REPLACE_GETLINE@
356
 
#  undef getline
357
 
#  define getline rpl_getline
358
 
# endif
359
 
# if !@HAVE_DECL_GETLINE@ || @REPLACE_GETLINE@
360
515
/* Read a line, up to (and including) the next newline, from STREAM, store it
361
516
   in *LINEPTR (and NUL-terminate it).
362
517
   *LINEPTR is a pointer returned from malloc (or NULL), pointing to *LINESIZE
363
518
   bytes of space.  It is realloc'd as necessary.
364
519
   Return the number of bytes read and stored at *LINEPTR (not including the
365
520
   NUL terminator), or -1 on error or EOF.  */
366
 
extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream);
 
521
# if @REPLACE_GETLINE@
 
522
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
523
#   undef getline
 
524
#   define getline rpl_getline
 
525
#  endif
 
526
_GL_FUNCDECL_RPL (getline, ssize_t,
 
527
                  (char **lineptr, size_t *linesize, FILE *stream)
 
528
                  _GL_ARG_NONNULL ((1, 2, 3)));
 
529
_GL_CXXALIAS_RPL (getline, ssize_t,
 
530
                  (char **lineptr, size_t *linesize, FILE *stream));
 
531
# else
 
532
#  if !@HAVE_DECL_GETLINE@
 
533
_GL_FUNCDECL_SYS (getline, ssize_t,
 
534
                  (char **lineptr, size_t *linesize, FILE *stream)
 
535
                  _GL_ARG_NONNULL ((1, 2, 3)));
 
536
#  endif
 
537
_GL_CXXALIAS_SYS (getline, ssize_t,
 
538
                  (char **lineptr, size_t *linesize, FILE *stream));
 
539
# endif
 
540
# if @HAVE_DECL_GETLINE@
 
541
_GL_CXXALIASWARN (getline);
367
542
# endif
368
543
#elif defined GNULIB_POSIXCHECK
369
544
# undef getline
370
 
# define getline(l, s, f)                                               \
371
 
  (GL_LINK_WARNING ("getline is unportable - "                          \
372
 
                    "use gnulib module getline for portability"),       \
373
 
   getline (l, s, f))
374
 
#endif
375
 
 
376
 
#ifdef __cplusplus
377
 
}
378
 
#endif
 
545
# if HAVE_RAW_DECL_GETLINE
 
546
_GL_WARN_ON_USE (getline, "getline is unportable - "
 
547
                 "use gnulib module getline for portability");
 
548
# endif
 
549
#endif
 
550
 
 
551
#if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
 
552
struct obstack;
 
553
/* Grow an obstack with formatted output.  Return the number of
 
554
   bytes added to OBS.  No trailing nul byte is added, and the
 
555
   object should be closed with obstack_finish before use.  Upon
 
556
   memory allocation error, call obstack_alloc_failed_handler.  Upon
 
557
   other error, return -1.  */
 
558
# if @REPLACE_OBSTACK_PRINTF@
 
559
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
560
#   define obstack_printf rpl_obstack_printf
 
561
#  endif
 
562
_GL_FUNCDECL_RPL (obstack_printf, int,
 
563
                  (struct obstack *obs, const char *format, ...)
 
564
                  __attribute__ ((__format__ (__printf__, 2, 3)))
 
565
                  _GL_ARG_NONNULL ((1, 2)));
 
566
_GL_CXXALIAS_RPL (obstack_printf, int,
 
567
                  (struct obstack *obs, const char *format, ...));
 
568
# else
 
569
#  if !@HAVE_DECL_OBSTACK_PRINTF@
 
570
_GL_FUNCDECL_SYS (obstack_printf, int,
 
571
                  (struct obstack *obs, const char *format, ...)
 
572
                  __attribute__ ((__format__ (__printf__, 2, 3)))
 
573
                  _GL_ARG_NONNULL ((1, 2)));
 
574
#  endif
 
575
_GL_CXXALIAS_SYS (obstack_printf, int,
 
576
                  (struct obstack *obs, const char *format, ...));
 
577
# endif
 
578
_GL_CXXALIASWARN (obstack_printf);
 
579
# if @REPLACE_OBSTACK_PRINTF@
 
580
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
581
#   define obstack_vprintf rpl_obstack_vprintf
 
582
#  endif
 
583
_GL_FUNCDECL_RPL (obstack_vprintf, int,
 
584
                  (struct obstack *obs, const char *format, va_list args)
 
585
                  __attribute__ ((__format__ (__printf__, 2, 0)))
 
586
                  _GL_ARG_NONNULL ((1, 2)));
 
587
_GL_CXXALIAS_RPL (obstack_vprintf, int,
 
588
                  (struct obstack *obs, const char *format, va_list args));
 
589
# else
 
590
#  if !@HAVE_DECL_OBSTACK_PRINTF@
 
591
_GL_FUNCDECL_SYS (obstack_vprintf, int,
 
592
                  (struct obstack *obs, const char *format, va_list args)
 
593
                  __attribute__ ((__format__ (__printf__, 2, 0)))
 
594
                  _GL_ARG_NONNULL ((1, 2)));
 
595
#  endif
 
596
_GL_CXXALIAS_SYS (obstack_vprintf, int,
 
597
                  (struct obstack *obs, const char *format, va_list args));
 
598
# endif
 
599
_GL_CXXALIASWARN (obstack_vprintf);
 
600
#endif
 
601
 
 
602
#if @GNULIB_PERROR@
 
603
/* Print a message to standard error, describing the value of ERRNO,
 
604
   (if STRING is not NULL and not empty) prefixed with STRING and ": ",
 
605
   and terminated with a newline.  */
 
606
# if @REPLACE_PERROR@
 
607
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
608
#   define perror rpl_perror
 
609
#  endif
 
610
_GL_FUNCDECL_RPL (perror, void, (const char *string));
 
611
_GL_CXXALIAS_RPL (perror, void, (const char *string));
 
612
# else
 
613
_GL_CXXALIAS_SYS (perror, void, (const char *string));
 
614
# endif
 
615
_GL_CXXALIASWARN (perror);
 
616
#elif defined GNULIB_POSIXCHECK
 
617
# undef perror
 
618
/* Assume perror is always declared.  */
 
619
_GL_WARN_ON_USE (perror, "perror is not always POSIX compliant - "
 
620
                 "use gnulib module perror for portability");
 
621
#endif
 
622
 
 
623
#if @GNULIB_POPEN@
 
624
# if @REPLACE_POPEN@
 
625
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
626
#   undef popen
 
627
#   define popen rpl_popen
 
628
#  endif
 
629
_GL_FUNCDECL_RPL (popen, FILE *, (const char *cmd, const char *mode)
 
630
                                 _GL_ARG_NONNULL ((1, 2)));
 
631
_GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode));
 
632
# else
 
633
_GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode));
 
634
# endif
 
635
_GL_CXXALIASWARN (popen);
 
636
#elif defined GNULIB_POSIXCHECK
 
637
# undef popen
 
638
# if HAVE_RAW_DECL_POPEN
 
639
_GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
 
640
                 "use gnulib module popen or pipe for more portability");
 
641
# endif
 
642
#endif
 
643
 
 
644
#if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@
 
645
# if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \
 
646
     || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@)
 
647
#  if defined __GNUC__
 
648
#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
649
/* Don't break __attribute__((format(printf,M,N))).  */
 
650
#    define printf __printf__
 
651
#   endif
 
652
_GL_FUNCDECL_RPL_1 (__printf__, int,
 
653
                    (const char *format, ...)
 
654
                    __asm__ (@ASM_SYMBOL_PREFIX@
 
655
                             _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
 
656
                    __attribute__ ((__format__ (__printf__, 1, 2)))
 
657
                    _GL_ARG_NONNULL ((1)));
 
658
_GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...));
 
659
#  else
 
660
_GL_FUNCDECL_RPL (printf, int,
 
661
                  (const char *format, ...)
 
662
                  __attribute__ ((__format__ (__printf__, 1, 2)))
 
663
                  _GL_ARG_NONNULL ((1)));
 
664
_GL_CXXALIAS_RPL (printf, printf, int, (const char *format, ...));
 
665
#  endif
 
666
#  define GNULIB_overrides_printf 1
 
667
# else
 
668
_GL_CXXALIAS_SYS (printf, int, (const char *format, ...));
 
669
# endif
 
670
_GL_CXXALIASWARN (printf);
 
671
#endif
 
672
#if !@GNULIB_PRINTF_POSIX@ && defined GNULIB_POSIXCHECK
 
673
# if !GNULIB_overrides_printf
 
674
#  undef printf
 
675
# endif
 
676
/* Assume printf is always declared.  */
 
677
_GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - "
 
678
                 "use gnulib module printf-posix for portable "
 
679
                 "POSIX compliance");
 
680
#endif
 
681
 
 
682
#if @GNULIB_PUTC@
 
683
# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
 
684
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
685
#   undef putc
 
686
#   define putc rpl_fputc
 
687
#  endif
 
688
_GL_FUNCDECL_RPL (fputc, int, (int c, FILE *stream) _GL_ARG_NONNULL ((2)));
 
689
_GL_CXXALIAS_RPL_1 (putc, rpl_fputc, int, (int c, FILE *stream));
 
690
# else
 
691
_GL_CXXALIAS_SYS (putc, int, (int c, FILE *stream));
 
692
# endif
 
693
_GL_CXXALIASWARN (putc);
 
694
#endif
 
695
 
 
696
#if @GNULIB_PUTCHAR@
 
697
# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
 
698
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
699
#   undef putchar
 
700
#   define putchar rpl_putchar
 
701
#  endif
 
702
_GL_FUNCDECL_RPL (putchar, int, (int c));
 
703
_GL_CXXALIAS_RPL (putchar, int, (int c));
 
704
# else
 
705
_GL_CXXALIAS_SYS (putchar, int, (int c));
 
706
# endif
 
707
_GL_CXXALIASWARN (putchar);
 
708
#endif
 
709
 
 
710
#if @GNULIB_PUTS@
 
711
# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
 
712
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
713
#   undef puts
 
714
#   define puts rpl_puts
 
715
#  endif
 
716
_GL_FUNCDECL_RPL (puts, int, (const char *string) _GL_ARG_NONNULL ((1)));
 
717
_GL_CXXALIAS_RPL (puts, int, (const char *string));
 
718
# else
 
719
_GL_CXXALIAS_SYS (puts, int, (const char *string));
 
720
# endif
 
721
_GL_CXXALIASWARN (puts);
 
722
#endif
 
723
 
 
724
#if @GNULIB_REMOVE@
 
725
# if @REPLACE_REMOVE@
 
726
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
727
#   undef remove
 
728
#   define remove rpl_remove
 
729
#  endif
 
730
_GL_FUNCDECL_RPL (remove, int, (const char *name) _GL_ARG_NONNULL ((1)));
 
731
_GL_CXXALIAS_RPL (remove, int, (const char *name));
 
732
# else
 
733
_GL_CXXALIAS_SYS (remove, int, (const char *name));
 
734
# endif
 
735
_GL_CXXALIASWARN (remove);
 
736
#elif defined GNULIB_POSIXCHECK
 
737
# undef remove
 
738
/* Assume remove is always declared.  */
 
739
_GL_WARN_ON_USE (remove, "remove cannot handle directories on some platforms - "
 
740
                 "use gnulib module remove for more portability");
 
741
#endif
 
742
 
 
743
#if @GNULIB_RENAME@
 
744
# if @REPLACE_RENAME@
 
745
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
746
#   undef rename
 
747
#   define rename rpl_rename
 
748
#  endif
 
749
_GL_FUNCDECL_RPL (rename, int,
 
750
                  (const char *old_filename, const char *new_filename)
 
751
                  _GL_ARG_NONNULL ((1, 2)));
 
752
_GL_CXXALIAS_RPL (rename, int,
 
753
                  (const char *old_filename, const char *new_filename));
 
754
# else
 
755
_GL_CXXALIAS_SYS (rename, int,
 
756
                  (const char *old_filename, const char *new_filename));
 
757
# endif
 
758
_GL_CXXALIASWARN (rename);
 
759
#elif defined GNULIB_POSIXCHECK
 
760
# undef rename
 
761
/* Assume rename is always declared.  */
 
762
_GL_WARN_ON_USE (rename, "rename is buggy on some platforms - "
 
763
                 "use gnulib module rename for more portability");
 
764
#endif
 
765
 
 
766
#if @GNULIB_RENAMEAT@
 
767
# if @REPLACE_RENAMEAT@
 
768
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
769
#   undef renameat
 
770
#   define renameat rpl_renameat
 
771
#  endif
 
772
_GL_FUNCDECL_RPL (renameat, int,
 
773
                  (int fd1, char const *file1, int fd2, char const *file2)
 
774
                  _GL_ARG_NONNULL ((2, 4)));
 
775
_GL_CXXALIAS_RPL (renameat, int,
 
776
                  (int fd1, char const *file1, int fd2, char const *file2));
 
777
# else
 
778
#  if !@HAVE_RENAMEAT@
 
779
_GL_FUNCDECL_SYS (renameat, int,
 
780
                  (int fd1, char const *file1, int fd2, char const *file2)
 
781
                  _GL_ARG_NONNULL ((2, 4)));
 
782
#  endif
 
783
_GL_CXXALIAS_SYS (renameat, int,
 
784
                  (int fd1, char const *file1, int fd2, char const *file2));
 
785
# endif
 
786
_GL_CXXALIASWARN (renameat);
 
787
#elif defined GNULIB_POSIXCHECK
 
788
# undef renameat
 
789
# if HAVE_RAW_DECL_RENAMEAT
 
790
_GL_WARN_ON_USE (renameat, "renameat is not portable - "
 
791
                 "use gnulib module renameat for portability");
 
792
# endif
 
793
#endif
 
794
 
 
795
#if @GNULIB_SNPRINTF@
 
796
# if @REPLACE_SNPRINTF@
 
797
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
798
#   define snprintf rpl_snprintf
 
799
#  endif
 
800
_GL_FUNCDECL_RPL (snprintf, int,
 
801
                  (char *str, size_t size, const char *format, ...)
 
802
                  __attribute__ ((__format__ (__printf__, 3, 4)))
 
803
                  _GL_ARG_NONNULL ((3)));
 
804
_GL_CXXALIAS_RPL (snprintf, int,
 
805
                  (char *str, size_t size, const char *format, ...));
 
806
# else
 
807
#  if !@HAVE_DECL_SNPRINTF@
 
808
_GL_FUNCDECL_SYS (snprintf, int,
 
809
                  (char *str, size_t size, const char *format, ...)
 
810
                  __attribute__ ((__format__ (__printf__, 3, 4)))
 
811
                  _GL_ARG_NONNULL ((3)));
 
812
#  endif
 
813
_GL_CXXALIAS_SYS (snprintf, int,
 
814
                  (char *str, size_t size, const char *format, ...));
 
815
# endif
 
816
_GL_CXXALIASWARN (snprintf);
 
817
#elif defined GNULIB_POSIXCHECK
 
818
# undef snprintf
 
819
# if HAVE_RAW_DECL_SNPRINTF
 
820
_GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
 
821
                 "use gnulib module snprintf for portability");
 
822
# endif
 
823
#endif
 
824
 
 
825
/* Some people would argue that sprintf should be handled like gets
 
826
   (for example, OpenBSD issues a link warning for both functions),
 
827
   since both can cause security holes due to buffer overruns.
 
828
   However, we believe that sprintf can be used safely, and is more
 
829
   efficient than snprintf in those safe cases; and as proof of our
 
830
   belief, we use sprintf in several gnulib modules.  So this header
 
831
   intentionally avoids adding a warning to sprintf except when
 
832
   GNULIB_POSIXCHECK is defined.  */
 
833
 
 
834
#if @GNULIB_SPRINTF_POSIX@
 
835
# if @REPLACE_SPRINTF@
 
836
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
837
#   define sprintf rpl_sprintf
 
838
#  endif
 
839
_GL_FUNCDECL_RPL (sprintf, int, (char *str, const char *format, ...)
 
840
                                __attribute__ ((__format__ (__printf__, 2, 3)))
 
841
                                _GL_ARG_NONNULL ((1, 2)));
 
842
_GL_CXXALIAS_RPL (sprintf, int, (char *str, const char *format, ...));
 
843
# else
 
844
_GL_CXXALIAS_SYS (sprintf, int, (char *str, const char *format, ...));
 
845
# endif
 
846
_GL_CXXALIASWARN (sprintf);
 
847
#elif defined GNULIB_POSIXCHECK
 
848
# undef sprintf
 
849
/* Assume sprintf is always declared.  */
 
850
_GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - "
 
851
                 "use gnulib module sprintf-posix for portable "
 
852
                 "POSIX compliance");
 
853
#endif
 
854
 
 
855
#if @GNULIB_TMPFILE@
 
856
# if @REPLACE_TMPFILE@
 
857
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
858
#   define tmpfile rpl_tmpfile
 
859
#  endif
 
860
_GL_FUNCDECL_RPL (tmpfile, FILE *, (void));
 
861
_GL_CXXALIAS_RPL (tmpfile, FILE *, (void));
 
862
# else
 
863
_GL_CXXALIAS_SYS (tmpfile, FILE *, (void));
 
864
# endif
 
865
_GL_CXXALIASWARN (tmpfile);
 
866
#elif defined GNULIB_POSIXCHECK
 
867
# undef tmpfile
 
868
# if HAVE_RAW_DECL_TMPFILE
 
869
_GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
 
870
                 "use gnulib module tmpfile for portability");
 
871
# endif
 
872
#endif
 
873
 
 
874
#if @GNULIB_VASPRINTF@
 
875
/* Write formatted output to a string dynamically allocated with malloc().
 
876
   If the memory allocation succeeds, store the address of the string in
 
877
   *RESULT and return the number of resulting bytes, excluding the trailing
 
878
   NUL.  Upon memory allocation error, or some other error, return -1.  */
 
879
# if @REPLACE_VASPRINTF@
 
880
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
881
#   define asprintf rpl_asprintf
 
882
#  endif
 
883
_GL_FUNCDECL_RPL (asprintf, int,
 
884
                  (char **result, const char *format, ...)
 
885
                  __attribute__ ((__format__ (__printf__, 2, 3)))
 
886
                  _GL_ARG_NONNULL ((1, 2)));
 
887
_GL_CXXALIAS_RPL (asprintf, int,
 
888
                  (char **result, const char *format, ...));
 
889
# else
 
890
#  if !@HAVE_VASPRINTF@
 
891
_GL_FUNCDECL_SYS (asprintf, int,
 
892
                  (char **result, const char *format, ...)
 
893
                  __attribute__ ((__format__ (__printf__, 2, 3)))
 
894
                  _GL_ARG_NONNULL ((1, 2)));
 
895
#  endif
 
896
_GL_CXXALIAS_SYS (asprintf, int,
 
897
                  (char **result, const char *format, ...));
 
898
# endif
 
899
_GL_CXXALIASWARN (asprintf);
 
900
# if @REPLACE_VASPRINTF@
 
901
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
902
#   define vasprintf rpl_vasprintf
 
903
#  endif
 
904
_GL_FUNCDECL_RPL (vasprintf, int,
 
905
                  (char **result, const char *format, va_list args)
 
906
                  __attribute__ ((__format__ (__printf__, 2, 0)))
 
907
                  _GL_ARG_NONNULL ((1, 2)));
 
908
_GL_CXXALIAS_RPL (vasprintf, int,
 
909
                  (char **result, const char *format, va_list args));
 
910
# else
 
911
#  if !@HAVE_VASPRINTF@
 
912
_GL_FUNCDECL_SYS (vasprintf, int,
 
913
                  (char **result, const char *format, va_list args)
 
914
                  __attribute__ ((__format__ (__printf__, 2, 0)))
 
915
                  _GL_ARG_NONNULL ((1, 2)));
 
916
#  endif
 
917
_GL_CXXALIAS_SYS (vasprintf, int,
 
918
                  (char **result, const char *format, va_list args));
 
919
# endif
 
920
_GL_CXXALIASWARN (vasprintf);
 
921
#endif
 
922
 
 
923
#if @GNULIB_VDPRINTF@
 
924
# if @REPLACE_VDPRINTF@
 
925
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
926
#   define vdprintf rpl_vdprintf
 
927
#  endif
 
928
_GL_FUNCDECL_RPL (vdprintf, int, (int fd, const char *format, va_list args)
 
929
                                 __attribute__ ((__format__ (__printf__, 2, 0)))
 
930
                                 _GL_ARG_NONNULL ((2)));
 
931
_GL_CXXALIAS_RPL (vdprintf, int, (int fd, const char *format, va_list args));
 
932
# else
 
933
#  if !@HAVE_VDPRINTF@
 
934
_GL_FUNCDECL_SYS (vdprintf, int, (int fd, const char *format, va_list args)
 
935
                                 __attribute__ ((__format__ (__printf__, 2, 0)))
 
936
                                 _GL_ARG_NONNULL ((2)));
 
937
#  endif
 
938
/* Need to cast, because on Solaris, the third parameter will likely be
 
939
                                                    __va_list args.  */
 
940
_GL_CXXALIAS_SYS_CAST (vdprintf, int,
 
941
                       (int fd, const char *format, va_list args));
 
942
# endif
 
943
_GL_CXXALIASWARN (vdprintf);
 
944
#elif defined GNULIB_POSIXCHECK
 
945
# undef vdprintf
 
946
# if HAVE_RAW_DECL_VDPRINTF
 
947
_GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - "
 
948
                 "use gnulib module vdprintf for portability");
 
949
# endif
 
950
#endif
 
951
 
 
952
#if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@
 
953
# if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \
 
954
     || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@)
 
955
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
956
#   define vfprintf rpl_vfprintf
 
957
#  endif
 
958
#  define GNULIB_overrides_vfprintf 1
 
959
_GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)
 
960
                                 __attribute__ ((__format__ (__printf__, 2, 0)))
 
961
                                 _GL_ARG_NONNULL ((1, 2)));
 
962
_GL_CXXALIAS_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args));
 
963
# else
 
964
/* Need to cast, because on Solaris, the third parameter is
 
965
                                                      __va_list args
 
966
   and GCC's fixincludes did not change this to __gnuc_va_list.  */
 
967
_GL_CXXALIAS_SYS_CAST (vfprintf, int,
 
968
                       (FILE *fp, const char *format, va_list args));
 
969
# endif
 
970
_GL_CXXALIASWARN (vfprintf);
 
971
#endif
 
972
#if !@GNULIB_VFPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
 
973
# if !GNULIB_overrides_vfprintf
 
974
#  undef vfprintf
 
975
# endif
 
976
/* Assume vfprintf is always declared.  */
 
977
_GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - "
 
978
                 "use gnulib module vfprintf-posix for portable "
 
979
                      "POSIX compliance");
 
980
#endif
 
981
 
 
982
#if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@
 
983
# if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \
 
984
     || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@)
 
985
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
986
#   define vprintf rpl_vprintf
 
987
#  endif
 
988
#  define GNULIB_overrides_vprintf 1
 
989
_GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args)
 
990
                                __attribute__ ((__format__ (__printf__, 1, 0)))
 
991
                                _GL_ARG_NONNULL ((1)));
 
992
_GL_CXXALIAS_RPL (vprintf, int, (const char *format, va_list args));
 
993
# else
 
994
/* Need to cast, because on Solaris, the second parameter is
 
995
                                                          __va_list args
 
996
   and GCC's fixincludes did not change this to __gnuc_va_list.  */
 
997
_GL_CXXALIAS_SYS_CAST (vprintf, int, (const char *format, va_list args));
 
998
# endif
 
999
_GL_CXXALIASWARN (vprintf);
 
1000
#endif
 
1001
#if !@GNULIB_VPRINTF_POSIX@ && defined GNULIB_POSIXCHECK
 
1002
# if !GNULIB_overrides_vprintf
 
1003
#  undef vprintf
 
1004
# endif
 
1005
/* Assume vprintf is always declared.  */
 
1006
_GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
 
1007
                 "use gnulib module vprintf-posix for portable "
 
1008
                 "POSIX compliance");
 
1009
#endif
 
1010
 
 
1011
#if @GNULIB_VSNPRINTF@
 
1012
# if @REPLACE_VSNPRINTF@
 
1013
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
1014
#   define vsnprintf rpl_vsnprintf
 
1015
#  endif
 
1016
_GL_FUNCDECL_RPL (vsnprintf, int,
 
1017
                  (char *str, size_t size, const char *format, va_list args)
 
1018
                  __attribute__ ((__format__ (__printf__, 3, 0)))
 
1019
                  _GL_ARG_NONNULL ((3)));
 
1020
_GL_CXXALIAS_RPL (vsnprintf, int,
 
1021
                  (char *str, size_t size, const char *format, va_list args));
 
1022
# else
 
1023
#  if !@HAVE_DECL_VSNPRINTF@
 
1024
_GL_FUNCDECL_SYS (vsnprintf, int,
 
1025
                  (char *str, size_t size, const char *format, va_list args)
 
1026
                  __attribute__ ((__format__ (__printf__, 3, 0)))
 
1027
                  _GL_ARG_NONNULL ((3)));
 
1028
#  endif
 
1029
_GL_CXXALIAS_SYS (vsnprintf, int,
 
1030
                  (char *str, size_t size, const char *format, va_list args));
 
1031
# endif
 
1032
_GL_CXXALIASWARN (vsnprintf);
 
1033
#elif defined GNULIB_POSIXCHECK
 
1034
# undef vsnprintf
 
1035
# if HAVE_RAW_DECL_VSNPRINTF
 
1036
_GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - "
 
1037
                 "use gnulib module vsnprintf for portability");
 
1038
# endif
 
1039
#endif
 
1040
 
 
1041
#if @GNULIB_VSPRINTF_POSIX@
 
1042
# if @REPLACE_VSPRINTF@
 
1043
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
1044
#   define vsprintf rpl_vsprintf
 
1045
#  endif
 
1046
_GL_FUNCDECL_RPL (vsprintf, int,
 
1047
                  (char *str, const char *format, va_list args)
 
1048
                  __attribute__ ((__format__ (__printf__, 2, 0)))
 
1049
                  _GL_ARG_NONNULL ((1, 2)));
 
1050
_GL_CXXALIAS_RPL (vsprintf, int,
 
1051
                  (char *str, const char *format, va_list args));
 
1052
# else
 
1053
/* Need to cast, because on Solaris, the third parameter is
 
1054
                                                       __va_list args
 
1055
   and GCC's fixincludes did not change this to __gnuc_va_list.  */
 
1056
_GL_CXXALIAS_SYS_CAST (vsprintf, int,
 
1057
                       (char *str, const char *format, va_list args));
 
1058
# endif
 
1059
_GL_CXXALIASWARN (vsprintf);
 
1060
#elif defined GNULIB_POSIXCHECK
 
1061
# undef vsprintf
 
1062
/* Assume vsprintf is always declared.  */
 
1063
_GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - "
 
1064
                 "use gnulib module vsprintf-posix for portable "
 
1065
                      "POSIX compliance");
 
1066
#endif
 
1067
 
379
1068
 
380
1069
#endif /* _GL_STDIO_H */
381
1070
#endif /* _GL_STDIO_H */