]>
Commit | Line | Data |
---|---|---|
224c7076 | 1 | /* |
1f2f436a | 2 | * Copyright (c) 2007, 2010 Apple Inc. All rights reserved. |
224c7076 A |
3 | * |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * This file contains Original Code and/or Modifications of Original Code | |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. Please obtain a copy of the License at | |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
11 | * file. | |
12 | * | |
13 | * The Original Code and all software distributed under the License are | |
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
18 | * Please see the License for the specific language governing rights and | |
19 | * limitations under the License. | |
20 | * | |
21 | * @APPLE_LICENSE_HEADER_END@ | |
22 | */ | |
23 | ||
24 | #ifndef _STDIO_H_ | |
25 | #error error "Never use <secure/_stdio.h> directly; include <stdio.h> instead." | |
26 | #endif | |
27 | ||
28 | #ifndef _SECURE__STDIO_H_ | |
29 | #define _SECURE__STDIO_H_ | |
30 | ||
31 | #include <secure/_common.h> | |
32 | ||
33 | #if _USE_FORTIFY_LEVEL > 0 | |
34 | ||
35 | #undef sprintf | |
36 | #undef vsprintf | |
1f2f436a A |
37 | |
38 | #if __DARWIN_C_LEVEL >= 200112L | |
224c7076 A |
39 | #undef snprintf |
40 | #undef vsnprintf | |
1f2f436a | 41 | #endif |
224c7076 A |
42 | |
43 | /* sprintf, vsprintf, snprintf, vsnprintf */ | |
44 | ||
45 | extern int __sprintf_chk (char * __restrict, int, size_t, | |
46 | const char * __restrict, ...) | |
47 | __DARWIN_LDBL_COMPAT (__sprintf_chk); | |
48 | ||
49 | #define sprintf(str, ...) \ | |
50 | __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__) | |
51 | ||
52 | extern int __snprintf_chk (char * __restrict, size_t, int, size_t, | |
53 | const char * __restrict, ...) | |
54 | __DARWIN_LDBL_COMPAT (__snprintf_chk); | |
55 | ||
1f2f436a | 56 | #if __DARWIN_C_LEVEL >= 200112L |
224c7076 A |
57 | #define snprintf(str, len, ...) \ |
58 | __builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS__) | |
59 | ||
60 | extern int __vsprintf_chk (char * __restrict, int, size_t, | |
34e8f829 | 61 | const char * __restrict, va_list) |
224c7076 A |
62 | __DARWIN_LDBL_COMPAT (__vsprintf_chk); |
63 | ||
64 | #define vsprintf(str, format, ap) \ | |
65 | __builtin___vsprintf_chk (str, 0, __darwin_obsz(str), format, ap) | |
66 | ||
67 | extern int __vsnprintf_chk (char * __restrict, size_t, int, size_t, | |
34e8f829 | 68 | const char * __restrict, va_list) |
224c7076 A |
69 | __DARWIN_LDBL_COMPAT (__vsnprintf_chk); |
70 | ||
71 | #define vsnprintf(str, len, format, ap) \ | |
72 | __builtin___vsnprintf_chk (str, len, 0, __darwin_obsz(str), format, ap) | |
1f2f436a | 73 | #endif |
224c7076 A |
74 | |
75 | #endif | |
76 | ||
77 | #endif |