23ad9bb77f482ca1329a73e58d6e62e2c0aa1bd5
[yaz-moved-to-github.git] / src / snprintf.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) 1995-2009 Index Data
3  * See the file LICENSE for details.
4  */
5 /**
6  * \file snprintf.c
7  * \brief snprintf wrapper
8  */
9
10 #include <stdlib.h>
11 #include <stdarg.h>
12 #include <yaz/snprintf.h>
13
14 void yaz_vsnprintf(char *buf, size_t size, const char *fmt, va_list ap)
15 {
16 #if HAVE_VSNPRINTF
17     vsnprintf(buf, size, fmt, ap);
18 #else
19 #ifdef WIN32
20     _vsnprintf(buf, size-1, fmt, ap);
21     buf[size-1] = '\0';
22 #else
23     vsprintf(buf, fmt, ap);
24 #endif
25 #endif
26 }
27
28 void yaz_snprintf(char *buf, size_t size, const char *fmt, ...)
29 {
30     va_list ap;
31     va_start(ap, fmt);
32     yaz_vsnprintf(buf, size, fmt, ap);
33     va_end(ap);
34 }
35
36 /*
37  * Local variables:
38  * c-basic-offset: 4
39  * indent-tabs-mode: nil
40  * End:
41  * vim: shiftwidth=4 tabstop=8 expandtab
42  */
43