Subversion Repositories Kolibri OS

Rev

Rev 4872 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4349 Serge 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
/*
19
FUNCTION
20
<>, <>, <>, <>, <>, <>---format output (integer only)
21
 
22
INDEX
23
	fiprintf
24
INDEX
25
	_fiprintf_r
26
INDEX
27
	iprintf
28
INDEX
29
	_iprintf_r
30
INDEX
31
	siprintf
32
INDEX
33
	_siprintf_r
34
INDEX
35
	sniprintf
36
INDEX
37
	_sniprintf_r
38
INDEX
39
	asiprintf
40
INDEX
41
	_asiprintf_r
42
INDEX
43
	asniprintf
44
INDEX
45
	_asniprintf_r
46
 
47
ANSI_SYNOPSIS
48
        #include 
49
 
50
        int iprintf(const char *<[format]>, ...);
51
        int fiprintf(FILE *<[fd]>, const char *<[format]> , ...);
52
        int siprintf(char *<[str]>, const char *<[format]>, ...);
53
        int sniprintf(char *<[str]>, size_t <[size]>, const char *<[format]>,
54
			...);
55
        int asiprintf(char **<[strp]>, const char *<[format]>, ...);
56
        char *asniprintf(char *<[str]>, size_t *<[size]>,
57
			const char *<[format]>, ...);
58
 
59
        int _iprintf_r(struct _reent *<[ptr]>, const char *<[format]>, ...);
60
        int _fiprintf_r(struct _reent *<[ptr]>, FILE *<[fd]>,
61
                        const char *<[format]>, ...);
62
        int _siprintf_r(struct _reent *<[ptr]>, char *<[str]>,
63
                        const char *<[format]>, ...);
64
        int _sniprintf_r(struct _reent *<[ptr]>, char *<[str]>, size_t <[size]>,
65
                         const char *<[format]>, ...);
66
        int _asiprintf_r(struct _reent *<[ptr]>, char **<[strp]>,
67
                         const char *<[format]>, ...);
68
        char *_asniprintf_r(struct _reent *<[ptr]>, char *<[str]>,
69
                            size_t *<[size]>, const char *<[format]>, ...);
70
 
71
DESCRIPTION
72
        <>, <>, <>, <>,
73
        <>, and <> are the same as <>,
74
        <>, <>, <>, <>, and
75
        <>, respectively, except that they restrict usage
76
        to non-floating-point format specifiers.
77
 
78
        <<_iprintf_r>>, <<_fiprintf_r>>, <<_asiprintf_r>>,
79
        <<_siprintf_r>>, <<_sniprintf_r>>, <<_asniprintf_r>> are
80
        simply reentrant versions of the functions above.
81
 
82
RETURNS
83
Similar to <>, <>, <>, <>, <>,
84
and <>.
85
 
86
PORTABILITY
87
<>, <>, <>, <>, <>,
88
and <> are newlib extensions.
89
 
90
Supporting OS subroutines required: <>, <>, <>,
91
<>, <>, <>, <>.
92
*/
93
 
94
#include <_ansi.h>
95
#include 
96
#include 
97
#ifdef _HAVE_STDC
98
#include 
99
#else
100
#include 
101
#endif
102
#include 
103
#include "local.h"
104
 
105
int
106
#ifdef _HAVE_STDC
107
_DEFUN(_siprintf_r, (ptr, str, fmt),
108
       struct _reent *ptr _AND
109
       char *str          _AND
110
       _CONST char *fmt _DOTS)
111
#else
112
_siprintf_r(ptr, str, fmt, va_alist)
113
           struct _reent *ptr;
114
           char *str;
115
           _CONST char *fmt;
116
           va_dcl
117
#endif
118
{
119
  int ret;
120
  va_list ap;
121
  FILE f;
122
 
123
  f._flags = __SWR | __SSTR;
124
  f._bf._base = f._p = (unsigned char *) str;
125
  f._bf._size = f._w = INT_MAX;
126
  f._file = -1;  /* No file. */
127
#ifdef _HAVE_STDC
128
  va_start (ap, fmt);
129
#else
130
  va_start (ap);
131
#endif
132
  ret = _svfiprintf_r (ptr, &f, fmt, ap);
133
  va_end (ap);
134
  *f._p = 0;
135
  return (ret);
136
}
137
 
138
#ifndef _REENT_ONLY
139
 
140
int
141
#ifdef _HAVE_STDC
142
_DEFUN(siprintf, (str, fmt),
143
       char *str _AND
144
       _CONST char *fmt _DOTS)
145
#else
146
siprintf(str, fmt, va_alist)
147
        char *str;
148
        _CONST char *fmt;
149
        va_dcl
150
#endif
151
{
152
  int ret;
153
  va_list ap;
154
  FILE f;
155
 
156
  f._flags = __SWR | __SSTR;
157
  f._bf._base = f._p = (unsigned char *) str;
158
  f._bf._size = f._w = INT_MAX;
159
  f._file = -1;  /* No file. */
160
#ifdef _HAVE_STDC
161
  va_start (ap, fmt);
162
#else
163
  va_start (ap);
164
#endif
165
  ret = _svfiprintf_r (_REENT, &f, fmt, ap);
166
  va_end (ap);
167
  *f._p = 0;
168
  return (ret);
169
}
170
 
171
#endif