xref: /minix/external/bsd/bind/dist/lib/lwres/print_p.h (revision bb9622b5)
1 /*	$NetBSD: print_p.h,v 1.4 2014/12/10 04:38:02 christos Exp $	*/
2 
3 /*
4  * Copyright (C) 2004, 2007, 2010  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_p.h,v 1.6 2010/08/16 23:46:52 tbox Exp  */
21 
22 #ifndef LWRES_PRINT_P_H
23 #define LWRES_PRINT_P_H 1
24 
25 /***
26  *** Imports
27  ***/
28 
29 #include <lwres/lang.h>
30 #include <lwres/platform.h>
31 
32 /*
33  * This block allows lib/lwres/print.c to be cleanly compiled even if
34  * the platform does not need it.  The standard Makefile will still
35  * not compile print.c or archive print.o, so this is just to make test
36  * compilation ("make print.o") easier.
37  */
38 #if !defined(LWRES_PLATFORM_NEEDVSNPRINTF) && defined(LWRES__PRINT_SOURCE)
39 #define LWRES_PLATFORM_NEEDVSNPRINTF
40 #endif
41 
42 #if !defined(LWRES_PLATFORM_NEEDSPRINTF) && defined(LWRES__PRINT_SOURCE)
43 #define LWRES_PLATFORM_NEEDSPRINTF
44 #endif
45 
46 /***
47  *** Macros.
48  ***/
49 
50 #ifdef __GNUC__
51 #define LWRES_FORMAT_PRINTF(fmt, args) \
52 	__attribute__((__format__(__printf__, fmt, args)))
53 #else
54 #define LWRES_FORMAT_PRINTF(fmt, args)
55 #endif
56 
57 /***
58  *** Functions
59  ***/
60 
61 #ifdef LWRES_PLATFORM_NEEDVSNPRINTF
62 #include <stdarg.h>
63 #include <stddef.h>
64 #endif
65 
66 LWRES_LANG_BEGINDECLS
67 
68 #ifdef LWRES_PLATFORM_NEEDVSNPRINTF
69 int
70 lwres__print_vsnprintf(char *str, size_t size, const char *format, va_list ap)
71      LWRES_FORMAT_PRINTF(3, 0);
72 #ifdef vsnprintf
73 #undef vsnprintf
74 #endif
75 #define vsnprintf lwres__print_vsnprintf
76 
77 int
78 lwres__print_snprintf(char *str, size_t size, const char *format, ...)
79      LWRES_FORMAT_PRINTF(3, 4);
80 #ifdef snprintf
81 #undef snprintf
82 #endif
83 #define snprintf lwres__print_snprintf
84 #endif /* LWRES_PLATFORM_NEEDVSNPRINTF */
85 
86 #ifdef LWRES_PLATFORM_NEEDSPRINTF
87 int
88 lwres__print_sprintf(char *str, const char *format, ...) LWRES_FORMAT_PRINTF(2, 3);
89 #ifdef sprintf
90 #undef sprintf
91 #endif
92 #define sprintf lwres__print_sprintf
93 #endif
94 
95 LWRES_LANG_ENDDECLS
96 
97 #endif /* LWRES_PRINT_P_H */
98