From 9550eb2dab1d03e03e6c060f92e655d47ac1fc1b Mon Sep 17 00:00:00 2001 From: Michael Graff Date: Mon, 19 Jun 2000 21:45:05 +0000 Subject: [PATCH] add formatcheck.h --- lib/isc/include/isc/Makefile.in | 3 ++- lib/isc/include/isc/formatcheck.h | 32 +++++++++++++++++++++++++++++++ lib/isc/include/isc/log.h | 14 ++------------ lib/isc/include/isc/print.h | 7 +++++-- 4 files changed, 41 insertions(+), 15 deletions(-) create mode 100644 lib/isc/include/isc/formatcheck.h diff --git a/lib/isc/include/isc/Makefile.in b/lib/isc/include/isc/Makefile.in index 7295ba1dd5..94c92efa14 100644 --- a/lib/isc/include/isc/Makefile.in +++ b/lib/isc/include/isc/Makefile.in @@ -24,7 +24,8 @@ top_srcdir = @top_srcdir@ # HEADERS = assertions.h base64.h bitstring.h boolean.h buffer.h \ bufferlist.h commandline.h error.h event.h eventclass.h \ - file.h heap.h interfaceiter.h @ISC_IPV6_H@ lang.h lex.h \ + file.h formatcheck.h heap.h interfaceiter.h \ + @ISC_IPV6_H@ lang.h lex.h \ lfsr.h lib.h list.h log.h magic.h md5.h mem.h msgcat.h \ mutexblock.h netaddr.h ondestroy.h platform.h \ print.h quota.h random.h ratelimiter.h region.h \ diff --git a/lib/isc/include/isc/formatcheck.h b/lib/isc/include/isc/formatcheck.h new file mode 100644 index 0000000000..2e0e21f12b --- /dev/null +++ b/lib/isc/include/isc/formatcheck.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 1999, 2000 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#ifndef ISC_FORMATCHECK_H +#define ISC_FORMATCHECK_H 1 + +/* + * fmt is the location of the format string parameter. + * args is the location of the first argument (or 0 for no argument checking). + * Note: the first parameter is 1, not 0. + */ +#ifdef __GNUC__ +#define ISC_FORMAT_PRINTF(fmt, args) __attribute__((__format__(__printf__, fmt, args))) +#else +#define ISC_FORMAT_PRINTF(fmt, args) +#endif + +#endif /* ISC_FORMATCHECK_H */ diff --git a/lib/isc/include/isc/log.h b/lib/isc/include/isc/log.h index 3a16800a65..091c763371 100644 --- a/lib/isc/include/isc/log.h +++ b/lib/isc/include/isc/log.h @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: log.h,v 1.24 2000/06/19 19:18:45 tale Exp $ */ +/* $Id: log.h,v 1.25 2000/06/19 21:45:03 explorer Exp $ */ #ifndef ISC_LOG_H #define ISC_LOG_H 1 @@ -24,22 +24,12 @@ #include #include /* XXXDCL NT */ +#include #include #include ISC_LANG_BEGINDECLS -/* - * fmt is the location of the format string parameter. - * args is the location of the first argument (or 0 for no argument checking). - * Note: the first parameter is 1, not 0. - */ -#ifdef __GNUC__ -#define ISC_FORMAT_PRINTF(fmt, args) __attribute__((format(printf, fmt, args))) -#else -#define ISC_FORMAT_PRINTF(fmt, args) -#endif - /* * Severity levels, patterned after Unix's syslog levels. * diff --git a/lib/isc/include/isc/print.h b/lib/isc/include/isc/print.h index 199637359f..c976c4581d 100644 --- a/lib/isc/include/isc/print.h +++ b/lib/isc/include/isc/print.h @@ -22,6 +22,7 @@ *** Imports ***/ +#include #include #include @@ -36,11 +37,13 @@ ISC_LANG_BEGINDECLS int -isc_print_vsnprintf(char *str, size_t size, const char *format, va_list ap); +isc_print_vsnprintf(char *str, size_t size, const char *format, va_list ap) + ISC_FORMAT_PRINTF(3, 0); #define vsnprintf isc_print_vsnprintf int -isc_print_snprintf(char *str, size_t size, const char *format, ...); +isc_print_snprintf(char *str, size_t size, const char *format, ...) + ISC_FORMAT_PRINTF(3, 4); #define snprintf isc_print_snprintf ISC_LANG_ENDDECLS