Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
asprintf-compat.h
Go to the documentation of this file.
1/*
2 * The MIT License (MIT)
3 *
4 * Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24#ifndef CRITERION_ASPRINTF_COMPAT_H_
25#define CRITERION_ASPRINTF_COMPAT_H_
26
27#ifdef __cplusplus
28# include <cstdarg>
29#else
30# include <stdarg.h>
31#endif
32
33#include <stddef.h>
34
35#include "common.h"
36
37/* MinGW makes the distinction between the printf and gnu_printf archetypes,
38 because they provide a C99-compliant implementation of printf when
39 the __USE_MINGW_ANSI_STDIO macro is defined. Since cr_asprintf calls
40 the vsnprintf function and is compiled in libcriterion, we need to make
41 the choice of which printf function to use.
42
43 Naturally, we use the C99-compliant implementation. */
44#ifdef __MINGW32__
45# define CRI_PRINTF_FORMAT gnu_printf
46#else
47# define CRI_PRINTF_FORMAT printf
48#endif
49
51
53CR_API int cr_asprintf(char **strp, const char *fmt, ...);
54CR_API int cr_vasprintf(char **strp, const char *fmt, va_list ap);
55CR_API void cr_asprintf_free(char *buf);
56
57CR_API int cri_fmt_bprintf(char **buf, size_t *offset, size_t *sz,
58 const char *fmt, ...);
59CR_API int cri_fmt_vbprintf(char **buf, size_t *offset, size_t *sz,
60 const char *fmt, va_list ap);
61
62CR_API char *cri_strtok_r(char *str, const char *delim, char **saveptr);
63
65
66#endif /* !CRITERION_ASPRINTF_COMPAT_H_ */
CR_API int cri_fmt_bprintf(char **buf, size_t *offset, size_t *sz, const char *fmt,...)
#define CRI_PRINTF_FORMAT
CR_API char * cri_strtok_r(char *str, const char *delim, char **saveptr)
CR_BEGIN_C_API CR_API int cr_asprintf(char **strp, const char *fmt,...)
CR_API void cr_asprintf_free(char *buf)
CR_API int cr_vasprintf(char **strp, const char *fmt, va_list ap)
CR_API int cri_fmt_vbprintf(char **buf, size_t *offset, size_t *sz, const char *fmt, va_list ap)
#define CR_BEGIN_C_API
Definition common.h:54
#define CR_API
Definition common.h:128
#define CR_FORMAT(Archetype, Index, Ftc)
Definition common.h:105
#define CR_END_C_API
Definition common.h:55