summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile32
-rwxr-xr-xsrc/Makefile.win324
-rw-r--r--src/ivy.c80
-rw-r--r--src/ivyprobe.c2
4 files changed, 60 insertions, 58 deletions
diff --git a/src/Makefile b/src/Makefile
index 3fe4580..b4f90ef 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -68,15 +68,15 @@ REGEXP= -DUSE_PCRE_REGEX -DPCRE_OPT=$(PCRE_OPT)
CHANNEL = -DTCL_CHANNEL_INTEGRATION
CFLAGS = -g -Wall #-DDEBUG
-OBJ = ivyloop.o timer.o ivysocket.o ivybind.o ivyargument.o ivy.o
-GOBJ = ivyloop.o timer.o ivysocket.o ivybind.o ivyargument.o givy.o
-XTOBJ = ivyxtloop.o ivysocket.o ivybind.o ivyargument.o ivy.o
-GLIBOBJ = ivyglibloop.o ivysocket.o ivybind.o ivy.o
-GLUTOBJ = ivyglutloop.o ivysocket.o ivybind.o ivy.o
-TCLOBJ = ivytcl.o timer.o ivysocket.o ivybind.o givy.o
+COMOBJ = hash.o ivysocket.o ivybind.o ivyargument.o ivy.o
+OBJ = $(COMOBJ) ivyloop.o timer.o
+XTOBJ = $(COMOBJ) ivyxtloop.o
+GLIBOBJ = $(COMOBJ) ivyglibloop.o
+GLUTOBJ = $(COMOBJ) ivyglutloop.o
+TCLOBJ = $(COMOBJ) ivytcl.o timer.o
# WINDOWS add ivyloop.o if TCL_CHANNEL_INTEGRATION is not set
TARGETS = ivyprobe ivyperf ivyglibprobe ivyxtprobe
-TARGETLIBS=libivy.so.$(MAJOR).$(MINOR) libgivy.so.$(MAJOR).$(MINOR) libxtivy.so.$(MAJOR).$(MINOR) libglibivy.so.$(MAJOR).$(MINOR) libtclivy.so.$(MAJOR).$(MINOR)
+TARGETLIBS=libivy.so.$(MAJOR).$(MINOR) libxtivy.so.$(MAJOR).$(MINOR) libglibivy.so.$(MAJOR).$(MINOR) libtclivy.so.$(MAJOR).$(MINOR)
# not yet need Modified Glut ivyglutprobe
.c.o:
@@ -84,7 +84,7 @@ TARGETLIBS=libivy.so.$(MAJOR).$(MINOR) libgivy.so.$(MAJOR).$(MINOR) libxtivy.so.
all: static-libs commands shared-libs
-static-libs: libivy.a libgivy.a libxtivy.a libglibivy.a libtclivy.a
+static-libs: libivy.a libxtivy.a libglibivy.a libtclivy.a
# not yet need Modified Glut libglutivy.a
shared-libs: $(TARGETLIBS)
@@ -104,9 +104,6 @@ ivybind.o: ivybind.c
ivyargument.o: ivyargument.c
$(CC) -c $(CFLAGS) $(REGEXP) $(PCREINC) ivyargument.c
-givy.o: ivy.c
- $(CC) -c $(CFLAGS) $(REGEXP) -o givy.o ivy.c
-
ivyglutloop.o: ivyglutloop.c ivyglutloop.h
$(CC) -c $(CFLAGS) $(GLUTINC) ivyglutloop.c
@@ -147,10 +144,6 @@ libivy.a: $(OBJ)
rm -f $@
$(LIBTOOL) $@ $(OBJ)
-libgivy.a: $(GOBJ)
- rm -f $@
- $(LIBTOOL) $@ $(GOBJ)
-
libxtivy.a: $(XTOBJ)
rm -f $@
$(LIBTOOL) $@ $(XTOBJ)
@@ -173,11 +166,6 @@ libivy.so.$(MAJOR).$(MINOR): $(OBJ)
# $(CC) -G -Wl,-h,libivy.so.$(MAJOR) -o $@ $(OBJ) #solaris
# libtool -dynamic -o $@ $(OBJ) $(PCRELIB) -lc
-libgivy.so.$(MAJOR).$(MINOR): $(GOBJ)
- $(CC) -shared -Wl,-soname,libgivy.so.$(MAJOR) -o $@ $(GOBJ) $(PCRELIB)
-# $(CC) -G -Wl,-h,libgivy.so.$(MAJOR) -o $@ $(GOBJ) #solaris
-# libtool -dynamic -o $@ $(GOBJ) $(PCRELIB) -lc
-
libxtivy.so.$(MAJOR).$(MINOR): $(XTOBJ)
$(CC) -shared -Wl,-soname,libxtivy.so.$(MAJOR) -o $@ $(XTOBJ) $(XTLIB) $(PCRELIB)
# $(CC) -G -Wl,-h,libxtivy.so.$(MAJOR) -o $@ $(XTOBJ) $(XTLIB) #solaris
@@ -206,13 +194,11 @@ installlibs: static-libs shared-libs
test -d $(PREFIX)/usr/X11R6/lib || mkdirhier $(PREFIX)/usr/X11R6/lib
test -d $(PREFIX)/usr/include || mkdirhier $(PREFIX)/usr/include
install -m644 libivy.a $(PREFIX)/usr/lib
- install -m644 libgivy.a $(PREFIX)/usr/lib
install -m644 libxtivy.a $(PREFIX)/usr/X11R6/lib
install -m644 libtclivy.a $(PREFIX)/usr/lib
install -m644 libglibivy.a $(PREFIX)/usr/lib
install -m644 libivy.so.$(MAJOR).$(MINOR) $(PREFIX)/usr/lib
- install -m644 libgivy.so.$(MAJOR).$(MINOR) $(PREFIX)/usr/lib
install -m644 libxtivy.so.$(MAJOR).$(MINOR) $(PREFIX)/usr/X11R6/lib
install -m644 libtclivy.so.$(MAJOR).$(MINOR) $(PREFIX)/usr/lib
install -m644 libglibivy.so.$(MAJOR).$(MINOR) $(PREFIX)/usr/lib
@@ -222,8 +208,6 @@ installlibs: static-libs shared-libs
installliblinks: installlibs
ln -fs /usr/lib/libivy.so.$(MAJOR).$(MINOR) $(PREFIX)/usr/lib/libivy.so
ln -fs /usr/lib/libivy.so.$(MAJOR).$(MINOR) $(PREFIX)/usr/lib/libivy.so.$(MAJOR)
- ln -fs /usr/lib/libgivy.so.$(MAJOR).$(MINOR) $(PREFIX)/usr/lib/libgivy.so
- ln -fs /usr/lib/libgivy.so.$(MAJOR).$(MINOR) $(PREFIX)/usr/lib/libgivy.so.$(MAJOR)
ln -fs /usr/X11R6/lib/libxtivy.so.$(MAJOR).$(MINOR) $(PREFIX)/usr/X11R6/lib/libxtivy.so
ln -fs /usr/X11R6/lib/libxtivy.so.$(MAJOR).$(MINOR) $(PREFIX)/usr/X11R6/lib/libxtivy.so.$(MAJOR)
ln -fs /usr/lib/libtclivy.so.$(MAJOR).$(MINOR) $(PREFIX)/usr/lib/libtclivy.so
diff --git a/src/Makefile.win32 b/src/Makefile.win32
index 2f318f1..7d91a8f 100755
--- a/src/Makefile.win32
+++ b/src/Makefile.win32
@@ -46,7 +46,7 @@ REGEXP= -DUSE_PCRE_REGEX -DPCRE_OPT=$(PCRE_OPT)
CHANNEL = -DTCL_CHANNEL_INTEGRATION
-OBJ = ivyloop.obj timer.obj ivysocket.obj ivy.obj ivybind.obj ivyargument.obj getopt.obj
+OBJ = hash.obj ivyloop.obj timer.obj ivysocket.obj ivy.obj ivybind.obj ivyargument.obj getopt.obj
# WINDOWS add ivyloop.obj if TCL_CHANNEL_INTEGRATION is not set
TARGETS = ivyprobe.exe ivyperf.exe
@@ -88,7 +88,7 @@ libivy.dll: $(OBJ)
$(CC) -nologo /LD -o $@ $(OBJ) wsock32.lib $(PCRELIB)
clean:
- -del /f $(TARGETS) $(TARGETLIBS) *.obj *.a *.dll *~
+ -del /f $(TARGETS) $(TARGETLIBS) *.obj *.a *.dll *.pdb *~
diff --git a/src/ivy.c b/src/ivy.c
index cec9b2f..1571161 100644
--- a/src/ivy.c
+++ b/src/ivy.c
@@ -37,6 +37,7 @@
#include "ivybind.h"
#include "ivysocket.h"
#include "list.h"
+#include "hash.h"
#include "ivy.h"
#define VERSION 4
@@ -140,7 +141,9 @@ static IvyDieCallback application_die_callback;
static void *application_die_user_data = 0;
/* liste des messages a recevoir */
-static MsgRcvPtr msg_recv = 0;
+//static MsgRcvPtr msg_recv = 0;
+static HASHTABLE msg_recv= NULL;
+
/* liste des clients connectes */
static IvyClientPtr clients = 0;
@@ -394,7 +397,8 @@ static char* Receive( Client client, void *data, char *message, unsigned int len
int kind_of_msg = Bye;
IvyBinding bind;
char *ptr_end;
- char *args =NULL;
+ void *args =NULL;
+ char *str_regexp;
ptr_end = message;
@@ -411,7 +415,7 @@ static char* Receive( Client client, void *data, char *message, unsigned int len
}
#ifdef DEBUG
- printf("Receive Message type=%d id=%d arg=%.*s\n", kind_of_msg, id, len_args, args);
+ printf("Receive Message type=%d id=%d arg=%.*s\n", kind_of_msg, id, len_args, (char*)args);
#endif //DEBUG
clnt = (IvyClientPtr)data;
@@ -420,34 +424,36 @@ static char* Receive( Client client, void *data, char *message, unsigned int len
case Bye:
#ifdef DEBUG
- printf("Quitting Bye %.*s\n", len_args, args);
+ printf("Quitting Bye %.*s\n", len_args, (char*)args);
#endif //DEBUG
SocketClose( client );
break;
case Error:
- printf ("Received error %d %.*s\n", id, len_args, args);
+ printf ("Received error %d %.*s\n", id, len_args, (char*)args);
break;
case AddRegexp:
#ifdef DEBUG
- printf("Regexp id=%d exp='%.*s'\n", id, len_args, args);
+ printf("Regexp id=%d exp='%.*s'\n", id, len_args, (char*)args);
#endif //DEBUG
- if ( !CheckRegexp( args ) )
+ if ( !CheckRegexp( args ) ) /* TODO check args limits !!!*/
{
#ifdef DEBUG
printf("Warning: regexp '%.*s' illegal, removing from %s\n",len_args,(char*)args,ApplicationName);
#endif //DEBUG
return ptr_end;
}
- bind = IvyBindingCompile( args );
+ str_regexp = DupArg( len_args, args );
+
+ bind = IvyBindingCompile( str_regexp );
if ( bind != NULL )
{
IVY_LIST_ADD( clnt->msg_send, snd )
if ( snd )
{
snd->id = id;
- snd->str_regexp = DupArg( len_args, args );
+ snd->str_regexp = str_regexp;
snd->bind = bind;
if ( application_bind_callback )
{
@@ -461,8 +467,8 @@ static char* Receive( Client client, void *data, char *message, unsigned int len
const char *errbuf;
IvyBindingGetCompileError( &offset, &errbuf );
MsgSendTo( client, Error, offset, strlen(errbuf), errbuf );
+ free( str_regexp );
}
-
break;
case DelRegexp:
#ifdef DEBUG
@@ -484,14 +490,14 @@ static char* Receive( Client client, void *data, char *message, unsigned int len
break;
case StartRegexp:
#ifdef DEBUG
- printf("Regexp Start id=%d Application='%s'\n", id, args);
+ printf("Regexp Start id=%d Application='%.*s'\n", id, len_args, (char*)args);
#endif //DEBUG
clnt->app_name = DupArg( len_args, args );
clnt->app_port = id;
if ( CheckConnected( clnt ) )
{
#ifdef DEBUG
- printf("Quitting already connected %s\n", args);
+ printf("Quitting already connected %.*s\n", len_args, (char*)args);
#endif //DEBUG
IvySendError( clnt, 0, "Application already connected" );
SocketClose( client );
@@ -520,28 +526,26 @@ static char* Receive( Client client, void *data, char *message, unsigned int len
case Msg:
#ifdef DEBUG
- printf("Message id=%d msg='%.*s'\n", id, len_args, args);
+ printf("Message id=%d msg='%.*s'\n", id, len_args, (char*)args);
#endif //DEBUG
-
- argc = SplitArg( len_args, args, MESSAGE_SEPARATOR, argv);
-
- IVY_LIST_EACH( msg_recv, rcv )
- {
- if ( id == rcv->id )
+ rcv = hash_lookup( msg_recv, id );
+ if ( rcv )
{
+ argc = SplitArg( len_args, args, MESSAGE_SEPARATOR, argv);
+
#ifdef DEBUG
printf("Calling id=%d argc=%d for %s\n", id, argc,rcv->regexp);
#endif
if ( rcv->callback ) (*rcv->callback)( clnt, rcv->user_data, argc, argv );
return ptr_end;
}
- }
- printf("Callback Message id=%d not found!!!'\n", id);
+ else
+ printf("Callback Message id=%d not found!!!'\n", id);
break;
case DirectMsg:
#ifdef DEBUG
- printf("Direct Message id=%d msg='%s'\n", id, args);
+ printf("Direct Message id=%d msg='%.*s'\n", id, len_args, (char*)args);
#endif //DEBUG
if ( direct_callback)
@@ -561,7 +565,7 @@ static char* Receive( Client client, void *data, char *message, unsigned int len
break;
case ApplicationId:
#ifdef DEBUG
- printf("ApplicationId priority=%d appid='%s'\n", id, args);
+ printf("ApplicationId priority=%d appid='%.*s'\n", id, len_args, (char*)args);
#endif //DEBUG
clnt->app_id = DupArg( len_args, args );
if ( id != clnt->priority )
@@ -576,11 +580,16 @@ static char* Receive( Client client, void *data, char *message, unsigned int len
}
return ptr_end;
}
-
+BOOL SendRegexp(HASHKEYTYPE key, void *data, va_list args)
+{
+ Client client = va_arg( args, Client);
+ MsgRcvPtr msg = (MsgRcvPtr)data;
+ MsgSendTo( client, AddRegexp,msg->id,strlen(msg->regexp), msg->regexp);
+ return FALSE; /* iter throught all hash table */
+}
static IvyClientPtr SendService( Client client )
{
IvyClientPtr clnt;
- MsgRcvPtr msg;
IVY_LIST_ADD( clients, clnt )
if ( clnt )
{
@@ -592,10 +601,7 @@ static IvyClientPtr SendService( Client client )
clnt->priority = DEFAULT_PRIORITY;
MsgSendTo( client, ApplicationId, applicationPriority, strlen(applicationUniqueId), applicationUniqueId );
MsgSendTo( client, StartRegexp, ApplicationPort, strlen(ApplicationName), ApplicationName );
- IVY_LIST_EACH(msg_recv, msg )
- {
- MsgSendTo( client, AddRegexp,msg->id,strlen(msg->regexp), msg->regexp);
- }
+ hash_search( msg_recv, SendRegexp, client);
MsgSendTo( client, EndRegexp, 0, 0,"");
}
return clnt;
@@ -738,6 +744,12 @@ void IvyInit (const char *appname, const char *ready,
struct hostent *host;
IvyChannelInit();
+ msg_recv = hash_create( 1024, FALSE );
+ if ( ! msg_recv )
+ {
+ fprintf(stderr,"IvyInit can't create Binding hash Table\n");
+ exit(-1);
+ }
ApplicationName = appname;
application_callback = callback;
application_user_data = data;
@@ -923,7 +935,7 @@ void IvyUnbindMsg (MsgRcvPtr msg)
IVY_LIST_EACH (clients, clnt ) {
MsgSendTo( clnt->client, DelRegexp,msg->id, 0, "");
}
- IVY_LIST_REMOVE( msg_recv, msg );
+ hash_remove( msg_recv, msg->id );
}
/* demande de reception d'un message */
@@ -943,12 +955,18 @@ MsgRcvPtr IvyBindMsg (MsgCallback callback, void *user_data, const char *fmt_reg
va_end (ap );
/* add Msg to the query list */
- IVY_LIST_ADD( msg_recv, msg );
+ msg = malloc(sizeof(struct _msg_rcv));
if (msg) {
msg->id = recv_id++;
msg->regexp = strdup(buffer);
msg->callback = callback;
msg->user_data = user_data;
+ hash_add(msg_recv, msg->id, msg);
+ }
+ else
+ {
+ perror("IvyBindMsg can't allocate Binding");
+ exit(-1);
}
len = strlen(msg->regexp);
/* Send to already connected clients */
diff --git a/src/ivyprobe.c b/src/ivyprobe.c
index aa96246..076b97b 100644
--- a/src/ivyprobe.c
+++ b/src/ivyprobe.c
@@ -208,7 +208,7 @@ void HandleStdin (Channel channel, IVY_HANDLE fd, void *data)
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(" .bindcall - toogle callback to binding\n");
printf(" .who - who is on the bus\n");
} else if (strcmp(cmd, "bindcall") == 0) {
if (!fbindcallback) {