xref: /freebsd/sys/contrib/ncsw/etc/sprint.c (revision c2c014f24c10f90d85126ac5fbd4d8524de32b1c)
1*b171cc2cSJustin Hibbits /*
2*b171cc2cSJustin Hibbits  * Copyright 2008-2012 Freescale Semiconductor Inc.
3*b171cc2cSJustin Hibbits  *
4*b171cc2cSJustin Hibbits  * Redistribution and use in source and binary forms, with or without
5*b171cc2cSJustin Hibbits  * modification, are permitted provided that the following conditions are met:
6*b171cc2cSJustin Hibbits  *     * Redistributions of source code must retain the above copyright
7*b171cc2cSJustin Hibbits  *       notice, this list of conditions and the following disclaimer.
8*b171cc2cSJustin Hibbits  *     * Redistributions in binary form must reproduce the above copyright
9*b171cc2cSJustin Hibbits  *       notice, this list of conditions and the following disclaimer in the
10*b171cc2cSJustin Hibbits  *       documentation and/or other materials provided with the distribution.
11*b171cc2cSJustin Hibbits  *     * Neither the name of Freescale Semiconductor nor the
12*b171cc2cSJustin Hibbits  *       names of its contributors may be used to endorse or promote products
13*b171cc2cSJustin Hibbits  *       derived from this software without specific prior written permission.
14*b171cc2cSJustin Hibbits  *
15*b171cc2cSJustin Hibbits  *
16*b171cc2cSJustin Hibbits  * ALTERNATIVELY, this software may be distributed under the terms of the
17*b171cc2cSJustin Hibbits  * GNU General Public License ("GPL") as published by the Free Software
18*b171cc2cSJustin Hibbits  * Foundation, either version 2 of that License or (at your option) any
19*b171cc2cSJustin Hibbits  * later version.
20*b171cc2cSJustin Hibbits  *
21*b171cc2cSJustin Hibbits  * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
22*b171cc2cSJustin Hibbits  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23*b171cc2cSJustin Hibbits  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24*b171cc2cSJustin Hibbits  * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
25*b171cc2cSJustin Hibbits  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26*b171cc2cSJustin Hibbits  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27*b171cc2cSJustin Hibbits  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28*b171cc2cSJustin Hibbits  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29*b171cc2cSJustin Hibbits  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30*b171cc2cSJustin Hibbits  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31*b171cc2cSJustin Hibbits  */
32*b171cc2cSJustin Hibbits 
33*b171cc2cSJustin Hibbits 
34*b171cc2cSJustin Hibbits /*------------------------------------------------------*/
35*b171cc2cSJustin Hibbits /* File: sprint.c                                       */
36*b171cc2cSJustin Hibbits /*                                                      */
37*b171cc2cSJustin Hibbits /* Description:                                         */
38*b171cc2cSJustin Hibbits /*    Debug routines (externals)                        */
39*b171cc2cSJustin Hibbits /*------------------------------------------------------*/
40*b171cc2cSJustin Hibbits #include "string_ext.h"
41*b171cc2cSJustin Hibbits #include "stdlib_ext.h"
42*b171cc2cSJustin Hibbits #include "stdarg_ext.h"
43*b171cc2cSJustin Hibbits #include "sprint_ext.h"
44*b171cc2cSJustin Hibbits #include "std_ext.h"
45*b171cc2cSJustin Hibbits #include "xx_ext.h"
46*b171cc2cSJustin Hibbits 
47*b171cc2cSJustin Hibbits 
Sprint(char * buf,const char * fmt,...)48*b171cc2cSJustin Hibbits int Sprint(char * buf, const char *fmt, ...)
49*b171cc2cSJustin Hibbits {
50*b171cc2cSJustin Hibbits     va_list args;
51*b171cc2cSJustin Hibbits     int i;
52*b171cc2cSJustin Hibbits 
53*b171cc2cSJustin Hibbits     va_start(args, fmt);
54*b171cc2cSJustin Hibbits     i=vsprintf(buf,fmt,args);
55*b171cc2cSJustin Hibbits     va_end(args);
56*b171cc2cSJustin Hibbits     return i;
57*b171cc2cSJustin Hibbits }
58*b171cc2cSJustin Hibbits 
Snprint(char * buf,uint32_t size,const char * fmt,...)59*b171cc2cSJustin Hibbits int Snprint(char * buf, uint32_t size, const char *fmt, ...)
60*b171cc2cSJustin Hibbits {
61*b171cc2cSJustin Hibbits     va_list args;
62*b171cc2cSJustin Hibbits     int i;
63*b171cc2cSJustin Hibbits 
64*b171cc2cSJustin Hibbits     va_start(args, fmt);
65*b171cc2cSJustin Hibbits     i=vsnprintf(buf,size,fmt,args);
66*b171cc2cSJustin Hibbits     va_end(args);
67*b171cc2cSJustin Hibbits     return i;
68*b171cc2cSJustin Hibbits }
69*b171cc2cSJustin Hibbits 
70*b171cc2cSJustin Hibbits #ifndef NCSW_VXWORKS
Sscan(const char * buf,const char * fmt,...)71*b171cc2cSJustin Hibbits int Sscan(const char * buf, const char * fmt, ...)
72*b171cc2cSJustin Hibbits {
73*b171cc2cSJustin Hibbits     va_list args;
74*b171cc2cSJustin Hibbits     int i;
75*b171cc2cSJustin Hibbits 
76*b171cc2cSJustin Hibbits     va_start(args,fmt);
77*b171cc2cSJustin Hibbits     i = vsscanf(buf,fmt,args);
78*b171cc2cSJustin Hibbits     va_end(args);
79*b171cc2cSJustin Hibbits     return i;
80*b171cc2cSJustin Hibbits }
81*b171cc2cSJustin Hibbits #endif /* NCSW_VXWORKS */
82