16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews/*
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Copyright (C) 1999-2001, 2003, 2004, 2007, 2010, 2016 Internet Systems Consortium, Inc. ("ISC")
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews *
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * This Source Code Form is subject to the terms of the Mozilla Public
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * License, v. 2.0. If a copy of the MPL was not distributed with this
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * file, You can obtain one at http://mozilla.org/MPL/2.0/.
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews */
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews
f428e385a4f7a42196b53de8e134909e8c488258Automatic Updater/* $Id: print_p.h,v 1.6 2010/08/16 23:46:52 tbox Exp $ */
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#ifndef LWRES_PRINT_P_H
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#define LWRES_PRINT_P_H 1
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews/***
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews *** Imports
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews ***/
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#include <lwres/lang.h>
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#include <lwres/platform.h>
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews/*
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews * This block allows lib/lwres/print.c to be cleanly compiled even if
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews * the platform does not need it. The standard Makefile will still
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews * not compile print.c or archive print.o, so this is just to make test
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews * compilation ("make print.o") easier.
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews */
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#if !defined(LWRES_PLATFORM_NEEDVSNPRINTF) && defined(LWRES__PRINT_SOURCE)
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#define LWRES_PLATFORM_NEEDVSNPRINTF
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#endif
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#if !defined(LWRES_PLATFORM_NEEDSPRINTF) && defined(LWRES__PRINT_SOURCE)
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#define LWRES_PLATFORM_NEEDSPRINTF
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#endif
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews/***
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews *** Macros.
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews ***/
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#ifdef __GNUC__
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#define LWRES_FORMAT_PRINTF(fmt, args) \
f428e385a4f7a42196b53de8e134909e8c488258Automatic Updater __attribute__((__format__(__printf__, fmt, args)))
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#else
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#define LWRES_FORMAT_PRINTF(fmt, args)
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#endif
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews/***
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews *** Functions
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews ***/
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#ifdef LWRES_PLATFORM_NEEDVSNPRINTF
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#include <stdarg.h>
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#include <stddef.h>
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#endif
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews
16a68807e13caea3183a41a5292f1b3f48b81a26Mark AndrewsLWRES_LANG_BEGINDECLS
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#ifdef LWRES_PLATFORM_NEEDVSNPRINTF
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrewsint
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrewslwres__print_vsnprintf(char *str, size_t size, const char *format, va_list ap)
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews LWRES_FORMAT_PRINTF(3, 0);
10f9e687f5824b41083c497adb4d0c54f965ebd6Mark Andrews#ifdef vsnprintf
10f9e687f5824b41083c497adb4d0c54f965ebd6Mark Andrews#undef vsnprintf
10f9e687f5824b41083c497adb4d0c54f965ebd6Mark Andrews#endif
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#define vsnprintf lwres__print_vsnprintf
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrewsint
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrewslwres__print_snprintf(char *str, size_t size, const char *format, ...)
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews LWRES_FORMAT_PRINTF(3, 4);
10f9e687f5824b41083c497adb4d0c54f965ebd6Mark Andrews#ifdef snprintf
10f9e687f5824b41083c497adb4d0c54f965ebd6Mark Andrews#undef snprintf
10f9e687f5824b41083c497adb4d0c54f965ebd6Mark Andrews#endif
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#define snprintf lwres__print_snprintf
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#endif /* LWRES_PLATFORM_NEEDVSNPRINTF */
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#ifdef LWRES_PLATFORM_NEEDSPRINTF
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrewsint
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrewslwres__print_sprintf(char *str, const char *format, ...) LWRES_FORMAT_PRINTF(2, 3);
10f9e687f5824b41083c497adb4d0c54f965ebd6Mark Andrews#ifdef sprintf
10f9e687f5824b41083c497adb4d0c54f965ebd6Mark Andrews#undef sprintf
10f9e687f5824b41083c497adb4d0c54f965ebd6Mark Andrews#endif
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#define sprintf lwres__print_sprintf
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#endif
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews
16a68807e13caea3183a41a5292f1b3f48b81a26Mark AndrewsLWRES_LANG_ENDDECLS
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews
16a68807e13caea3183a41a5292f1b3f48b81a26Mark Andrews#endif /* LWRES_PRINT_P_H */