summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfcolin2006-04-20 15:51:37 +0000
committerfcolin2006-04-20 15:51:37 +0000
commitd20808b04feb328272a35ee2b03f4ae19db23fbe (patch)
tree070f5efb4b7f9b4603a8d2d830c8ef5210495572
parent68372c19d14986d372918cd268d5855fd7665fc3 (diff)
downloadivy-c-d20808b04feb328272a35ee2b03f4ae19db23fbe.zip
ivy-c-d20808b04feb328272a35ee2b03f4ae19db23fbe.tar.gz
ivy-c-d20808b04feb328272a35ee2b03f4ae19db23fbe.tar.bz2
ivy-c-d20808b04feb328272a35ee2b03f4ae19db23fbe.tar.xz
cleanup DEBUG code
-rw-r--r--src/Makefile2
-rwxr-xr-xsrc/Makefile.win3231
-rw-r--r--src/ivy.c143
-rw-r--r--src/ivy.h4
-rw-r--r--src/ivyglibloop.c10
-rwxr-xr-xsrc/ivyglutloop.c9
-rwxr-xr-xsrc/ivyperf.c11
-rw-r--r--src/ivyprobe.c64
-rw-r--r--src/ivysocket.c17
-rw-r--r--src/ivyxtloop.c9
10 files changed, 125 insertions, 175 deletions
diff --git a/src/Makefile b/src/Makefile
index fdd3e28..31d1367 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -101,7 +101,7 @@ ivy.o: ivy.c
$(CC) -c $(CFLAGS) $(REGEXP) $(PCREINC) ivy.c
givy.o: ivy.c
- $(CC) -c $(CFLAGS) $(REGEXP) -DREGCOMP_OPT=$(REGCOMP_OPT) -o givy.o ivy.c
+ $(CC) -c $(CFLAGS) $(REGEXP) $(PCREINC) -DDEBUG -o givy.o ivy.c
ivyglutloop.o: ivyglutloop.c ivyglutloop.h
$(CC) -c $(CFLAGS) $(GLUTINC) ivyglutloop.c
diff --git a/src/Makefile.win32 b/src/Makefile.win32
index f7aec5a..0d05a89 100755
--- a/src/Makefile.win32
+++ b/src/Makefile.win32
@@ -19,7 +19,7 @@
MAJOR=3
MINOR=8
-PCREINC = -I "C:\Documents and Settings\fcolin\My Documents\Visual Studio 2005\Projects\pcre-6.4"
+PCREINC = -I "C:\Documents and Settings\fcolin\My Documents\Visual Studio 2005\Projects\pcre-6.4\\"
PCRELIB = "C:\Documents and Settings\fcolin\My Documents\Visual Studio 2005\Projects\pcre-6.4\lib\libpcre.lib" #`pcre-config --libs`
#PCREINC = -I "C:\Program Files\GnuWin32\include" #`pcre-config --cflags`
@@ -37,13 +37,13 @@ PCREOBJ =
#CC=gcc
#CFLAGS = -g -Wall
-CFLAGS = -DWIN32 -D_CRT_SECURE_NO_DEPRECATE -nologo
+CFLAGS = /W3 /DWIN32 /D_CRT_SECURE_NO_DEPRECATE /nologo
#LIBTOOL=ar q # linux and solaris
#LIBTOOL=libtool -static -o
-LIBTOOL=lib -nologo /out:
+LIBTOOL=lib /nologo /out:
#REGEXP = -DGNU_REGEXP -DREGCOMP_OPT=$(REGCOMP_OPT) # deprecated !
-REGEXP= -DUSE_PCRE_REGEX -DPCRE_OPT=$(PCRE_OPT)
+REGEXP= /DUSE_PCRE_REGEX /DPCRE_OPT=$(PCRE_OPT)
# on activeTCL , set #define CHANNEL to null, and add ivyloop.obj in the ivytcl target,
# see below
CHANNEL = -DTCL_CHANNEL_INTEGRATION
@@ -51,11 +51,11 @@ CHANNEL = -DTCL_CHANNEL_INTEGRATION
OBJ = ivyloop.obj timer.obj ivysocket.obj ivy.obj
# WINDOWS add ivyloop.obj if TCL_CHANNEL_INTEGRATION is not set
-TARGETS = ivyprobe ivyperf
+TARGETS = ivyprobe.exe ivyperf.exe
TARGETLIBS=libivy.dll
.c.obj:
- $(CC) $(CFLAGS) -c $*.c
+ $(CC) $(CFLAGS) /c $*.c
all: static-libs commands shared-libs
@@ -66,34 +66,31 @@ shared-libs: $(TARGETLIBS)
commands: $(TARGETS)
ivy.obj: ivy.c
- $(CC) -c $(CFLAGS) $(REGEXP) $(PCREINC) ivy.c
+ $(CC) $(CFLAGS) $(REGEXP) $(PCREINC) /c ivy.c
-ivyprobe: ivyprobe.obj libivy.lib
+ivyprobe.exe: ivyprobe.obj libivy.lib
$(CC) $(CFLAGS) -o $@ ivyprobe.obj libivy.lib wsock32.lib $(PCRELIB)
ivyprobe.obj : ivyprobe.c
- $(CC) $(CFLAGS) $(REGEXP) $(PCREINC) -c ivyprobe.c -o $@
+ $(CC) $(CFLAGS) $(REGEXP) $(PCREINC) /c ivyprobe.c
-ivyperf: ivyperf.obj libivy.lib
- $(CC) $(CFLAGS) -o $@ ivyperf.obj libivy.lib wsock32.lib $(PCRELIB)
+ivyperf.exe: ivyperf.obj libivy.lib
+ $(CC) $(CFLAGS) -o $@ ivyperf.obj libivy.lib wsock32.lib $(PCRELIB)
ivyperf.obj : ivyperf.c
- $(CC) $(CFLAGS) $(REGEXP) $(PCREINC) -c ivyperf.c -o $@
+ $(CC) $(CFLAGS) $(REGEXP) $(PCREINC) /c ivyperf.c
libivy.lib: $(OBJ)
del /f $@
$(LIBTOOL)$@ $(OBJ)
-
-# TODO this PCREOBJ is a dirty hack
-
libivy.dll: $(OBJ)
- $(CC) /dll -o $@ $(OBJ) $(PCRELIB)
+ $(CC) /dll /out: $@ $(OBJ) $(PCRELIB)
clean:
- -del /f $(TARGETS) $(TARGETLIBS) *.obj *.a *.dll *~
+ -del /f $(TARGETS) $(TARGETLIBS) *.obj *.lib *.dll *~
diff --git a/src/ivy.c b/src/ivy.c
index 00362ab..dd8aa04 100644
--- a/src/ivy.c
+++ b/src/ivy.c
@@ -39,6 +39,7 @@
#include "ivysocket.h"
#include "list.h"
#include "ivybuffer.h"
+#include "ivydebug.h"
#include "ivy.h"
#define VERSION 3
@@ -212,17 +213,17 @@ MsgCall (const char *message, MsgSndPtr msg, IvyClientPtr client)
ovector,
OVECSIZE);
if (rc<1) return 0; /* no match */
-#ifdef DEBUG
- printf( "Sending message id=%d '%s'\n",msg->id,message);
-#endif
+
+ TRACE( "Sending message id=%d '%s'\n",msg->id,message);
+
buffer.offset = 0;
// il faut essayer d'envoyer le message en une seule fois sur la socket
// pour eviter au maximun de passer dans le select plusieur fois par message du protocole Ivy
// pour eviter la latence ( PB de perfo detecte par ivyperf ping roudtrip )
err = make_message_var( &buffer, "%d %d" ARG_START ,Msg, msg->id);
-#ifdef DEBUG
- printf( "Send matching args count %ld\n",msg->regexp.re_nsub);
-#endif
+
+ TRACE( "Send matching args count %d\n",rc);
+
index=1;
while ( index<rc ) {
err = make_message_var( &buffer, "%.*s" ARG_END , ovector[2*index+1]- ovector[2*index],
@@ -254,18 +255,15 @@ MsgCall (const char *message, MsgSndPtr msg, IvyClientPtr client)
if (regexec (&msg->regexp, message, MAX_MATCHING_ARGS, match, 0) != 0)
return 0;
-#ifdef DEBUG
- printf( "Sending message id=%d '%s'\n",msg->id,message);
-#endif
+ TRACE( "Sending message id=%d '%s'\n",msg->id,message);
+
// il faut essayer d'envoyer le message en une seule fois sur la socket
// pour eviter au maximun de passer dans le select plusieur fois par message du protocole Ivy
// pour eviter la latence ( PB detecte par ivyperf ping roudtrip )
buffer.offset = 0;
err = make_message_var( &buffer, "%d %d" ARG_START ,Msg, msg->id);
-#ifdef DEBUG
- printf( "Send matching args count %ld\n",msg->regexp.re_nsub);
-#endif //DEBUG
+ TRACE( "Send matching args count %ld\n",msg->regexp.re_nsub);
#ifdef GNU_REGEXP
p = &match[1];
@@ -277,18 +275,17 @@ MsgCall (const char *message, MsgSndPtr msg, IvyClientPtr client)
#else
for ( i = 1; i < msg->regexp.re_nsub+1; i ++ ) {
if ( match[i].rm_so != -1 ) {
-#ifdef DEBUG
- printf ("Send matching arg%d %d %d\n",i,match[i].rm_so , match[i].rm_eo);
- printf ("Send matching arg%d %.*s\n",i,(int)(match[i].rm_eo - match[i].rm_so),
+
+ TRACE("Send matching arg%d %d %d\n",i,match[i].rm_so , match[i].rm_eo);
+ TRACE ("Send matching arg%d %.*s\n",i,(int)(match[i].rm_eo - match[i].rm_so),
message + match[i].rm_so);
-#endif
+
buffer.offset += make_message_var( &buffer, "%.*s" ARG_END ,(int)(match[i].rm_eo - match[i].rm_so),
message + match[i].rm_so);
} else {
buffer.offset += make_message_var( &buffer, ARG_END );
-#ifdef DEBUG
- printf( "Send matching arg%d VIDE\n",i);
-#endif //DEBUG
+
+ TRACE( "Send matching arg%d VIDE\n",i);
}
}
#endif
@@ -356,11 +353,11 @@ static int ExtractTokenRegexp (const char *exp, char *buffer, int buffersize)
#else
for ( i = 1; i < msg->regexp.re_nsub+1; i ++ ) {
if ( match[i].rm_so != -1 ) {
-#ifdef DEBUG
- printf ("Send matching arg%d %d %d\n",i,match[i].rm_so , match[i].rm_eo);
- printf ("Send matching arg%d %.*s\n",i,(int)(match[i].rm_eo - match[i].rm_so),
+
+ TRACE ("Send matching arg%d %d %d\n",i,match[i].rm_so , match[i].rm_eo);
+ TRACE ("Send matching arg%d %.*s\n",i,(int)(match[i].rm_eo - match[i].rm_so),
message + match[i].rm_so);
-#endif
+
buffer.offset += make_message_var( &buffer, "%.*s" ARG_END ,(int)(match[i].rm_eo - match[i].rm_so),
message + match[i].rm_so);
} else {
@@ -376,6 +373,7 @@ static int ExtractTokenRegexp (const char *exp, char *buffer, int buffersize)
static int CheckRegexp(char *exp)
{
int i;
+ int err;
int regexp_ok = 1; /* accepte tout par default */
char token[200];
@@ -384,7 +382,7 @@ static int CheckRegexp(char *exp)
regexp_ok = 0;
/* extract token */
- int err = ExtractTokenRegexp ( exp, token, sizeof(token));
+ err = ExtractTokenRegexp ( exp, token, sizeof(token));
if ( err < 1 ) return 1;
for ( i = 0 ; i < messages_classes_count; i++ )
{
@@ -455,9 +453,7 @@ static void Receive( Client client, void *data, char *line )
{
case Bye:
-#ifdef DEBUG
- printf("Quitting %s\n", line);
-#endif //DEBUG
+ TRACE("Quitting %s\n", line);
SocketClose( client );
break;
@@ -466,14 +462,14 @@ static void Receive( Client client, void *data, char *line )
break;
case AddRegexp:
-#ifdef DEBUG
- printf("Regexp id=%d exp='%s'\n", id, arg);
-#endif //DEBUG
+
+ TRACE("Regexp id=%d exp='%s'\n", id, arg);
+
if ( !CheckRegexp( arg ) )
{
-#ifdef DEBUG
- printf("Warning: regexp '%s' illegal, removing from %s\n",arg,ApplicationName);
-#endif //DEBUG
+
+ TRACE("Warning: regexp '%s' illegal, removing from %s\n",arg,ApplicationName);
+
if ( application_bind_callback )
{
(*application_bind_callback)( clnt, application_bind_data, id, arg, IvyFilterBind );
@@ -530,9 +526,8 @@ static void Receive( Client client, void *data, char *line )
#endif
break;
case DelRegexp:
-#ifdef DEBUG
- printf("Regexp Delete id=%d\n", id);
-#endif //DEBUG
+
+ TRACE("Regexp Delete id=%d\n", id);
IVY_LIST_ITER( clnt->msg_send, snd, ( id != snd->id ));
if ( snd )
@@ -552,25 +547,24 @@ static void Receive( Client client, void *data, char *line )
}
break;
case StartRegexp:
-#ifdef DEBUG
- printf("Regexp Start id=%d Application='%s'\n", id, arg);
-#endif //DEBUG
+
+ TRACE("Regexp Start id=%d Application='%s'\n", id, arg);
+
clnt->app_name = strdup( arg );
clnt->app_port = id;
if ( CheckConnected( clnt ) )
{
-#ifdef DEBUG
- printf("Quitting already connected %s\n", line);
-#endif //DEBUG
+
+ TRACE("Quitting already connected %s\n", line);
+
IvySendError( clnt, 0, "Application already connected" );
SocketClose( client );
}
break;
case EndRegexp:
-#ifdef DEBUG
- printf("Regexp End id=%d\n", id);
-#endif //DEBUG
+ TRACE("Regexp End id=%d\n", id);
+
if ( application_callback )
{
(*application_callback)( clnt, application_user_data, IvyApplicationConnected );
@@ -580,17 +574,12 @@ static void Receive( Client client, void *data, char *line )
int count;
count = ClientCall( clnt, ready_message );
-#ifdef DEBUG
- printf(" Sendind ready message %d\n", count);
-#endif //DEBUG
-
+ TRACE(" Sendind ready message %d\n", count);
}
break;
case Msg:
-#ifdef DEBUG
- printf("Message id=%d msg='%s'\n", id, arg);
-#endif //DEBUG
+ TRACE("Message id=%d msg='%s'\n", id, arg);
IVY_LIST_EACH( msg_recv, rcv )
{
@@ -602,9 +591,7 @@ static void Receive( Client client, void *data, char *line )
argv[argc++] = arg;
arg = nextArg( 0, ARG_END );
}
-#ifdef DEBUG
- printf("Calling id=%d argc=%d for %s\n", id, argc,rcv->regexp);
-#endif
+ TRACE("Calling id=%d argc=%d for %s\n", id, argc,rcv->regexp);
if ( rcv->callback ) (*rcv->callback)( clnt, rcv->user_data, argc, argv );
return;
}
@@ -613,9 +600,7 @@ static void Receive( Client client, void *data, char *line )
break;
case DirectMsg:
-#ifdef DEBUG
- printf("Direct Message id=%d msg='%s'\n", id, arg);
-#endif //DEBUG
+ TRACE("Direct Message id=%d msg='%s'\n", id, arg);
if ( direct_callback)
(*direct_callback)( clnt, direct_user_data, id, arg );
@@ -623,9 +608,7 @@ static void Receive( Client client, void *data, char *line )
case Die:
-#ifdef DEBUG
- printf("Die Message\n");
-#endif //DEBUG
+ TRACE("Die Message\n");
if ( application_die_callback)
(*application_die_callback)( clnt, application_die_user_data, id );
@@ -678,7 +661,7 @@ static void ClientDelete( Client client, void *data )
#ifdef DEBUG
/* probably bogus call, but this is for debug only anyway */
SocketGetRemoteHost( client, &remotehost, &remoteport );
- printf("Deconnexion de %s:%hu\n", remotehost, remoteport );
+ TRACE("Deconnexion de %s:%hu\n", remotehost, remoteport );
#endif //DEBUG
if ( clnt->app_name ) free( clnt->app_name );
@@ -698,7 +681,7 @@ static void *ClientCreate( Client client )
char *remotehost;
unsigned short remoteport;
SocketGetRemoteHost( client, &remotehost, &remoteport );
- printf("Connexion de %s:%hu\n", remotehost, remoteport );
+ TRACE("Connexion de %s:%hu\n", remotehost, remoteport );
#endif //DEBUG
return SendService (client);
@@ -739,7 +722,7 @@ static void BroadcastReceive( Client client, void *data, char *line )
#ifdef DEBUG
SocketGetRemoteHost (client, &remotehost, &remoteport );
- printf(" Broadcast de %s:%hu port %hu\n", remotehost, remoteport, serviceport );
+ TRACE(" Broadcast de %s:%hu port %hu\n", remotehost, remoteport, serviceport );
#endif //DEBUG
/* connect to the service and send the regexp */
@@ -773,25 +756,18 @@ void IvySetBindCallback(IvyBindCallback bind_callback, void *bind_data
application_bind_data=bind_data;
}
-void IvyDelBindCallback()
-{
- application_bind_callback=0;
- free(application_bind_data);
- application_bind_data=0;
-}
void IvyClasses( int argc, const char **argv)
{
- messages_classes_count = argc;
- messages_classes = argv;
#ifndef USE_PCRE_REGEX
- regex_t regexp;
int reg;
#else
- pcre *regexp;
const char *errbuf;
int erroffset;
#endif
+ messages_classes_count = argc;
+ messages_classes = argv;
+
/* compile the token extraction regexp */
#ifndef USE_PCRE_REGEX
reg = regcomp(&token_extract, "^\\^([a-zA-Z_0-9-]+).*", REGCOMP_OPT|REG_EXTENDED);
@@ -930,9 +906,7 @@ void IvyStart (const char* bus)
++p;
}
-#ifdef DEBUG
- fprintf (stderr,"Listening on TCP:%hu\n",ApplicationPort);
-#endif
+ TRACE ("Listening on TCP:%hu\n",ApplicationPort);
}
@@ -995,9 +969,7 @@ int IvySendMsg(const char *fmt, ...)
IVY_LIST_EACH (clients, clnt) {
match_count += ClientCall (clnt, buffer.data);
}
-#ifdef DEBUG
- if ( match_count == 0 ) printf( "Warning no recipient for %s\n",buffer);
-#endif
+ TRACE_IF( match_count == 0, "Warning no recipient for %s\n",buffer.data);
return match_count;
}
@@ -1066,6 +1038,9 @@ void IvyDefaultBindCallback( IvyClientPtr app, void *user_data, int id, char* re
case IvyRemoveBind:
printf("Application: %s on %s remove regexp %d :%s\n", IvyGetApplicationName( app ), IvyGetApplicationHost(app), id, regexp);
break;
+ case IvyFilterBind:
+ printf("Application: %s on %s as been filtred regexp %d :%s\n", IvyGetApplicationName( app ), IvyGetApplicationHost(app), id, regexp);
+ break;
default:
printf("Application: %s unkown event %d\n",IvyGetApplicationName( app ), event);
break;
@@ -1079,22 +1054,22 @@ IvyClientPtr IvyGetApplication( char *name )
return app;
}
-char *IvyGetApplicationList()
+char *IvyGetApplicationList(const char *sep)
{
- static char applist[4096];
+ static char applist[4096]; /* TODO remove that ugly Thing */
IvyClientPtr app;
applist[0] = '\0';
IVY_LIST_EACH( clients, app )
{
strcat( applist, app->app_name );
- strcat( applist, " " );
+ strcat( applist, sep );
}
return applist;
}
char **IvyGetApplicationMessages( IvyClientPtr app )
{
- static char *messagelist[200];
+ static char *messagelist[200];/* TODO remove that ugly Thing */
MsgSndPtr msg;
int msgCount= 0;
memset( messagelist, 0 , sizeof( messagelist ));
diff --git a/src/ivy.h b/src/ivy.h
index fd1fb62..1056cd1 100644
--- a/src/ivy.h
+++ b/src/ivy.h
@@ -68,7 +68,7 @@ void IvyInit(
void IvySetBindCallback(
IvyBindCallback bind_callback,
void *bind_data );
-void IvyDelBindCallback();
+
void IvyStart (const char*);
void IvyStop ();
@@ -76,7 +76,7 @@ void IvyStop ();
char *IvyGetApplicationName( IvyClientPtr app );
char *IvyGetApplicationHost( IvyClientPtr app );
IvyClientPtr IvyGetApplication( char *name );
-char *IvyGetApplicationList();
+char *IvyGetApplicationList(const char *sep);
char **IvyGetApplicationMessages( IvyClientPtr app); /* demande de reception d'un message */
MsgRcvPtr IvyBindMsg( MsgCallback callback, void *user_data, const char *fmt_regexp, ... ); /* avec sprintf prealable */
diff --git a/src/ivyglibloop.c b/src/ivyglibloop.c
index 968824a..aea3c54 100644
--- a/src/ivyglibloop.c
+++ b/src/ivyglibloop.c
@@ -26,7 +26,7 @@
#endif
#include <glib.h>
-
+#include "ivydebug.h"
#include "ivyglibloop.h"
struct _channel {
@@ -100,9 +100,7 @@ static gboolean IvyGlibHandleChannelRead(GIOChannel *source,
GIOCondition condition,
gpointer data) {
Channel channel = (Channel)data;
-#ifdef DEBUG
- printf("Handle Channel read %d\n",source );
-#endif
+ TRACE("Handle Channel read %d\n",source );
(*channel->handle_read)(channel, g_io_channel_unix_get_fd(source), channel->data);
return TRUE;
}
@@ -111,9 +109,7 @@ static gboolean IvyGlibHandleChannelDelete(GIOChannel *source,
GIOCondition condition,
gpointer data) {
Channel channel = (Channel)data;
-#ifdef DEBUG
- printf("Handle Channel delete %d\n",source );
-#endif
+ TRACE("Handle Channel delete %d\n",source );
(*channel->handle_delete)(channel->data);
return TRUE;
}
diff --git a/src/ivyglutloop.c b/src/ivyglutloop.c
index a777a30..372c268 100755
--- a/src/ivyglutloop.c
+++ b/src/ivyglutloop.c
@@ -39,6 +39,7 @@
#include <GL/glut.h>
+#include "ivydebug.h"
#include "ivychannel.h"
#include "ivyglutloop.h"
@@ -83,18 +84,14 @@ void IvyGlutChannelClose( Channel channel )
static void IvyGlutHandleChannelRead( int source, GLUTInputId id, void *data )
{
Channel channel = (Channel)data;
-#ifdef DEBUG
- printf("Handle Channel read %d\n",source );
-#endif
+ TRACE("Handle Channel read %d\n",source );
(*channel->handle_read)(channel,source,channel->data);
}
static void IvyGlutHandleChannelDelete( int source, GLUTInputId id, void *data )
{
Channel channel = (Channel)data;
-#ifdef DEBUG
- printf("Handle Channel delete %d\n",source );
-#endif
+ TRACE("Handle Channel delete %d\n",source );
(*channel->handle_delete)(channel->data);
}
diff --git a/src/ivyperf.c b/src/ivyperf.c
index 283771c..92ea982 100755
--- a/src/ivyperf.c
+++ b/src/ivyperf.c
@@ -39,7 +39,8 @@ extern int optind;
#include "ivyloop.h"
#define MILLISEC 1000.0
-char *mymessages[] = { "ping", "pong" };
+const char *mymessages[] = { "IvyPerf", "ping", "pong" };
+static double origin = 0;
static double currentTime()
{
@@ -56,11 +57,11 @@ static double currentTime()
void Reply (IvyClientPtr app, void *user_data, int argc, char *argv[])
{
- IvySendMsg ("pong ts=%s tr=%f", *argv, currentTime());
+ IvySendMsg ("pong ts=%s tr=%f", *argv, currentTime()- origin);
}
void Pong (IvyClientPtr app, void *user_data, int argc, char *argv[])
{
- double current = currentTime();
+ double current = currentTime() - origin ;
double ts = atof( *argv++ );
double tr = atof( *argv++ );
double roundtrip1 = tr-ts;
@@ -71,7 +72,7 @@ void Pong (IvyClientPtr app, void *user_data, int argc, char *argv[])
void TimerCall(TimerId id, void *user_data, unsigned long delta)
{
- int count = IvySendMsg ("ping ts=%f", currentTime() );
+ int count = IvySendMsg ("ping ts=%f", currentTime() - origin );
if ( count == 0 ) fprintf(stderr, "." );
}
@@ -104,7 +105,7 @@ int main(int argc, char *argv[])
IvySetBindCallback( binCB, 0 ),
IvyBindMsg (Reply, NULL, "^ping ts=(.*)");
IvyBindMsg (Pong, NULL, "^pong ts=(.*) tr=(.*)");
-
+ origin = currentTime();
IvyStart (0);
TimerRepeatAfter (TIMER_LOOP, time, TimerCall, (void*)1);
diff --git a/src/ivyprobe.c b/src/ivyprobe.c
index 6c3313b..10d0667 100644
--- a/src/ivyprobe.c
+++ b/src/ivyprobe.c
@@ -45,11 +45,11 @@
extern char *optarg;
extern int optind;
#endif
-#ifndef USE_PCRE_REGEX
-#include <regex.h>
-#else
+#ifdef USE_PCRE_REGEX
#define OVECSIZE 60 /* must be multiple of 3, for regexp return */
#include <pcre.h>
+#else
+#include <regex.h>
#endif
@@ -79,22 +79,12 @@ int app_count = 0;
int wait_count = 0;
int fbindcallback = 0;
-void DirectCallback(IvyClientPtr app, void *user_data, int id, char *msg ) {
+void DirectCallback(IvyClientPtr app, void *user_data, int id, char *msg )
+{
printf("%s sent a direct message, id=%d, message=%s\n",
IvyGetApplicationName(app),id,msg);
}
-void BindCallback(IvyClientPtr app, void *user_data, int id, char *regexp, IvyBindEvent event ) {
- char *sevent;
- if (event==IvyAddBind){
- sevent="added";
- }
- else{
- sevent="removed";
- }
- printf("%s has modified his binding, id=%d, regexp=%s is %s\n",
- IvyGetApplicationName(app),id,regexp,sevent);
-}
void Callback (IvyClientPtr app, void *user_data, int argc, char *argv[])
{
@@ -153,8 +143,8 @@ void HandleStdin (Channel channel, HANDLE fd, void *data)
}
} else if (strcmp(cmd, "dieall-yes-i-am-sure") == 0) {
- arg = IvyGetApplicationList();
- arg = strtok (arg, " \n");
+ arg = IvyGetApplicationList("#");
+ arg = strtok (arg, "#");
while (arg) {
app = IvyGetApplication (arg);
if (app)
@@ -167,15 +157,7 @@ void HandleStdin (Channel channel, HANDLE fd, void *data)
} else if (strcmp(cmd, "bind") == 0) {
arg = strtok (NULL, "'");
if (arg) {
-#ifndef USE_PCRE_REGEX
- regex_t reg;
- int err;
- Chop(arg);
- if (err=regcomp(&reg,arg,REG_ICASE|REG_EXTENDED)!=0) {
- char errbuf[4096];
- regerror (err, &reg, errbuf, 4096);
- printf("Error compiling '%s', %s, not bound\n", arg, errbuf);
-#else
+#ifdef USE_PCRE_REGEX
pcre *regexp;
const char *errbuf;
int erroffset;
@@ -183,6 +165,14 @@ void HandleStdin (Channel channel, HANDLE fd, void *data)
regexp = pcre_compile(arg, 0,&errbuf,&erroffset,NULL);
if (regexp==NULL) {
printf("Error compiling '%s', %s, not bound\n", arg, errbuf);
+#else
+ regex_t reg;
+ int err;
+ Chop(arg);
+ if (err=regcomp(&reg,arg,REG_ICASE|REG_EXTENDED)!=0) {
+ char errbuf[4096];
+ regerror (err, &reg, errbuf, 4096);
+ printf("Error compiling '%s', %s, not bound\n", arg, errbuf);
#endif
} else {
IvyBindMsg (Callback, NULL, Chop(arg));
@@ -211,26 +201,26 @@ void HandleStdin (Channel channel, HANDLE fd, void *data)
}
} else if (strcmp(cmd, "who") == 0) {
- printf("Apps: %s\n", IvyGetApplicationList());
+ printf("Apps: %s\n", IvyGetApplicationList(","));
} else if (strcmp(cmd, "help") == 0) {
fprintf(stderr,"Commands list:\n");
- printf(" .help - this help\n");
- printf(" .quit - terminate this application\n");
- printf(" .die appname - send die msg to appname\n");
+ printf(" .help - this help\n");
+ printf(" .quit - terminate this application\n");
+ printf(" .die appname - send die msg to appname\n");
printf(" .dieall-yes-i-am-sure - send die msg to all applis\n");
printf(" .direct appname id 'arg' - send direct msg to appname\n");
- printf(" .where appname - on which host is appname\n");
- printf(" .bind 'regexp' - add a msg to receive\n");
- printf(" .bindcall - show binds \n");
+ printf(" .where appname - on which host is appname\n");
+ printf(" .bind 'regexp' - add a msg to receive\n");
+ printf(" .showbind - show bindings \n");
printf(" .who - who is on the bus\n");
- } else if (strcmp(cmd, "bindcall") == 0) {
+ } else if (strcmp(cmd, "showbind") == 0) {
if (!fbindcallback) {
- IvySetBindCallback(BindCallback, NULL);
+ IvySetBindCallback(IvyDefaultBindCallback, NULL);
fbindcallback=1;
} else {
- IvyDelBindCallback();
+ IvySetBindCallback(NULL, NULL);
fbindcallback=0;
}
} else if (strcmp(cmd, "quit") == 0) {
@@ -334,7 +324,7 @@ int main(int argc, char *argv[])
timer_test = 1;
break;
case 's':
- IvySetBindCallback(BindCallback, NULL);
+ IvySetBindCallback(IvyDefaultBindCallback, NULL);
fbindcallback=1;
break;
default:
diff --git a/src/ivysocket.c b/src/ivysocket.c
index 5b2fa93..d38f66a 100644
--- a/src/ivysocket.c
+++ b/src/ivysocket.c
@@ -42,6 +42,7 @@
#include "ivysocket.h"
#include "ivyloop.h"
#include "ivybuffer.h"
+#include "ivydebug.h"
#define BUFFER_SIZE 4096 /* taille buffer initiale on multiple pas deux a chaque realloc */
@@ -75,11 +76,7 @@ struct _client {
static Server servers_list = NULL;
static Client clients_list = NULL;
-#ifdef DEBUG
-static int debug_send = 1;
-#else
static int debug_send = 0;
-#endif
#ifdef WIN32
WSADATA WsaData;
@@ -180,18 +177,18 @@ static void HandleServer(Channel channel, HANDLE fd, void *data)
HANDLE ns;
socklen_t addrlen;
struct sockaddr_in remote2;
-#ifdef DEBUG
- printf( "Accepting Connection...\n");
-#endif //DEBUG
+
+ TRACE( "Accepting Connection...\n");
+
addrlen = sizeof (remote2 );
if ((ns = accept (fd, (struct sockaddr *)&remote2, &addrlen)) <0)
{
perror ("*** accept ***");
return;
};
-#ifdef DEBUG
- printf( "Accepting Connection ret\n");
-#endif //DEBUG
+
+ TRACE( "Accepting Connection ret\n");
+
IVY_LIST_ADD_START (clients_list, client );
client->buffer_size = BUFFER_SIZE;
diff --git a/src/ivyxtloop.c b/src/ivyxtloop.c
index 2764fe4..b09ccee 100644
--- a/src/ivyxtloop.c
+++ b/src/ivyxtloop.c
@@ -39,6 +39,7 @@
#include <X11/Intrinsic.h>
+#include "ivydebug.h"
#include "ivychannel.h"
#include "ivyxtloop.h"
@@ -92,18 +93,14 @@ void IvyXtChannelClose( Channel channel )
static void IvyXtHandleChannelRead( XtPointer closure, int* source, XtInputId* id )
{
Channel channel = (Channel)closure;
-#ifdef DEBUG
- printf("Handle Channel read %d\n",*source );
-#endif
+ TRACE("Handle Channel read %d\n",*source );
(*channel->handle_read)(channel,*source,channel->data);
}
static void IvyXtHandleChannelDelete( XtPointer closure, int* source, XtInputId* id )
{
Channel channel = (Channel)closure;
-#ifdef DEBUG
- printf("Handle Channel delete %d\n",*source );
-#endif
+ TRACE("Handle Channel delete %d\n",*source );
(*channel->handle_delete)(channel->data);
}