summaryrefslogtreecommitdiff
path: root/Ivy/Ivy.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Ivy/Ivy.cxx')
-rw-r--r--Ivy/Ivy.cxx56
1 files changed, 52 insertions, 4 deletions
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
+}
+