1 /*
2  *  Copyright (C) 2013-2022 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
3  *  Copyright (C) 2009-2013 Sourcefire, Inc.
4  *
5  *  Authors: aCaB <acab@clamav.net>
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License version 2 as
9  *  published by the Free Software Foundation.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19  *  MA 02110-1301, USA.
20  */
21 
22 #if HAVE_CONFIG_H
23 #include "clamav-config.h"
24 #endif
25 
26 #include <stdio.h>
27 #include <stdarg.h>
28 #include <errno.h>
29 #include "snprintf.h"
30 
31 #ifndef HAVE_SNPRINTF
32 
snprintf(char * str,size_t size,const char * format,...)33 int snprintf(char *str, size_t size, const char *format, ...)
34 {
35     va_list va;
36     int len;
37 
38     va_start(va, format);
39     errno = 0;
40     len   = vsnprintf(str, size, format, va);
41     if (len == -1 && errno == ERANGE)
42         len = size;
43     va_end(va);
44     return len;
45 }
46 
47 #endif
48