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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib-1.10.0/] [newlib/] [libc/] [stdio/] [vsnprintf.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
/* doc in vfprintf.c */
2
 
3
/* This code created by modifying vsprintf.c so copyright inherited. */
4
 
5
/*
6
 * Copyright (c) 1990 The Regents of the University of California.
7
 * All rights reserved.
8
 *
9
 * Redistribution and use in source and binary forms are permitted
10
 * provided that the above copyright notice and this paragraph are
11
 * duplicated in all such forms and that any documentation,
12
 * advertising materials, and other materials related to such
13
 * distribution and use acknowledge that the software was developed
14
 * by the University of California, Berkeley.  The name of the
15
 * University may not be used to endorse or promote products derived
16
 * from this software without specific prior written permission.
17
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
18
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
19
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20
 */
21
 
22
#if defined(LIBC_SCCS) && !defined(lint)
23
static char sccsid[] = "%W% (Berkeley) %G%";
24
#endif /* LIBC_SCCS and not lint */
25
 
26
#include <_ansi.h>
27
#include <reent.h>
28
#include <stdio.h>
29
#include <limits.h>
30
#ifdef _HAVE_STDC
31
#include <stdarg.h>
32
#else
33
#include <varargs.h>
34
#endif
35
 
36
int
37
_DEFUN (vsnprintf, (str, size, fmt, ap),
38
     char *str _AND
39
     size_t size _AND
40
     _CONST char *fmt _AND
41
     va_list ap)
42
{
43
  int ret;
44
  FILE f;
45
 
46
  f._flags = __SWR | __SSTR;
47
  f._bf._base = f._p = (unsigned char *) str;
48
  f._bf._size = f._w = (size > 0 ? size - 1 : 0);
49
  f._data = _REENT;
50
  ret = vfprintf (&f, fmt, ap);
51
  if (size > 0)
52
    *f._p = 0;
53
  return ret;
54
}
55
 
56
int
57
_DEFUN (_vsnprintf_r, (ptr, str, size, fmt, ap),
58
     struct _reent *ptr _AND
59
     char *str _AND
60
     size_t size _AND
61
     _CONST char *fmt _AND
62
     va_list ap)
63
{
64
  int ret;
65
  FILE f;
66
 
67
  f._flags = __SWR | __SSTR;
68
  f._bf._base = f._p = (unsigned char *) str;
69
  f._bf._size = f._w = (size > 0 ? size - 1 : 0);
70
  f._data = ptr;
71
  ret = _vfprintf_r (ptr, &f, fmt, ap);
72
  if (size > 0)
73
    *f._p = 0;
74
  return ret;
75
}

powered by: WebSVN 2.1.0

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