From cb4acfaf1f4b6a1a1fe0ee4722592022893f1d2a Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:59:29 +0000 Subject: Utilisateur : Fcolin Date : 16/06/00 Heure : 10:14 Créé (vss 1) --- Ivy/IvyApplication.cxx | 307 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 307 insertions(+) create mode 100644 Ivy/IvyApplication.cxx (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx new file mode 100644 index 0000000..26d0adf --- /dev/null +++ b/Ivy/IvyApplication.cxx @@ -0,0 +1,307 @@ +// IvyApplication.cpp : implementation file +// + +#include "stdafx.h" +//#include "libIvy.h" +#include "IvyApplication.h" +#include "Regexp.h" + +//#define DEBUG + +#define ARG_START "\002" +#define ARG_END "\003" + + +///////////////////////////////////////////////////////////////////////////// +// IvyApplication + +IvyApplication::IvyApplication(Ivy * bus) +{ + this->bus = bus; + remoteService = 0; /* unknown or unconnected application */ + appname = "Unknown"; + AppConnectedCallbackCalled = false; +} + +IvyApplication::~IvyApplication() +{ +// bus->RemoveApplication( this ); + for ( int i = 0; i < regexp_in.size(); i++) + delete regexp_in[i]; + regexp_in.clear(); + if ( m_hSocket != INVALID_SOCKET ) + Close(); +} + + +///////////////////////////////////////////////////////////////////////////// +// IvyApplication member functions + + +void IvyApplication::Create(const char* host, UINT & port) +{ + // Exception to catch + CBufferedSocket::Create(); + Connect(host, port); +} + + + +UINT IvyApplication::Create() +{ + string host; + UINT port; + CBufferedSocket::Create(); + // Max Listen Connexion + Listen( SOMAXCONN ); + GetSockName( host, port ); + TRACE(" TCP %s:%d\n", host.c_str(), port ); +#ifdef DEBUG + TRACE( "IvyApplication::Create server socket %d\n", m_hSocket ); +#endif + return port; +} + +void IvyApplication::OnReceive(char * line) +{ + int err,id; + int kind_of_msg = Bye; + Regexp *exp; + + + int argc = 0; + const char *argv[Regexp::NSUBEXP]; + char *arg; + +#ifdef DEBUG + TRACE("Receive %s\n",line); +#endif //DEBUG + + err = sscanf( line ,"%d %d", &kind_of_msg, &id); + arg = strstr( line , ARG_START ); + if ( (err != 2) || (arg == NULL) ) + { + TRACE("Quitting bad format %s\n", line); + SendMsg(Error, Error, "bad format request expected 'type id ...'"); +// bus->RemoveApplication( this ); + Close(); + return; + } + arg++; + switch( kind_of_msg ) + { + case Bye: + +#ifdef DEBUG + TRACE("Quitting %s\n", line); +#endif //DEBUG + +// bus->RemoveApplication( this ); + Close(); + break; + case Error: + +#ifdef DEBUG + TRACE("Receive error %d %s\n", id, arg); +#endif //DEBUG + + break; + case AddRegexp: + +#ifdef DEBUG + TRACE("Regexp id=%d exp='%s'\n", id, arg); +#endif //DEBUG + + if ( !bus->CheckRegexp( arg ) ) + { +#ifdef DEBUG + TRACE("Warning exp='%s' can't match removing from %s\n",arg,appname); +#endif //DEBUG + return; + } + exp = new Regexp( arg ); + if ( !exp->CompiledOK() ) + { + string regerr = exp->GetErrorString(); + string err; + err = "Error can't compile regexp '"+string(arg)+"' error "+regerr; + SendMsg( Error, Error, err.c_str() ); + TRACE("IvyApplication %s\n",err.c_str()); + return; + } + if ( id +1 < regexp_in.size() ) + regexp_in[ id ] = exp ; + else regexp_in.push_back( exp ); + break; + case DelRegexp: + +#ifdef DEBUG + TRACE("Regexp Delete id=%d\n", id); +#endif //DEBUG + if ( id < regexp_in.size() ) + { + exp = regexp_in[ id ]; + delete exp; + regexp_in[ id ] = NULL ; + } + break; + case StartRegexp: + +#ifdef DEBUG + TRACE("Regexp Start id=%d\n", id); +#endif //DEBUG + + appname = arg; + /* remote socket port */ + remoteService = id; + if ( bus->CheckConnected( this ) ) + { + TRACE("Quitting already connected %s\n", appname); + SendMsg( Error, Error, "already connected" ); +// bus->RemoveApplication( this ); + Close(); + } + break; + case EndRegexp: + +#ifdef DEBUG + TRACE("Regexp End id=%d\n", id); +#endif //DEBUG + + bus->CallApplicationConnectedCallback( this ); + AppConnectedCallbackCalled = true; + if ( !bus->ready_message.empty() ) + SendMsg( bus->ready_message.c_str() ); + break; + case Msg: + +#ifdef DEBUG + TRACE("Message id=%d msg='%s'\n", id, arg); +#endif //DEBUG + + arg = strtok( arg, ARG_END); + while ( arg ) + { + argv[argc++] = arg; + arg = strtok( NULL, ARG_END ); + } + bus->CallMessageCallback( this, id, argc, argv ); + break; + case DirectMsg: + +#ifdef DEBUG + TRACE("Direct Message id=%d msg='%s'\n", id, arg); +#endif //DEBUG + + bus->CallDirectMessageCallback( this, id, arg ); + break; + case Die: + +#ifdef DEBUG + TRACE("Die Message id=%d msg='%s'\n", id, arg); +#endif //DEBUG + + if ( bus->CallDieCallback( this, id, arg ) ) + { + PostMessage( NULL, WM_CLOSE, 0, 0); + } + break; + + default: + TRACE("Receive unhandled message %s\n", line); + break; + } +} + + +void IvyApplication::SendMsg(MsgType msg, int id, const char * arg) +{ + char buffer[1024]; + if ( arg ) + sprintf( buffer, "%d %d" ARG_START "%s\n", msg, id, arg ); + else sprintf( buffer, "%d %d" ARG_START "\n", msg, id ); + +#ifdef DEBUG + TRACE("SendMsg %s\n",buffer); +#endif //DEBUG + Send( buffer ); +} + +void IvyApplication::OnAccept(int nErrorCode) +{ + string remotehost; + UINT remoteport; + + // construct a new, empty socket + + IvyApplication *newapp = new IvyApplication(bus); + + // accept connection + + Accept( *newapp ); + newapp->GetPeerName( remotehost, remoteport ); + TRACE("Connexion de %s:%u\n", remotehost.c_str(), remoteport ); + bus->AddApplication( newapp ); +} + +void IvyApplication::OnClose(int nErrorCode) +{ + string remotehost; + UINT remoteport; + GetPeerName( remotehost, remoteport ); + TRACE("Deconnexion de %s:%u\n", remotehost.c_str(), remoteport ); + if ( AppConnectedCallbackCalled ) + bus->CallApplicationDisconnectedCallback( this ); +// bus->RemoveApplication( this ); + for ( int i = 0; i < regexp_in.size(); i++) + delete regexp_in[i]; + regexp_in.clear(); + Close(); +} + +int IvyApplication::SendMsg(const char *message) +{ + int count = 0; + Regexp *exp; + + /* send to already connected */ + for ( int id = 0; id < regexp_in.size(); id++ ) + { + exp = regexp_in[ id ]; + + if ( exp && exp->Match( message ) ) + { + string buffer; + for ( int i = 1; i < exp->SubStrings()+1; i++ ) + { + buffer += (*exp)[i]; + buffer += ARG_END; + } + SendMsg( Msg, id, buffer.c_str() ); + count++; + } + } + return count; +} + +const char *IvyApplication::GetName(void) +{ +return appname.c_str(); +} + + +BOOL IvyApplication::SameApplication(IvyApplication * app) +{ + string host1; + UINT port1; + string host2; + UINT port2; + if ( (remoteService != 0) && (remoteService == app->remoteService) ) + { + GetPeerName( host1, port1 ); + app->GetPeerName( host2, port2 ); + TRACE( "IvyApplication::SameApplication %s:%d %s:%d\n", host1.c_str(),port1, host2.c_str(),port2); + return ( host1 == host2 ); + } + return false; +} -- cgit v1.1 From 2e418cb4dd7804abf714cea0fb94903bad70a985 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:59:31 +0000 Subject: Utilisateur : Fcolin Date : 20/07/00 Heure : 10:57 Archivé dans $/Ivy (vss 2) --- Ivy/IvyApplication.cxx | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index 26d0adf..de43bd0 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -129,20 +129,18 @@ void IvyApplication::OnReceive(char * line) TRACE("IvyApplication %s\n",err.c_str()); return; } - if ( id +1 < regexp_in.size() ) - regexp_in[ id ] = exp ; - else regexp_in.push_back( exp ); + regexp_in[ id ] = exp ; break; case DelRegexp: #ifdef DEBUG TRACE("Regexp Delete id=%d\n", id); #endif //DEBUG - if ( id < regexp_in.size() ) + if ( regexp_in.find(id) != regexp_in.end() ) { exp = regexp_in[ id ]; delete exp; - regexp_in[ id ] = NULL ; + regexp_in.erase( id ); } break; case StartRegexp: @@ -263,11 +261,12 @@ int IvyApplication::SendMsg(const char *message) { int count = 0; Regexp *exp; - + map::iterator iter; /* send to already connected */ - for ( int id = 0; id < regexp_in.size(); id++ ) + if ( !regexp_in.empty() ) + for ( iter = regexp_in.begin(); iter != regexp_in.end(); iter++ ) { - exp = regexp_in[ id ]; + exp = (*iter).second; if ( exp && exp->Match( message ) ) { @@ -277,7 +276,7 @@ int IvyApplication::SendMsg(const char *message) buffer += (*exp)[i]; buffer += ARG_END; } - SendMsg( Msg, id, buffer.c_str() ); + SendMsg( Msg, (*iter).first, buffer.c_str() ); count++; } } -- cgit v1.1 From 98f393ff247e0073b052cd7484584719cf93fdaf Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:59:33 +0000 Subject: Utilisateur : Fcolin Date : 30/11/00 Heure : 15:34 Archivé dans $/Ivy Commentaire: pb sur l'exit le postMessage se fait sur une Thread Ivy donc pas de fenetre (vss 3) --- Ivy/IvyApplication.cxx | 1 + 1 file changed, 1 insertion(+) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index de43bd0..cd0e70c 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -202,6 +202,7 @@ void IvyApplication::OnReceive(char * line) if ( bus->CallDieCallback( this, id, arg ) ) { PostMessage( NULL, WM_CLOSE, 0, 0); + exit(-1); } break; -- cgit v1.1 From db8db20b17a99485aaa54d8839f044acb99d29b9 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:59:35 +0000 Subject: Utilisateur : Fcolin Date : 16/01/01 Heure : 14:56 Archivé dans $/Ivy (vss 4) --- Ivy/IvyApplication.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index cd0e70c..d949845 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -115,7 +115,7 @@ void IvyApplication::OnReceive(char * line) if ( !bus->CheckRegexp( arg ) ) { #ifdef DEBUG - TRACE("Warning exp='%s' can't match removing from %s\n",arg,appname); + TRACE("Warning exp='%s' can't match removing from %s\n",arg,appname.c_str()); #endif //DEBUG return; } @@ -154,7 +154,7 @@ void IvyApplication::OnReceive(char * line) remoteService = id; if ( bus->CheckConnected( this ) ) { - TRACE("Quitting already connected %s\n", appname); + TRACE("Quitting already connected %s\n", appname.c_str()); SendMsg( Error, Error, "already connected" ); // bus->RemoveApplication( this ); Close(); -- cgit v1.1 From 439a1c2233af689583e026d1841578b241b335d0 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:59:37 +0000 Subject: Utilisateur : Fcolin Date : 23/01/01 Heure : 13:12 Archivé dans $/Ivy Commentaire: remove 'using name space std;' (vss 5) --- Ivy/IvyApplication.cxx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index d949845..79110e1 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -49,7 +49,7 @@ void IvyApplication::Create(const char* host, UINT & port) UINT IvyApplication::Create() { - string host; + String host; UINT port; CBufferedSocket::Create(); // Max Listen Connexion @@ -122,9 +122,9 @@ void IvyApplication::OnReceive(char * line) exp = new Regexp( arg ); if ( !exp->CompiledOK() ) { - string regerr = exp->GetErrorString(); - string err; - err = "Error can't compile regexp '"+string(arg)+"' error "+regerr; + String regerr = exp->GetErrorString(); + String err; + err = "Error can't compile regexp '"+String(arg)+"' error "+regerr; SendMsg( Error, Error, err.c_str() ); TRACE("IvyApplication %s\n",err.c_str()); return; @@ -228,7 +228,7 @@ void IvyApplication::SendMsg(MsgType msg, int id, const char * arg) void IvyApplication::OnAccept(int nErrorCode) { - string remotehost; + String remotehost; UINT remoteport; // construct a new, empty socket @@ -245,7 +245,7 @@ void IvyApplication::OnAccept(int nErrorCode) void IvyApplication::OnClose(int nErrorCode) { - string remotehost; + String remotehost; UINT remoteport; GetPeerName( remotehost, remoteport ); TRACE("Deconnexion de %s:%u\n", remotehost.c_str(), remoteport ); @@ -262,7 +262,7 @@ int IvyApplication::SendMsg(const char *message) { int count = 0; Regexp *exp; - map::iterator iter; + std::map::iterator iter; /* send to already connected */ if ( !regexp_in.empty() ) for ( iter = regexp_in.begin(); iter != regexp_in.end(); iter++ ) @@ -271,7 +271,7 @@ int IvyApplication::SendMsg(const char *message) if ( exp && exp->Match( message ) ) { - string buffer; + String buffer; for ( int i = 1; i < exp->SubStrings()+1; i++ ) { buffer += (*exp)[i]; @@ -292,9 +292,9 @@ return appname.c_str(); BOOL IvyApplication::SameApplication(IvyApplication * app) { - string host1; + String host1; UINT port1; - string host2; + String host2; UINT port2; if ( (remoteService != 0) && (remoteService == app->remoteService) ) { -- cgit v1.1 From a2ad73d7b7c3812434be4d82eb1155dc4e6a6380 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:59:39 +0000 Subject: Utilisateur : Fcolin Date : 31/01/01 Heure : 11:18 Archivé dans $/Ivy (vss 6) --- Ivy/IvyApplication.cxx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index 79110e1..7d55bf1 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -49,7 +49,7 @@ void IvyApplication::Create(const char* host, UINT & port) UINT IvyApplication::Create() { - String host; + string host; UINT port; CBufferedSocket::Create(); // Max Listen Connexion @@ -122,9 +122,9 @@ void IvyApplication::OnReceive(char * line) exp = new Regexp( arg ); if ( !exp->CompiledOK() ) { - String regerr = exp->GetErrorString(); - String err; - err = "Error can't compile regexp '"+String(arg)+"' error "+regerr; + string regerr = exp->GetErrorString(); + string err; + err = "Error can't compile regexp '"+string(arg)+"' error "+regerr; SendMsg( Error, Error, err.c_str() ); TRACE("IvyApplication %s\n",err.c_str()); return; @@ -228,7 +228,7 @@ void IvyApplication::SendMsg(MsgType msg, int id, const char * arg) void IvyApplication::OnAccept(int nErrorCode) { - String remotehost; + string remotehost; UINT remoteport; // construct a new, empty socket @@ -245,7 +245,7 @@ void IvyApplication::OnAccept(int nErrorCode) void IvyApplication::OnClose(int nErrorCode) { - String remotehost; + string remotehost; UINT remoteport; GetPeerName( remotehost, remoteport ); TRACE("Deconnexion de %s:%u\n", remotehost.c_str(), remoteport ); @@ -271,7 +271,7 @@ int IvyApplication::SendMsg(const char *message) if ( exp && exp->Match( message ) ) { - String buffer; + string buffer; for ( int i = 1; i < exp->SubStrings()+1; i++ ) { buffer += (*exp)[i]; @@ -292,9 +292,9 @@ return appname.c_str(); BOOL IvyApplication::SameApplication(IvyApplication * app) { - String host1; + string host1; UINT port1; - String host2; + string host2; UINT port2; if ( (remoteService != 0) && (remoteService == app->remoteService) ) { -- cgit v1.1 From 86f4b157ddaee8993b6e5b9591967a077ff8ff85 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:59:41 +0000 Subject: Utilisateur : Fcolin Date : 2/02/01 Heure : 18:30 Archivé dans $/Ivy Commentaire: win CE compile not finished (vss 7) --- Ivy/IvyApplication.cxx | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index 7d55bf1..cbb3ee6 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -2,7 +2,12 @@ // #include "stdafx.h" -//#include "libIvy.h" + +#ifdef _DEBUG +#define DEBUG_NEW new(__FILE__, __LINE__) +#define new DEBUG_NEW +#endif + #include "IvyApplication.h" #include "Regexp.h" @@ -26,7 +31,7 @@ IvyApplication::IvyApplication(Ivy * bus) IvyApplication::~IvyApplication() { // bus->RemoveApplication( this ); - for ( int i = 0; i < regexp_in.size(); i++) + for ( unsigned int i = 0; i < regexp_in.size(); i++) delete regexp_in[i]; regexp_in.clear(); if ( m_hSocket != INVALID_SOCKET ) @@ -122,25 +127,27 @@ void IvyApplication::OnReceive(char * line) exp = new Regexp( arg ); if ( !exp->CompiledOK() ) { - string regerr = exp->GetErrorString(); - string err; - err = "Error can't compile regexp '"+string(arg)+"' error "+regerr; + string err( "Error can't compile regexp '" ); + err += arg; + err += "' error "; + err += exp->GetErrorString(); SendMsg( Error, Error, err.c_str() ); TRACE("IvyApplication %s\n",err.c_str()); return; } - regexp_in[ id ] = exp ; + regexp_in.reserve( id +1 ); + regexp_in[ id ] = exp; break; case DelRegexp: #ifdef DEBUG TRACE("Regexp Delete id=%d\n", id); #endif //DEBUG - if ( regexp_in.find(id) != regexp_in.end() ) + if ( regexp_in[id] ) { exp = regexp_in[ id ]; delete exp; - regexp_in.erase( id ); + regexp_in[ id ] = NULL; } break; case StartRegexp: @@ -252,7 +259,7 @@ void IvyApplication::OnClose(int nErrorCode) if ( AppConnectedCallbackCalled ) bus->CallApplicationDisconnectedCallback( this ); // bus->RemoveApplication( this ); - for ( int i = 0; i < regexp_in.size(); i++) + for ( unsigned int i = 0; i < regexp_in.size(); i++) delete regexp_in[i]; regexp_in.clear(); Close(); @@ -262,12 +269,10 @@ int IvyApplication::SendMsg(const char *message) { int count = 0; Regexp *exp; - std::map::iterator iter; /* send to already connected */ - if ( !regexp_in.empty() ) - for ( iter = regexp_in.begin(); iter != regexp_in.end(); iter++ ) + for ( unsigned int i = 0; i < regexp_in.size(); i++ ) { - exp = (*iter).second; + exp = regexp_in[i]; if ( exp && exp->Match( message ) ) { @@ -277,7 +282,7 @@ int IvyApplication::SendMsg(const char *message) buffer += (*exp)[i]; buffer += ARG_END; } - SendMsg( Msg, (*iter).first, buffer.c_str() ); + SendMsg( Msg, i, buffer.c_str() ); count++; } } -- cgit v1.1 From a46b379fb2a8a1399606db6a753c85a6546f5336 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:59:43 +0000 Subject: Utilisateur : Fcolin Date : 14/02/01 Heure : 18:47 Archivé dans $/Ivy (vss 8) --- Ivy/IvyApplication.cxx | 52 +++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index cbb3ee6..ef72bd1 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -11,7 +11,7 @@ #include "IvyApplication.h" #include "Regexp.h" -//#define DEBUG +#define IVY_DEBUG #define ARG_START "\002" #define ARG_END "\003" @@ -61,7 +61,7 @@ UINT IvyApplication::Create() Listen( SOMAXCONN ); GetSockName( host, port ); TRACE(" TCP %s:%d\n", host.c_str(), port ); -#ifdef DEBUG +#ifdef IVY_DEBUG TRACE( "IvyApplication::Create server socket %d\n", m_hSocket ); #endif return port; @@ -78,9 +78,9 @@ void IvyApplication::OnReceive(char * line) const char *argv[Regexp::NSUBEXP]; char *arg; -#ifdef DEBUG +#ifdef IVY_DEBUG TRACE("Receive %s\n",line); -#endif //DEBUG +#endif //IVY_DEBUG err = sscanf( line ,"%d %d", &kind_of_msg, &id); arg = strstr( line , ARG_START ); @@ -97,31 +97,31 @@ void IvyApplication::OnReceive(char * line) { case Bye: -#ifdef DEBUG +#ifdef IVY_DEBUG TRACE("Quitting %s\n", line); -#endif //DEBUG +#endif //IVY_DEBUG // bus->RemoveApplication( this ); Close(); break; case Error: -#ifdef DEBUG +#ifdef IVY_DEBUG TRACE("Receive error %d %s\n", id, arg); -#endif //DEBUG +#endif //IVY_DEBUG break; case AddRegexp: -#ifdef DEBUG +#ifdef IVY_DEBUG TRACE("Regexp id=%d exp='%s'\n", id, arg); -#endif //DEBUG +#endif //IVY_DEBUG if ( !bus->CheckRegexp( arg ) ) { -#ifdef DEBUG +#ifdef IVY_DEBUG TRACE("Warning exp='%s' can't match removing from %s\n",arg,appname.c_str()); -#endif //DEBUG +#endif //IVY_DEBUG return; } exp = new Regexp( arg ); @@ -140,9 +140,9 @@ void IvyApplication::OnReceive(char * line) break; case DelRegexp: -#ifdef DEBUG +#ifdef IVY_DEBUG TRACE("Regexp Delete id=%d\n", id); -#endif //DEBUG +#endif //IVY_DEBUG if ( regexp_in[id] ) { exp = regexp_in[ id ]; @@ -152,9 +152,9 @@ void IvyApplication::OnReceive(char * line) break; case StartRegexp: -#ifdef DEBUG +#ifdef IVY_DEBUG TRACE("Regexp Start id=%d\n", id); -#endif //DEBUG +#endif //IVY_DEBUG appname = arg; /* remote socket port */ @@ -169,9 +169,9 @@ void IvyApplication::OnReceive(char * line) break; case EndRegexp: -#ifdef DEBUG +#ifdef IVY_DEBUG TRACE("Regexp End id=%d\n", id); -#endif //DEBUG +#endif //IVY_DEBUG bus->CallApplicationConnectedCallback( this ); AppConnectedCallbackCalled = true; @@ -180,9 +180,9 @@ void IvyApplication::OnReceive(char * line) break; case Msg: -#ifdef DEBUG +#ifdef IVY_DEBUG TRACE("Message id=%d msg='%s'\n", id, arg); -#endif //DEBUG +#endif //IVY_DEBUG arg = strtok( arg, ARG_END); while ( arg ) @@ -194,17 +194,17 @@ void IvyApplication::OnReceive(char * line) break; case DirectMsg: -#ifdef DEBUG +#ifdef IVY_DEBUG TRACE("Direct Message id=%d msg='%s'\n", id, arg); -#endif //DEBUG +#endif //IVY_DEBUG bus->CallDirectMessageCallback( this, id, arg ); break; case Die: -#ifdef DEBUG +#ifdef IVY_DEBUG TRACE("Die Message id=%d msg='%s'\n", id, arg); -#endif //DEBUG +#endif //IVY_DEBUG if ( bus->CallDieCallback( this, id, arg ) ) { @@ -227,9 +227,9 @@ void IvyApplication::SendMsg(MsgType msg, int id, const char * arg) sprintf( buffer, "%d %d" ARG_START "%s\n", msg, id, arg ); else sprintf( buffer, "%d %d" ARG_START "\n", msg, id ); -#ifdef DEBUG +#ifdef IVY_DEBUG TRACE("SendMsg %s\n",buffer); -#endif //DEBUG +#endif //IVY_DEBUG Send( buffer ); } -- cgit v1.1 From 2ffcb31f76e9358254f9da9d9cefb9441a10dcaf Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:59:45 +0000 Subject: Utilisateur : Fcolin Date : 19/02/01 Heure : 10:37 Archivé dans $/Ivy (vss 9) --- Ivy/IvyApplication.cxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index ef72bd1..2d1f937 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -11,7 +11,7 @@ #include "IvyApplication.h" #include "Regexp.h" -#define IVY_DEBUG +//#define IVY_DEBUG #define ARG_START "\002" #define ARG_END "\003" @@ -137,6 +137,9 @@ void IvyApplication::OnReceive(char * line) } regexp_in.reserve( id +1 ); regexp_in[ id ] = exp; +#ifdef IVY_DEBUG + TRACE("Adding regexp[%d]='%s'\n",id,arg); +#endif //IVY_DEBUG break; case DelRegexp: @@ -277,9 +280,9 @@ int IvyApplication::SendMsg(const char *message) if ( exp && exp->Match( message ) ) { string buffer; - for ( int i = 1; i < exp->SubStrings()+1; i++ ) + for ( int j = 1; j < exp->SubStrings()+1; j++ ) { - buffer += (*exp)[i]; + buffer += (*exp)[j]; buffer += ARG_END; } SendMsg( Msg, i, buffer.c_str() ); -- cgit v1.1 From f95aae747dc2b2511bd934d3084b24c77e895cf0 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:59:47 +0000 Subject: Utilisateur : Fcolin Date : 6/06/01 Heure : 8:50 Archivé dans $/Ivy Commentaire: Pb avec vector resize reserve et ajout de regexp !!! => replace list (vss 10) --- Ivy/IvyApplication.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index 2d1f937..6d3b7ea 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -135,10 +135,10 @@ void IvyApplication::OnReceive(char * line) TRACE("IvyApplication %s\n",err.c_str()); return; } - regexp_in.reserve( id +1 ); + regexp_in.resize( id +1 ); regexp_in[ id ] = exp; #ifdef IVY_DEBUG - TRACE("Adding regexp[%d]='%s'\n",id,arg); + TRACE("Adding regexp[%d]='%s' size:%d\n",id,arg,regexp_in.size()); #endif //IVY_DEBUG break; case DelRegexp: -- cgit v1.1 From 362bf21b18d9bfd64e598d0a259f5d38bce5e7ac Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:59:49 +0000 Subject: Utilisateur : Fcolin Date : 17/07/01 Heure : 18:25 Archivé dans $/Ivy (vss 11) --- Ivy/IvyApplication.cxx | 5 ----- 1 file changed, 5 deletions(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index 6d3b7ea..245381a 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -3,11 +3,6 @@ #include "stdafx.h" -#ifdef _DEBUG -#define DEBUG_NEW new(__FILE__, __LINE__) -#define new DEBUG_NEW -#endif - #include "IvyApplication.h" #include "Regexp.h" -- cgit v1.1 From d48ae3305891a6fab5d9ae1eee90afbe57934eb1 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:59:51 +0000 Subject: Utilisateur : Fcolin Date : 14/09/01 Heure : 16:44 Archivé dans $/Ivy Commentaire: correction BUG Ivy socket Listen apres start Listener et regexp_in.resize (vss 12) --- Ivy/IvyApplication.cxx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index 245381a..33d62b0 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -6,7 +6,7 @@ #include "IvyApplication.h" #include "Regexp.h" -//#define IVY_DEBUG +#define IVY_DEBUG #define ARG_START "\002" #define ARG_END "\003" @@ -130,10 +130,11 @@ void IvyApplication::OnReceive(char * line) TRACE("IvyApplication %s\n",err.c_str()); return; } - regexp_in.resize( id +1 ); + if ( regexp_in.size() < (id + 1) ) + regexp_in.resize( id + 1 ); regexp_in[ id ] = exp; #ifdef IVY_DEBUG - TRACE("Adding regexp[%d]='%s' size:%d\n",id,arg,regexp_in.size()); + TRACE("Adding regexp[%d]='%s' size: %d\n",id,arg,regexp_in.size()); #endif //IVY_DEBUG break; case DelRegexp: -- cgit v1.1 From fd1b7bce694095d4cecb2724b6dfe71449f16f6f Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:59:53 +0000 Subject: Utilisateur : Fcolin Date : 14/09/01 Heure : 16:53 Archivé dans $/Ivy (vss 13) --- Ivy/IvyApplication.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index 33d62b0..b27b77b 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -6,7 +6,7 @@ #include "IvyApplication.h" #include "Regexp.h" -#define IVY_DEBUG +//#define IVY_DEBUG #define ARG_START "\002" #define ARG_END "\003" -- cgit v1.1 From 0a4563c486f43bf613730d1f00fb7ba876eae868 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:59:55 +0000 Subject: Utilisateur : Fcolin Date : 8/10/01 Heure : 14:15 Archivé dans $/Ivy Commentaire: bug strtok si argument vide !!! (vss 14) --- Ivy/IvyApplication.cxx | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index b27b77b..7f798c2 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -11,7 +11,25 @@ #define ARG_START "\002" #define ARG_END "\003" - +/* +function like strok but do not eat consecutive separator +*/ +static char * nextArg( char *s, const char *separator ) +{ + static char *start = NULL; + static char *end = NULL; + if ( s ) + { + end = s; + } + start = end; + + while ( *end && *end != *separator ) + end++; + if ( *end == *separator ) *end++ = '\0'; + if ( end == start ) return NULL; + return start; +} ///////////////////////////////////////////////////////////////////////////// // IvyApplication @@ -183,11 +201,11 @@ void IvyApplication::OnReceive(char * line) TRACE("Message id=%d msg='%s'\n", id, arg); #endif //IVY_DEBUG - arg = strtok( arg, ARG_END); + arg = nextArg( arg, ARG_END); while ( arg ) { argv[argc++] = arg; - arg = strtok( NULL, ARG_END ); + arg = nextArg( NULL, ARG_END ); } bus->CallMessageCallback( this, id, argc, argv ); break; -- cgit v1.1 From 1da73b3dd4ed8ef47e7b1367ad99c5c1070423ff Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:59:57 +0000 Subject: Utilisateur : Fcolin Date : 10/06/02 Heure : 12:53 Archivé dans $/Ivy Commentaire: (vss 15) --- Ivy/IvyApplication.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index 7f798c2..c4d4ed0 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -82,7 +82,8 @@ UINT IvyApplication::Create() void IvyApplication::OnReceive(char * line) { - int err,id; + int err; + unsigned int id; int kind_of_msg = Bye; Regexp *exp; -- cgit v1.1 From 67abfec93d33a97a97433e01d9efa78ab430ea45 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:59:59 +0000 Subject: Utilisateur : Fcolin Date : 14/11/02 Heure : 15:45 Archivé dans $/Bus/Ivy Commentaire: (vss 16) --- Ivy/IvyApplication.cxx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index c4d4ed0..96023c7 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -11,6 +11,16 @@ #define ARG_START "\002" #define ARG_END "\003" +static char * firstArg( char *s, const char *separator ) +{ + char *ptr = s; + + while ( *ptr && *ptr != *separator ) + ptr++; + if ( *ptr == *separator ) + return ptr++ ; + else return NULL; +} /* function like strok but do not eat consecutive separator */ @@ -97,7 +107,7 @@ void IvyApplication::OnReceive(char * line) #endif //IVY_DEBUG err = sscanf( line ,"%d %d", &kind_of_msg, &id); - arg = strstr( line , ARG_START ); + arg = firstArg( line , ARG_START ); if ( (err != 2) || (arg == NULL) ) { TRACE("Quitting bad format %s\n", line); -- cgit v1.1 From 4cd382a0d401eb9a4447473555d82d30a8d44e16 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 13:00:01 +0000 Subject: Utilisateur : Fcolin Date : 15/12/03 Heure : 16:54 Archivé dans $/Bus/Ivy Commentaire: (vss 17) --- Ivy/IvyApplication.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index 96023c7..008be70 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -126,7 +126,8 @@ void IvyApplication::OnReceive(char * line) #endif //IVY_DEBUG // bus->RemoveApplication( this ); - Close(); + OnClose(0); + //Close(); break; case Error: -- cgit v1.1 From fc091c2b6c66878f01575c3c24121f3dde9450a3 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 13:00:03 +0000 Subject: Utilisateur : Fcolin Date : 9/02/04 Heure : 16:14 Archivé dans $/Bus/Ivy Commentaire: (vss 18) --- Ivy/IvyApplication.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index 008be70..f0d4f75 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -287,11 +287,12 @@ void IvyApplication::OnClose(int nErrorCode) TRACE("Deconnexion de %s:%u\n", remotehost.c_str(), remoteport ); if ( AppConnectedCallbackCalled ) bus->CallApplicationDisconnectedCallback( this ); -// bus->RemoveApplication( this ); + for ( unsigned int i = 0; i < regexp_in.size(); i++) delete regexp_in[i]; regexp_in.clear(); Close(); +// bus->RemoveApplication( this ); } int IvyApplication::SendMsg(const char *message) -- cgit v1.1 From 3340cd8c77dc2335915a3bb9a766f9a089774e1d Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 13:00:05 +0000 Subject: Utilisateur : Fcolin Date : 3/03/05 Heure : 14:02 Archivé dans $/Bus/Ivy Commentaire: Passage a la lib PCRE (vss 19) --- Ivy/IvyApplication.cxx | 66 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 6 deletions(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index f0d4f75..faafaf4 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -4,7 +4,8 @@ #include "stdafx.h" #include "IvyApplication.h" -#include "Regexp.h" + + //#define IVY_DEBUG @@ -55,7 +56,10 @@ IvyApplication::~IvyApplication() { // bus->RemoveApplication( this ); for ( unsigned int i = 0; i < regexp_in.size(); i++) +#ifdef USE_PCRE +#else delete regexp_in[i]; +#endif regexp_in.clear(); if ( m_hSocket != INVALID_SOCKET ) Close(); @@ -95,12 +99,19 @@ void IvyApplication::OnReceive(char * line) int err; unsigned int id; int kind_of_msg = Bye; + char *arg; + int argc = 0; + +#ifdef USE_PCRE + pcre *exp; + const char *argv[max_subexp]; + const char *errmsg; + int erroffset; +#else Regexp *exp; - - - int argc = 0; const char *argv[Regexp::NSUBEXP]; - char *arg; +#endif + #ifdef IVY_DEBUG TRACE("Receive %s\n",line); @@ -149,6 +160,19 @@ void IvyApplication::OnReceive(char * line) #endif //IVY_DEBUG return; } +#ifdef USE_PCRE + exp = pcre_compile( arg, PCRE_CASELESS, &errmsg, &erroffset, NULL ); + if ( !exp ) + { + string err( "Error can't compile regexp '" ); + err += arg; + err += "' error "; + err += errmsg; + SendMsg( Error, Error, err.c_str() ); + TRACE("IvyApplication %s\n",err.c_str()); + return; + } +#else exp = new Regexp( arg ); if ( !exp->CompiledOK() ) { @@ -160,6 +184,7 @@ void IvyApplication::OnReceive(char * line) TRACE("IvyApplication %s\n",err.c_str()); return; } +#endif if ( regexp_in.size() < (id + 1) ) regexp_in.resize( id + 1 ); regexp_in[ id ] = exp; @@ -175,7 +200,10 @@ void IvyApplication::OnReceive(char * line) if ( regexp_in[id] ) { exp = regexp_in[ id ]; +#ifdef USE_PCRE +#else delete exp; +#endif regexp_in[ id ] = NULL; } break; @@ -289,7 +317,11 @@ void IvyApplication::OnClose(int nErrorCode) bus->CallApplicationDisconnectedCallback( this ); for ( unsigned int i = 0; i < regexp_in.size(); i++) +#ifdef USE_PCRE + pcre_free( regexp_in[i] ); +#else delete regexp_in[i]; +#endif regexp_in.clear(); Close(); // bus->RemoveApplication( this ); @@ -298,12 +330,33 @@ void IvyApplication::OnClose(int nErrorCode) int IvyApplication::SendMsg(const char *message) { int count = 0; +#ifdef USE_PCRE + pcre *exp; + int ovector[max_subexp*3]; +#else Regexp *exp; +#endif /* send to already connected */ for ( unsigned int i = 0; i < regexp_in.size(); i++ ) { exp = regexp_in[i]; - +#ifdef USE_PCRE + int match_count = pcre_exec( exp, NULL, message, strlen( message ), 0, 0, ovector, max_subexp ); + if ( match_count > 1 ) + { + string buffer; + const char *substring; + for ( int j = 1; j < match_count; j++ ) + { + pcre_get_substring(message, ovector, match_count, j, &substring); + buffer += substring; + buffer += ARG_END; + pcre_free_substring( substring ); + } + SendMsg( Msg, i, buffer.c_str() ); + count++; + } +#else if ( exp && exp->Match( message ) ) { string buffer; @@ -315,6 +368,7 @@ int IvyApplication::SendMsg(const char *message) SendMsg( Msg, i, buffer.c_str() ); count++; } +#endif } return count; } -- cgit v1.1 From 03f69b1c55a75ecf83a81ec4a342b924c95b68e5 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 13:00:07 +0000 Subject: Utilisateur : Fcolin Date : 8/03/05 Heure : 15:20 Archivé dans $/Bus/Ivy Commentaire: Bug en cas d'expression vide de subexpression (vss 20) --- Ivy/IvyApplication.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index faafaf4..23abfbf 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -342,7 +342,7 @@ int IvyApplication::SendMsg(const char *message) exp = regexp_in[i]; #ifdef USE_PCRE int match_count = pcre_exec( exp, NULL, message, strlen( message ), 0, 0, ovector, max_subexp ); - if ( match_count > 1 ) + if ( match_count > 0 ) { string buffer; const char *substring; -- cgit v1.1 From 009f570f9c4e60137201d782d7c1f6a3b918232f Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 13:00:09 +0000 Subject: Utilisateur : Fcolin Date : 1/06/05 Heure : 16:45 Archivé dans $/Bus/Ivy Commentaire: (vss 21) --- Ivy/IvyApplication.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index 23abfbf..3eaecdb 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -1,7 +1,7 @@ // IvyApplication.cpp : implementation file // -#include "stdafx.h" +#include "IvyStdAfx.h" #include "IvyApplication.h" @@ -281,7 +281,7 @@ void IvyApplication::SendMsg(MsgType msg, int id, const char * arg) { char buffer[1024]; if ( arg ) - sprintf( buffer, "%d %d" ARG_START "%s\n", msg, id, arg ); + _snprintf( buffer, sizeof( buffer ), "%d %d" ARG_START "%s\n", msg, id, arg ); else sprintf( buffer, "%d %d" ARG_START "\n", msg, id ); #ifdef IVY_DEBUG -- cgit v1.1 From f872905e098d43cc350bfad3903a8ce9756e07e2 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 13:00:11 +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 22) --- Ivy/IvyApplication.cxx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index 3eaecdb..fb399a6 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -81,7 +81,7 @@ void IvyApplication::Create(const char* host, UINT & port) UINT IvyApplication::Create() { - string host; + ivy::string host; UINT port; CBufferedSocket::Create(); // Max Listen Connexion @@ -164,7 +164,7 @@ void IvyApplication::OnReceive(char * line) exp = pcre_compile( arg, PCRE_CASELESS, &errmsg, &erroffset, NULL ); if ( !exp ) { - string err( "Error can't compile regexp '" ); + ivy::string err( "Error can't compile regexp '" ); err += arg; err += "' error "; err += errmsg; @@ -176,7 +176,7 @@ void IvyApplication::OnReceive(char * line) exp = new Regexp( arg ); if ( !exp->CompiledOK() ) { - string err( "Error can't compile regexp '" ); + ivy::string err( "Error can't compile regexp '" ); err += arg; err += "' error "; err += exp->GetErrorString(); @@ -292,7 +292,7 @@ void IvyApplication::SendMsg(MsgType msg, int id, const char * arg) void IvyApplication::OnAccept(int nErrorCode) { - string remotehost; + ivy::string remotehost; UINT remoteport; // construct a new, empty socket @@ -309,7 +309,7 @@ void IvyApplication::OnAccept(int nErrorCode) void IvyApplication::OnClose(int nErrorCode) { - string remotehost; + ivy::string remotehost; UINT remoteport; GetPeerName( remotehost, remoteport ); TRACE("Deconnexion de %s:%u\n", remotehost.c_str(), remoteport ); @@ -344,7 +344,7 @@ int IvyApplication::SendMsg(const char *message) int match_count = pcre_exec( exp, NULL, message, strlen( message ), 0, 0, ovector, max_subexp ); if ( match_count > 0 ) { - string buffer; + ivy::string buffer; const char *substring; for ( int j = 1; j < match_count; j++ ) { @@ -359,7 +359,7 @@ int IvyApplication::SendMsg(const char *message) #else if ( exp && exp->Match( message ) ) { - string buffer; + ivy::string buffer; for ( int j = 1; j < exp->SubStrings()+1; j++ ) { buffer += (*exp)[j]; @@ -381,9 +381,9 @@ return appname.c_str(); BOOL IvyApplication::SameApplication(IvyApplication * app) { - string host1; + ivy::string host1; UINT port1; - string host2; + ivy::string host2; UINT port2; if ( (remoteService != 0) && (remoteService == app->remoteService) ) { -- cgit v1.1 From 914228ac4531f1ea31ae2987ab875017a28e3b57 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 13:00:13 +0000 Subject: Utilisateur : Fcolin Date : 14/06/05 Heure : 11:02 Archivé dans $/Bus/Ivy Commentaire: get all the pcre sublist in one time (vss 23) --- Ivy/IvyApplication.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index fb399a6..91a2d98 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -345,14 +345,14 @@ int IvyApplication::SendMsg(const char *message) if ( match_count > 0 ) { ivy::string buffer; - const char *substring; + const char **substring; + pcre_get_substring_list(message,ovector, match_count, &substring); for ( int j = 1; j < match_count; j++ ) { - pcre_get_substring(message, ovector, match_count, j, &substring); - buffer += substring; + buffer += substring[j]; buffer += ARG_END; - pcre_free_substring( substring ); } + pcre_free_substring_list(substring); SendMsg( Msg, i, buffer.c_str() ); count++; } -- cgit v1.1 From 80dc36e4b37ee8b6de9b9b3d6954f6ec11d43324 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 13:00:15 +0000 Subject: Utilisateur : Fcolin Date : 14/06/05 Heure : 11:37 Archivé dans $/Bus/Ivy Commentaire: (vss 24) --- Ivy/IvyApplication.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index 91a2d98..7ed553c 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -346,7 +346,12 @@ int IvyApplication::SendMsg(const char *message) { ivy::string buffer; const char **substring; - pcre_get_substring_list(message,ovector, match_count, &substring); + int err = pcre_get_substring_list(message,ovector, match_count, &substring); + if ( err != 0 ) + { + SendMsg( Error, Error, "Memory Alloc Error" ); + } + else { for ( int j = 1; j < match_count; j++ ) { buffer += substring[j]; @@ -355,6 +360,7 @@ int IvyApplication::SendMsg(const char *message) pcre_free_substring_list(substring); SendMsg( Msg, i, buffer.c_str() ); count++; + } } #else if ( exp && exp->Match( message ) ) -- cgit v1.1 From 66549353d2e6f98710579f6af961e2d10ec2b031 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 13:00:17 +0000 Subject: Utilisateur : Fcolin Date : 28/06/05 Heure : 14:14 Archivé dans $/Bus/Ivy Commentaire: (vss 25) --- Ivy/IvyApplication.cxx | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index 7ed553c..6aa3668 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -57,6 +57,7 @@ IvyApplication::~IvyApplication() // bus->RemoveApplication( this ); for ( unsigned int i = 0; i < regexp_in.size(); i++) #ifdef USE_PCRE + pcre_free( regexp_in[i] ); #else delete regexp_in[i]; #endif @@ -201,6 +202,7 @@ void IvyApplication::OnReceive(char * line) { exp = regexp_in[ id ]; #ifdef USE_PCRE + pcre_free( exp ); #else delete exp; #endif -- cgit v1.1 From 896c064fa646fb30d446aaf66567f81d7590f9e9 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 13:00:19 +0000 Subject: Utilisateur : Fcolin Date : 16/11/05 Heure : 9:54 Archivé dans $/Bus/Ivy Commentaire: 64 bits ports (vss 26) --- Ivy/IvyApplication.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index 6aa3668..5a50b96 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -118,7 +118,7 @@ void IvyApplication::OnReceive(char * line) TRACE("Receive %s\n",line); #endif //IVY_DEBUG - err = sscanf( line ,"%d %d", &kind_of_msg, &id); + err = sscanf_s( line ,"%d %d", &kind_of_msg, &id); arg = firstArg( line , ARG_START ); if ( (err != 2) || (arg == NULL) ) { @@ -283,8 +283,8 @@ void IvyApplication::SendMsg(MsgType msg, int id, const char * arg) { char buffer[1024]; if ( arg ) - _snprintf( buffer, sizeof( buffer ), "%d %d" ARG_START "%s\n", msg, id, arg ); - else sprintf( buffer, "%d %d" ARG_START "\n", msg, id ); + _snprintf_s( buffer, sizeof( buffer ),sizeof( buffer )-1, "%d %d" ARG_START "%s\n", msg, id, arg ); + else sprintf_s( buffer,sizeof( buffer ), "%d %d" ARG_START "\n", msg, id ); #ifdef IVY_DEBUG TRACE("SendMsg %s\n",buffer); @@ -343,7 +343,7 @@ int IvyApplication::SendMsg(const char *message) { exp = regexp_in[i]; #ifdef USE_PCRE - int match_count = pcre_exec( exp, NULL, message, strlen( message ), 0, 0, ovector, max_subexp ); + int match_count = pcre_exec( exp, NULL, message, (int) strlen( message ), 0, 0, ovector, max_subexp ); if ( match_count > 0 ) { ivy::string buffer; -- cgit v1.1 From 2132f900f65f521c61e60a3541716104d83ee384 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 13:00:21 +0000 Subject: Utilisateur : Fcolin Date : 17/11/05 Heure : 15:08 Archivé dans $/Bus/Ivy Commentaire: nice Bug in nextArg not reentrant routine due to static variable (vss 27) --- Ivy/IvyApplication.cxx | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index 5a50b96..32b89a2 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -9,36 +9,32 @@ //#define IVY_DEBUG -#define ARG_START "\002" -#define ARG_END "\003" +#define ARG_START 2 +#define ARG_END 3 -static char * firstArg( char *s, const char *separator ) +static char * firstArg( char *s, const char separator ) { char *ptr = s; - while ( *ptr && *ptr != *separator ) + while ( *ptr && *ptr != separator ) ptr++; - if ( *ptr == *separator ) + if ( *ptr == separator ) return ptr++ ; else return NULL; } /* function like strok but do not eat consecutive separator */ -static char * nextArg( char *s, const char *separator ) +static char * nextArg( char **s, const char separator ) { - static char *start = NULL; - static char *end = NULL; - if ( s ) - { - end = s; - } - start = end; + char *start = *s; + char *end = *s; - while ( *end && *end != *separator ) + while ( *end && *end != separator ) end++; - if ( *end == *separator ) *end++ = '\0'; + if ( *end == separator ) *end++ = '\0'; if ( end == start ) return NULL; + *s = end; return start; } ///////////////////////////////////////////////////////////////////////////// @@ -102,6 +98,7 @@ void IvyApplication::OnReceive(char * line) int kind_of_msg = Bye; char *arg; int argc = 0; + char *arg_ptr; #ifdef USE_PCRE pcre *exp; @@ -243,11 +240,12 @@ void IvyApplication::OnReceive(char * line) TRACE("Message id=%d msg='%s'\n", id, arg); #endif //IVY_DEBUG - arg = nextArg( arg, ARG_END); + arg_ptr = arg; + arg = nextArg( &arg_ptr, ARG_END); while ( arg ) { argv[argc++] = arg; - arg = nextArg( NULL, ARG_END ); + arg = nextArg( &arg_ptr, ARG_END ); } bus->CallMessageCallback( this, id, argc, argv ); break; @@ -283,8 +281,8 @@ void IvyApplication::SendMsg(MsgType msg, int id, const char * arg) { char buffer[1024]; if ( arg ) - _snprintf_s( buffer, sizeof( buffer ),sizeof( buffer )-1, "%d %d" ARG_START "%s\n", msg, id, arg ); - else sprintf_s( buffer,sizeof( buffer ), "%d %d" ARG_START "\n", msg, id ); + _snprintf_s( buffer, sizeof( buffer ),sizeof( buffer )-1, "%d %d%c%s\n", msg, id, ARG_START, arg ); + else sprintf_s( buffer,sizeof( buffer ), "%d %d%c\n", msg, id, ARG_START); #ifdef IVY_DEBUG TRACE("SendMsg %s\n",buffer); -- cgit v1.1 From 836c3cea5435c0313827691cb6cc71de3c872237 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 13:00:23 +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 28) --- Ivy/IvyApplication.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index 32b89a2..b0fa052 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -324,7 +324,7 @@ void IvyApplication::OnClose(int nErrorCode) #endif regexp_in.clear(); Close(); -// bus->RemoveApplication( this ); + //bus->RemoveApplication( this ); } int IvyApplication::SendMsg(const char *message) -- cgit v1.1 From abb65226983bbee29c17c004b75bc50918d15003 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 13:00:25 +0000 Subject: Utilisateur : Fcolin Date : 19/04/06 Heure : 15:07 Archivé dans $/Bus/Ivy Commentaire: (vss 29) --- Ivy/IvyApplication.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index b0fa052..c9ba0e4 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -162,12 +162,12 @@ void IvyApplication::OnReceive(char * line) exp = pcre_compile( arg, PCRE_CASELESS, &errmsg, &erroffset, NULL ); if ( !exp ) { - ivy::string err( "Error can't compile regexp '" ); - err += arg; - err += "' error "; - err += errmsg; - SendMsg( Error, Error, err.c_str() ); - TRACE("IvyApplication %s\n",err.c_str()); + ivy::string errstr( "Error can't compile regexp '" ); + errstr += arg; + errstr += "' error "; + errstr += errmsg; + SendMsg( Error, Error, errstr.c_str() ); + TRACE("IvyApplication %s\n",errstr.c_str()); return; } #else -- cgit v1.1 From 4a8451ff484c9fe7656acab4edd61713e2212ed6 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 13:00:27 +0000 Subject: Utilisateur : Fcolin Date : 23/05/06 Heure : 18:18 Archivé dans $/Bus/Ivy Commentaire: Modification protocol UDP (vss 30) --- Ivy/IvyApplication.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index c9ba0e4..c4de075 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -67,8 +67,9 @@ IvyApplication::~IvyApplication() // IvyApplication member functions -void IvyApplication::Create(const char* host, UINT & port) +void IvyApplication::Create(const char* host, UINT & port, const char* name) { + appname = name; // Exception to catch CBufferedSocket::Create(); Connect(host, port); -- cgit v1.1 From 8e63bb805a09c8c1bd019347071dad478ea034b9 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 13:00:29 +0000 Subject: Utilisateur : Fcolin Date : 1/06/06 Heure : 10:14 Archivé dans $/Bus/Ivy Commentaire: ajout Binding Callback et SetFilter (vss 31) --- Ivy/IvyApplication.cxx | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index c4de075..c3f6f02 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -157,6 +157,7 @@ void IvyApplication::OnReceive(char * line) #ifdef IVY_DEBUG TRACE("Warning exp='%s' can't match removing from %s\n",arg,appname.c_str()); #endif //IVY_DEBUG + bus->CallBindingFilterCallback( this, id, arg ); return; } #ifdef USE_PCRE @@ -185,11 +186,16 @@ void IvyApplication::OnReceive(char * line) } #endif if ( regexp_in.size() < (id + 1) ) + { regexp_in.resize( id + 1 ); + regexp_str_in.resize( id + 1 ); + } regexp_in[ id ] = exp; + regexp_str_in[ id ] = arg; #ifdef IVY_DEBUG TRACE("Adding regexp[%d]='%s' size: %d\n",id,arg,regexp_in.size()); #endif //IVY_DEBUG + bus->CallBindingAddCallback( this, id, arg ); break; case DelRegexp: @@ -199,6 +205,7 @@ void IvyApplication::OnReceive(char * line) if ( regexp_in[id] ) { exp = regexp_in[ id ]; + bus->CallBindingRemoveCallback( this, id, regexp_str_in[id].c_str() ); #ifdef USE_PCRE pcre_free( exp ); #else -- cgit v1.1 From ea91919a2278f4894f11b47d1397e99f4a28f85f Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 13:00:31 +0000 Subject: Utilisateur : Fcolin Date : 1/06/06 Heure : 15:54 Archivé dans $/Bus/Ivy Commentaire: Separation module de traitement regexp (vss 32) --- Ivy/IvyApplication.cxx | 92 ++++++++++++-------------------------------------- 1 file changed, 21 insertions(+), 71 deletions(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index c3f6f02..53341bc 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -4,7 +4,7 @@ #include "IvyStdAfx.h" #include "IvyApplication.h" - +#include "IvyBinding.h" //#define IVY_DEBUG @@ -52,11 +52,7 @@ IvyApplication::~IvyApplication() { // bus->RemoveApplication( this ); for ( unsigned int i = 0; i < regexp_in.size(); i++) -#ifdef USE_PCRE - pcre_free( regexp_in[i] ); -#else delete regexp_in[i]; -#endif regexp_in.clear(); if ( m_hSocket != INVALID_SOCKET ) Close(); @@ -100,18 +96,13 @@ void IvyApplication::OnReceive(char * line) char *arg; int argc = 0; char *arg_ptr; - -#ifdef USE_PCRE - pcre *exp; + static const int max_subexp = 200; const char *argv[max_subexp]; - const char *errmsg; - int erroffset; -#else - Regexp *exp; - const char *argv[Regexp::NSUBEXP]; -#endif - + IvyBinding *exp; + int erroffset; + const char *errmsg; + #ifdef IVY_DEBUG TRACE("Receive %s\n",line); #endif //IVY_DEBUG @@ -152,7 +143,7 @@ void IvyApplication::OnReceive(char * line) TRACE("Regexp id=%d exp='%s'\n", id, arg); #endif //IVY_DEBUG - if ( !bus->CheckRegexp( arg ) ) + if ( !IvyBinding::Filter( arg ) ) { #ifdef IVY_DEBUG TRACE("Warning exp='%s' can't match removing from %s\n",arg,appname.c_str()); @@ -160,9 +151,8 @@ void IvyApplication::OnReceive(char * line) bus->CallBindingFilterCallback( this, id, arg ); return; } -#ifdef USE_PCRE - exp = pcre_compile( arg, PCRE_CASELESS, &errmsg, &erroffset, NULL ); - if ( !exp ) + exp = new IvyBinding(); + if ( !exp->Compile(arg, &erroffset, &errmsg ) ) { ivy::string errstr( "Error can't compile regexp '" ); errstr += arg; @@ -170,21 +160,10 @@ void IvyApplication::OnReceive(char * line) errstr += errmsg; SendMsg( Error, Error, errstr.c_str() ); TRACE("IvyApplication %s\n",errstr.c_str()); + delete exp; return; } -#else - exp = new Regexp( arg ); - if ( !exp->CompiledOK() ) - { - ivy::string err( "Error can't compile regexp '" ); - err += arg; - err += "' error "; - err += exp->GetErrorString(); - SendMsg( Error, Error, err.c_str() ); - TRACE("IvyApplication %s\n",err.c_str()); - return; - } -#endif + if ( regexp_in.size() < (id + 1) ) { regexp_in.resize( id + 1 ); @@ -206,11 +185,8 @@ void IvyApplication::OnReceive(char * line) { exp = regexp_in[ id ]; bus->CallBindingRemoveCallback( this, id, regexp_str_in[id].c_str() ); -#ifdef USE_PCRE - pcre_free( exp ); -#else + delete exp; -#endif regexp_in[ id ] = NULL; } break; @@ -325,11 +301,7 @@ void IvyApplication::OnClose(int nErrorCode) bus->CallApplicationDisconnectedCallback( this ); for ( unsigned int i = 0; i < regexp_in.size(); i++) -#ifdef USE_PCRE - pcre_free( regexp_in[i] ); -#else delete regexp_in[i]; -#endif regexp_in.clear(); Close(); //bus->RemoveApplication( this ); @@ -338,51 +310,29 @@ void IvyApplication::OnClose(int nErrorCode) int IvyApplication::SendMsg(const char *message) { int count = 0; -#ifdef USE_PCRE - pcre *exp; - int ovector[max_subexp*3]; -#else - Regexp *exp; -#endif + IvyBinding *exp; + /* send to already connected */ for ( unsigned int i = 0; i < regexp_in.size(); i++ ) { exp = regexp_in[i]; -#ifdef USE_PCRE - int match_count = pcre_exec( exp, NULL, message, (int) strlen( message ), 0, 0, ovector, max_subexp ); + int match_count = exp->Exec( message ); if ( match_count > 0 ) { ivy::string buffer; - const char **substring; - int err = pcre_get_substring_list(message,ovector, match_count, &substring); - if ( err != 0 ) - { - SendMsg( Error, Error, "Memory Alloc Error" ); - } - else { + int arglen; + const char *arg; + for ( int j = 1; j < match_count; j++ ) { - buffer += substring[j]; + exp->Match(message, j, &arglen, &arg); + buffer += arg; buffer += ARG_END; } - pcre_free_substring_list(substring); SendMsg( Msg, i, buffer.c_str() ); count++; - } } -#else - if ( exp && exp->Match( message ) ) - { - ivy::string buffer; - for ( int j = 1; j < exp->SubStrings()+1; j++ ) - { - buffer += (*exp)[j]; - buffer += ARG_END; - } - SendMsg( Msg, i, buffer.c_str() ); - count++; - } -#endif + } return count; } -- cgit v1.1 From c7734bf97cb2c4df14edd238257b95a6136c614a Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 13:00:33 +0000 Subject: Utilisateur : Fcolin Date : 1/06/06 Heure : 16:40 Archivé dans $/Bus/Ivy Commentaire: correction bug du a la separation du module regexp transformation des tables de regexp en table de Hash (vss 33) --- Ivy/IvyApplication.cxx | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index 53341bc..bad4910 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -51,8 +51,8 @@ IvyApplication::IvyApplication(Ivy * bus) IvyApplication::~IvyApplication() { // bus->RemoveApplication( this ); - for ( unsigned int i = 0; i < regexp_in.size(); i++) - delete regexp_in[i]; + for ( Bindings::iterator iter = regexp_in.begin( ); iter != regexp_in.end( ); iter++ ) + delete iter->second; regexp_in.clear(); if ( m_hSocket != INVALID_SOCKET ) Close(); @@ -164,11 +164,11 @@ void IvyApplication::OnReceive(char * line) return; } - if ( regexp_in.size() < (id + 1) ) + /*if ( regexp_in.size() < (id + 1) ) { regexp_in.resize( id + 1 ); regexp_str_in.resize( id + 1 ); - } + }*/ regexp_in[ id ] = exp; regexp_str_in[ id ] = arg; #ifdef IVY_DEBUG @@ -300,8 +300,8 @@ void IvyApplication::OnClose(int nErrorCode) if ( AppConnectedCallbackCalled ) bus->CallApplicationDisconnectedCallback( this ); - for ( unsigned int i = 0; i < regexp_in.size(); i++) - delete regexp_in[i]; + for ( Bindings::iterator iter = regexp_in.begin( ); iter != regexp_in.end( ); iter++) + delete iter->second; regexp_in.clear(); Close(); //bus->RemoveApplication( this ); @@ -313,9 +313,11 @@ int IvyApplication::SendMsg(const char *message) IvyBinding *exp; /* send to already connected */ - for ( unsigned int i = 0; i < regexp_in.size(); i++ ) + for ( Bindings::iterator iter = regexp_in.begin( ); iter != regexp_in.end( ); iter++ ) { - exp = regexp_in[i]; + exp = iter->second; + if ( !exp ) + continue; int match_count = exp->Exec( message ); if ( match_count > 0 ) { @@ -326,10 +328,10 @@ int IvyApplication::SendMsg(const char *message) for ( int j = 1; j < match_count; j++ ) { exp->Match(message, j, &arglen, &arg); - buffer += arg; + buffer += ivy::string(arg,arglen ); buffer += ARG_END; } - SendMsg( Msg, i, buffer.c_str() ); + SendMsg( Msg, iter->first, buffer.c_str() ); count++; } -- cgit v1.1 From 27cc7f3435b1561d686aa214c5083aa2a41b39f1 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 13:00:35 +0000 Subject: Utilisateur : Fcolin Date : 1/08/06 Heure : 9:48 Archivé dans $/Bus/Ivy Commentaire: (vss 34) --- Ivy/IvyApplication.cxx | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'Ivy/IvyApplication.cxx') diff --git a/Ivy/IvyApplication.cxx b/Ivy/IvyApplication.cxx index bad4910..07f37be 100644 --- a/Ivy/IvyApplication.cxx +++ b/Ivy/IvyApplication.cxx @@ -253,6 +253,19 @@ void IvyApplication::OnReceive(char * line) exit(-1); } break; + case Ping: +#ifdef IVY_DEBUG + TRACE("Ping Message\n"); +#endif //IVY_DEBUG + this->SendMsg( Pong, 0, "beurk" ); + break; + + case Pong: +#ifdef IVY_DEBUG + TRACE("Pong Message\n"); +#endif //IVY_DEBUG + TRACE("Receive unhandled Pong message (ivy-c++ not able to send ping)\n"); + break; default: TRACE("Receive unhandled message %s\n", line); -- cgit v1.1