]>
Commit | Line | Data |
---|---|---|
b5cc329c | 1 | /* Checking macros for stdio functions. |
553cc5f9 | 2 | Copyright (C) 2004, 2005 Free Software Foundation, Inc. |
b5cc329c UD |
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, write to the Free | |
17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
18 | 02111-1307 USA. */ | |
19 | ||
20 | #ifndef _STDIO_H | |
21 | # error "Never include <bits/stdio2.h> directly; use <stdio.h> instead." | |
22 | #endif | |
23 | ||
24 | extern int __sprintf_chk (char *__restrict __s, int __flag, size_t __slen, | |
25 | __const char *__restrict __format, ...) __THROW; | |
26 | extern int __vsprintf_chk (char *__restrict __s, int __flag, size_t __slen, | |
27 | __const char *__restrict __format, | |
28 | _G_va_list __ap) __THROW; | |
29 | ||
30 | #define sprintf(str, ...) \ | |
31 | __builtin___sprintf_chk (str, __USE_FORTIFY_LEVEL - 1, __bos (str), \ | |
32 | __VA_ARGS__) | |
33 | #define vsprintf(str, fmt, ap) \ | |
34 | __builtin___vsprintf_chk (str, __USE_FORTIFY_LEVEL - 1, __bos (str), fmt, ap) | |
35 | ||
36 | #if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98 | |
37 | ||
38 | extern int __snprintf_chk (char *__restrict __s, size_t __n, int __flag, | |
39 | size_t __slen, __const char *__restrict __format, | |
40 | ...) __THROW; | |
41 | extern int __vsnprintf_chk (char *__restrict __s, size_t __n, int __flag, | |
42 | size_t __slen, __const char *__restrict __format, | |
43 | _G_va_list __ap) __THROW; | |
44 | ||
45 | # define snprintf(str, len, ...) \ | |
46 | __builtin___snprintf_chk (str, len, __USE_FORTIFY_LEVEL - 1, __bos (str), \ | |
47 | __VA_ARGS__) | |
48 | # define vsnprintf(str, len, fmt, ap) \ | |
49 | __builtin___vsnprintf_chk (str, len, __USE_FORTIFY_LEVEL - 1, __bos (str), \ | |
50 | fmt, ap) | |
51 | ||
553cc5f9 | 52 | #endif |
b5cc329c UD |
53 | |
54 | #if __USE_FORTIFY_LEVEL > 1 | |
55 | ||
56 | extern int __fprintf_chk (FILE *__restrict __stream, int __flag, | |
57 | __const char *__restrict __format, ...); | |
58 | extern int __printf_chk (int __flag, __const char *__restrict __format, ...); | |
59 | extern int __vfprintf_chk (FILE *__restrict __stream, int __flag, | |
60 | __const char *__restrict __format, _G_va_list __ap); | |
61 | extern int __vprintf_chk (int __flag, __const char *__restrict __format, | |
62 | _G_va_list __ap); | |
63 | ||
a334319f | 64 | # define printf(...) \ |
b5cc329c | 65 | __printf_chk (__USE_FORTIFY_LEVEL - 1, __VA_ARGS__) |
a334319f | 66 | # define fprintf(stream, ...) \ |
b5cc329c | 67 | __fprintf_chk (stream, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) |
a334319f | 68 | # define vprintf(format, ap) \ |
b5cc329c | 69 | __vprintf_chk (__USE_FORTIFY_LEVEL - 1, format, ap) |
a334319f | 70 | # define vfprintf(stream, format, ap) \ |
b5cc329c UD |
71 | __vfprintf_chk (stream, __USE_FORTIFY_LEVEL - 1, format, ap) |
72 | ||
73 | #endif | |
74 | ||
a334319f UD |
75 | extern char *__gets_chk (char *__str, size_t); |
76 | #define gets(__str) \ | |
553cc5f9 UD |
77 | ((__bos (__str) == (size_t) -1) \ |
78 | ? gets (__str) : __gets_chk (__str, __bos (__str))) | |
79 | ||
80 | extern char *__fgets_chk (char *s, size_t size, int n, FILE *stream); | |
81 | #define fgets(__str, __n, __fp) \ | |
82 | ((__bos (__str) == (size_t) -1) \ | |
83 | ? fgets (__str, __n, __fp) : __fgets_chk (__str, __bos (__str), __n, __fp)) | |
84 | ||
85 | extern char *__fgets_unlocked_chk (char *s, size_t size, int n, FILE *stream); | |
86 | #define fgets_unlocked(__str, __n, __fp) \ | |
87 | ((__bos (__str) == (size_t) -1) \ | |
88 | ? fgets_unlocked (__str, __n, __fp) \ | |
89 | : __fgets_unlocked_chk (__str, __bos (__str), __n, __fp)) |