From 19723f6393be5d66a750ce9a21ca4e4dba264cac Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:56:32 +0000 Subject: Utilisateur : Fcolin Date : 22/09/06 Heure : 14:54 Archivé dans $/Bus/Ivy Commentaire: (vss 28) --- Ivy/Ivy.cxx | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 4 deletions(-) (limited to 'Ivy') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index d4c6056..0a09c91 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -10,6 +10,7 @@ #include "IvyApplication.h" #include "IvySynchroWnd.h" #include "IvyBinding.h" +#include "intervalRegexp.h" #define DEFAULT_ADDR "127.255.255.255" #define SEPARATOR ":" @@ -149,7 +150,10 @@ void Ivy::stop() } int Ivy::BindMsg(const char *regexp, IvyMessageCallback *cb) { - regexp_out.push_back( regexp ); + char buffer[8192]; + + SubstituteInterval( regexp, buffer, sizeof( buffer ) ); + regexp_out.push_back( buffer ); callbacks.push_back( synchronous ? new IvySynchronousMessageCallback(cb) : cb ); /* send to already connected */ @@ -157,20 +161,23 @@ int Ivy::BindMsg(const char *regexp, IvyMessageCallback *cb) for ( iter = applications.begin() ; iter != applications.end() ; ++iter ) { IvyApplication *app = *iter; - app->SendMsg(IvyApplication::AddRegexp, regexp_id, regexp ); + app->SendMsg(IvyApplication::AddRegexp, regexp_id, buffer ); } return regexp_id++; } int Ivy::BindMsg( IvyMessageCallback *cb, const char *regexp, ... ) { char buffer[4096]; + char buffer2[8192]; va_list args; va_start( args, regexp ); /* Initialize variable arguments. */ _vsnprintf_s( buffer, sizeof(buffer), sizeof(buffer)-1, regexp, args ); va_end( args); - regexp_out.push_back( regexp ); + SubstituteInterval( buffer, buffer2, sizeof( buffer2 ) ); + + regexp_out.push_back( buffer2 ); callbacks.push_back( synchronous ? new IvySynchronousMessageCallback(cb) : cb ); /* send to already connected */ @@ -178,7 +185,7 @@ int Ivy::BindMsg( IvyMessageCallback *cb, const char *regexp, ... ) for ( iter = applications.begin() ; iter != applications.end() ; ++iter ) { IvyApplication *app = *iter; - app->SendMsg(IvyApplication::AddRegexp, regexp_id, buffer ); + app->SendMsg(IvyApplication::AddRegexp, regexp_id, buffer2 ); } return regexp_id++; } @@ -387,3 +394,44 @@ bool Ivy::CheckConnected(IvyApplication * app) } return false; } +void Ivy::SubstituteInterval (const char *src, char *dst, size_t dst_len) +{ +// #ifdef INTERVALREGEXP + + // pas de traitement couteux s'il n'y a rien à interpoler + if (strstr (src, "(?I") == NULL) { + return; + } else { + char *curPos; + char *itvPos; + char *dstPos = dst; + + curPos = (char *)src; + while ((itvPos = strstr (curPos, "(?I")) != NULL) { + // copie depuis la position courante jusqu'à l'intervalle + int lenCp, min,max; + char withDecimal; + lenCp = itvPos-curPos; + memcpy ( dstPos, curPos, lenCp); + curPos=itvPos; + dstPos += lenCp; + + // extraction des paramètres de l'intervalle + sscanf (itvPos, "(?I%d#%d%c", &min, &max, &withDecimal); + + // printf ("DBG> substituteInterval min=%d max=%d withDecimal=%d\n", + // min, max, (withDecimal != 'i')); + + // generation et copie de l'intervalle + regexpGen (dstPos, dst_len-(dstPos-dst), min, max, (withDecimal != 'i')); + dstPos = dst + strlen (dst); + + // consommation des caractères décrivant intervalle dans la chaine source + curPos = strstr (curPos, ")"); + curPos++; + } + strncat (dstPos, curPos, dst_len-(dstPos-dst)); + } +// #endif +} + -- cgit v1.1