]>
Commit | Line | Data |
---|---|---|
6465356a A |
1 | /* |
2 | * Copyright (c) 2012 Apple Inc. All rights reserved. | |
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 | #define __va_list __darwin_va_list | |
25 | ||
26 | #include <printf.h> | |
27 | #include <stdarg.h> | |
28 | #include <errno.h> | |
29 | #include <local.h> | |
30 | #include <xprintf_private.h> | |
31 | ||
70ad1dc8 A |
32 | #pragma clang diagnostic push |
33 | #pragma clang diagnostic ignored "-Wpointer-bool-conversion" | |
34 | ||
6465356a A |
35 | int |
36 | asxprintf_exec(char ** __restrict ret, | |
37 | printf_comp_t __restrict pc, ...) | |
38 | { | |
39 | int iret; | |
40 | va_list ap; | |
41 | ||
42 | if (!pc) { | |
43 | errno = EINVAL; | |
44 | return -1; | |
45 | } | |
46 | ||
47 | va_start(ap, pc); | |
48 | iret = _vasprintf(pc, NULL, ret, NULL, NULL, ap); | |
49 | va_end(ap); | |
50 | return iret; | |
51 | } | |
52 | ||
53 | int | |
54 | dxprintf_exec(int fd, printf_comp_t __restrict pc, ...) | |
55 | { | |
56 | int ret; | |
57 | va_list ap; | |
58 | ||
59 | if (!pc) { | |
60 | errno = EINVAL; | |
61 | return -1; | |
62 | } | |
63 | ||
64 | va_start(ap, pc); | |
65 | ret = _vdprintf(pc, NULL, fd, NULL, NULL, ap); | |
66 | va_end(ap); | |
67 | return ret; | |
68 | } | |
69 | ||
70 | int | |
71 | fxprintf_exec(FILE * __restrict stream, | |
72 | printf_comp_t __restrict pc, ...) | |
73 | { | |
74 | int ret; | |
75 | va_list ap; | |
76 | ||
77 | if (!pc) { | |
78 | errno = EINVAL; | |
79 | return -1; | |
80 | } | |
81 | ||
82 | va_start(ap, pc); | |
83 | ret = __xvprintf(pc, NULL, stream, NULL, NULL, ap); | |
84 | va_end(ap); | |
85 | return ret; | |
86 | } | |
87 | ||
88 | int | |
89 | sxprintf_exec(char * __restrict str, size_t size, | |
90 | printf_comp_t __restrict pc, ...) | |
91 | { | |
92 | int ret; | |
93 | va_list ap; | |
94 | ||
95 | if (!pc) { | |
96 | errno = EINVAL; | |
97 | return -1; | |
98 | } | |
99 | ||
100 | va_start(ap, pc); | |
101 | ret = _vsnprintf(pc, NULL, str, size, NULL, NULL, ap); | |
102 | va_end(ap); | |
103 | return ret; | |
104 | } | |
105 | ||
106 | int | |
107 | xprintf_exec(printf_comp_t __restrict pc, ...) | |
108 | { | |
109 | int ret; | |
110 | va_list ap; | |
111 | ||
112 | if (!pc) { | |
113 | errno = EINVAL; | |
114 | return -1; | |
115 | } | |
116 | ||
117 | va_start(ap, pc); | |
118 | ret = __xvprintf(pc, NULL, stdout, NULL, NULL, ap); | |
119 | va_end(ap); | |
120 | return ret; | |
121 | } | |
122 | ||
123 | int | |
124 | vasxprintf_exec(char ** __restrict ret, | |
125 | printf_comp_t __restrict pc, va_list ap) | |
126 | { | |
127 | if (!pc) { | |
128 | errno = EINVAL; | |
129 | return -1; | |
130 | } | |
131 | ||
132 | return _vasprintf(pc, NULL, ret, NULL, NULL, ap); | |
133 | } | |
134 | ||
135 | int | |
136 | vdxprintf_exec(int fd, printf_comp_t __restrict pc, | |
137 | va_list ap) | |
138 | { | |
139 | if (!pc) { | |
140 | errno = EINVAL; | |
141 | return -1; | |
142 | } | |
143 | ||
144 | return _vdprintf(pc, NULL, fd, NULL, NULL, ap); | |
145 | } | |
146 | ||
147 | int | |
148 | vfxprintf_exec(FILE * __restrict stream, | |
149 | printf_comp_t __restrict pc, va_list ap) | |
150 | { | |
151 | if (!pc) { | |
152 | errno = EINVAL; | |
153 | return -1; | |
154 | } | |
155 | ||
156 | return __xvprintf(pc, NULL, stream, NULL, NULL, ap); | |
157 | } | |
158 | ||
159 | int | |
160 | vsxprintf_exec(char * __restrict str, size_t size, | |
161 | printf_comp_t __restrict pc, va_list ap) | |
162 | { | |
163 | if (!pc) { | |
164 | errno = EINVAL; | |
165 | return -1; | |
166 | } | |
167 | ||
168 | return _vsnprintf(pc, NULL, str, size, NULL, NULL, ap); | |
169 | } | |
170 | ||
171 | int | |
172 | vxprintf_exec(printf_comp_t __restrict pc, va_list ap) | |
173 | { | |
174 | if (!pc) { | |
175 | errno = EINVAL; | |
176 | return -1; | |
177 | } | |
178 | ||
179 | return __xvprintf(pc, NULL, stdout, NULL, NULL, ap); | |
180 | } | |
70ad1dc8 | 181 | #pragma clang diagnostic pop |