[Nagiosplug-devel] thoughts on regexp using plugins

Andreas Ericsson ae at op5.se
Thu Mar 23 15:22:05 CET 2006


sean finney wrote:
> 
> i'm hard pressed to see why this is a better option... compared to adding
> two new files into CVS and defining an extra CFLAG or two if configure
> doesn't find a valid regex library :)
> 

#include "np_regex.h"

(in np_regex.h, do this)
#ifndef HAVE_REGEX
#define regex_t char
#define regmatch_t char

static void no_regex_support(void)
{
	die("Sorry. regex support not available on this platform\n");
}

int regcomp(regex_t *a, const char *b, int flags)
{
	no_regex_support();
	return 0; /* musn't upset the compiler */
}

With similar replacements for regfree(), regexec() and regerror().
No #ifdef's, no hassle and no bloat.

-- 
Andreas Ericsson                   andreas.ericsson at op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231




More information about the Devel mailing list