X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/anag/blobdiff_plain/d9af4a2b674e5ab91df0f9af236283b617bb81c7..HEAD:/anag.h diff --git a/anag.h b/anag.h index eca5091..32b5ea5 100644 --- a/anag.h +++ b/anag.h @@ -1,13 +1,11 @@ /* -*-c-*- - * - * $Id: anag.h,v 1.4 2003/11/29 23:38:37 mdw Exp $ * * External definitions for Anag * * (c) 2001 Mark Wooding */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of Anag: a simple wordgame helper. * @@ -15,35 +13,17 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * Anag 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 Anag; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/*----- Revision history --------------------------------------------------* - * - * $Log: anag.h,v $ - * Revision 1.4 2003/11/29 23:38:37 mdw - * Debianization. - * - * Revision 1.3 2003/09/15 02:48:55 mdw - * Monoalphabetic match filter. - * - * Revision 1.2 2002/08/11 12:58:09 mdw - * Added support for regular expression matching, if supported by the C - * library. - * - * Revision 1.1 2001/02/04 17:14:42 mdw - * Initial checkin - * - */ - #ifndef ANAG_H #define ANAG_H @@ -64,6 +44,36 @@ #include #include +/*----- Preliminaries -----------------------------------------------------*/ + +#if defined(__GNUC__) +# define GCC_VERSION_P(maj, min) \ + (__GNUC__ > (maj) || (__GNUC__ == (maj) && __GNUC_MINOR__ >= (min))) +#else +# define GCC_VERSION_P(maj, min) 0 +#endif + +#ifdef __clang__ +# define CLANG_VERSION_P(maj, min) \ + (__clang_major__ > (maj) || (__clang_major__ == (maj) && \ + __clang_minor__ >= (min))) +#else +# define CLANG_VERSION_P(maj, min) 0 +#endif + +#if GCC_VERSION_P(2, 5) || CLANG_VERSION_P(3, 3) +# define NORETURN __attribute__((noreturn)) +# define PRINTF_LIKE(fix, aix) __attribute__((format(printf, fix, aix))) +#endif + +#ifndef NORETURN +# define NORETURN +#endif + +#ifndef PRINTF_LIKE +# define PRINTF_LIKE +#endif + /*----- Data structures ---------------------------------------------------*/ typedef struct node { @@ -85,8 +95,20 @@ extern node *subgram(const char *const */*av*/); extern node *wildcard(const char *const */*av*/); extern node *trackword(const char *const */*av*/); extern node *mono(const char *const */*av*/); -extern node *regexp(const char *const */*av*/); -extern node *pcrenode(const char *const */*av*/); +#ifdef HAVE_REGCOMP + extern node *regexp(const char *const */*av*/); +#endif +#if defined(HAVE_PCRE) || defined(HAVE_PCRE2) + extern node *pcrenode(const char *const */*av*/); +#endif +extern node *longest(const char *const */*av*/); +extern node *shortest(const char *const */*av*/); + +/*----- Exit codes --------------------------------------------------------*/ + +#define EX_OK 0 +#define EX_NONE 1 +#define EX_FAIL 127 /*----- Error reporting ---------------------------------------------------*/ @@ -126,7 +148,7 @@ extern int pquis(FILE */*fp*/, const char */*p*/); * Use: Reports an error and exits. */ -extern void die(const char */*f*/, ...); +extern PRINTF_LIKE(1, 2) NORETURN void die(const char */*f*/, ...); /*----- Memory allocation -------------------------------------------------*/ @@ -207,6 +229,22 @@ extern void dstr_ensure(dstr */*d*/, size_t /*sz*/); extern int dstr_putline(dstr */*d*/, FILE */*fp*/); +/*----- Infrastructure ----------------------------------------------------*/ + +/* --- @atend_register@ --- * + * + * Arguments: @int (*func)(void *)@ = function to call + * @void *p@ = handle to pass to it + * + * Returns: --- + * + * Use: Adds a function to the list of things to do at the end of the + * program. The function should return nonzero if it produced + * any output. + */ + +extern void atend_register(int (*/*func*/)(void */*p*/), void */*p*/); + /*----- That's all, folks -------------------------------------------------*/ #ifdef __cplusplus