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