print.h revision 290001
1/*
2 * Copyright (C) 2004-2007  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/* $Id: print.h,v 1.26 2007/06/19 23:47:18 tbox Exp $ */
19
20#ifndef ISC_PRINT_H
21#define ISC_PRINT_H 1
22
23/*! \file isc/print.h */
24
25/***
26 *** Imports
27 ***/
28
29#include <isc/formatcheck.h>    /* Required for ISC_FORMAT_PRINTF() macro. */
30#include <isc/lang.h>
31#include <isc/platform.h>
32
33/*!
34 * This block allows lib/isc/print.c to be cleanly compiled even if
35 * the platform does not need it.  The standard Makefile will still
36 * not compile print.c or archive print.o, so this is just to make test
37 * compilation ("make print.o") easier.
38 */
39#if !defined(ISC_PLATFORM_NEEDVSNPRINTF) && defined(ISC__PRINT_SOURCE)
40#define ISC_PLATFORM_NEEDVSNPRINTF
41#endif
42
43#if !defined(ISC_PLATFORM_NEEDSPRINTF) && defined(ISC__PRINT_SOURCE)
44#define ISC_PLATFORM_NEEDSPRINTF
45#endif
46
47/***
48 *** Macros
49 ***/
50#define ISC_PRINT_QUADFORMAT ISC_PLATFORM_QUADFORMAT
51
52/***
53 *** Functions
54 ***/
55
56#ifdef ISC_PLATFORM_NEEDVSNPRINTF
57#include <stdarg.h>
58#include <stddef.h>
59#endif
60#ifdef ISC_PLATFORM_NEEDSPRINTF
61#include <stdio.h>
62#endif
63
64
65ISC_LANG_BEGINDECLS
66
67#ifdef ISC_PLATFORM_NEEDVSNPRINTF
68int
69isc_print_vsnprintf(char *str, size_t size, const char *format, va_list ap)
70     ISC_FORMAT_PRINTF(3, 0);
71#define vsnprintf isc_print_vsnprintf
72
73int
74isc_print_snprintf(char *str, size_t size, const char *format, ...)
75     ISC_FORMAT_PRINTF(3, 4);
76#define snprintf isc_print_snprintf
77#endif /* ISC_PLATFORM_NEEDVSNPRINTF */
78
79#ifdef ISC_PLATFORM_NEEDSPRINTF
80int
81isc_print_sprintf(char *str, const char *format, ...) ISC_FORMAT_PRINTF(2, 3);
82#define sprintf isc_print_sprintf
83#endif
84
85ISC_LANG_ENDDECLS
86
87#endif /* ISC_PRINT_H */
88