xref: /netbsd-src/sys/lib/libsa/snprintf.c (revision 3eb244d801190b3a7d8cd42193c38a77c1dbae1a)
1*3eb244d8Sjoerg /*	$NetBSD: snprintf.c,v 1.5 2011/07/17 20:54:52 joerg Exp $	*/
2bae33b3aSpk 
3bae33b3aSpk /*-
4bae33b3aSpk  * Copyright (c) 1993
5bae33b3aSpk  *	The Regents of the University of California.  All rights reserved.
6bae33b3aSpk  *
7bae33b3aSpk  * Redistribution and use in source and binary forms, with or without
8bae33b3aSpk  * modification, are permitted provided that the following conditions
9bae33b3aSpk  * are met:
10bae33b3aSpk  * 1. Redistributions of source code must retain the above copyright
11bae33b3aSpk  *    notice, this list of conditions and the following disclaimer.
12bae33b3aSpk  * 2. Redistributions in binary form must reproduce the above copyright
13bae33b3aSpk  *    notice, this list of conditions and the following disclaimer in the
14bae33b3aSpk  *    documentation and/or other materials provided with the distribution.
15aad01611Sagc  * 3. Neither the name of the University nor the names of its contributors
16bae33b3aSpk  *    may be used to endorse or promote products derived from this software
17bae33b3aSpk  *    without specific prior written permission.
18bae33b3aSpk  *
19bae33b3aSpk  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20bae33b3aSpk  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21bae33b3aSpk  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22bae33b3aSpk  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23bae33b3aSpk  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24bae33b3aSpk  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25bae33b3aSpk  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26bae33b3aSpk  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27bae33b3aSpk  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28bae33b3aSpk  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29bae33b3aSpk  * SUCH DAMAGE.
30bae33b3aSpk  *
31bae33b3aSpk  *	@(#)printf.c	8.1 (Berkeley) 6/11/93
32bae33b3aSpk  */
33bae33b3aSpk 
34bae33b3aSpk #include <sys/cdefs.h>
35bae33b3aSpk #include <sys/types.h>
36*3eb244d8Sjoerg #include <sys/stdarg.h>
37bae33b3aSpk 
38bae33b3aSpk #include "stand.h"
39bae33b3aSpk 
40bae33b3aSpk int
snprintf(char * buf,size_t size,const char * fmt,...)41bae33b3aSpk snprintf(char *buf, size_t size, const char *fmt, ...)
42bae33b3aSpk {
43bae33b3aSpk 	va_list ap;
44bae33b3aSpk 	int len;
45bae33b3aSpk 
46bae33b3aSpk 	va_start(ap, fmt);
47bae33b3aSpk 	len = vsnprintf(buf, size, fmt, ap);
48bae33b3aSpk 	va_end(ap);
491c038e68Sisaki 	return len;
50bae33b3aSpk }
51