]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - contrib/bind9/lib/isc/include/isc/print.h
MFC r363988:
[FreeBSD/stable/9.git] / contrib / bind9 / lib / isc / include / isc / print.h
1 /*
2  * Copyright (C) 2004-2007, 2014, 2015  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 1999-2001, 2003  Internet Software Consortium.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15  * PERFORMANCE OF THIS SOFTWARE.
16  */
17
18 #ifndef ISC_PRINT_H
19 #define ISC_PRINT_H 1
20
21 /*! \file isc/print.h */
22
23 /***
24  *** Imports
25  ***/
26
27 #include <isc/formatcheck.h>    /* Required for ISC_FORMAT_PRINTF() macro. */
28 #include <isc/lang.h>
29 #include <isc/platform.h>
30
31 /*!
32  * This block allows lib/isc/print.c to be cleanly compiled even if
33  * the platform does not need it.  The standard Makefile will still
34  * not compile print.c or archive print.o, so this is just to make test
35  * compilation ("make print.o") easier.
36  */
37 #if !defined(ISC_PLATFORM_NEEDVSNPRINTF) && defined(ISC__PRINT_SOURCE)
38 #define ISC_PLATFORM_NEEDVSNPRINTF
39 #undef snprintf
40 #undef vsnprintf
41 #endif
42
43 #if !defined(ISC_PLATFORM_NEEDSPRINTF) && defined(ISC__PRINT_SOURCE)
44 #define ISC_PLATFORM_NEEDSPRINTF
45 #undef sprintf
46 #endif
47
48 #if !defined(ISC_PLATFORM_NEEDFPRINTF) && defined(ISC__PRINT_SOURCE)
49 #define ISC_PLATFORM_NEEDFPRINTF
50 #undef fprintf
51 #endif
52
53 #if !defined(ISC_PLATFORM_NEEDPRINTF) && defined(ISC__PRINT_SOURCE)
54 #define ISC_PLATFORM_NEEDPRINTF
55 #undef printf
56 #endif
57
58 /***
59  *** Macros
60  ***/
61 #define ISC_PRINT_QUADFORMAT ISC_PLATFORM_QUADFORMAT
62
63 /***
64  *** Functions
65  ***/
66
67 #ifdef ISC_PLATFORM_NEEDVSNPRINTF
68 #include <stdarg.h>
69 #include <stddef.h>
70 #endif
71
72 #include <stdio.h>
73
74 ISC_LANG_BEGINDECLS
75
76 #ifdef ISC_PLATFORM_NEEDVSNPRINTF
77 int
78 isc_print_vsnprintf(char *str, size_t size, const char *format, va_list ap)
79      ISC_FORMAT_PRINTF(3, 0);
80 #undef vsnprintf
81 #define vsnprintf isc_print_vsnprintf
82
83 int
84 isc_print_snprintf(char *str, size_t size, const char *format, ...)
85      ISC_FORMAT_PRINTF(3, 4);
86 #undef snprintf
87 #define snprintf isc_print_snprintf
88 #endif /* ISC_PLATFORM_NEEDVSNPRINTF */
89
90 #ifdef ISC_PLATFORM_NEEDSPRINTF
91 int
92 isc_print_sprintf(char *str, const char *format, ...) ISC_FORMAT_PRINTF(2, 3);
93 #undef sprintf
94 #define sprintf isc_print_sprintf
95 #endif
96
97 #ifdef ISC_PLATFORM_NEEDPRINTF
98 int
99 isc_print_printf(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);
100 #undef printf
101 #define printf isc_print_printf
102 #endif
103
104 #ifdef ISC_PLATFORM_NEEDFPRINTF
105 int
106 isc_print_fprintf(FILE * fp, const char *format, ...) ISC_FORMAT_PRINTF(2, 3);
107 #undef fprintf
108 #define fprintf isc_print_fprintf
109 #endif
110
111 ISC_LANG_ENDDECLS
112
113 #endif /* ISC_PRINT_H */