summaryrefslogtreecommitdiff
path: root/Bus/Ivy/Ivy.cxx
diff options
context:
space:
mode:
authorfcolin2007-02-01 12:56:32 +0000
committerfcolin2007-02-01 12:56:32 +0000
commit34016e13302324442add93fa6082924d03bfbefc (patch)
treef866fee847e8399e4d47584e7432cf8b95d04d6e /Bus/Ivy/Ivy.cxx
parent714705dcb50aff5ab0a0976c8e4a725a968d6a46 (diff)
downloadivy-cplusplus-34016e13302324442add93fa6082924d03bfbefc.zip
ivy-cplusplus-34016e13302324442add93fa6082924d03bfbefc.tar.gz
ivy-cplusplus-34016e13302324442add93fa6082924d03bfbefc.tar.bz2
ivy-cplusplus-34016e13302324442add93fa6082924d03bfbefc.tar.xz
Utilisateur : Fcolin Date : 22/09/06 Heure : 14:54 Archivé dans $/Bus/Ivy Commentaire: (vss 28)
Diffstat (limited to 'Bus/Ivy/Ivy.cxx')
-rw-r--r--Bus/Ivy/Ivy.cxx56
1 files changed, 52 insertions, 4 deletions
diff --git a/Bus/Ivy/Ivy.cxx b/Bus/Ivy/Ivy.cxx
index d4c6056..0a09c91 100644
--- a/Bus/Ivy/Ivy.cxx
+++ b/Bus/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
+}
+