summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile4
-rw-r--r--src/bus.c4
-rw-r--r--src/bussocket.h1
-rw-r--r--src/testbus.c21
-rw-r--r--src/timer.c21
5 files changed, 33 insertions, 18 deletions
diff --git a/src/Makefile b/src/Makefile
index e9d704f..4d73cae 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,4 +1,4 @@
-XTINC =
+XTINC =-I/usr/local/X11R6.3/include
CC=gcc
OBJ = timer.o bussocket.o bus.o
GOBJ = timer.o bussocket.o gbus.o
@@ -13,7 +13,7 @@ xtsocket.o: bussocket.c
$(CC) -DXTMAINLOOP $(XTINC) -c $(CFLAGS) -o xtsocket.o bussocket.c
testbus: testbus.o $(OBJ)
- $(CC) -o testbus testbus.o $(OBJ)
+ $(CC) -o testbus testbus.o $(OBJ) -lsocket -lnsl
libbus.a: $(OBJ)
ar q libbus.a $(OBJ)
diff --git a/src/bus.c b/src/bus.c
index e1d9a50..dc291c1 100644
--- a/src/bus.c
+++ b/src/bus.c
@@ -129,7 +129,7 @@ static int MsgCall( const char *message, MsgSndPtr msg, Client client )
#else
unsigned int i;
#endif
-
+ memset( match, -1, sizeof(match )); /* work around bug !!!*/
if (regexec(&msg->regexp, message, MAX_MATCHING_ARGS, match, 0)==0) {
#ifdef DEBUG
printf( "Sending message id=%d '%s'\n",msg->id,message);
@@ -381,7 +381,7 @@ static void Receive( Client client, void *data, char *line )
case Die:
#ifdef DEBUG
- printf("Die Message\n",);
+ printf("Die Message\n");
#endif //DEBUG
if ( application_die_callback)
diff --git a/src/bussocket.h b/src/bussocket.h
index 99b9abd..b40571f 100644
--- a/src/bussocket.h
+++ b/src/bussocket.h
@@ -77,6 +77,7 @@ extern void SocketGetRemote( Client client, char **host, unsigned short *port );
extern void SocketSendBroadcast( Client client, unsigned long host, unsigned short port, char *fmt, ... );
#ifdef XTMAINLOOP
+#include <X11/Intrinsic.h>
extern void SetSocketAppContext( XtAppContext cntx );
#endif
diff --git a/src/testbus.c b/src/testbus.c
index e42094d..db52985 100644
--- a/src/testbus.c
+++ b/src/testbus.c
@@ -49,6 +49,21 @@ void HandleStdin( Channel channel, int fd, void *data)
else printf( "No Application %s!!!\n",arg);
}
}
+ if ( strcmp(cmd, "dieall-yes-i-am-sure") == 0 )
+ {
+ arg = GetApplicationList();
+ arg = strtok( arg, " " );
+ while ( arg )
+ {
+ app = GetApplication( arg );
+ if ( app )
+ SendDieMsg( app );
+ else printf( "No Application %s!!!\n",arg);
+ arg = strtok( NULL, " ");
+ }
+
+ }
+
if ( strcmp(cmd, "bind" ) == 0 )
{
arg = strtok( NULL, "'" );
@@ -122,7 +137,7 @@ void ApplicationCallback( BusClientPtr app, void *user_data, BusApplicationEvent
switch ( event ) {
case BusApplicationConnected:
app_count++;
- printf("Application(%d): %s ready on %s\n",app_count, appname, host);
+ printf("Application(%s): ready on %s\n", appname, host);
printf("Application(%s): Begin Messages\n", appname);
msgList = GetApplicationMessages( app );
while( *msgList )
@@ -133,10 +148,10 @@ void ApplicationCallback( BusClientPtr app, void *user_data, BusApplicationEvent
break;
case BusApplicationDisconnected:
app_count--;
- printf("Application(%d): %s bye on %s\n",app_count, appname, host);
+ printf("Application(%s): bye on %s\n", appname, host);
break;
default:
- printf("Application(%d): %s unkown event %d\n", app_count, appname, event);
+ printf("Application(%s): unkown event %d\n", appname, event);
break;
}
diff --git a/src/timer.c b/src/timer.c
index a1fb791..dfa10bd 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -1,12 +1,13 @@
/* Module de gestion des timers autour d'un select */
#include <stdio.h>
#include <sys/types.h>
-#include <sys/timeb.h>
-#include <stdlib.h>
#include <time.h>
+#include <stdlib.h>
#include <memory.h>
#ifdef WIN32
#include <windows.h>
+#else
+#include <sys/time.h>
#endif
#include "list.h"
#include "timer.h"
@@ -33,17 +34,15 @@ TimerId timers = NULL;
static long currentTime()
{
- struct timeval tv;
- unsigned long current;
- gettimeofday (&tv, 0);
- current = 1000 * tv.tv_sec + tv.tv_usec / 1000;
- return current;
-
-#if 0
unsigned long current;
- current = clock();
- return current;
+#ifdef WIN32
+ current = GetTickCount();
+#else
+ struct timeval stamp;
+ gettimeofday( &stamp, NULL );
+ current = stamp.tv_sec * MILLISEC + stamp.tv_usec/MILLISEC;
#endif
+ return current;
}
static void SetNewTimeout( unsigned long current, unsigned long when )
{