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