/contrib/bind9/lib/lwres/print_p.h

https://bitbucket.org/freebsd/freebsd-head/ · C Header · 95 lines · 47 code · 16 blank · 32 comment · 2 complexity · bacb448301caa46233926f131d4ae907 MD5 · raw file

  1. /*
  2. * Copyright (C) 2004, 2007, 2010, 2012 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. /* $Id$ */
  18. #ifndef LWRES_PRINT_P_H
  19. #define LWRES_PRINT_P_H 1
  20. /***
  21. *** Imports
  22. ***/
  23. #include <lwres/lang.h>
  24. #include <lwres/platform.h>
  25. /*
  26. * This block allows lib/lwres/print.c to be cleanly compiled even if
  27. * the platform does not need it. The standard Makefile will still
  28. * not compile print.c or archive print.o, so this is just to make test
  29. * compilation ("make print.o") easier.
  30. */
  31. #if !defined(LWRES_PLATFORM_NEEDVSNPRINTF) && defined(LWRES__PRINT_SOURCE)
  32. #define LWRES_PLATFORM_NEEDVSNPRINTF
  33. #endif
  34. #if !defined(LWRES_PLATFORM_NEEDSPRINTF) && defined(LWRES__PRINT_SOURCE)
  35. #define LWRES_PLATFORM_NEEDSPRINTF
  36. #endif
  37. /***
  38. *** Macros.
  39. ***/
  40. #ifdef __GNUC__
  41. #define LWRES_FORMAT_PRINTF(fmt, args) \
  42. __attribute__((__format__(__printf__, fmt, args)))
  43. #else
  44. #define LWRES_FORMAT_PRINTF(fmt, args)
  45. #endif
  46. /***
  47. *** Functions
  48. ***/
  49. #ifdef LWRES_PLATFORM_NEEDVSNPRINTF
  50. #include <stdarg.h>
  51. #include <stddef.h>
  52. #endif
  53. LWRES_LANG_BEGINDECLS
  54. #ifdef LWRES_PLATFORM_NEEDVSNPRINTF
  55. int
  56. lwres__print_vsnprintf(char *str, size_t size, const char *format, va_list ap)
  57. LWRES_FORMAT_PRINTF(3, 0);
  58. #ifdef vsnprintf
  59. #undef vsnprintf
  60. #endif
  61. #define vsnprintf lwres__print_vsnprintf
  62. int
  63. lwres__print_snprintf(char *str, size_t size, const char *format, ...)
  64. LWRES_FORMAT_PRINTF(3, 4);
  65. #ifdef snprintf
  66. #undef snprintf
  67. #endif
  68. #define snprintf lwres__print_snprintf
  69. #endif /* LWRES_PLATFORM_NEEDVSNPRINTF */
  70. #ifdef LWRES_PLATFORM_NEEDSPRINTF
  71. int
  72. lwres__print_sprintf(char *str, const char *format, ...) LWRES_FORMAT_PRINTF(2, 3);
  73. #ifdef sprintf
  74. #undef sprintf
  75. #endif
  76. #define sprintf lwres__print_sprintf
  77. #endif
  78. LWRES_LANG_ENDDECLS
  79. #endif /* LWRES_PRINT_P_H */