From feaa8372e6a9849dae2b624a432bf38cd60d6568 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:55:38 +0000 Subject: Utilisateur : Fcolin Date : 16/06/00 Heure : 10:14 Créé (vss 1) --- Ivy/Ivy.cxx | 304 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 304 insertions(+) create mode 100644 Ivy/Ivy.cxx (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx new file mode 100644 index 0000000..e3c6bc6 --- /dev/null +++ b/Ivy/Ivy.cxx @@ -0,0 +1,304 @@ +// Ivy.cpp: implementation of the Ivy class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +//#include "libIvy.h" +#include "Ivy.h" + +#include "IvyWatcher.h" +#include "IvyApplication.h" +#include "IvySynchroWnd.h" + + +#define DEFAULT_ADDR "127.255.255.255" +#define SEPARATOR ":" +#define DEFAULT_PORT "2010" +#define DEFAULT_DOMAIN DEFAULT_ADDR/**/SEPARATOR/**/DEFAULT_PORT + + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +Ivy::~Ivy() +{ + // remove all app and stop watcher + stop(); + regexp_out.clear(); + + for ( int i = 0; i < callbacks.size(); i ++) + { + delete callbacks[i]; + } + callbacks.clear(); + +// if ( direct_callback ) delete direct_callback; +// if ( application_callback ) delete application_callback; + + delete watcher; + server->Close(); + delete server; + if ( synchronous ) + { + delete IvySynchronousCallback::m_synchro; + delete application_callback; + } +} + + +Ivy::Ivy(const char* name, const char * ready, IvyApplicationCallback *callback, bool Synchronous) +{ + InitializeCriticalSection( &m_application_cs ); + + synchronous = Synchronous; + if ( synchronous ) + IvySynchronousCallback::m_synchro = new IvySynchroWnd(); + ready_message = ready; + appname = name; + messages_classes_count = 0; + messages_classes = NULL; + application_callback = synchronous ? new IvySynchronousApplicationCallback(callback) : callback; + direct_callback = NULL; + die_callback = NULL; + server = new IvyApplication(this); + applicationPort = server->Create(); + if ( !applicationPort ) + { + TRACE( " Can't Create server %d\n", server->GetLastError( ) ); + return; + } + watcher = new IvyWatcher(this); + + +} +const char * Ivy::GetDomain(const char *domainlist) +{ + // determine domain to use + // the syntax of domain is "IpBroadcastAddr1,IpBroadcastAddr2,IpBroadcastAddr2:port" + if ( domainlist ) + { + domain = domainlist; + } + if ( domain.empty() ) + { + domain = getenv ( "IVYBUS" ); + if ( domain.empty() ) + domain = DEFAULT_DOMAIN; + } + // first find our UDP port + int sep_index = domain.rfind( ':' ); + if ( sep_index == -1 ) + { + domain = DEFAULT_DOMAIN; + TRACE(" Missing ':' in domain list using default domain %s\n", domain.c_str() ); + } + if ( sep_index == 0 ) + { + /* missing addr using localhost */ + domain.insert(0,DEFAULT_ADDR); + } + return domain.c_str(); +} + +void Ivy::start(const char *domain) +{ + watcher->start(domain); +} +void Ivy::stop() +{ + watcher->stop(); + + for ( int pos = 0 ; pos < applications.size() ; pos++ ) + { + IvyApplication *app = applications[pos]; + delete app; + } + applications.clear(); +} +int Ivy::BindMsg(const char *regexp, IvyMessageCallback *cb) +{ + static int id = 0; + regexp_out.push_back( regexp ); + callbacks.push_back( synchronous ? new IvySynchronousMessageCallback(cb) : cb ); + + /* send to already connected */ + for ( int pos = 0 ; pos < applications.size() ; pos ++ ) + { + IvyApplication *app = applications[ pos ]; + app->SendMsg(IvyApplication::AddRegexp, id, regexp ); + } + return id++; +} + +void Ivy::UnbindMsg(int id) +{ + regexp_out[ id ] = ""; + callbacks[ id ] = NULL; + /* send to already connected */ + for ( int pos = 0 ; pos < applications.size(); pos ++ ) + { + IvyApplication *app = applications[ pos ]; + app->SendMsg(IvyApplication::DelRegexp, id, "" ); + } + +} + +void Ivy::BindDirectMsg(IvyDirectMessageCallback *callback) +{ +direct_callback = callback; +} + +UINT Ivy::GetApplicationPort() +{ + return applicationPort; +} + +void Ivy::AddApplication(IvyApplication *app) +{ + EnterCriticalSection( &m_application_cs ); + // Check for disconnected Application + for ( int pos = 0; pos < applications.size(); pos ++ ) + { + IvyApplication *disc_app = applications[ pos ]; + if ( disc_app->m_hSocket == INVALID_SOCKET ) + { + //applications.erase( pos ); + delete disc_app; + } + } + applications.push_back( app ); + LeaveCriticalSection( &m_application_cs ); + SendSubscriptions( app ); +} +void Ivy::RemoveApplication(IvyApplication * app) +{ + /// OLD NOT called because of deallocation PB + // the real remove is done at arrival of a new Application + // or at the bus Stop + assert( TRUE ); + if ( app ) + { + for ( int pos = 0; pos < applications.size(); pos ++ ) + { + if ( app == applications[ pos ] ) + { + EnterCriticalSection( &m_application_cs ); + //applications.erase( pos ); + LeaveCriticalSection( &m_application_cs ); + delete app; + } + } + } +} + +void Ivy::SendSubscriptions(IvyApplication *app) +{ + app->SendMsg( IvyApplication::StartRegexp, GetApplicationPort(), appname.c_str()); + for ( int id = 0 ; id < regexp_out.size(); id++ ) + { + const string& regexp = regexp_out[id]; + if ( !regexp.empty() ) + app->SendMsg( IvyApplication::AddRegexp, id, regexp.c_str()); + } + app->SendMsg( IvyApplication::EndRegexp, 0); + +} + + +int Ivy::SendMsg(const char * message) +{ + int count = 0; + /* send to already connected */ + for ( int pos = 0 ; pos < applications.size(); pos ++ ) + { + IvyApplication *app = applications[ pos ]; + count += app->SendMsg( message ); + } + return count; +} + + +void Ivy::CallMessageCallback(IvyApplication *app, int id, int argc, const char ** argv) +{ + IvyMessageCallback *callback; + callback = callbacks[ id ]; + if ( callback ) + { + callback->OnMessage( app, argc, argv ); + } +} + +void Ivy::CallDirectMessageCallback(IvyApplication *app, int id, const char *arg) +{ + if ( direct_callback ) + { + direct_callback->OnDirectMessage( app, id, arg ); + } +} + +BOOL Ivy::CallDieCallback(IvyApplication *app, int id, const char *arg) +{ + if ( die_callback ) + { + return die_callback->OnDie( app, id, arg ); + } + return TRUE; +} + +void Ivy::CallApplicationConnectedCallback(IvyApplication * app) +{ + if ( application_callback ) + { + application_callback->OnApplicationConnected( app ); + } +} +void Ivy::CallApplicationDisconnectedCallback(IvyApplication * app) +{ + if ( application_callback ) + { + application_callback->OnApplicationDisconnected( app ); + } +} +void Ivy::SendDirectMsg(IvyApplication * app, int id, const char *message) +{ + app->SendMsg( IvyApplication::DirectMsg, id, message ); +} + +BOOL Ivy::CheckRegexp(const char * exp) +{ + /* accepte tout par default */ + int i; + int regexp_ok = 1; + 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; + } + } + return regexp_ok; +} + +void Ivy::Classes(int argc, const char **argv ) +{ + messages_classes_count = argc; + messages_classes = argv; +} + +BOOL Ivy::CheckConnected(IvyApplication * app) +{ + if (app->remoteService == 0) /* old application dont check */ + return false; + /* check to see if app already connected */ + for ( int pos = 0; pos < applications.size(); pos++ ) + { + IvyApplication *application = applications[ pos ]; + if ( application != app && application->SameApplication(app)) + return true; + } + return false; +} -- cgit v1.1 From 574e115b9a6ee3e2469084a874bfa04f18316208 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:55:40 +0000 Subject: Utilisateur : Fcolin Date : 30/06/00 Heure : 9:37 Archivé dans $/Ivy Commentaire: bug si pas de IVYBUS (vss 2) --- Ivy/Ivy.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index e3c6bc6..fd762b6 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -83,7 +83,9 @@ const char * Ivy::GetDomain(const char *domainlist) } if ( domain.empty() ) { - domain = getenv ( "IVYBUS" ); + const char *env = getenv ( "IVYBUS" ); + if ( env ) + domain = env; if ( domain.empty() ) domain = DEFAULT_DOMAIN; } -- cgit v1.1 From 04c9642429d5008dd5cb6a90ca7fa544c20d6fc8 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:55:42 +0000 Subject: Utilisateur : Fcolin Date : 20/07/00 Heure : 10:57 Archivé dans $/Ivy (vss 3) --- Ivy/Ivy.cxx | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index fd762b6..9091264 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -112,9 +112,10 @@ void Ivy::stop() { watcher->stop(); - for ( int pos = 0 ; pos < applications.size() ; pos++ ) + IvyApplicationList::iterator iter; + for ( iter = applications.begin() ; iter != applications.end() ; ++iter ) { - IvyApplication *app = applications[pos]; + IvyApplication *app = *iter; delete app; } applications.clear(); @@ -126,9 +127,10 @@ int Ivy::BindMsg(const char *regexp, IvyMessageCallback *cb) callbacks.push_back( synchronous ? new IvySynchronousMessageCallback(cb) : cb ); /* send to already connected */ - for ( int pos = 0 ; pos < applications.size() ; pos ++ ) + IvyApplicationList::iterator iter; + for ( iter = applications.begin() ; iter != applications.end() ; ++iter ) { - IvyApplication *app = applications[ pos ]; + IvyApplication *app = *iter; app->SendMsg(IvyApplication::AddRegexp, id, regexp ); } return id++; @@ -139,9 +141,10 @@ void Ivy::UnbindMsg(int id) regexp_out[ id ] = ""; callbacks[ id ] = NULL; /* send to already connected */ - for ( int pos = 0 ; pos < applications.size(); pos ++ ) + IvyApplicationList::iterator iter; + for ( iter = applications.begin() ; iter != applications.end() ; ++iter ) { - IvyApplication *app = applications[ pos ]; + IvyApplication *app = *iter; app->SendMsg(IvyApplication::DelRegexp, id, "" ); } @@ -161,12 +164,13 @@ void Ivy::AddApplication(IvyApplication *app) { EnterCriticalSection( &m_application_cs ); // Check for disconnected Application - for ( int pos = 0; pos < applications.size(); pos ++ ) + IvyApplicationList::iterator iter; + for ( iter = applications.begin() ; iter != applications.end() ; ) { - IvyApplication *disc_app = applications[ pos ]; + IvyApplication *disc_app = *iter++; if ( disc_app->m_hSocket == INVALID_SOCKET ) { - //applications.erase( pos ); + applications.remove( disc_app ); delete disc_app; } } @@ -182,16 +186,11 @@ void Ivy::RemoveApplication(IvyApplication * app) assert( TRUE ); if ( app ) { - for ( int pos = 0; pos < applications.size(); pos ++ ) - { - if ( app == applications[ pos ] ) - { + EnterCriticalSection( &m_application_cs ); - //applications.erase( pos ); + applications.remove( app ); LeaveCriticalSection( &m_application_cs ); delete app; - } - } } } @@ -213,9 +212,10 @@ int Ivy::SendMsg(const char * message) { int count = 0; /* send to already connected */ - for ( int pos = 0 ; pos < applications.size(); pos ++ ) + IvyApplicationList::iterator iter; + for ( iter = applications.begin() ; iter != applications.end() ; ++iter ) { - IvyApplication *app = applications[ pos ]; + IvyApplication *app = *iter; count += app->SendMsg( message ); } return count; @@ -296,9 +296,10 @@ BOOL Ivy::CheckConnected(IvyApplication * app) if (app->remoteService == 0) /* old application dont check */ return false; /* check to see if app already connected */ - for ( int pos = 0; pos < applications.size(); pos++ ) + IvyApplicationList::iterator iter; + for ( iter = applications.begin() ; iter != applications.end() ; ++iter ) { - IvyApplication *application = applications[ pos ]; + IvyApplication *application = *iter; if ( application != app && application->SameApplication(app)) return true; } -- cgit v1.1 From 570fc607cb946a8caa2ef7536e024c617df4d243 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:55:44 +0000 Subject: Utilisateur : Fcolin Date : 23/01/01 Heure : 13:12 Archivé dans $/Ivy Commentaire: remove 'using name space std;' (vss 4) --- Ivy/Ivy.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index 9091264..7ab5ac9 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -199,7 +199,7 @@ void Ivy::SendSubscriptions(IvyApplication *app) app->SendMsg( IvyApplication::StartRegexp, GetApplicationPort(), appname.c_str()); for ( int id = 0 ; id < regexp_out.size(); id++ ) { - const string& regexp = regexp_out[id]; + const String& regexp = regexp_out[id]; if ( !regexp.empty() ) app->SendMsg( IvyApplication::AddRegexp, id, regexp.c_str()); } -- cgit v1.1 From c3cb3ebbf3e254a0a1e5c0837ff410d44987e87c Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:55:46 +0000 Subject: Utilisateur : Fcolin Date : 31/01/01 Heure : 11:18 Archivé dans $/Ivy (vss 5) --- Ivy/Ivy.cxx | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index 7ab5ac9..54b7069 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -83,9 +83,11 @@ const char * Ivy::GetDomain(const char *domainlist) } if ( domain.empty() ) { +#ifdef _WIN_CE const char *env = getenv ( "IVYBUS" ); if ( env ) domain = env; +#endif if ( domain.empty() ) domain = DEFAULT_DOMAIN; } @@ -94,7 +96,7 @@ const char * Ivy::GetDomain(const char *domainlist) if ( sep_index == -1 ) { domain = DEFAULT_DOMAIN; - TRACE(" Missing ':' in domain list using default domain %s\n", domain.c_str() ); + TRACE(" Missing ':' in domain list using default domain %s\n", domain ); } if ( sep_index == 0 ) { @@ -155,7 +157,7 @@ void Ivy::BindDirectMsg(IvyDirectMessageCallback *callback) direct_callback = callback; } -UINT Ivy::GetApplicationPort() +unsigned short Ivy::GetApplicationPort() { return applicationPort; } @@ -183,7 +185,7 @@ void Ivy::RemoveApplication(IvyApplication * app) /// OLD NOT called because of deallocation PB // the real remove is done at arrival of a new Application // or at the bus Stop - assert( TRUE ); + ASSERT( TRUE ); if ( app ) { @@ -199,7 +201,7 @@ void Ivy::SendSubscriptions(IvyApplication *app) app->SendMsg( IvyApplication::StartRegexp, GetApplicationPort(), appname.c_str()); for ( int id = 0 ; id < regexp_out.size(); id++ ) { - const String& regexp = regexp_out[id]; + const string& regexp = regexp_out[id]; if ( !regexp.empty() ) app->SendMsg( IvyApplication::AddRegexp, id, regexp.c_str()); } @@ -240,7 +242,7 @@ void Ivy::CallDirectMessageCallback(IvyApplication *app, int id, const char *ar } } -BOOL Ivy::CallDieCallback(IvyApplication *app, int id, const char *arg) +bool Ivy::CallDieCallback(IvyApplication *app, int id, const char *arg) { if ( die_callback ) { @@ -268,14 +270,14 @@ void Ivy::SendDirectMsg(IvyApplication * app, int id, const char *message) app->SendMsg( IvyApplication::DirectMsg, id, message ); } -BOOL Ivy::CheckRegexp(const char * exp) +bool Ivy::CheckRegexp(const char * exp) { /* accepte tout par default */ int i; - int regexp_ok = 1; + bool regexp_ok = true; if ( *exp =='^' && messages_classes_count !=0 ) { - regexp_ok = 0; + regexp_ok = false; for ( i = 0 ; i < messages_classes_count; i++ ) { if (strncmp( messages_classes[i], exp+1, strlen( messages_classes[i] )) == 0) @@ -291,7 +293,7 @@ void Ivy::Classes(int argc, const char **argv ) messages_classes = argv; } -BOOL Ivy::CheckConnected(IvyApplication * app) +bool Ivy::CheckConnected(IvyApplication * app) { if (app->remoteService == 0) /* old application dont check */ return false; -- cgit v1.1 From e0729eb3b7aed25acde9992dad2e4614fda677de Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:55:48 +0000 Subject: Utilisateur : Fcolin Date : 2/02/01 Heure : 18:30 Archivé dans $/Ivy Commentaire: win CE compile not finished (vss 6) --- Ivy/Ivy.cxx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index 54b7069..6284c0c 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -3,7 +3,13 @@ ////////////////////////////////////////////////////////////////////// #include "stdafx.h" -//#include "libIvy.h" + +#ifdef _DEBUG +#define DEBUG_NEW new(__FILE__, __LINE__) +#define new DEBUG_NEW +#endif + + #include "Ivy.h" #include "IvyWatcher.h" @@ -28,7 +34,7 @@ Ivy::~Ivy() stop(); regexp_out.clear(); - for ( int i = 0; i < callbacks.size(); i ++) + for ( unsigned int i = 0; i < callbacks.size(); i ++) { delete callbacks[i]; } @@ -199,7 +205,7 @@ void Ivy::RemoveApplication(IvyApplication * app) void Ivy::SendSubscriptions(IvyApplication *app) { app->SendMsg( IvyApplication::StartRegexp, GetApplicationPort(), appname.c_str()); - for ( int id = 0 ; id < regexp_out.size(); id++ ) + for ( unsigned int id = 0 ; id < regexp_out.size(); id++ ) { const string& regexp = regexp_out[id]; if ( !regexp.empty() ) -- cgit v1.1 From ddfc3e0fa9d9fbf86d2d8ca1ead9ab4223d27dd1 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:55:50 +0000 Subject: Utilisateur : Fcolin Date : 14/02/01 Heure : 18:47 Archivé dans $/Ivy (vss 7) --- Ivy/Ivy.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index 6284c0c..561031c 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -44,7 +44,7 @@ Ivy::~Ivy() // if ( application_callback ) delete application_callback; delete watcher; - server->Close(); +// server->Close(); delete server; if ( synchronous ) { -- cgit v1.1 From 00cf18f4f75ac42dad7337ad22c1808e53b62a3e Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:55:52 +0000 Subject: Utilisateur : Fcolin Date : 20/02/01 Heure : 10:27 Archivé dans $/Ivy (vss 8) --- Ivy/Ivy.cxx | 1 - 1 file changed, 1 deletion(-) (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index 561031c..3f8daed 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -9,7 +9,6 @@ #define new DEBUG_NEW #endif - #include "Ivy.h" #include "IvyWatcher.h" -- cgit v1.1 From 121227691c09257a90493aa8dbf0a57f2f8ad199 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:55:54 +0000 Subject: Utilisateur : Fcolin Date : 17/07/01 Heure : 18:25 Archivé dans $/Ivy (vss 9) --- Ivy/Ivy.cxx | 5 ----- 1 file changed, 5 deletions(-) (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index 3f8daed..c56356c 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -4,11 +4,6 @@ #include "stdafx.h" -#ifdef _DEBUG -#define DEBUG_NEW new(__FILE__, __LINE__) -#define new DEBUG_NEW -#endif - #include "Ivy.h" #include "IvyWatcher.h" -- cgit v1.1 From 9af56b54bfcef47df42532d79ab7743548e32c0b Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:55:56 +0000 Subject: Utilisateur : Fcolin Date : 25/10/01 Heure : 18:39 Archivé dans $/Ivy (vss 10) --- Ivy/Ivy.cxx | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index c56356c..3906333 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -83,7 +83,7 @@ const char * Ivy::GetDomain(const char *domainlist) } if ( domain.empty() ) { -#ifdef _WIN_CE +#ifndef _WIN_CE const char *env = getenv ( "IVYBUS" ); if ( env ) domain = env; @@ -210,19 +210,44 @@ void Ivy::SendSubscriptions(IvyApplication *app) } -int Ivy::SendMsg(const char * message) +int Ivy::SendMsg(const char * message, ... ) { int count = 0; + char buffer[4096]; + va_list args; + + va_start( args, message ); /* Initialize variable arguments. */ + vsprintf( buffer, message, args ); + va_end( args); /* send to already connected */ IvyApplicationList::iterator iter; for ( iter = applications.begin() ; iter != applications.end() ; ++iter ) { IvyApplication *app = *iter; - count += app->SendMsg( message ); + count += app->SendMsg( buffer ); } return count; } - +void Ivy::SendDieMsg( IvyApplication *app ) +{ + app->SendMsg( IvyApplication::Die, 0 ); +} +IvyApplication * Ivy::GetApplication(const char *name) +{ + EnterCriticalSection( &m_application_cs ); + IvyApplicationList::iterator iter; + for ( iter = applications.begin() ; iter != applications.end() ; ) + { + IvyApplication *app = *iter++; + if ( (app->m_hSocket != INVALID_SOCKET) && app->appname == name ) + { + return app; + } + } + LeaveCriticalSection( &m_application_cs ); + return NULL; +} + void Ivy::CallMessageCallback(IvyApplication *app, int id, int argc, const char ** argv) { -- cgit v1.1 From 49ebd55611e86e6fc63d8afcc38888c5991799fc Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:55:58 +0000 Subject: Utilisateur : Fcolin Date : 7/06/02 Heure : 9:35 Archivé dans $/Ivy (vss 11) --- Ivy/Ivy.cxx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index 3906333..c10785f 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -28,11 +28,15 @@ Ivy::~Ivy() stop(); regexp_out.clear(); - for ( unsigned int i = 0; i < callbacks.size(); i ++) - { + if ( synchronous ) + { + for ( unsigned int i = 0; i < callbacks.size(); i ++) + { delete callbacks[i]; - } + } + } callbacks.clear(); + // if ( direct_callback ) delete direct_callback; // if ( application_callback ) delete application_callback; -- cgit v1.1 From 3b071ef64481621c5fdea7c0117ff88407b87269 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:56:00 +0000 Subject: Utilisateur : Fcolin Date : 19/06/02 Heure : 15:14 Archivé dans $/Ivy (vss 12) --- Ivy/Ivy.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index c10785f..a6757c2 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -161,7 +161,7 @@ void Ivy::BindDirectMsg(IvyDirectMessageCallback *callback) direct_callback = callback; } -unsigned short Ivy::GetApplicationPort() +unsigned int Ivy::GetApplicationPort() { return applicationPort; } -- cgit v1.1 From b92f4c6128c14ad1c63a37a9d71cc2b0e42c056f Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:56:02 +0000 Subject: Utilisateur : Fcolin Date : 25/11/02 Heure : 16:15 Archivé dans $/Bus/Ivy Commentaire: (vss 13) --- Ivy/Ivy.cxx | 1 + 1 file changed, 1 insertion(+) (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index a6757c2..e5b11ea 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -122,6 +122,7 @@ void Ivy::stop() for ( iter = applications.begin() ; iter != applications.end() ; ++iter ) { IvyApplication *app = *iter; + app->Close(); delete app; } applications.clear(); -- cgit v1.1 From 8538e20f9ef0bb69a6b7a82f8b46e662d59ce398 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:56:04 +0000 Subject: Utilisateur : Fcolin Date : 6/01/03 Heure : 14:47 Archivé dans $/Bus/Ivy Commentaire: (vss 14) --- Ivy/Ivy.cxx | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index e5b11ea..8b26e77 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -27,6 +27,7 @@ Ivy::~Ivy() // remove all app and stop watcher stop(); regexp_out.clear(); + if ( synchronous ) { @@ -55,7 +56,7 @@ Ivy::~Ivy() Ivy::Ivy(const char* name, const char * ready, IvyApplicationCallback *callback, bool Synchronous) { InitializeCriticalSection( &m_application_cs ); - + regexp_id = 0; synchronous = Synchronous; if ( synchronous ) IvySynchronousCallback::m_synchro = new IvySynchroWnd(); @@ -129,7 +130,6 @@ void Ivy::stop() } int Ivy::BindMsg(const char *regexp, IvyMessageCallback *cb) { - static int id = 0; regexp_out.push_back( regexp ); callbacks.push_back( synchronous ? new IvySynchronousMessageCallback(cb) : cb ); @@ -138,11 +138,32 @@ int Ivy::BindMsg(const char *regexp, IvyMessageCallback *cb) for ( iter = applications.begin() ; iter != applications.end() ; ++iter ) { IvyApplication *app = *iter; - app->SendMsg(IvyApplication::AddRegexp, id, regexp ); + app->SendMsg(IvyApplication::AddRegexp, regexp_id, regexp ); } - return id++; + return regexp_id++; } +int Ivy::BindMsg( IvyMessageCallback *cb, const char *regexp, ... ) +{ + char buffer[4096]; + va_list args; + + va_start( args, regexp ); /* Initialize variable arguments. */ + vsprintf( buffer, regexp, args ); + va_end( args); + + regexp_out.push_back( regexp ); + callbacks.push_back( synchronous ? new IvySynchronousMessageCallback(cb) : cb ); + /* send to already connected */ + IvyApplicationList::iterator iter; + for ( iter = applications.begin() ; iter != applications.end() ; ++iter ) + { + IvyApplication *app = *iter; + app->SendMsg(IvyApplication::AddRegexp, regexp_id, buffer ); + } + return regexp_id++; +} + void Ivy::UnbindMsg(int id) { regexp_out[ id ] = ""; -- cgit v1.1 From 9477367dc0a9a232bf57edaa5e1e2595bb70cba7 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:56:06 +0000 Subject: Utilisateur : Fcolin Date : 4/02/03 Heure : 8:59 Archivé dans $/Bus/Ivy Commentaire: (vss 15) --- Ivy/Ivy.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index 8b26e77..b592c11 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -88,7 +88,7 @@ const char * Ivy::GetDomain(const char *domainlist) } if ( domain.empty() ) { -#ifndef _WIN_CE +#ifndef UNDER_CE const char *env = getenv ( "IVYBUS" ); if ( env ) domain = env; -- cgit v1.1 From 3f87f03a578226cd5a8700889deb6f2a06264b9e Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:56:08 +0000 Subject: Utilisateur : Fcolin Date : 30/09/03 Heure : 16:49 Archivé dans $/Bus/Ivy Commentaire: (vss 16) --- Ivy/Ivy.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index b592c11..609733d 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -101,7 +101,7 @@ const char * Ivy::GetDomain(const char *domainlist) if ( sep_index == -1 ) { domain = DEFAULT_DOMAIN; - TRACE(" Missing ':' in domain list using default domain %s\n", domain ); + TRACE(" Missing ':' in domain list using default domain %s\n", domain.c_str() ); } if ( sep_index == 0 ) { -- cgit v1.1 From f2271c04c9c833d3c4c8a9dc2d5cd579cb97913d Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:56:10 +0000 Subject: Utilisateur : Fcolin Date : 5/02/04 Heure : 18:32 Archivé dans $/Bus/Ivy Commentaire: (vss 17) --- Ivy/Ivy.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index 609733d..b592c11 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -101,7 +101,7 @@ const char * Ivy::GetDomain(const char *domainlist) if ( sep_index == -1 ) { domain = DEFAULT_DOMAIN; - TRACE(" Missing ':' in domain list using default domain %s\n", domain.c_str() ); + TRACE(" Missing ':' in domain list using default domain %s\n", domain ); } if ( sep_index == 0 ) { -- cgit v1.1 From d05917942b4a46fccad770655235fbfdc06bbf99 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:56:12 +0000 Subject: Utilisateur : Fcolin Date : 12/05/05 Heure : 14:05 Archivé dans $/Bus/Ivy Commentaire: Bug dans Ivy GetApplication ( name ) pas de release de la section critique!! (vss 18) --- Ivy/Ivy.cxx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index b592c11..e7505d1 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -260,18 +260,20 @@ void Ivy::SendDieMsg( IvyApplication *app ) } IvyApplication * Ivy::GetApplication(const char *name) { + IvyApplication *app = NULL; EnterCriticalSection( &m_application_cs ); IvyApplicationList::iterator iter; for ( iter = applications.begin() ; iter != applications.end() ; ) { - IvyApplication *app = *iter++; - if ( (app->m_hSocket != INVALID_SOCKET) && app->appname == name ) + IvyApplication *ap = *iter++; + if ( (ap->m_hSocket != INVALID_SOCKET) && ap->appname == name ) { - return app; + app = ap; + break; // dont return because of LeaveCriticalSection !!! } } LeaveCriticalSection( &m_application_cs ); - return NULL; + return app; } -- cgit v1.1 From b1d9a197c185ccc3b0f67ee55713f16cdebad461 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:56:14 +0000 Subject: Utilisateur : Fcolin Date : 1/06/05 Heure : 16:45 Archivé dans $/Bus/Ivy Commentaire: (vss 19) --- Ivy/Ivy.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index e7505d1..7cd8dde 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -2,7 +2,7 @@ // ////////////////////////////////////////////////////////////////////// -#include "stdafx.h" +#include "IvyStdAfx.h" #include "Ivy.h" @@ -148,7 +148,7 @@ int Ivy::BindMsg( IvyMessageCallback *cb, const char *regexp, ... ) va_list args; va_start( args, regexp ); /* Initialize variable arguments. */ - vsprintf( buffer, regexp, args ); + _vsnprintf( buffer, sizeof(buffer), regexp, args ); va_end( args); regexp_out.push_back( regexp ); @@ -243,7 +243,7 @@ int Ivy::SendMsg(const char * message, ... ) va_list args; va_start( args, message ); /* Initialize variable arguments. */ - vsprintf( buffer, message, args ); + _vsnprintf( buffer, sizeof(buffer), message, args ); va_end( args); /* send to already connected */ IvyApplicationList::iterator iter; -- cgit v1.1 From 36b8ea1503500ad1e4220090b90f1b0001da896f Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:56:16 +0000 Subject: Utilisateur : Fcolin Date : 2/06/05 Heure : 18:42 Archivé dans $/Bus/Ivy Commentaire: Suppression de la STL et ajout d'un namespace pour les datatypes internes Ivy (vss 20) --- Ivy/Ivy.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index 7cd8dde..3ef0ce2 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -227,7 +227,7 @@ void Ivy::SendSubscriptions(IvyApplication *app) app->SendMsg( IvyApplication::StartRegexp, GetApplicationPort(), appname.c_str()); for ( unsigned int id = 0 ; id < regexp_out.size(); id++ ) { - const string& regexp = regexp_out[id]; + const ivy::string& regexp = regexp_out[id]; if ( !regexp.empty() ) app->SendMsg( IvyApplication::AddRegexp, id, regexp.c_str()); } -- cgit v1.1 From e2773f2d3c326d4492311332cedbc33dc71d9205 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:56:18 +0000 Subject: Utilisateur : Fcolin Date : 23/09/05 Heure : 15:27 Archivé dans $/Bus/Ivy Commentaire: (vss 21) --- Ivy/Ivy.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index 3ef0ce2..c70d23f 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -97,7 +97,7 @@ const char * Ivy::GetDomain(const char *domainlist) domain = DEFAULT_DOMAIN; } // first find our UDP port - int sep_index = domain.rfind( ':' ); + size_t sep_index = domain.rfind( ':' ); if ( sep_index == -1 ) { domain = DEFAULT_DOMAIN; -- cgit v1.1 From 875e598e3e1b09ee41a3aeaefc3b8bc78ac68d48 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:56:20 +0000 Subject: Utilisateur : Fcolin Date : 16/11/05 Heure : 9:54 Archivé dans $/Bus/Ivy Commentaire: 64 bits ports (vss 22) --- Ivy/Ivy.cxx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index c70d23f..daa2129 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -89,9 +89,17 @@ const char * Ivy::GetDomain(const char *domainlist) if ( domain.empty() ) { #ifndef UNDER_CE - const char *env = getenv ( "IVYBUS" ); - if ( env ) + size_t requiredSize; + + getenv_s( &requiredSize, NULL, 0, "IVYBUS"); + + if ( requiredSize ) + { + char *env = (char*)malloc( requiredSize * sizeof(char)); + getenv_s( &requiredSize, env, requiredSize, "IVYBUS"); domain = env; + free( env ); + } #endif if ( domain.empty() ) domain = DEFAULT_DOMAIN; @@ -148,7 +156,7 @@ int Ivy::BindMsg( IvyMessageCallback *cb, const char *regexp, ... ) va_list args; va_start( args, regexp ); /* Initialize variable arguments. */ - _vsnprintf( buffer, sizeof(buffer), regexp, args ); + _vsnprintf_s( buffer, sizeof(buffer), sizeof(buffer)-1, regexp, args ); va_end( args); regexp_out.push_back( regexp ); @@ -243,7 +251,7 @@ int Ivy::SendMsg(const char * message, ... ) va_list args; va_start( args, message ); /* Initialize variable arguments. */ - _vsnprintf( buffer, sizeof(buffer), message, args ); + _vsnprintf_s( buffer, sizeof(buffer), sizeof(buffer)-1, message, args ); va_end( args); /* send to already connected */ IvyApplicationList::iterator iter; -- cgit v1.1 From e5faff1c9281641151f0fb6cff53d223fc1d1b91 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:56:22 +0000 Subject: Utilisateur : Fcolin Date : 18/11/05 Heure : 11:46 Archivé dans $/Bus/Ivy Commentaire: repassage a la STL et correction bug multithread (vss 23) --- Ivy/Ivy.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index daa2129..49be33b 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -219,7 +219,7 @@ void Ivy::RemoveApplication(IvyApplication * app) /// OLD NOT called because of deallocation PB // the real remove is done at arrival of a new Application // or at the bus Stop - ASSERT( TRUE ); + TRACE( "Ivy::RemoveApplication %lu\n", app ); if ( app ) { -- cgit v1.1 From 4012d9d589b8063a57be612b913dfa7270f5a017 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:56:24 +0000 Subject: Utilisateur : Fcolin Date : 23/05/06 Heure : 18:18 Archivé dans $/Bus/Ivy Commentaire: Modification protocol UDP (vss 24) --- Ivy/Ivy.cxx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index 49be33b..66c1715 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -61,7 +61,7 @@ Ivy::Ivy(const char* name, const char * ready, IvyApplicationCallback *callback, if ( synchronous ) IvySynchronousCallback::m_synchro = new IvySynchroWnd(); ready_message = ready; - appname = name; + ApplicationName = name; messages_classes_count = 0; messages_classes = NULL; application_callback = synchronous ? new IvySynchronousApplicationCallback(callback) : callback; @@ -74,10 +74,21 @@ Ivy::Ivy(const char* name, const char * ready, IvyApplicationCallback *callback, TRACE( " Can't Create server %d\n", server->GetLastError( ) ); return; } + ApplicationID = GenApplicationUniqueIdentifier(); watcher = new IvyWatcher(this); } +const char *Ivy::GenApplicationUniqueIdentifier() +{ + static char appid[2048]; + long curtime; + curtime = GetTickCount(); + srand( curtime ); + sprintf(appid,"%d:%ld:%d",rand(),curtime,applicationPort); + return appid; +} + const char * Ivy::GetDomain(const char *domainlist) { // determine domain to use @@ -232,7 +243,7 @@ void Ivy::RemoveApplication(IvyApplication * app) void Ivy::SendSubscriptions(IvyApplication *app) { - app->SendMsg( IvyApplication::StartRegexp, GetApplicationPort(), appname.c_str()); + app->SendMsg( IvyApplication::StartRegexp, GetApplicationPort(), ApplicationName.c_str()); for ( unsigned int id = 0 ; id < regexp_out.size(); id++ ) { const ivy::string& regexp = regexp_out[id]; -- cgit v1.1 From 3e928d698cf896b413b894a5c2df83562872ec4f Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:56:26 +0000 Subject: Utilisateur : Fcolin Date : 1/06/06 Heure : 10:14 Archivé dans $/Bus/Ivy Commentaire: ajout Binding Callback et SetFilter (vss 25) --- Ivy/Ivy.cxx | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index 66c1715..2da3766 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -64,6 +64,7 @@ Ivy::Ivy(const char* name, const char * ready, IvyApplicationCallback *callback, ApplicationName = name; messages_classes_count = 0; messages_classes = NULL; + binding_callback = NULL; application_callback = synchronous ? new IvySynchronousApplicationCallback(callback) : callback; direct_callback = NULL; die_callback = NULL; @@ -337,6 +338,27 @@ void Ivy::CallApplicationDisconnectedCallback(IvyApplication * app) application_callback->OnApplicationDisconnected( app ); } } +void Ivy::CallBindingAddCallback(IvyApplication * app, int id, const char * regexp) +{ + if ( binding_callback ) + { + binding_callback->OnAddBind( app, id, regexp ); + } +} +void Ivy::CallBindingRemoveCallback(IvyApplication * app, int id, const char * regexp) +{ + if ( binding_callback ) + { + binding_callback->OnRemoveBind( app, id, regexp ); + } +} +void Ivy::CallBindingFilterCallback(IvyApplication * app, int id, const char * regexp) +{ + if ( binding_callback ) + { + binding_callback->OnFilterBind( app, id, regexp ); + } +} void Ivy::SendDirectMsg(IvyApplication * app, int id, const char *message) { app->SendMsg( IvyApplication::DirectMsg, id, message ); @@ -358,8 +380,12 @@ bool Ivy::CheckRegexp(const char * exp) } return regexp_ok; } - -void Ivy::Classes(int argc, const char **argv ) +void Ivy::SetBindCallback( IvyBindingCallback* bind_callback ) +{ + binding_callback = synchronous ? new IvySynchronousBindingCallback(bind_callback) : bind_callback; +} + +void Ivy::SetFilter(int argc, const char **argv ) { messages_classes_count = argc; messages_classes = argv; -- cgit v1.1 From d7ee0aeb171c78ab5ec980d869ae67747a9bc87c Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:56:28 +0000 Subject: Utilisateur : Fcolin Date : 1/06/06 Heure : 15:54 Archivé dans $/Bus/Ivy Commentaire: Separation module de traitement regexp (vss 26) --- Ivy/Ivy.cxx | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index 2da3766..60ba574 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -9,7 +9,7 @@ #include "IvyWatcher.h" #include "IvyApplication.h" #include "IvySynchroWnd.h" - +#include "IvyBinding.h" #define DEFAULT_ADDR "127.255.255.255" #define SEPARATOR ":" @@ -62,8 +62,7 @@ Ivy::Ivy(const char* name, const char * ready, IvyApplicationCallback *callback, IvySynchronousCallback::m_synchro = new IvySynchroWnd(); ready_message = ready; ApplicationName = name; - messages_classes_count = 0; - messages_classes = NULL; + binding_callback = NULL; application_callback = synchronous ? new IvySynchronousApplicationCallback(callback) : callback; direct_callback = NULL; @@ -364,22 +363,6 @@ void Ivy::SendDirectMsg(IvyApplication * app, int id, const char *message) app->SendMsg( IvyApplication::DirectMsg, id, message ); } -bool Ivy::CheckRegexp(const char * exp) -{ - /* accepte tout par default */ - int i; - bool regexp_ok = true; - if ( *exp =='^' && messages_classes_count !=0 ) - { - regexp_ok = false; - for ( i = 0 ; i < messages_classes_count; i++ ) - { - if (strncmp( messages_classes[i], exp+1, strlen( messages_classes[i] )) == 0) - return 1; - } - } - return regexp_ok; -} void Ivy::SetBindCallback( IvyBindingCallback* bind_callback ) { binding_callback = synchronous ? new IvySynchronousBindingCallback(bind_callback) : bind_callback; @@ -387,8 +370,7 @@ void Ivy::SetBindCallback( IvyBindingCallback* bind_callback ) void Ivy::SetFilter(int argc, const char **argv ) { - messages_classes_count = argc; - messages_classes = argv; + IvyBinding::SetFilter(argc, argv ); } bool Ivy::CheckConnected(IvyApplication * app) -- cgit v1.1 From fd7e142c90b804b21c86e8905922897f7f2ec4c5 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:56:30 +0000 Subject: Utilisateur : Fcolin Date : 2/06/06 Heure : 17:00 Archivé dans $/Bus/Ivy Commentaire: correction pb signe dans applicationUniqueID (vss 27) --- Ivy/Ivy.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index 60ba574..d4c6056 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -82,10 +82,10 @@ Ivy::Ivy(const char* name, const char * ready, IvyApplicationCallback *callback, const char *Ivy::GenApplicationUniqueIdentifier() { static char appid[2048]; - long curtime; + unsigned long curtime; curtime = GetTickCount(); srand( curtime ); - sprintf(appid,"%d:%ld:%d",rand(),curtime,applicationPort); + sprintf(appid,"%d:%lu:%d",rand(),curtime,applicationPort); return appid; } -- cgit v1.1 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/Ivy.cxx') 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 From 0bae5197999f5ed9e52bf3b94acb9e3f107a20e6 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:56:34 +0000 Subject: Utilisateur : Fcolin Date : 22/09/06 Heure : 18:11 Archivé dans $/Bus/Ivy Commentaire: ajout intervalRegexp (vss 29) --- Ivy/Ivy.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Ivy/Ivy.cxx') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index 0a09c91..4564c6f 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -396,10 +396,10 @@ bool Ivy::CheckConnected(IvyApplication * app) } 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) { + strcpy (dst,src); return; } else { char *curPos; @@ -432,6 +432,6 @@ void Ivy::SubstituteInterval (const char *src, char *dst, size_t dst_len) } strncat (dstPos, curPos, dst_len-(dstPos-dst)); } -// #endif + } -- cgit v1.1