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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib-1.10.0/] [newlib/] [libc/] [stdio/] [siprintf.c] - Blame information for rev 1773

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

Line No. Rev Author Line
1 1010 ivang
/*
2
FUNCTION
3
        <<siprintf>>---write formatted output (integer only)
4
INDEX
5
        siprintf
6
 
7
ANSI_SYNOPSIS
8
        #include <stdio.h>
9
 
10
        int siprintf(char *<[str]>, const char *<[format]> [, <[arg]>, ...]);
11
 
12
 
13
DESCRIPTION
14
<<siprintf>> is a restricted version of <<sprintf>>: it has the same
15
arguments and behavior, save that it cannot perform any floating-point
16
formatting: the <<f>>, <<g>>, <<G>>, <<e>>, and <<F>> type specifiers
17
are not recognized.
18
 
19
RETURNS
20
        <<siprintf>> returns the number of bytes in the output string,
21
        save that the concluding <<NULL>> is not counted.
22
        <<siprintf>> returns when the end of the format string is
23
        encountered.
24
 
25
PORTABILITY
26
<<siprintf>> is not required by ANSI C.
27
 
28
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
29
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
30
*/
31
 
32
#include <stdio.h>
33
#ifdef _HAVE_STDC
34
#include <stdarg.h>
35
#else
36
#include <varargs.h>
37
#endif
38
#include <limits.h>
39
#include <_ansi.h>
40
#include <reent.h>
41
#include "local.h"
42
 
43
int
44
#ifdef _HAVE_STDC
45
_DEFUN (siprintf, (str, fmt), char *str _AND _CONST char *fmt _DOTS)
46
#else
47
siprintf (str, fmt, va_alist)
48
     char *str;
49
     _CONST char *fmt;
50
     va_dcl
51
#endif
52
{
53
  int ret;
54
  va_list ap;
55
  FILE f;
56
 
57
  f._flags = __SWR | __SSTR;
58
  f._bf._base = f._p = (unsigned char *) str;
59
  f._bf._size = f._w = INT_MAX;
60
  f._data = _REENT;
61
#ifdef _HAVE_STDC
62
  va_start (ap, fmt);
63
#else
64
  va_start (ap);
65
#endif
66
  ret = vfiprintf (&f, fmt, ap);
67
  va_end (ap);
68
  *f._p = 0;
69
  return (ret);
70
}

powered by: WebSVN 2.1.0

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