source: trunk/libs/newlib/src/newlib/libc/stdio/viprintf.c

Last change on this file was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 3.8 KB
Line 
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 * advertising materials, and 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/*
19FUNCTION
20<<viprintf>>, <<vfiprintf>>, <<vsiprintf>>, <<vsniprintf>>, <<vasiprintf>>, <<vasniprintf>>---format argument list (integer only)
21
22INDEX
23        viprintf
24INDEX
25        _viprintf_r
26INDEX
27        vfiprintf
28INDEX
29        _vfiprintf_r
30INDEX
31        vsiprintf
32INDEX
33        _vsiprintf_r
34INDEX
35        vsniprintf
36INDEX
37        _vsniprintf_r
38INDEX
39        vasiprintf
40INDEX
41        _vasiprintf_r
42INDEX
43        vasniprintf
44INDEX
45        _vasniprintf_r
46
47SYNOPSIS
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_r(struct _reent *<[reent]>, const char *<[fmt]>,
60                        va_list <[list]>);
61        int _vfiprintf_r(struct _reent *<[reent]>, FILE *<[fp]>,
62                        const char *<[fmt]>, va_list <[list]>);
63        int _vsiprintf_r(struct _reent *<[reent]>, char *<[str]>,
64                        const char *<[fmt]>, va_list <[list]>);
65        int _vsniprintf_r(struct _reent *<[reent]>, char *<[str]>,
66                          size_t <[size]>, const char *<[fmt]>, va_list <[list]>);
67        int _vasiprintf_r(struct _reent *<[reent]>, char **<[str]>,
68                          const char *<[fmt]>, va_list <[list]>);
69        char *_vasniprintf_r(struct _reent *<[reent]>, char *<[str]>,
70                             size_t *<[size]>, const char *<[fmt]>, va_list <[list]>);
71
72DESCRIPTION
73<<viprintf>>, <<vfiprintf>>, <<vasiprintf>>, <<vsiprintf>>,
74<<vsniprintf>>, and <<vasniprintf>> are (respectively) variants of
75<<iprintf>>, <<fiprintf>>, <<asiprintf>>, <<siprintf>>, <<sniprintf>>,
76and <<asniprintf>>.  They differ only in allowing their caller to pass
77the variable argument list as a <<va_list>> object (initialized by
78<<va_start>>) rather than directly accepting a variable number of
79arguments.  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
83reentrant versions of the above.
84
85RETURNS
86The return values are consistent with the corresponding functions:
87
88PORTABILITY
89All of these functions are newlib extensions.
90
91Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
92<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
93*/
94
95#include <_ansi.h>
96#include <reent.h>
97#include <stdio.h>
98#include <stdarg.h>
99#include "local.h"
100
101#ifndef _REENT_ONLY
102
103int
104viprintf (const char *fmt,
105       va_list ap)
106{
107  struct _reent *reent = _REENT;
108
109  _REENT_SMALL_CHECK_INIT (reent);
110  return _vfiprintf_r (reent, _stdout_r (reent), fmt, ap);
111}
112
113#endif /* !_REENT_ONLY */
114
115int
116_viprintf_r (struct _reent *ptr,
117       const char *fmt,
118       va_list ap)
119{
120  _REENT_SMALL_CHECK_INIT (ptr);
121  return _vfiprintf_r (ptr, _stdout_r (ptr), fmt, ap);
122}
Note: See TracBrowser for help on using the repository browser.