strusBase  0.17
snprintf.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Patrick P. Frey
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7  */
8 /* \brief Simple implementation of snprintf only supporing a small subset of format characters that is guaranteed not to use malloc
9 * We need this function because we want to print error messages in an exception context without using malloc because we might not have memory available anymore (std::bad_alloc)
10 */
11 #ifndef _STRUS_BASE_SNPRINTF_HPP_INCLUDED
12 #define _STRUS_BASE_SNPRINTF_HPP_INCLUDED
13 #include <stdlib.h>
14 #include <stdarg.h>
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 extern int strus_vsnprintf( char* buf, size_t bufsize, const char* format, va_list arg);
21 extern int strus_snprintf( char* buf, size_t bufsize, const char* format, ...);
22 
23 #ifdef __cplusplus
24 }
25 #endif
26 #endif
int strus_snprintf(char *buf, size_t bufsize, const char *format,...)
int strus_vsnprintf(char *buf, size_t bufsize, const char *format, va_list arg)