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