1 /*
2  * Copyright (c) 1990 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that the above copyright notice and this paragraph are
7  * duplicated in all such forms and that any documentation,
8  * and/or other materials related to such
9  * distribution and use acknowledge that the software was developed
10  * by the University of California, Berkeley.  The name of the
11  * University may not be used to endorse or promote products derived
12  * from this software without specific prior written permission.
13  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16  */
17 
18 /*
19 FUNCTION
20 <<viprintf>>, <<vfiprintf>>, <<vsiprintf>>, <<vsniprintf>>, <<vasiprintf>>, <<vasniprintf>>---format argument list (integer only)
21 
22 INDEX
23 	viprintf
24 INDEX
25 	_viprintf_r
26 INDEX
27 	vfiprintf
28 INDEX
29 	_vfiprintf_r
30 INDEX
31 	vsiprintf
32 INDEX
33 	_vsiprintf_r
34 INDEX
35 	vsniprintf
36 INDEX
37 	_vsniprintf_r
38 INDEX
39 	vasiprintf
40 INDEX
41 	_vasiprintf_r
42 INDEX
43 	vasniprintf
44 INDEX
45 	_vasniprintf_r
46 
47 SYNOPSIS
48 	#include <stdio.h>
49 	#include <stdarg.h>
50 	int viprintf(const char *<[fmt]>, va_list <[list]>);
51 	int vfiprintf(FILE *<[fp]>, const char *<[fmt]>, va_list <[list]>);
52 	int vsiprintf(char *<[str]>, const char *<[fmt]>, va_list <[list]>);
53 	int vsniprintf(char *<[str]>, size_t <[size]>, const char *<[fmt]>,
54                        va_list <[list]>);
55 	int vasiprintf(char **<[strp]>, const char *<[fmt]>, va_list <[list]>);
56 	char *vasniprintf(char *<[str]>, size_t *<[size]>, const char *<[fmt]>,
57                           va_list <[list]>);
58 
59 	int viprintf( const char *<[fmt]>,
60                         va_list <[list]>);
61 	int vfiprintf( FILE *<[fp]>,
62                         const char *<[fmt]>, va_list <[list]>);
63 	int vsiprintf( char *<[str]>,
64                         const char *<[fmt]>, va_list <[list]>);
65 	int vsniprintf( char *<[str]>,
66                           size_t <[size]>, const char *<[fmt]>, va_list <[list]>);
67 	int vasiprintf( char **<[str]>,
68                           const char *<[fmt]>, va_list <[list]>);
69 	char *vasniprintf( char *<[str]>,
70                              size_t *<[size]>, const char *<[fmt]>, va_list <[list]>);
71 
72 DESCRIPTION
73 <<viprintf>>, <<vfiprintf>>, <<vasiprintf>>, <<vsiprintf>>,
74 <<vsniprintf>>, and <<vasniprintf>> are (respectively) variants of
75 <<iprintf>>, <<fiprintf>>, <<asiprintf>>, <<siprintf>>, <<sniprintf>>,
76 and <<asniprintf>>.  They differ only in allowing their caller to pass
77 the variable argument list as a <<va_list>> object (initialized by
78 <<va_start>>) rather than directly accepting a variable number of
79 arguments.  The caller is responsible for calling <<va_end>>.
80 
81 <<_viprintf_r>>, <<_vfiprintf_r>>, <<_vasiprintf_r>>,
82 <<_vsiprintf_r>>, <<_vsniprintf_r>>, and <<_vasniprintf_r>> are
83 reentrant versions of the above.
84 
85 RETURNS
86 The return values are consistent with the corresponding functions:
87 
88 PORTABILITY
89 All of these functions are newlib extensions.
90 
91 Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
92 <<lseek>>, <<read>>, <<sbrk>>, <<write>>.
93 */
94 
95 #define _DEFAULT_SOURCE
96 #include <_ansi.h>
97 #include <stdio.h>
98 #include <stdarg.h>
99 #include "local.h"
100 
101 int
viprintf(const char * fmt,va_list ap)102 viprintf (const char *fmt,
103        va_list ap)
104 {
105   _REENT_SMALL_CHECK_INIT (reent);
106   return vfiprintf ( _stdout_r (reent), fmt, ap);
107 }
108