1 /* Checking macros for stdio functions. Declarations only.
2 Copyright (C) 2004-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19 #ifndef _BITS_STDIO2_DEC_H
20 #define _BITS_STDIO2_DEC_H 1
21
22 #ifndef _STDIO_H
23 # error "Never include <bits/stdio2-decl.h> directly; use <stdio.h> instead."
24 #endif
25
26 extern int __sprintf_chk (char *__restrict __s, int __flag, size_t __slen,
27 const char *__restrict __format, ...) __THROW
28 __attr_access ((__write_only__, 1, 3));
29 extern int __vsprintf_chk (char *__restrict __s, int __flag, size_t __slen,
30 const char *__restrict __format,
31 __gnuc_va_list __ap) __THROW
32 __attr_access ((__write_only__, 1, 3));
33
34 #if defined __USE_ISOC99 || defined __USE_UNIX98
35
36 extern int __snprintf_chk (char *__restrict __s, size_t __n, int __flag,
37 size_t __slen, const char *__restrict __format,
38 ...) __THROW
39 __attr_access ((__write_only__, 1, 2));
40 extern int __vsnprintf_chk (char *__restrict __s, size_t __n, int __flag,
41 size_t __slen, const char *__restrict __format,
42 __gnuc_va_list __ap) __THROW
43 __attr_access ((__write_only__, 1, 2));
44
45 #endif
46
47 #if __USE_FORTIFY_LEVEL > 1
48
49 extern int __fprintf_chk (FILE *__restrict __stream, int __flag,
50 const char *__restrict __format, ...);
51 extern int __printf_chk (int __flag, const char *__restrict __format, ...);
52 extern int __vfprintf_chk (FILE *__restrict __stream, int __flag,
53 const char *__restrict __format, __gnuc_va_list __ap);
54 extern int __vprintf_chk (int __flag, const char *__restrict __format,
55 __gnuc_va_list __ap);
56
57 # ifdef __USE_XOPEN2K8
58 extern int __dprintf_chk (int __fd, int __flag, const char *__restrict __fmt,
59 ...) __attribute__ ((__format__ (__printf__, 3, 4)));
60 extern int __vdprintf_chk (int __fd, int __flag,
61 const char *__restrict __fmt, __gnuc_va_list __arg)
62 __attribute__ ((__format__ (__printf__, 3, 0)));
63 # endif
64
65 # ifdef __USE_GNU
66
67 extern int __asprintf_chk (char **__restrict __ptr, int __flag,
68 const char *__restrict __fmt, ...)
69 __THROW __attribute__ ((__format__ (__printf__, 3, 4))) __wur;
70 extern int __vasprintf_chk (char **__restrict __ptr, int __flag,
71 const char *__restrict __fmt, __gnuc_va_list __arg)
72 __THROW __attribute__ ((__format__ (__printf__, 3, 0))) __wur;
73 extern int __obstack_printf_chk (struct obstack *__restrict __obstack,
74 int __flag, const char *__restrict __format,
75 ...)
76 __THROW __attribute__ ((__format__ (__printf__, 3, 4)));
77 extern int __obstack_vprintf_chk (struct obstack *__restrict __obstack,
78 int __flag,
79 const char *__restrict __format,
80 __gnuc_va_list __args)
81 __THROW __attribute__ ((__format__ (__printf__, 3, 0)));
82
83 # endif
84 #endif
85
86 #if __GLIBC_USE (DEPRECATED_GETS)
87 extern char *__REDIRECT (__gets_warn, (char *__str), gets)
88 __wur __warnattr ("please use fgets or getline instead, gets can't "
89 "specify buffer size");
90
91 extern char *__gets_chk (char *__str, size_t) __wur;
92 #endif
93
94 extern char *__REDIRECT (__fgets_alias,
95 (char *__restrict __s, int __n,
96 FILE *__restrict __stream), fgets)
97 __wur __attr_access ((__write_only__, 1, 2));
98 extern char *__REDIRECT (__fgets_chk_warn,
99 (char *__restrict __s, size_t __size, int __n,
100 FILE *__restrict __stream), __fgets_chk)
101 __wur __warnattr ("fgets called with bigger size than length "
102 "of destination buffer");
103
104 extern char *__fgets_chk (char *__restrict __s, size_t __size, int __n,
105 FILE *__restrict __stream)
106 __wur __attr_access ((__write_only__, 1, 3));
107
108 extern size_t __REDIRECT (__fread_alias,
109 (void *__restrict __ptr, size_t __size,
110 size_t __n, FILE *__restrict __stream),
111 fread) __wur;
112 extern size_t __REDIRECT (__fread_chk_warn,
113 (void *__restrict __ptr, size_t __ptrlen,
114 size_t __size, size_t __n,
115 FILE *__restrict __stream),
116 __fread_chk)
117 __wur __warnattr ("fread called with bigger size * nmemb than length "
118 "of destination buffer");
119
120 extern size_t __fread_chk (void *__restrict __ptr, size_t __ptrlen,
121 size_t __size, size_t __n,
122 FILE *__restrict __stream) __wur;
123
124 #ifdef __USE_GNU
125 extern char *__REDIRECT_FORTIFY (__fgets_unlocked_alias,
126 (char *__restrict __s, int __n,
127 FILE *__restrict __stream), fgets_unlocked)
128 __wur __attr_access ((__write_only__, 1, 2));
129 extern char *__REDIRECT (__fgets_unlocked_chk_warn,
130 (char *__restrict __s, size_t __size, int __n,
131 FILE *__restrict __stream), __fgets_unlocked_chk)
132 __wur __warnattr ("fgets_unlocked called with bigger size than length "
133 "of destination buffer");
134
135
136 extern char *__fgets_unlocked_chk (char *__restrict __s, size_t __size,
137 int __n, FILE *__restrict __stream)
138 __wur __attr_access ((__write_only__, 1, 3));
139 #endif
140
141 #ifdef __USE_MISC
142 # undef fread_unlocked
143 extern size_t __REDIRECT (__fread_unlocked_alias,
144 (void *__restrict __ptr, size_t __size,
145 size_t __n, FILE *__restrict __stream),
146 fread_unlocked) __wur;
147 extern size_t __REDIRECT (__fread_unlocked_chk_warn,
148 (void *__restrict __ptr, size_t __ptrlen,
149 size_t __size, size_t __n,
150 FILE *__restrict __stream),
151 __fread_unlocked_chk)
152 __wur __warnattr ("fread_unlocked called with bigger size * nmemb than "
153 "length of destination buffer");
154
155 extern size_t __fread_unlocked_chk (void *__restrict __ptr, size_t __ptrlen,
156 size_t __size, size_t __n,
157 FILE *__restrict __stream) __wur;
158 #endif
159
160 #endif /* bits/stdio2-decl.h. */