summaryrefslogtreecommitdiff
path: root/src/ivyprobe.c
diff options
context:
space:
mode:
authorjestin2003-03-17 17:13:35 +0000
committerjestin2003-03-17 17:13:35 +0000
commitfef671cb8c63508e5f7d85b922c7d90c59df6f5a (patch)
tree570a4c0091a4797ca8fb44351e244a5cbc727758 /src/ivyprobe.c
parent7e69fa28993cea50230bc7a43455f373d3e0316a (diff)
downloadivy-c-fef671cb8c63508e5f7d85b922c7d90c59df6f5a.zip
ivy-c-fef671cb8c63508e5f7d85b922c7d90c59df6f5a.tar.gz
ivy-c-fef671cb8c63508e5f7d85b922c7d90c59df6f5a.tar.bz2
ivy-c-fef671cb8c63508e5f7d85b922c7d90c59df6f5a.tar.xz
Makefile changed ... once again. We need a configure ?
Diffstat (limited to 'src/ivyprobe.c')
-rw-r--r--src/ivyprobe.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/ivyprobe.c b/src/ivyprobe.c
index f8e02fb..ec79567 100644
--- a/src/ivyprobe.c
+++ b/src/ivyprobe.c
@@ -36,6 +36,7 @@
#else
#include <sys/time.h>
#include <unistd.h>
+#include <regex.h>
#endif
#ifdef XTMAINLOOP
#include "ivyxtloop.h"
@@ -60,6 +61,11 @@ XtAppContext cntx;
int app_count = 0;
int wait_count = 0;
+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 Callback (IvyClientPtr app, void *user_data, int argc, char *argv[])
{
int i;
@@ -69,6 +75,15 @@ void Callback (IvyClientPtr app, void *user_data, int argc, char *argv[])
printf("\n");
}
+char * Chop(char *arg)
+{
+ int len;
+ if (arg==NULL) return arg;
+ len=strlen(arg)-1;
+ if ((*(arg+len))=='\n') *(arg+len)=0;
+ return arg;
+}
+
void HandleStdin (Channel channel, HANDLE fd, void *data)
{
char buf[4096];
@@ -122,7 +137,19 @@ void HandleStdin (Channel channel, HANDLE fd, void *data)
} else if (strcmp(cmd, "bind") == 0) {
arg = strtok (NULL, "'");
if (arg) {
- IvyBindMsg (Callback, NULL, arg);
+ 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
+ {
+ IvyBindMsg (Callback, NULL, Chop(arg));
+ }
}
} else if (strcmp(cmd, "where") == 0) {
@@ -141,7 +168,7 @@ void HandleStdin (Channel channel, HANDLE fd, void *data)
arg = strtok (NULL, " ");
id = atoi (arg) ;
arg = strtok (NULL, "'");
- IvySendDirectMsg (app, id, arg);
+ IvySendDirectMsg (app, id, Chop(arg));
} else
printf ("No Application %s!!!\n",arg);
}
@@ -263,6 +290,7 @@ int main(int argc, char *argv[])
glutDisplayFunc(display);
#endif
IvyInit ("IVYPROBE", "IVYPROBE READY", ApplicationCallback,NULL,NULL,NULL);
+ IvyBindDirectMsg( DirectCallback,NULL);
for (; optind < argc; optind++)
IvyBindMsg (Callback, NULL, argv[optind]);