Home | History | Annotate | Line # | Download | only in isc
      1 /*	$NetBSD: print.h,v 1.2 2024/08/18 20:47:14 christos Exp $	*/
      2 
      3 /*
      4  * Copyright (C) 2004-2007  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 #endif
     44 
     45 #if !defined(ISC_PLATFORM_NEEDSPRINTF) && defined(ISC__PRINT_SOURCE)
     46 #define ISC_PLATFORM_NEEDSPRINTF
     47 #endif
     48 
     49 /***
     50  *** Macros
     51  ***/
     52 #define ISC_PRINT_QUADFORMAT ISC_PLATFORM_QUADFORMAT
     53 
     54 /***
     55  *** Functions
     56  ***/
     57 
     58 #ifdef ISC_PLATFORM_NEEDVSNPRINTF
     59 #include <stdarg.h>
     60 #include <stddef.h>
     61 #endif
     62 #ifdef ISC_PLATFORM_NEEDSPRINTF
     63 #include <stdio.h>
     64 #endif
     65 
     66 
     67 ISC_LANG_BEGINDECLS
     68 
     69 #ifdef ISC_PLATFORM_NEEDVSNPRINTF
     70 int
     71 isc_print_vsnprintf(char *str, size_t size, const char *format, va_list ap)
     72      ISC_FORMAT_PRINTF(3, 0);
     73 #define vsnprintf isc_print_vsnprintf
     74 
     75 int
     76 isc_print_snprintf(char *str, size_t size, const char *format, ...)
     77      ISC_FORMAT_PRINTF(3, 4);
     78 #define snprintf isc_print_snprintf
     79 #endif /* ISC_PLATFORM_NEEDVSNPRINTF */
     80 
     81 #ifdef ISC_PLATFORM_NEEDSPRINTF
     82 int
     83 isc_print_sprintf(char *str, const char *format, ...) ISC_FORMAT_PRINTF(2, 3);
     84 #define sprintf isc_print_sprintf
     85 #endif
     86 
     87 ISC_LANG_ENDDECLS
     88 
     89 #endif /* ISC_PRINT_H */
     90