OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libc/] [stdio/] [siprintf.c] - Blame information for rev 853

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/*
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
<<siprintf>>, <<fiprintf>>, <<iprintf>>, <<sniprintf>>, <<asiprintf>>, <<asniprintf>>---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 <stdio.h>
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
        <<iprintf>>, <<fiprintf>>, <<siprintf>>, <<sniprintf>>,
73
        <<asiprintf>>, and <<asniprintf>> are the same as <<printf>>,
74
        <<fprintf>>, <<sprintf>>, <<snprintf>>, <<asprintf>>, and
75
        <<asnprintf>>, 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 <<printf>>, <<fprintf>>, <<sprintf>>, <<snprintf>>, <<asprintf>>,
84
and <<asnprintf>>.
85
 
86
PORTABILITY
87
<<iprintf>>, <<fiprintf>>, <<siprintf>>, <<sniprintf>>, <<asiprintf>>,
88
and <<asniprintf>> are newlib extensions.
89
 
90
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
91
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
92
*/
93
 
94
#include <_ansi.h>
95
#include <reent.h>
96
#include <stdio.h>
97
#ifdef _HAVE_STDC
98
#include <stdarg.h>
99
#else
100
#include <varargs.h>
101
#endif
102
#include <limits.h>
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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.