From 4cdbde3775be5c961d11bb5497d1c97e07c429b2 Mon Sep 17 00:00:00 2001 From: fcolin Date: Fri, 16 Jun 2006 14:36:22 +0000 Subject: correction d'un BUG dans IvyGetMessages ( si nb > 200 ) ajout d'un argument -f a ivyprobe pour passer des regexps dans un fichier --- src/ivy.c | 8 +++++++- src/ivyprobe.c | 32 +++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ivy.c b/src/ivy.c index 5f5a93c..e0102c8 100644 --- a/src/ivy.c +++ b/src/ivy.c @@ -860,7 +860,8 @@ char *IvyGetApplicationList(const char *sep) char **IvyGetApplicationMessages( IvyClientPtr app ) { - static char *messagelist[200];/* TODO remove that ugly Thing */ +#define MAX_REGEXP 4096 + static char *messagelist[MAX_REGEXP+1];/* TODO remove that ugly Thing */ MsgSndPtr msg; int msgCount= 0; memset( messagelist, 0 , sizeof( messagelist )); @@ -868,6 +869,11 @@ char **IvyGetApplicationMessages( IvyClientPtr app ) IVY_LIST_EACH( app->msg_send, msg ) { messagelist[msgCount++]= msg->str_regexp; + if ( msgCount >= MAX_REGEXP ) + { + fprintf(stderr,"Too Much expression(%d) for buffer\n",msgCount); + break; + } } return messagelist; } diff --git a/src/ivyprobe.c b/src/ivyprobe.c index 0ef674a..40790f6 100644 --- a/src/ivyprobe.c +++ b/src/ivyprobe.c @@ -263,18 +263,43 @@ display(void) } #endif +void BindMsgOfFile( const char * regex_file ) +{ + char line[4096]; + size_t size; + FILE* file; + file = fopen( regex_file, "r" ); + if ( !file ) { + perror( "Regexp file open "); + return; + } + while( !feof( file ) ) + { + if ( fgets( line, sizeof(line), file ) ) + { + size = strlen(line); + if ( size > 1 ) + { + line[size-1] = '\0'; /* supress \n */ + IvyBindMsg (Callback, NULL, line); + } + } + } +} + int main(int argc, char *argv[]) { int c; int timer_test = 0; char busbuf [1024] = ""; const char* bus = 0; + const char* regex_file = 0; char agentnamebuf [1024] = ""; const char* agentname = DEFAULT_IVYPROBE_NAME; char agentready [1024] = ""; const char* helpmsg = "[options] [regexps]\n\t-b bus\tdefines the Ivy bus to which to connect to, defaults to 127:2010\n\t-t\ttriggers the timer test\n\t-n name\tchanges the name of the agent, defaults to IVYPROBE\n\t-v\tprints the ivy relase number\n\nregexp is a Perl5 compatible regular expression (see ivyprobe(1) and pcrepattern(3) for more info\nuse .help within ivyprobe\n\t-s bindcall\tactive the interception of regexp's subscribing or unscribing\n"; - while ((c = getopt(argc, argv, "vn:d:b:w:t:s")) != EOF) + while ((c = getopt(argc, argv, "vn:d:b:w:t:sf:")) != EOF) switch (c) { case 'b': strcpy (busbuf, optarg); @@ -283,6 +308,9 @@ int main(int argc, char *argv[]) case 'w': wait_count = atoi(optarg) ; break; + case 'f': + regex_file = optarg ; + break; case 'n': strcpy(agentnamebuf, optarg); agentname=agentnamebuf; @@ -316,6 +344,8 @@ int main(int argc, char *argv[]) #endif IvyInit (agentname, agentready, ApplicationCallback,NULL,NULL,NULL); IvyBindDirectMsg( DirectCallback,NULL); + if ( regex_file ) + BindMsgOfFile( regex_file ); for (; optind < argc; optind++) IvyBindMsg (Callback, NULL, argv[optind]); -- cgit v1.1