X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/5aff007d8fcfb4c6cc3c3627ae15f45562db7a0d..af21fb6be8e226ce86b47ed923ee124e739ca48c:/lib/disorder.h diff --git a/lib/disorder.h b/lib/disorder.h index 856f0a3..9fde2d8 100644 --- a/lib/disorder.h +++ b/lib/disorder.h @@ -2,20 +2,18 @@ * This file is part of DisOrder. * Copyright (C) 2004-2008 Richard Kettlewell * - * This program is free software; you can redistribute it and/or modify + * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA + * along with this program. If not, see . */ #ifndef DISORDER_H @@ -27,6 +25,12 @@ extern "C" { #endif +#ifdef __GNUC__ +# define DISORDER_IFGNUC(x) x +#else +# define DISORDER_IFGNUC(x) +#endif + /* memory allocation **********************************************************/ void *disorder_malloc(size_t); @@ -49,34 +53,24 @@ char *disorder_strndup(const char *, size_t); * {xmalloc,xrealloc}_noptr don't promise to clear the new space */ -#ifdef __GNUC__ - int disorder_snprintf(char buffer[], size_t bufsize, const char *fmt, ...) - __attribute__((format (printf, 3, 4))); + DISORDER_IFGNUC(__attribute__((format (printf, 3, 4)))); /* like snprintf */ int disorder_asprintf(char **rp, const char *fmt, ...) - __attribute__((format (printf, 2, 3))); + DISORDER_IFGNUC(__attribute__((format (printf, 2, 3)))); /* like asprintf but uses xmalloc_noptr() */ -#else - -int disorder_snprintf(char buffer[], size_t bufsize, const char *fmt, ...); -/* like snprintf */ - -int disorder_asprintf(char **rp, const char *fmt, ...); -/* like asprintf but uses xmalloc_noptr() */ - -#endif - - /* logging ********************************************************************/ -void disorder_error(int errno_value, const char *fmt, ...); +void disorder_error(int errno_value, const char *fmt, ...) + DISORDER_IFGNUC(__attribute__((format (printf, 2, 3)))); /* report an error. If errno_value is nonzero then the errno string * is included. */ -void disorder_fatal(int errno_value, const char *fmt, ...); +void disorder_fatal(int errno_value, const char *fmt, ...) + DISORDER_IFGNUC(__attribute__((noreturn)) + __attribute__((format (printf, 2, 3)))); /* report an error and terminate. If errno_value is nonzero then the * errno string is included. This is the only safe way to terminate * the process. */