summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ivy.c25
-rw-r--r--src/ivy.h10
-rw-r--r--src/ivyprobe.c37
3 files changed, 31 insertions, 41 deletions
diff --git a/src/ivy.c b/src/ivy.c
index ca4d8b3..8288558 100644
--- a/src/ivy.c
+++ b/src/ivy.c
@@ -137,11 +137,11 @@ static MsgDirectCallback direct_callback = 0;
static void *direct_user_data = 0;
/* callback appele sur changement d'etat d'application */
-static IvyApplicationCallback application_callback;
+static IvyApplicationCallback application_callback = 0;
static void *application_user_data = 0;
/* callback appele sur ajout suppression de regexp */
-static IvyBindCallback application_bind_callback;
+static IvyBindCallback application_bind_callback = 0;
static void *application_bind_data = 0;
/* callback appele sur demande de terminaison d'application */
@@ -513,7 +513,7 @@ static void Receive( Client client, void *data, char *line )
snd->regexp = regexp;
if ( application_bind_callback )
{
- (*application_bind_callback)( clnt, application_bind_data, id, snd->str_regexp, IvyAddBind );
+ (*application_bind_callback)( clnt, application_bind_data, snd->str_regexp, IvyAddBind );
}
}
}
@@ -542,7 +542,7 @@ static void Receive( Client client, void *data, char *line )
if ( application_bind_callback )
{
- (*application_bind_callback)( clnt, application_bind_data, id, snd->str_regexp, IvyAddBind );
+ (*application_bind_callback)( clnt, application_bind_data, IvyAddBind, snd->str_regexp );
}
}
}
@@ -563,7 +563,7 @@ static void Receive( Client client, void *data, char *line )
{
if ( application_bind_callback )
{
- (*application_bind_callback)( clnt, application_bind_data, id, snd->str_regexp, IvyRemoveBind );
+ (*application_bind_callback)( clnt, application_bind_data, IvyRemoveBind, snd->str_regexp );
}
#ifndef USE_PCRE_REGEX
free( snd->str_regexp );
@@ -813,19 +813,12 @@ void IvySetApplicationPriority( int priority )
}
}
-void IvySetBindCallback(IvyBindCallback bind_callback, void *bind_data
- )
+void IvySetBindCallback(IvyBindCallback bind_callback, void *bind_data)
{
application_bind_callback=bind_callback;
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;
@@ -1083,14 +1076,14 @@ void IvyDefaultApplicationCallback( IvyClientPtr app, void *user_data, IvyApplic
break;
}
}
-void IvyDefaultBindCallback( IvyClientPtr app, void *user_data, int id, char* regexp, IvyBindEvent event)
+void IvyDefaultBindCallback( IvyClientPtr app, void *user_data, IvyBindEvent event, char* regexp )
{
switch ( event ) {
case IvyAddBind:
- printf("Application: %s on %s add regexp %d : %s\n", IvyGetApplicationName( app ), IvyGetApplicationHost(app), id, regexp);
+ printf("Application: %s on %s add regexp %s\n", IvyGetApplicationName( app ), IvyGetApplicationHost(app), regexp);
break;
case IvyRemoveBind:
- printf("Application: %s on %s remove regexp %d :%s\n", IvyGetApplicationName( app ), IvyGetApplicationHost(app), id, regexp);
+ printf("Application: %s on %s remove regexp %s\n", IvyGetApplicationName( app ), IvyGetApplicationHost(app), regexp);
break;
default:
printf("Application: %s unkown event %d\n",IvyGetApplicationName( app ), event);
diff --git a/src/ivy.h b/src/ivy.h
index 10c7f86..a9298ab 100644
--- a/src/ivy.h
+++ b/src/ivy.h
@@ -33,14 +33,14 @@ typedef enum { IvyApplicationConnected, IvyApplicationDisconnected } IvyApplicat
typedef enum { IvyAddBind, IvyRemoveBind } IvyBindEvent;
extern void IvyDefaultApplicationCallback( IvyClientPtr app, void *user_data, IvyApplicationEvent event ) ;
-extern void IvyDefaultBindCallback( IvyClientPtr app, void *user_data, int id, char* regexp, IvyBindEvent event ) ;
+extern void IvyDefaultBindCallback( IvyClientPtr app, void *user_data, IvyBindEvent event, char* regexp ) ;
/* callback callback appele sur connexion deconnexion d'une appli */
typedef void (*IvyApplicationCallback)( IvyClientPtr app, void *user_data, IvyApplicationEvent event ) ;
/* callback callback appele sur ajout ou suppression d'un bind */
-typedef void (*IvyBindCallback)( IvyClientPtr app, void *user_data, int id, char* regexp, IvyBindEvent event ) ;
+typedef void (*IvyBindCallback)( IvyClientPtr app, void *user_data, IvyBindEvent event, char* regexp ) ;
/* callback appele sur reception de die */
typedef void (*IvyDieCallback)( IvyClientPtr app, void *user_data, int id ) ;
@@ -65,11 +65,9 @@ void IvyInit(
IvyDieCallback die_callback, /* last change callback before die */
void *die_data /* user data */
);
+
void IvySetApplicationPriority( int priority );
-void IvySetBindCallback(
- IvyBindCallback bind_callback,
- void *bind_data );
-void IvyDelBindCallback();
+void IvySetBindCallback( IvyBindCallback bind_callback, void *bind_data );
void IvyStart (const char*);
void IvyStop ();
diff --git a/src/ivyprobe.c b/src/ivyprobe.c
index fd4e0cb..1da9ebc 100644
--- a/src/ivyprobe.c
+++ b/src/ivyprobe.c
@@ -70,21 +70,19 @@ 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 ) {
+void BindCallback(IvyClientPtr app, void *user_data, IvyBindEvent event, char *regexp )
+{
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);
+ sevent= event==IvyAddBind ? "added" :"removed";
+
+ printf("%s has modified his binding, regexp=%s is %s\n",
+ IvyGetApplicationName(app),regexp,sevent);
}
void Callback (IvyClientPtr app, void *user_data, int argc, char *argv[])
@@ -195,20 +193,21 @@ void HandleStdin (Channel channel, HANDLE fd, void *data)
} 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(" .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(" .who - who is on the bus\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 - add callback to binding\n");
+ printf(" .who - who is on the bus\n");
} else if (strcmp(cmd, "bindcall") == 0) {
if (!fbindcallback) {
IvySetBindCallback(BindCallback, NULL);
fbindcallback=1;
} else {
- IvyDelBindCallback();
+ IvySetBindCallback(NULL, NULL);
fbindcallback=0;
}
} else if (strcmp(cmd, "quit") == 0) {