]> git.saurik.com Git - apple/libc.git/blob - stdio/xprintf_all_in_one.c
Libc-1044.1.2.tar.gz
[apple/libc.git] / stdio / xprintf_all_in_one.c
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 <local.h>
29 #include <xprintf_private.h>
30
31 int
32 asxprintf(char ** __restrict ret, printf_domain_t __restrict domain,
33 locale_t __restrict loc, const char * __restrict format, ...)
34 {
35 int iret;
36 va_list ap;
37
38 va_start(ap, format);
39 iret = _vasprintf(NULL, domain, ret, loc, format, ap);
40 va_end(ap);
41 return iret;
42 }
43
44 int
45 dxprintf(int fd, printf_domain_t __restrict domain, locale_t __restrict loc,
46 const char * __restrict format, ...)
47 {
48 int ret;
49 va_list ap;
50
51 va_start(ap, format);
52 ret = _vdprintf(NULL, domain, fd, loc, format, ap);
53 va_end(ap);
54 return ret;
55 }
56
57 int
58 fxprintf(FILE * __restrict stream, printf_domain_t __restrict domain,
59 locale_t __restrict loc, const char * __restrict format, ...)
60 {
61 int ret;
62 va_list ap;
63
64 va_start(ap, format);
65 ret = __xvprintf(NULL, domain, stream, loc, format, ap);
66 va_end(ap);
67 return ret;
68 }
69
70 int
71 sxprintf(char * __restrict str, size_t size, printf_domain_t __restrict domain,
72 locale_t __restrict loc, const char * __restrict format, ...)
73 {
74 int ret;
75 va_list ap;
76
77 va_start(ap, format);
78 ret = _vsnprintf(NULL, domain, str, size, loc, format, ap);
79 va_end(ap);
80 return ret;
81 }
82
83 int
84 xprintf(printf_domain_t __restrict domain, locale_t __restrict loc,
85 const char * __restrict format, ...)
86 {
87 int ret;
88 va_list ap;
89
90 va_start(ap, format);
91 ret = __xvprintf(NULL, domain, stdout, loc, format, ap);
92 va_end(ap);
93 return ret;
94 }
95
96 int
97 vasxprintf(char ** __restrict ret, printf_domain_t __restrict domain,
98 locale_t __restrict loc, const char * __restrict format, va_list ap)
99 {
100 return _vasprintf(NULL, domain, ret, loc, format, ap);
101 }
102
103 int
104 vdxprintf(int fd, printf_domain_t __restrict domain, locale_t __restrict loc,
105 const char * __restrict format, va_list ap)
106 {
107 return _vdprintf(NULL, domain, fd, loc, format, ap);
108 }
109
110 int
111 vfxprintf(FILE * __restrict stream, printf_domain_t __restrict domain,
112 locale_t __restrict loc, const char * __restrict format, va_list ap)
113 {
114 return __xvprintf(NULL, domain, stream, loc, format, ap);
115 }
116
117 int
118 vsxprintf(char * __restrict str, size_t size, printf_domain_t __restrict domain,
119 locale_t __restrict loc, const char * __restrict format, va_list ap)
120 {
121 return _vsnprintf(NULL, domain, str, size, loc, format, ap);
122 }
123
124 int
125 vxprintf(printf_domain_t __restrict domain, locale_t __restrict loc,
126 const char * __restrict format, va_list ap)
127 {
128 return __xvprintf(NULL, domain, stdout, loc, format, ap);
129 }