From d7960adb0c52a7abb2af932d1e7af98b980c8642 Mon Sep 17 00:00:00 2001 From: (no author) Date: Tue, 10 Jan 2006 13:51:39 +0000 Subject: This commit was manufactured by cvs2svn to create branch 'protocol_v3'. --- src/ivybind.c | 322 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 322 insertions(+) create mode 100644 src/ivybind.c (limited to 'src/ivybind.c') diff --git a/src/ivybind.c b/src/ivybind.c new file mode 100644 index 0000000..237ee78 --- /dev/null +++ b/src/ivybind.c @@ -0,0 +1,322 @@ +/* + * Ivy, C interface + * + * Copyright (C) 1997-2000 + * Centre d'Études de la Navigation Aérienne + * + * Bind syntax for extracting message comtent + * using regexp or other + * + * Authors: François-Régis Colin + * + * $Id$ + * + * Please refer to file version.h for the + * copyright notice regarding this software + */ +/* Module de gestion de la syntaxe des messages Ivy */ +#include +#include +#include +#include +#include +#include +#include + +#ifdef WIN32 +#include +#endif + + +#ifdef USE_PCRE_REGEX +#define OVECSIZE 60 /* must be multiple of 3, for regexp return */ +#include +#else +#define MAX_MSG_FIELDS 200 +#include +#endif + +#include "list.h" +#include "hash.h" +#include "ivybind.h" + +static int err_offset; + +#ifdef USE_PCRE_REGEX + static const char *err_buf; +#else + static char err_buf[4096]; +#endif + +struct _binding { + IvyBindingType type; + const char *msgname; /* msg tag name first word of message */ + char **msgargs; /* list of msg argument name */ + IvyArgument args; /* result */ +#ifdef USE_PCRE_REGEX + pcre *regexp; + pcre_extra *inspect; + int nb_match; + int ovector[OVECSIZE]; +#else + regex_t regexp; /* la regexp sous forme machine */ + regmatch_t match[MAX_MSG_FIELDS+1]; /* resultat du match */ +#endif + }; + + +/* classes de messages emis par l'application utilise pour le filtrage */ +static int messages_classes_count = 0; +static const char **messages_classes = 0; + + +/* stokage du message parse avant l'execution des regles de binding simple */ +static char *current_msg = NULL; +static char *msgtag; +static HASHTABLE msg_args_values = NULL; + +static IvyBinding IvyBindingCompileSimple( IvyBindingType typ, const char * expression ) +{ + int nb_arg= 0; + char *argname; + char **argv; + char *expr; + IvyBinding bind=0; + + expr = strdup( expression ); //Allocate a new buffer of separated token + /* count nb args */ + argname = expr; + while ( *argname ) + { + if ( *argname++ == ' ' ) nb_arg++; + } + + bind = (IvyBinding)malloc( sizeof( struct _binding )); + memset( bind, 0, sizeof(*bind ) ); + bind->type = IvyBindSimple; + bind->msgname = strtok( expr, " "); + bind->msgargs = malloc ( sizeof( char* ) * ( nb_arg + 1) ); + argv = bind->msgargs; + while ( (argname = strtok( NULL, " ")) ) + *argv++ = argname; + *argv++ = argname; /* end with NULL */ + return bind; +} +static IvyBinding IvyBindingCompileRegexp( IvyBindingType typ, const char * expression ) +{ + IvyBinding bind=0; +#ifdef USE_PCRE_REGEX + pcre *regexp; + regexp = pcre_compile(expression, PCRE_OPT,&err_buf,&err_offset,NULL); + if ( regexp != NULL ) + { + bind = (IvyBinding)malloc( sizeof( struct _binding )); + memset( bind, 0, sizeof(*bind ) ); + bind->regexp = regexp; + bind->type = IvyBindRegexp; + bind->inspect = pcre_study(regexp,0,&err_buf); + if (err_buf!=NULL) + { + printf("Error studying %s, message: %s\n",expression,err_buf); + } + } + else + { + printf("Error compiling '%s', %s\n", expression, err_buf); + } +#else + regex_t regexp; + int reg; + reg = regcomp(®exp, expression, REGCOMP_OPT|REG_EXTENDED); + if ( reg == 0 ) + { + bind = (IvyBinding)malloc( sizeof( struct _binding )); + memset( bind, 0, sizeof(*bind ) ); + bind->regexp = regexp; + bind->next = NULL; + } + else + { + regerror (reg, ®exp, err_buf, sizeof(err_buf) ); + err_offset = 0; // TODO unkown offset error + printf("Error compiling '%s', %s\n", expression, err_buf); + } +#endif + return bind; +} +IvyBinding IvyBindingCompile( IvyBindingType typ, const char * expression ) +{ + if ( typ == IvyBindRegexp ) + return IvyBindingCompileRegexp( typ, expression); + else + return IvyBindingCompileSimple( typ, expression); +} +void IvyBindingGetCompileError( int *offset, const char **errmessage ) +{ + *offset = err_offset; + *errmessage = err_buf; +} +void IvyBindingFree( IvyBinding bind ) +{ +#ifdef USE_PCRE_REGEX + if (bind->inspect!=NULL) pcre_free(bind->inspect); + pcre_free(bind->regexp); +#else +#endif + if (bind->msgname) + free ( bind->msgname ); + if (bind->msgargs) + free ( bind->msgargs ); + free ( bind ); +} +int IvyBindingExecRegexp( IvyBinding bind, const char * message ) +{ + int nb_match = 0; +#ifdef USE_PCRE_REGEX + + nb_match = pcre_exec( + bind->regexp, + bind->inspect, + message, + strlen(message), + 0, /* debut */ + 0, /* no other regexp option */ + bind->ovector, + OVECSIZE); + if (nb_match<1) return 0; /* no match */ + bind->nb_match = nb_match; + nb_match--; // firts arg wall string ??? + +#else + memset( bind->match, -1, sizeof(bind->match )); /* work around bug !!!*/ + nb_match = regexec (&bind->regexp, message, MAX_MSG_FIELDS, bind->match, 0) + if (nb_match == REG_NOMATCH) + return 0; + for ( index = 1; index < MAX_MSG_FIELDS; index++ ) + { + if ( bind->match[i].rm_so != -1 ) + nb_match++; + } +#endif + return nb_match; +} +int IvyBindingExecSimple( IvyBinding bind, const char * message ) +{ + char **msg_args; + if ( strcmp( bind->msgname, msgtag ) != 0 ) + return 0; + msg_args = bind->msgargs; + bind->args = IvyArgumentNew( 0,NULL ); + while( *msg_args ) + { + char *value; + value = hash_lookup(msg_args_values, (HASHKEYTYPE)*msg_args++); + if ( !value ) value = ""; /* TODO should we report matching ??? */ + IvyAddChildValue( bind->args, strlen( value ), value); + } + return 1; +} +int IvyBindingExec( IvyBinding bind, const char * message ) +{ + if ( bind->type == IvyBindRegexp ) + return IvyBindingExecRegexp( bind, message); + else + return IvyBindingExecSimple( bind, message); +} +static IvyArgument IvyBindingMatchSimple( IvyBinding bind, const char *message) +{ + return bind->args; +} +static IvyArgument IvyBindingMatchRegexp( IvyBinding bind, const char *message) +{ + int index=1;// firts arg wall string ??? + int arglen; + const void* arg; + IvyArgument args; + args = IvyArgumentNew( 0,NULL ); + +#ifdef USE_PCRE_REGEX + while ( indexnb_match ) { + arglen = bind->ovector[2*index+1]- bind->ovector[2*index]; + arg = message + bind->ovector[2*index]; + index++; +#else /* we don't USE_PCRE_REGEX */ + for ( index = 1; index < MAX_MSG_FIELDS; index++ ) + { + regmatch_t* p; + + p = &bind->match[index]; + if ( p->rm_so != -1 ) { + arglen = p->rm_eo - p->rm_so; + arg = message + p->rm_so; + } else { // ARG VIDE + arglen = 0; + arg = NULL; + } +#endif // USE_PCRE_REGEX + IvyAddChildValue( args, arglen, arg ); + } + return args; +} +IvyArgument IvyBindingMatch( IvyBinding bind, const char *message) +{ + if ( bind->type == IvyBindRegexp ) + return IvyBindingMatchRegexp( bind, message); + else + return IvyBindingMatchSimple( bind, message); +} + +//filter Expression Bind +void IvyBindingSetFilter( int argc, const char **argv) +{ + messages_classes_count = argc; + messages_classes = argv; +} +void IvyBindingParseMessage( const char *msg ) +{ + char *arg; + if ( current_msg ) free( current_msg ); + if ( msg_args_values ) hash_destroy( msg_args_values ); + current_msg = strdup( msg ); + msg_args_values = hash_create( 256, TRUE ); + msgtag = strtok( current_msg, " " ); + while( (arg = strtok( NULL, " =" )) ) + { + char *val = strtok( NULL, " ="); + if ( arg && val ) + hash_addstring( msg_args_values, arg, val ); + } +} +int IvyBindingFilter(IvyBindingType typ, int len, const char *exp) +{ + /* TODO check args limits !!!*/ + int i; + /* accepte tout par default */ + int regexp_ok = 1; + // TODO simplify test 3 conditions + if ( typ == IvyBindRegexp ) + { + if ( *exp =='^' && messages_classes_count !=0 ) + { + regexp_ok = 0; + for ( i = 0 ; i < messages_classes_count; i++ ) + { + if (strncmp( messages_classes[i], exp+1, strlen( messages_classes[i] )) == 0) + return 1; + } + } + } + else + { + if ( messages_classes_count !=0 ) + { + regexp_ok = 0; + for ( i = 0 ; i < messages_classes_count; i++ ) + { + if (strncmp( messages_classes[i], exp, strlen( messages_classes[i] )) == 0) + return 1; + } + } + } + return regexp_ok; +} \ No newline at end of file -- cgit v1.1 From a885259e1ffaa6de1d71107d19c815fb7875c86a Mon Sep 17 00:00:00 2001 From: fcolin Date: Fri, 21 Apr 2006 12:13:54 +0000 Subject: Separation du code Regexp dans un module --- src/ivybind.c | 194 +++++++++++++++------------------------------------------- 1 file changed, 50 insertions(+), 144 deletions(-) (limited to 'src/ivybind.c') diff --git a/src/ivybind.c b/src/ivybind.c index 237ee78..5e0ffe0 100644 --- a/src/ivybind.c +++ b/src/ivybind.c @@ -37,7 +37,6 @@ #endif #include "list.h" -#include "hash.h" #include "ivybind.h" static int err_offset; @@ -49,10 +48,7 @@ static int err_offset; #endif struct _binding { - IvyBindingType type; - const char *msgname; /* msg tag name first word of message */ - char **msgargs; /* list of msg argument name */ - IvyArgument args; /* result */ + const char *expression; /* regexp*/ #ifdef USE_PCRE_REGEX pcre *regexp; pcre_extra *inspect; @@ -64,45 +60,13 @@ struct _binding { #endif }; - /* classes de messages emis par l'application utilise pour le filtrage */ static int messages_classes_count = 0; static const char **messages_classes = 0; +/* regexp d'extraction du mot clef des regexp client pour le filtrage des regexp , ca va c'est clair ??? */ +static IvyBinding token_extract; - -/* stokage du message parse avant l'execution des regles de binding simple */ -static char *current_msg = NULL; -static char *msgtag; -static HASHTABLE msg_args_values = NULL; - -static IvyBinding IvyBindingCompileSimple( IvyBindingType typ, const char * expression ) -{ - int nb_arg= 0; - char *argname; - char **argv; - char *expr; - IvyBinding bind=0; - - expr = strdup( expression ); //Allocate a new buffer of separated token - /* count nb args */ - argname = expr; - while ( *argname ) - { - if ( *argname++ == ' ' ) nb_arg++; - } - - bind = (IvyBinding)malloc( sizeof( struct _binding )); - memset( bind, 0, sizeof(*bind ) ); - bind->type = IvyBindSimple; - bind->msgname = strtok( expr, " "); - bind->msgargs = malloc ( sizeof( char* ) * ( nb_arg + 1) ); - argv = bind->msgargs; - while ( (argname = strtok( NULL, " ")) ) - *argv++ = argname; - *argv++ = argname; /* end with NULL */ - return bind; -} -static IvyBinding IvyBindingCompileRegexp( IvyBindingType typ, const char * expression ) +IvyBinding IvyBindingCompile( const char * expression ) { IvyBinding bind=0; #ifdef USE_PCRE_REGEX @@ -111,9 +75,13 @@ static IvyBinding IvyBindingCompileRegexp( IvyBindingType typ, const char * expr if ( regexp != NULL ) { bind = (IvyBinding)malloc( sizeof( struct _binding )); + if ( ! bind ) + { + perror( "IvyBindingCompile malloc error: "); + exit(-1); + } memset( bind, 0, sizeof(*bind ) ); bind->regexp = regexp; - bind->type = IvyBindRegexp; bind->inspect = pcre_study(regexp,0,&err_buf); if (err_buf!=NULL) { @@ -144,13 +112,7 @@ static IvyBinding IvyBindingCompileRegexp( IvyBindingType typ, const char * expr #endif return bind; } -IvyBinding IvyBindingCompile( IvyBindingType typ, const char * expression ) -{ - if ( typ == IvyBindRegexp ) - return IvyBindingCompileRegexp( typ, expression); - else - return IvyBindingCompileSimple( typ, expression); -} + void IvyBindingGetCompileError( int *offset, const char **errmessage ) { *offset = err_offset; @@ -159,17 +121,15 @@ void IvyBindingGetCompileError( int *offset, const char **errmessage ) void IvyBindingFree( IvyBinding bind ) { #ifdef USE_PCRE_REGEX - if (bind->inspect!=NULL) pcre_free(bind->inspect); + if (bind->inspect!=NULL) + pcre_free(bind->inspect); pcre_free(bind->regexp); #else + free( bind->regexp ); #endif - if (bind->msgname) - free ( bind->msgname ); - if (bind->msgargs) - free ( bind->msgargs ); free ( bind ); } -int IvyBindingExecRegexp( IvyBinding bind, const char * message ) +int IvyBindingExec( IvyBinding bind, const char * message ) { int nb_match = 0; #ifdef USE_PCRE_REGEX @@ -200,123 +160,69 @@ int IvyBindingExecRegexp( IvyBinding bind, const char * message ) #endif return nb_match; } -int IvyBindingExecSimple( IvyBinding bind, const char * message ) -{ - char **msg_args; - if ( strcmp( bind->msgname, msgtag ) != 0 ) - return 0; - msg_args = bind->msgargs; - bind->args = IvyArgumentNew( 0,NULL ); - while( *msg_args ) - { - char *value; - value = hash_lookup(msg_args_values, (HASHKEYTYPE)*msg_args++); - if ( !value ) value = ""; /* TODO should we report matching ??? */ - IvyAddChildValue( bind->args, strlen( value ), value); - } - return 1; -} -int IvyBindingExec( IvyBinding bind, const char * message ) -{ - if ( bind->type == IvyBindRegexp ) - return IvyBindingExecRegexp( bind, message); - else - return IvyBindingExecSimple( bind, message); -} -static IvyArgument IvyBindingMatchSimple( IvyBinding bind, const char *message) -{ - return bind->args; -} -static IvyArgument IvyBindingMatchRegexp( IvyBinding bind, const char *message) + +void IvyBindingMatch( IvyBinding bind, const char *message, int argnum, int *arglen, const char **arg) { - int index=1;// firts arg wall string ??? - int arglen; - const void* arg; - IvyArgument args; - args = IvyArgumentNew( 0,NULL ); #ifdef USE_PCRE_REGEX - while ( indexnb_match ) { - arglen = bind->ovector[2*index+1]- bind->ovector[2*index]; - arg = message + bind->ovector[2*index]; - index++; + + *arglen = bind->ovector[2*argnum+1]- bind->ovector[2*argnum]; + *arg = message + bind->ovector[2*argnum]; #else /* we don't USE_PCRE_REGEX */ - for ( index = 1; index < MAX_MSG_FIELDS; index++ ) - { + regmatch_t* p; - p = &bind->match[index]; + p = &bind->match[argnum+1]; if ( p->rm_so != -1 ) { - arglen = p->rm_eo - p->rm_so; - arg = message + p->rm_so; + *arglen = p->rm_eo - p->rm_so; + *arg = message + p->rm_so; } else { // ARG VIDE - arglen = 0; - arg = NULL; + *arglen = 0; + *arg = NULL; } #endif // USE_PCRE_REGEX - IvyAddChildValue( args, arglen, arg ); - } - return args; -} -IvyArgument IvyBindingMatch( IvyBinding bind, const char *message) -{ - if ( bind->type == IvyBindRegexp ) - return IvyBindingMatchRegexp( bind, message); - else - return IvyBindingMatchSimple( bind, message); + } //filter Expression Bind void IvyBindingSetFilter( int argc, const char **argv) { + const char *errbuf; + int erroffset; + messages_classes_count = argc; messages_classes = argv; -} -void IvyBindingParseMessage( const char *msg ) -{ - char *arg; - if ( current_msg ) free( current_msg ); - if ( msg_args_values ) hash_destroy( msg_args_values ); - current_msg = strdup( msg ); - msg_args_values = hash_create( 256, TRUE ); - msgtag = strtok( current_msg, " " ); - while( (arg = strtok( NULL, " =" )) ) + /* compile the token extraction regexp */ + + token_extract = IvyBindingCompile("^\\^([a-zA-Z_0-9-]+).*"); + if ( !token_extract ) { - char *val = strtok( NULL, " ="); - if ( arg && val ) - hash_addstring( msg_args_values, arg, val ); + IvyBindingGetCompileError( & erroffset, & errbuf ); + printf("Error compiling Token Extract regexp: %s\n", errbuf); } } -int IvyBindingFilter(IvyBindingType typ, int len, const char *exp) + +int IvyBindingFilter(const char *expression) { - /* TODO check args limits !!!*/ int i; - /* accepte tout par default */ - int regexp_ok = 1; - // TODO simplify test 3 conditions - if ( typ == IvyBindRegexp ) - { - if ( *exp =='^' && messages_classes_count !=0 ) - { - regexp_ok = 0; - for ( i = 0 ; i < messages_classes_count; i++ ) - { - if (strncmp( messages_classes[i], exp+1, strlen( messages_classes[i] )) == 0) - return 1; - } - } - } - else - { - if ( messages_classes_count !=0 ) + int err; + int regexp_ok = 1; /* accepte tout par default */ + int tokenlen; + const char *token; + + if ( *expression =='^' && messages_classes_count !=0 ) { regexp_ok = 0; + + /* extract token */ + err = IvyBindingExec( token_extract, expression ); + if ( err < 1 ) return 1; + IvyBindingMatch( token_extract, expression , 0, &tokenlen, &token ); for ( i = 0 ; i < messages_classes_count; i++ ) { - if (strncmp( messages_classes[i], exp, strlen( messages_classes[i] )) == 0) + if (strncmp( messages_classes[i], token, tokenlen ) == 0) return 1; } } - } return regexp_ok; -} \ No newline at end of file +} -- cgit v1.1 From 8b42932b4ec978040acf341e69cd7b037721b24f Mon Sep 17 00:00:00 2001 From: fcolin Date: Fri, 21 Apr 2006 12:49:19 +0000 Subject: separation regexp en module ( bug arg num edbute a 1 ) --- src/ivybind.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ivybind.c') diff --git a/src/ivybind.c b/src/ivybind.c index 5e0ffe0..9522ba5 100644 --- a/src/ivybind.c +++ b/src/ivybind.c @@ -163,7 +163,7 @@ int IvyBindingExec( IvyBinding bind, const char * message ) void IvyBindingMatch( IvyBinding bind, const char *message, int argnum, int *arglen, const char **arg) { - + argnum++; /* first arg == Wall string */ #ifdef USE_PCRE_REGEX *arglen = bind->ovector[2*argnum+1]- bind->ovector[2*argnum]; -- cgit v1.1 From 2cf893c0c34d50a68a27e1704b38f2facc10c9bc Mon Sep 17 00:00:00 2001 From: fcolin Date: Fri, 21 Apr 2006 15:51:55 +0000 Subject: suppression de l'indirection sur les fonction channel et renomage ! --- src/ivybind.c | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) (limited to 'src/ivybind.c') diff --git a/src/ivybind.c b/src/ivybind.c index 9522ba5..20e174f 100644 --- a/src/ivybind.c +++ b/src/ivybind.c @@ -31,10 +31,10 @@ #ifdef USE_PCRE_REGEX #define OVECSIZE 60 /* must be multiple of 3, for regexp return */ #include -#else +#else /* we don't USE_PCRE_REGEX */ #define MAX_MSG_FIELDS 200 #include -#endif +#endif /* USE_PCRE_REGEX */ #include "list.h" #include "ivybind.h" @@ -43,21 +43,20 @@ static int err_offset; #ifdef USE_PCRE_REGEX static const char *err_buf; -#else +#else /* we don't USE_PCRE_REGEX */ static char err_buf[4096]; -#endif +#endif /* USE_PCRE_REGEX */ struct _binding { - const char *expression; /* regexp*/ #ifdef USE_PCRE_REGEX pcre *regexp; pcre_extra *inspect; int nb_match; int ovector[OVECSIZE]; -#else +#else /* we don't USE_PCRE_REGEX */ regex_t regexp; /* la regexp sous forme machine */ regmatch_t match[MAX_MSG_FIELDS+1]; /* resultat du match */ -#endif +#endif /* USE_PCRE_REGEX */ }; /* classes de messages emis par l'application utilise pour le filtrage */ @@ -66,7 +65,7 @@ static const char **messages_classes = 0; /* regexp d'extraction du mot clef des regexp client pour le filtrage des regexp , ca va c'est clair ??? */ static IvyBinding token_extract; -IvyBinding IvyBindingCompile( const char * expression ) +IvyBinding IvyBindingCompile( const char * expression, int *erroffset, const char **errmessage ) { IvyBinding bind=0; #ifdef USE_PCRE_REGEX @@ -90,9 +89,11 @@ IvyBinding IvyBindingCompile( const char * expression ) } else { + *erroffset = err_offset; + *errmessage = err_buf; printf("Error compiling '%s', %s\n", expression, err_buf); } -#else +#else /* we don't USE_PCRE_REGEX */ regex_t regexp; int reg; reg = regcomp(®exp, expression, REGCOMP_OPT|REG_EXTENDED); @@ -106,27 +107,23 @@ IvyBinding IvyBindingCompile( const char * expression ) else { regerror (reg, ®exp, err_buf, sizeof(err_buf) ); - err_offset = 0; // TODO unkown offset error + *erroffset = err_offset; + *errmessage = err_buf; printf("Error compiling '%s', %s\n", expression, err_buf); } -#endif +#endif /* USE_PCRE_REGEX */ return bind; } -void IvyBindingGetCompileError( int *offset, const char **errmessage ) -{ - *offset = err_offset; - *errmessage = err_buf; -} void IvyBindingFree( IvyBinding bind ) { #ifdef USE_PCRE_REGEX if (bind->inspect!=NULL) pcre_free(bind->inspect); pcre_free(bind->regexp); -#else +#else /* we don't USE_PCRE_REGEX */ free( bind->regexp ); -#endif +#endif /* USE_PCRE_REGEX */ free ( bind ); } int IvyBindingExec( IvyBinding bind, const char * message ) @@ -147,7 +144,7 @@ int IvyBindingExec( IvyBinding bind, const char * message ) bind->nb_match = nb_match; nb_match--; // firts arg wall string ??? -#else +#else /* we don't USE_PCRE_REGEX */ memset( bind->match, -1, sizeof(bind->match )); /* work around bug !!!*/ nb_match = regexec (&bind->regexp, message, MAX_MSG_FIELDS, bind->match, 0) if (nb_match == REG_NOMATCH) @@ -157,7 +154,7 @@ int IvyBindingExec( IvyBinding bind, const char * message ) if ( bind->match[i].rm_so != -1 ) nb_match++; } -#endif +#endif /* USE_PCRE_REGEX */ return nb_match; } @@ -180,7 +177,7 @@ void IvyBindingMatch( IvyBinding bind, const char *message, int argnum, int *arg *arglen = 0; *arg = NULL; } -#endif // USE_PCRE_REGEX +#endif /* USE_PCRE_REGEX */ } @@ -194,10 +191,9 @@ void IvyBindingSetFilter( int argc, const char **argv) messages_classes = argv; /* compile the token extraction regexp */ - token_extract = IvyBindingCompile("^\\^([a-zA-Z_0-9-]+).*"); + token_extract = IvyBindingCompile("^\\^([a-zA-Z_0-9-]+).*", & erroffset, & errbuf); if ( !token_extract ) { - IvyBindingGetCompileError( & erroffset, & errbuf ); printf("Error compiling Token Extract regexp: %s\n", errbuf); } } -- cgit v1.1 From 3d7f9a4339556f458005fbfb3da2072aff4e1d9c Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 11 May 2006 16:42:00 +0000 Subject: correction Bug introduit lors de la separation ivybind ( regexp sans argument ) --- src/ivybind.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/ivybind.c') diff --git a/src/ivybind.c b/src/ivybind.c index 20e174f..e7d126a 100644 --- a/src/ivybind.c +++ b/src/ivybind.c @@ -142,8 +142,6 @@ int IvyBindingExec( IvyBinding bind, const char * message ) OVECSIZE); if (nb_match<1) return 0; /* no match */ bind->nb_match = nb_match; - nb_match--; // firts arg wall string ??? - #else /* we don't USE_PCRE_REGEX */ memset( bind->match, -1, sizeof(bind->match )); /* work around bug !!!*/ nb_match = regexec (&bind->regexp, message, MAX_MSG_FIELDS, bind->match, 0) -- cgit v1.1 From f6a2f7141ea1e9e6aeec32c38c33b7526f3ea088 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 11 May 2006 17:20:45 +0000 Subject: correction BUg regexp encore --- src/ivybind.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/ivybind.c') diff --git a/src/ivybind.c b/src/ivybind.c index e7d126a..7c5b406 100644 --- a/src/ivybind.c +++ b/src/ivybind.c @@ -158,7 +158,6 @@ int IvyBindingExec( IvyBinding bind, const char * message ) void IvyBindingMatch( IvyBinding bind, const char *message, int argnum, int *arglen, const char **arg) { - argnum++; /* first arg == Wall string */ #ifdef USE_PCRE_REGEX *arglen = bind->ovector[2*argnum+1]- bind->ovector[2*argnum]; -- cgit v1.1 From 7ba87263b60bbbc2f8f45215bdb3bcfa3ae20594 Mon Sep 17 00:00:00 2001 From: bustico Date: Thu, 1 Jun 2006 12:07:17 +0000 Subject: fix bug de filtrage --- src/ivybind.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/ivybind.c') diff --git a/src/ivybind.c b/src/ivybind.c index 7c5b406..0232a31 100644 --- a/src/ivybind.c +++ b/src/ivybind.c @@ -210,11 +210,14 @@ int IvyBindingFilter(const char *expression) /* extract token */ err = IvyBindingExec( token_extract, expression ); if ( err < 1 ) return 1; - IvyBindingMatch( token_extract, expression , 0, &tokenlen, &token ); + IvyBindingMatch( token_extract, expression , 1, &tokenlen, &token ); for ( i = 0 ; i < messages_classes_count; i++ ) { - if (strncmp( messages_classes[i], token, tokenlen ) == 0) - return 1; + if (strncmp( messages_classes[i], token, tokenlen ) == 0) { + return 1; } + // else { + //printf ("DBG> %s eliminé [%s]\n", token, expression); + //} } } return regexp_ok; -- cgit v1.1 From 6308f81fa5ce79a10dea3877aee4ec8f7fc4926c Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Jun 2006 12:33:47 +0000 Subject: Correction bug IvyBinding dans le cas de regexp non pcre --- src/ivybind.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ivybind.c') diff --git a/src/ivybind.c b/src/ivybind.c index 0232a31..b0a8db4 100644 --- a/src/ivybind.c +++ b/src/ivybind.c @@ -166,7 +166,7 @@ void IvyBindingMatch( IvyBinding bind, const char *message, int argnum, int *arg regmatch_t* p; - p = &bind->match[argnum+1]; + p = &bind->match[argnum]; if ( p->rm_so != -1 ) { *arglen = p->rm_eo - p->rm_so; *arg = message + p->rm_so; -- cgit v1.1 From 19735bb3c818f78d5ce53d1482b0bd62f63d76e8 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 22 Jun 2006 10:47:46 +0000 Subject: Ajout d'un warning si la variable IVY_DEBUG_FILTER est postionne et que le message n'est pas emit , on controle la table des filtres ajout d'un flag -c a ivyprobe pour la gestion des filtres de regexps --- src/ivybind.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/ivybind.c') diff --git a/src/ivybind.c b/src/ivybind.c index b0a8db4..c506ab3 100644 --- a/src/ivybind.c +++ b/src/ivybind.c @@ -179,6 +179,10 @@ void IvyBindingMatch( IvyBinding bind, const char *message, int argnum, int *arg } //filter Expression Bind +int IvyBindingGetFilterCount() +{ +return messages_classes_count; +} void IvyBindingSetFilter( int argc, const char **argv) { const char *errbuf; @@ -222,3 +226,16 @@ int IvyBindingFilter(const char *expression) } return regexp_ok; } +/* recherche si le message commence par un mot clef de la table */ +void IvyBindindFilterCheck( const char *message ) +{ + int i; + for ( i = 0 ; i < messages_classes_count; i++ ) + { + if (strcmp( messages_classes[i], message ) == 0) + { + return; + } + } + fprintf(stderr,"*** WARNING *** message '%s' not sent due to missing keyword in filter table!!!\n", message ); +} -- cgit v1.1