summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbustico2008-05-19 15:31:30 +0000
committerbustico2008-05-19 15:31:30 +0000
commit09f82d4e1e6dd1672b272c314c42d5cf30c91ea8 (patch)
treea25557d3aad5edc2641f98ea434e0b676f6b6872
parent7cd590600a7ff3dd8defc3d639fd3e87f1973015 (diff)
downloadivy-c-09f82d4e1e6dd1672b272c314c42d5cf30c91ea8.zip
ivy-c-09f82d4e1e6dd1672b272c314c42d5cf30c91ea8.tar.gz
ivy-c-09f82d4e1e6dd1672b272c314c42d5cf30c91ea8.tar.bz2
ivy-c-09f82d4e1e6dd1672b272c314c42d5cf30c91ea8.tar.xz
* make the lib and api more robust by adding const where they should be
* compile with -Wall and eliminate remaining warnings
-rw-r--r--debian/changelog10
-rw-r--r--src/Makefile3
-rw-r--r--src/intervalRegexp.c18
-rw-r--r--src/ivy.c72
-rw-r--r--src/ivy.h13
-rw-r--r--src/ivyglibloop.c6
-rw-r--r--src/ivysocket.c28
-rw-r--r--src/ivysocket.h18
-rw-r--r--src/ivytcl.c10
-rw-r--r--src/list.h4
-rw-r--r--src/timer.c19
-rw-r--r--tools/ivyperf.c5
-rw-r--r--tools/ivyprobe.c10
-rw-r--r--tools/ivythroughput.cpp5
14 files changed, 121 insertions, 100 deletions
diff --git a/debian/changelog b/debian/changelog
index e507261..18a6057 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,16 @@
+ivy-c (3.12) unstable; urgency=low
+
+ * fix again timer.c (thanks again to brno ivy dev team) so that timer could be removed within the callback
+ * make the lib and api more robust by adding const where they should be
+ * compile with -Wall and eliminate remaining warnings
+
+ -- Alexandre Bustico <bustico@cena.fr> Mon, 19 May 2008 17:30:00 +0200
+
ivy-c (3.11.3) unstable; urgency=low
* fix timer.c (thanks to brno ivy dev team), and ivydebug.h
+ * add __attribute__ gcc hooks which permit to emit warning when format
+ and arguments of bindmessage and sendmessage aren't concordant.
-- Alexandre Bustico <bustico@cena.fr> Tue, 14 May 2008 11:00:00 +0200
diff --git a/src/Makefile b/src/Makefile
index 686055b..c329ca4 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -36,6 +36,9 @@ ifndef X11_PREFIX
X11_PREFIX = /usr/X11R6
endif
+# Export all variables (Petr Mejzlik)
+export
+
XTINC = -I$(X11_PREFIX)/include
XTLIB = -L$(X11_PREFIX)$(LIB) -lXt -lX11 -lSM -lICE
GLIBINC = `pkg-config --cflags glib-2.0`
diff --git a/src/intervalRegexp.c b/src/intervalRegexp.c
index 54a06f0..cbe4f32 100644
--- a/src/intervalRegexp.c
+++ b/src/intervalRegexp.c
@@ -189,7 +189,7 @@ static bool strictPosRegexpGen (char *regexp, size_t buflen, long min, long max,
*/
static NextMax nextMax (const char *min, const char *max)
{
- NextMax nextMax ={0,0};
+ NextMax nextMaxi ={0,0};
char revMin[32], revMax[32];
size_t nbDigitsMin, nbDigitsMax;
size_t rankRev=0, rankForw, rank=0;
@@ -201,11 +201,11 @@ static NextMax nextMax (const char *min, const char *max)
for (i=nbDigitsMin-1; i >= 0; i--) {
revMin[nbDigitsMin-i-1]= min[i];
- /* printf ("DBG> nextMax revMin[%d]= %c\n", nbDigitsMin-i-1, min[i]); */
+ /* printf ("DBG> nextMaxi revMin[%d]= %c\n", nbDigitsMin-i-1, min[i]); */
}
for (i=nbDigitsMax-nbDigitsMin; i >= 0; i--) {
revMin[nbDigitsMax-i]= '0';
- /* printf ("DBG> nextMax revMin[%d]= %c\n", nbDigitsMax-i, '0'); */
+ /* printf ("DBG> nextMaxi revMin[%d]= %c\n", nbDigitsMax-i, '0'); */
}
for (i=nbDigitsMax-1; i >= 0; i--) {
@@ -214,7 +214,7 @@ static NextMax nextMax (const char *min, const char *max)
revMin[nbDigitsMax] = revMax[nbDigitsMax] = 0;
rankForw = nbDigitsMax -1;
- /* printf ("DBG> nextMax rev(%s)=%s rev(%s)=%s rankForw=%d\n", min, revMin, max, revMax, rankForw); */
+ /* printf ("DBG> nextMaxi rev(%s)=%s rev(%s)=%s rankForw=%d\n", min, revMin, max, revMax, rankForw); */
/* en partant des unitées (digit de poids faible), premier digit de min != 0 */
while ((revMin[rankRev] == '0') && (rankRev < nbDigitsMax)) rankRev++;
@@ -230,14 +230,14 @@ static NextMax nextMax (const char *min, const char *max)
for (i=0; i<=rankRev; i++) revMin[i] = '9';
}
- nextMax.max = atoi (reverse (revMin));
- nextMax.rank = rank+1;
+ nextMaxi.max = atoi (reverse (revMin));
+ nextMaxi.rank = rank+1;
currMax = atoi (max);
- if (nextMax.max > currMax) nextMax.max = currMax;
+ if (nextMaxi.max > currMax) nextMaxi.max = currMax;
- /* printf ("DBG> nextMax ('%s', '%s') = %d@%d\n", min, max, nextMax.max, nextMax.rank); */
- return (nextMax);
+ /* printf ("DBG> nextMaxi ('%s', '%s') = %d@%d\n", min, max, nextMaxi.max, nextMaxi.rank); */
+ return (nextMaxi);
}
diff --git a/src/ivy.c b/src/ivy.c
index 2bc958f..439f334 100644
--- a/src/ivy.c
+++ b/src/ivy.c
@@ -104,14 +104,14 @@ struct _global_reg_lst { /* liste des regexp source */
struct _msg_snd_dict { /* requete de reception d'un client */
UT_hash_handle hh; /* makes this structure hashable */
char *regexp_src; /* clef du dictionnaire (hash uthash) */
- IvyClientPtr clientList; /* liste des clients */
+ RWIvyClientPtr clientList; /* liste des clients */
IvyBinding binding; /* la regexp sous forme machine */
};
/* liste de clients, champ de la struct _msg_snd_dict qui est valeur du dictionnaire */
/* typedef IvyClientPtr */
struct _clnt_lst_dict {
- IvyClientPtr next;
+ RWIvyClientPtr next;
Client client; /* la socket client */
char *app_name; /* nom de l'application */
@@ -167,7 +167,7 @@ static void *application_die_user_data = NULL;
static MsgRcvPtr msg_recv = NULL;
/* liste des clients connectes */
-static IvyClientPtr allClients = NULL;
+static RWIvyClientPtr allClients = NULL;
/* dictionnaire clef : regexp, valeur : liste de clients IvyClientPtr */
static MsgSndDictPtr messSndByRegexp = NULL;
@@ -179,19 +179,19 @@ static int RegexpCall (const MsgSndDictPtr msg, const char * const message);
static int RegexpCallUnique (const MsgSndDictPtr msg, const char * const message,
const Client clientUnique);
-static void freeClient ( IvyClientPtr client);
+static void freeClient ( RWIvyClientPtr client);
static void delOneClient (const Client client);
-static void delRegexpForOneClientFromDictionary (const char *regexp, const IvyClientPtr client);
+static void delRegexpForOneClientFromDictionary (const char *regexp, IvyClientPtr client);
static void delOneIvyClientFromDictionaryEntry (MsgSndDictPtr msgSendDict,
- const IvyClientPtr client);
+ IvyClientPtr client);
static void delOneClientFromDictionaryEntry (MsgSndDictPtr msgSendDict,
const Client client);
static void delAllRegexpsFromDictionary ();
static void addRegexpToDictionary (const char* regexp, IvyClientPtr client);
static void changeRegexpInDictionary (const char* regexp, IvyClientPtr client);
-static char delRegexpForOneClient (const IvyClientPtr client, int id);
+static char delRegexpForOneClient (IvyClientPtr client, int id);
static void addRegexp (const char* regexp, IvyClientPtr client);
static void changeRegexp (const char* regexp, IvyClientPtr client);
static void addOrChangeRegexp (const char* regexp, IvyClientPtr client);
@@ -276,7 +276,7 @@ static SendState MsgSendTo(IvyClientPtr ivyClient,
static void IvyCleanup()
{
- IvyClientPtr clnt,next;
+ RWIvyClientPtr clnt,next;
GlobRegPtr regLst;
@@ -505,9 +505,9 @@ static int CheckConnected( Client sclnt )
-static void Receive( Client client, void *data, char *line )
+static void Receive( Client client, const void *data, char *line )
{
- IvyClientPtr clnt;
+ RWIvyClientPtr clnt;
int err,id;
MsgRcvPtr rcv;
int argc = 0;
@@ -515,7 +515,7 @@ static void Receive( Client client, void *data, char *line )
char *arg;
int kind_of_msg = Bye;
- clnt = (IvyClientPtr)data;
+ clnt = (RWIvyClientPtr) data;
err = sscanf( line ,"%d %d", &kind_of_msg, &id );
arg = strstr( line , ARG_START );
if ( (err != 2) || (arg == 0) )
@@ -666,9 +666,9 @@ static void Receive( Client client, void *data, char *line )
}
-static IvyClientPtr SendService( Client client, const char *appname )
+static RWIvyClientPtr SendService( Client client, const char *appname )
{
- IvyClientPtr clnt;
+ RWIvyClientPtr clnt;
MsgRcvPtr msg;
IVY_LIST_ADD_START( allClients, clnt )
clnt->client = client;
@@ -687,7 +687,7 @@ static IvyClientPtr SendService( Client client, const char *appname )
return clnt;
}
-static void ClientDelete( Client client, void *data )
+static void ClientDelete( Client client, const void *data )
{
IvyClientPtr clnt;
@@ -708,7 +708,7 @@ static void ClientDelete( Client client, void *data )
delOneClient (client);
}
-static void ClientDecongestion ( Client client, void *data )
+static void ClientDecongestion ( Client client, const void *data )
{
IvyClientPtr clnt;
@@ -757,7 +757,7 @@ static void *ClientCreate( Client client )
-static void BroadcastReceive( Client client, void *data, char *line )
+static void BroadcastReceive( Client client, const void *data, char *line )
{
Client app;
int err;
@@ -1178,7 +1178,7 @@ static int IvyCheckBuffer( const char* buffer )
}
-void IvySendError( IvyClientPtr app, int id, const char *fmt, ... )
+void IvySendError(IvyClientPtr app, int id, const char *fmt, ... )
{
static IvyBuffer buffer = { NULL, 0, 0}; /* Use static mem to eliminate multiple call to malloc /free */
va_list ap;
@@ -1196,31 +1196,31 @@ void IvyBindDirectMsg( MsgDirectCallback callback, void *user_data)
direct_user_data = user_data;
}
-void IvySendDirectMsg( IvyClientPtr app, int id, char *msg )
+void IvySendDirectMsg(IvyClientPtr app, int id, char *msg )
{
MsgSendTo( app, DirectMsg, id, msg);
}
-void IvySendDieMsg( IvyClientPtr app )
+void IvySendDieMsg(IvyClientPtr app )
{
MsgSendTo(app, Die, 0, "" );
}
-char *IvyGetApplicationName( IvyClientPtr app )
+char *IvyGetApplicationName(IvyClientPtr app )
{
if ( app && app->app_name )
return app->app_name;
else return "Unknown";
}
-char *IvyGetApplicationHost( IvyClientPtr app )
+char *IvyGetApplicationHost(IvyClientPtr app )
{
if ( app && app->client )
return SocketGetPeerHost (app->client );
else return 0;
}
-void IvyDefaultApplicationCallback( IvyClientPtr app, void *user_data, IvyApplicationEvent event)
+void IvyDefaultApplicationCallback(IvyClientPtr app, void *user_data, IvyApplicationEvent event)
{
switch ( event ) {
case IvyApplicationConnected:
@@ -1245,7 +1245,7 @@ void IvyDefaultApplicationCallback( IvyClientPtr app, void *user_data, IvyApplic
}
}
-void IvyDefaultBindCallback( IvyClientPtr app, void *user_data, int id, char* regexp, IvyBindEvent event)
+void IvyDefaultBindCallback(IvyClientPtr app, void *user_data, int id, const char* regexp, IvyBindEvent event)
{
switch ( event ) {
case IvyAddBind:
@@ -1350,7 +1350,7 @@ static void substituteInterval (IvyBuffer *src)
}
-static void freeClient ( IvyClientPtr client)
+static void freeClient ( RWIvyClientPtr client)
{
GlobRegPtr srcReg;
@@ -1375,7 +1375,7 @@ static void freeClient ( IvyClientPtr client)
-static void delRegexpForOneClientFromDictionary (const char *regexp, const IvyClientPtr client)
+static void delRegexpForOneClientFromDictionary (const char *regexp, IvyClientPtr client)
{
MsgSndDictPtr msgSendDict = NULL;
// printf ("DBG> ENTER delRegexpForOneClientFromDictionary clnt=%d, reg='%s'\n", client, regexp);
@@ -1398,9 +1398,9 @@ static void delRegexpForOneClientFromDictionary (const char *regexp, const IvyCl
static void delOneIvyClientFromDictionaryEntry (MsgSndDictPtr msgSendDict,
- const IvyClientPtr client)
+ IvyClientPtr client)
{
- IvyClientPtr client_itr, next;
+ RWIvyClientPtr client_itr, next;
@@ -1438,7 +1438,7 @@ static void delOneIvyClientFromDictionaryEntry (MsgSndDictPtr msgSendDict,
static void delOneClientFromDictionaryEntry (MsgSndDictPtr msgSendDict,
const Client client)
{
- IvyClientPtr client_itr, next;
+ RWIvyClientPtr client_itr, next;
/* la clef est trouvée, on itere sur la liste de client associée */
IVY_LIST_EACH_SAFE ( msgSendDict->clientList, client_itr, next) {
@@ -1472,7 +1472,7 @@ static void delOneClientFromDictionaryEntry (MsgSndDictPtr msgSendDict,
static void delAllRegexpsFromDictionary ()
{
MsgSndDictPtr msgSendDict;
- IvyClientPtr client;
+ RWIvyClientPtr client;
/* pour toutes les entrees du dictionnaire des regexps */
for (msgSendDict=messSndByRegexp; msgSendDict ; msgSendDict=msgSendDict->hh.next) {
@@ -1509,7 +1509,7 @@ static void delAllRegexpsFromDictionary ()
static void addRegexpToDictionary (const char* regexp, IvyClientPtr client)
{
MsgSndDictPtr msgSendDict = NULL;
- IvyClientPtr newClient = NULL;
+ RWIvyClientPtr newClient = NULL;
/* on cherche si une entrée existe deja pour cette regexp source */
HASH_FIND_STR(messSndByRegexp, regexp, msgSendDict);
/* l'entree n'existe pas dans le dictionnaire : on la cree */
@@ -1591,17 +1591,17 @@ static void changeRegexpInDictionary (const char* regexp, IvyClientPtr client)
/* met a jour le dictionnaire et la liste globale */
static void delOneClient (const Client client)
{
- IvyClientPtr client_itr, next;
+ RWIvyClientPtr client_itr, next;
MsgSndDictPtr msgSendDict, mnext=NULL;
/* on cherche le client dans la liste globale des clients */
IVY_LIST_EACH_SAFE(allClients, client_itr, next) {
- GlobRegPtr regxpSrc =NULL, next;
+ GlobRegPtr regxpSrc =NULL, next2;
/* si on le trouve */
if (client_itr->client == client) {
/* pour chaque regexp source de ce client */
- IVY_LIST_EACH_SAFE (client_itr->srcRegList, regxpSrc, next) {
+ IVY_LIST_EACH_SAFE (client_itr->srcRegList, regxpSrc, next2) {
/* on met a jour la liste des clients associee a la regexp source */
delRegexpForOneClient (client_itr, regxpSrc->id);
/* on libere la memoire associee a la regexp source */
@@ -1641,9 +1641,9 @@ static void delOneClient (const Client client)
}
-static char delRegexpForOneClient (const IvyClientPtr client, int id)
+static char delRegexpForOneClient (IvyClientPtr client, int id)
{
- IvyClientPtr client_itr = NULL;
+ RWIvyClientPtr client_itr = NULL;
GlobRegPtr regxpSrc = NULL, next = NULL;
char removed = 0;
@@ -1703,7 +1703,7 @@ static void addOrChangeRegexp (const char* regexp, IvyClientPtr client)
static void addRegexp (const char* regexp, IvyClientPtr client)
{
- IvyClientPtr client_itr = NULL;
+ RWIvyClientPtr client_itr = NULL;
GlobRegPtr regxpSrc = NULL;
diff --git a/src/ivy.h b/src/ivy.h
index bd107ff..1701fc1 100644
--- a/src/ivy.h
+++ b/src/ivy.h
@@ -29,22 +29,23 @@ extern "C" {
/* numero par default du bus */
-typedef struct _clnt_lst_dict *IvyClientPtr;
+typedef struct _clnt_lst_dict *RWIvyClientPtr;
+typedef const struct _clnt_lst_dict *IvyClientPtr;
typedef enum { IvyApplicationConnected, IvyApplicationDisconnected,
- IvyApplicationCongestion , IvyApplicationDecongestion ,
+ IvyApplicationCongestion , IvyApplicationDecongestion,
IvyApplicationFifoFull } IvyApplicationEvent;
typedef enum { IvyAddBind, IvyRemoveBind, IvyFilterBind, IvyChangeBind } 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, int id, const char* regexp, IvyBindEvent event ) ;
/* 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, int id, const char* regexp, IvyBindEvent event ) ;
/* callback appele sur reception de die */
typedef void (*IvyDieCallback)( IvyClientPtr app, void *user_data, int id ) ;
@@ -93,11 +94,11 @@ __attribute__((format(printf,2,3))); /* avec sprintf prealable */
void IvyUnbindMsg( MsgRcvPtr id );
/* emission d'un message d'erreur */
-void IvySendError( IvyClientPtr app, int id, const char *fmt, ... )
+void IvySendError(IvyClientPtr app, int id, const char *fmt, ... )
__attribute__((format(printf,3,4))) ; /* avec sprintf prealable */
/* emmission d'un message die pour terminer l'application */
-void IvySendDieMsg( IvyClientPtr app );
+void IvySendDieMsg(IvyClientPtr app );
/* emission d'un message retourne le nb effectivement emis */
diff --git a/src/ivyglibloop.c b/src/ivyglibloop.c
index eba2606..8bd2ad8 100644
--- a/src/ivyglibloop.c
+++ b/src/ivyglibloop.c
@@ -116,7 +116,7 @@ static gboolean IvyGlibHandleChannelRead(GIOChannel *source,
GIOCondition condition,
gpointer data) {
Channel channel = (Channel)data;
- TRACE("Handle Channel read %d\n",source );
+ TRACE("Handle Channel read %p\n",source );
(*channel->handle_read)(channel, g_io_channel_unix_get_fd(source), channel->data);
return TRUE;
}
@@ -125,7 +125,7 @@ static gboolean IvyGlibHandleChannelWrite(GIOChannel *source,
GIOCondition condition,
gpointer data) {
Channel channel = (Channel)data;
- TRACE("Handle Channel read %d\n",source );
+ TRACE("Handle Channel read %p\n",source );
(*channel->handle_write)(channel, g_io_channel_unix_get_fd(source), channel->data);
return TRUE;
}
@@ -134,7 +134,7 @@ static gboolean IvyGlibHandleChannelDelete(GIOChannel *source,
GIOCondition condition,
gpointer data) {
Channel channel = (Channel)data;
- TRACE("Handle Channel delete %d\n",source );
+ TRACE("Handle Channel delete %p\n",source );
(*channel->handle_delete)(channel->data);
return TRUE;
}
diff --git a/src/ivysocket.c b/src/ivysocket.c
index 06ac27f..cc9a54b 100644
--- a/src/ivysocket.c
+++ b/src/ivysocket.c
@@ -58,8 +58,8 @@ struct _server {
Channel channel;
unsigned short port;
void *(*create)(Client client);
- void (*handle_delete)(Client client, void *data);
- void (*handle_decongestion)(Client client, void *data);
+ void (*handle_delete)(Client client, const void *data);
+ void (*handle_decongestion)(Client client, const void *data);
SocketInterpretation interpretation;
};
@@ -71,8 +71,8 @@ struct _client {
char app_uuid[128];
struct sockaddr_in from;
SocketInterpretation interpretation;
- void (*handle_delete)(Client client, void *data);
- void (*handle_decongestion)(Client client, void *data);
+ void (*handle_delete)(Client client, const void *data);
+ void (*handle_decongestion)(Client client, const void *data);
char terminator; /* character delimiter of the message */
/* Buffer de reception */
long buffer_size;
@@ -81,7 +81,7 @@ struct _client {
/* Buffer d'emission */
IvyFifoBuffer *ifb; /* le buffer circulaire en cas de congestion */
/* user data */
- void *data;
+ const void *data;
#ifdef OPENMP
omp_lock_t fdLock;
#endif
@@ -284,9 +284,9 @@ static void HandleServer(Channel channel, HANDLE fd, void *data)
Server SocketServer(unsigned short port,
void*(*create)(Client client),
- void(*handle_delete)(Client client, void *data),
- void(*handle_decongestion)(Client client, void *data),
- void(*interpretation) (Client client, void *data, char *ligne))
+ void(*handle_delete)(Client client, const void *data),
+ void(*handle_decongestion)(Client client, const void *data),
+ void(*interpretation) (Client client, const void *data, char *ligne))
{
Server server;
HANDLE fd;
@@ -546,7 +546,7 @@ SendState SocketSendRawWithId( const Client client, const char *id, const char *
}
-void SocketSetData (Client client, void *data )
+void SocketSetData (Client client, const void *data )
{
if (client) {
client->data = data;
@@ -571,7 +571,7 @@ SendState SocketSend (Client client, char *fmt, ... )
return state;
}
-void *SocketGetData (Client client )
+const void *SocketGetData (Client client )
{
return client ? client->data : 0;
}
@@ -602,8 +602,8 @@ Ouverture d'un canal TCP/IP en mode client
Client SocketConnect (char * host, unsigned short port,
void *data,
SocketInterpretation interpretation,
- void (*handle_delete)(Client client, void *data),
- void(*handle_decongestion)(Client client, void *data)
+ void (*handle_delete)(Client client, const void *data),
+ void(*handle_decongestion)(Client client, const void *data)
)
{
struct hostent *rhost;
@@ -619,8 +619,8 @@ Client SocketConnect (char * host, unsigned short port,
Client SocketConnectAddr (struct in_addr * addr, unsigned short port,
void *data,
SocketInterpretation interpretation,
- void (*handle_delete)(Client client, void *data),
- void(*handle_decongestion)(Client client, void *data)
+ void (*handle_delete)(Client client, const void *data),
+ void(*handle_decongestion)(Client client, const void *data)
)
{
HANDLE handle;
diff --git a/src/ivysocket.h b/src/ivysocket.h
index 551ec52..df43303 100644
--- a/src/ivysocket.h
+++ b/src/ivysocket.h
@@ -54,14 +54,14 @@ extern void SocketInit();
/* Forward def */
typedef struct _client *Client;
-typedef void (*SocketInterpretation) (Client client, void *data, char *ligne);
+typedef void (*SocketInterpretation) (Client client, const void *data, char *ligne);
/* Server Part */
typedef struct _server *Server;
extern Server SocketServer(unsigned short port,
void*(*create)(Client client),
- void(*handle_delete)(Client client, void *data),
- void(*handle_decongestion)(Client client, void *data),
+ void(*handle_delete)(Client client, const void *data),
+ void(*handle_decongestion)(Client client, const void *data),
SocketInterpretation interpretation);
extern unsigned short SocketServerGetPort( Server server );
extern void SocketServerClose( Server server );
@@ -73,21 +73,21 @@ extern SendState SocketSend( Client client, char *fmt, ... );
extern SendState SocketSendRaw( const Client client, const char *buffer, const int len );
extern SendState SocketSendRawWithId( const Client client, const char *id, const char *buffer, const int len );
extern char *SocketGetPeerHost( Client client );
-extern void SocketSetData( Client client, void *data );
-extern void *SocketGetData( Client client );
+extern void SocketSetData( Client client, const void *data );
+extern const void *SocketGetData( Client client );
extern void SocketBroadcast( char *fmt, ... );
extern Client SocketConnect( char * host, unsigned short port,
void *data,
SocketInterpretation interpretation,
- void (*handle_delete)(Client client, void *data),
- void(*handle_decongestion)(Client client, void *data)
+ void (*handle_delete)(Client client, const void *data),
+ void(*handle_decongestion)(Client client, const void *data)
);
extern Client SocketConnectAddr( struct in_addr * addr, unsigned short port,
void *data,
SocketInterpretation interpretation,
- void (*handle_delete)(Client client, void *data),
- void(*handle_decongestion)(Client client, void *data)
+ void (*handle_delete)(Client client, const void *data),
+ void(*handle_decongestion)(Client client, const void *data)
);
extern int SocketWaitForReply( Client client, char *buffer, int size, int delai);
diff --git a/src/ivytcl.c b/src/ivytcl.c
index 19a6b6b..5fb7880 100644
--- a/src/ivytcl.c
+++ b/src/ivytcl.c
@@ -124,7 +124,7 @@ Channel IvyChannelAdd(HANDLE fd, void *data,
channel->fd = fd;
/*printf("Create handle fd %d\n", fd);*/
- channel->tcl_channel = Tcl_MakeTcpClientChannel((void*) fd);
+ channel->tcl_channel = Tcl_MakeTcpClientChannel((void*) (long) fd);
Tcl_CreateChannelHandler(channel->tcl_channel, TCL_READABLE|TCL_EXCEPTION,
IvyHandleFd, (ClientData) channel);
return channel;
@@ -431,7 +431,7 @@ IvyBindCmd(ClientData clientData,
strcpy(filter->script, argv[2]);
filter->id = IvyBindMsg(IvyMsgCB, (void *) filter, filter->filter, NULL); /* MsgPtr id */
filter->interp = interp;
- entry = Tcl_CreateHashEntry(&filter_table, (char *) filter_id, &dummy);
+ entry = Tcl_CreateHashEntry(&filter_table, (char *) (long) filter_id, &dummy);
Tcl_SetHashValue(entry, (ClientData) filter);
sprintf(msg, "%d", filter_id);
filter_id++;
@@ -446,7 +446,7 @@ IvyUnbindCmd(ClientData clientData,
int argc,
const char **argv)
{
- unsigned long filter_id;
+ unsigned long filterId;
char *end;
filter_struct *filter;
Tcl_HashEntry *entry;
@@ -455,13 +455,13 @@ IvyUnbindCmd(ClientData clientData,
argv[0], " filterId\"", (char *) NULL);
return TCL_ERROR;
}
- filter_id = strtol(argv[1], &end, 10);
+ filterId = strtol(argv[1], &end, 10);
if (*end) {
Tcl_AppendResult(interp, argv[0], " wrong filter id: \"", argv[1],
(char *) NULL);
return TCL_ERROR;
}
- entry = Tcl_FindHashEntry(&filter_table, (char *) filter_id);
+ entry = Tcl_FindHashEntry(&filter_table, (char *) filterId);
if (!entry) {
Tcl_AppendResult(interp, argv[0], " unknown filter: \"", argv[1],
(char *) NULL);
diff --git a/src/list.h b/src/list.h
index 2a7ea84..b06406d 100644
--- a/src/list.h
+++ b/src/list.h
@@ -75,8 +75,8 @@ pour eviter de chainer un objet non initialise
#define IVY_LIST_EACH( list, p ) \
for ( p = list ; p ; p = p -> next )
-#define IVY_LIST_EACH_SAFE( list, p, next )\
-for ( p = list ; (next = p ? p->next: p ),p ; p = next )
+#define IVY_LIST_EACH_SAFE( list, p, nxt )\
+for ( p = list ; (nxt = p ? p->next: p ),p ; p = nxt )
#define IVY_LIST_IS_EMPTY( list ) \
list == NULL
diff --git a/src/timer.c b/src/timer.c
index d3ff656..2205634 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -43,6 +43,7 @@ struct _timer {
unsigned long when;
TimerCb callback;
void *user_data;
+ unsigned char mark2Remove;
};
/* liste des timers */
@@ -81,9 +82,8 @@ static void AdjTimeout(unsigned long current)
newTimeout = timers->when ; /* remise a la premiere valeur */
IVY_LIST_EACH( timers , timer )
{
- if ( timer->when < newTimeout )
- newTimeout = timer->when;
-
+ if ((!timer->mark2Remove) && (timer->when < newTimeout ))
+ newTimeout = timer->when;
}
SetNewTimeout( current, newTimeout );
}
@@ -110,6 +110,7 @@ TimerId TimerRepeatAfter( int count, long ltime, TimerCb cb, void *user_data )
stamp = currentTime();
timer->period = ltime;
timer->when = stamp + ltime;
+ timer->mark2Remove = 0;
if ( (timer->when < nextTimeout) || (timeoutptr == NULL))
SetNewTimeout( stamp, timer->when );
IVY_LIST_ADD_END( timers, timer )
@@ -118,15 +119,16 @@ TimerId TimerRepeatAfter( int count, long ltime, TimerCb cb, void *user_data )
void TimerRemove( TimerId timer )
{
unsigned long stamp;
- if ( !timer ) return;
- IVY_LIST_REMOVE( timers, timer );
+ if (( !timer ) || (timer->mark2Remove)) return;
+ // IVY_LIST_REMOVE( timers, timer );
+ timer->mark2Remove = 1;
stamp = currentTime();
AdjTimeout(stamp);
}
void TimerModify( TimerId timer, long ltime )
{
unsigned long stamp;
- if ( !timer ) return;
+ if (( !timer ) || (timer->mark2Remove)) return;
stamp = currentTime();
timer->period = ltime;
@@ -168,7 +170,10 @@ void TimerScan()
IVY_LIST_EACH_SAFE( timers , timer, next )
{
- if ( timer->when <= stamp )
+ if (timer->mark2Remove) {
+ IVY_LIST_REMOVE( timers, timer );
+ }
+ else if ( timer->when <= stamp )
{
if ( timer->repeat == TIMER_LOOP || --(timer->repeat) )
{
diff --git a/tools/ivyperf.c b/tools/ivyperf.c
index 07453e3..8babd35 100644
--- a/tools/ivyperf.c
+++ b/tools/ivyperf.c
@@ -76,7 +76,7 @@ void TimerCall(TimerId id, void *user_data, unsigned long delta)
if ( count == 0 ) fprintf(stderr, "." );
}
-void binCB( IvyClientPtr app, void *user_data, int id, char* regexp, IvyBindEvent event )
+void binCB( IvyClientPtr app, void *user_data, int id, const char* regexp, IvyBindEvent event )
{
char *app_name = IvyGetApplicationName( app );
switch ( event )
@@ -87,6 +87,9 @@ void binCB( IvyClientPtr app, void *user_data, int id, char* regexp, IvyBindEve
case IvyRemoveBind:
printf("Application:%s bind '%s' REMOVED\n", app_name, regexp );
break;
+ case IvyChangeBind:
+ printf("Application:%s bind '%s' CHANGED\n", app_name, regexp );
+ break;
case IvyFilterBind:
printf("Application:%s bind '%s' FILTRED\n", app_name, regexp );
break;
diff --git a/tools/ivyprobe.c b/tools/ivyprobe.c
index ed16455..a70d1bb 100644
--- a/tools/ivyprobe.c
+++ b/tools/ivyprobe.c
@@ -147,14 +147,14 @@ void HandleStdin (Channel channel, HANDLE fd, void *data)
arg = strtok (NULL, "'");
Chop(arg);
if (arg) {
- IvyBinding bind;
+ IvyBinding binding;
const char *errbuf;
int erroffset;
- bind = IvyBindingCompile(arg, & erroffset, & errbuf);
- if (bind==NULL) {
+ binding = IvyBindingCompile(arg, & erroffset, & errbuf);
+ if (binding==NULL) {
printf("Error compiling '%s', %s, not bound\n", arg, errbuf);
} else {
- IvyBindingFree( bind );
+ IvyBindingFree( binding );
IvyBindMsg (Callback, NULL, arg);
}
}
@@ -249,7 +249,7 @@ void ApplicationCallback (IvyClientPtr app, void *user_data, IvyApplicationEvent
break;
}
}
-void IvyPrintBindCallback( IvyClientPtr app, void *user_data, int id, char* regexp, IvyBindEvent event)
+void IvyPrintBindCallback( IvyClientPtr app, void *user_data, int id, const char* regexp, IvyBindEvent event)
{
switch ( event ) {
case IvyAddBind:
diff --git a/tools/ivythroughput.cpp b/tools/ivythroughput.cpp
index 513e6eb..1803e66 100644
--- a/tools/ivythroughput.cpp
+++ b/tools/ivythroughput.cpp
@@ -86,8 +86,7 @@ bool getMessages (const char*fileName, ListOfString &messages, unsigned int numM
bool getRegexps (const char*fileName, ListOfString &regexps, unsigned int numReg);
double currentTime();
-void binCB( IvyClientPtr app, void *user_data, int id, char* regexp, IvyBindEvent event ) ;
-void binCBR( IvyClientPtr app, void *user_data, int id, char* regexp, IvyBindEvent event ) ;
+void binCB( IvyClientPtr app, void *user_data, int id, const char* regexp, IvyBindEvent event ) ;
void congestCB ( IvyClientPtr app, void *user_data, IvyApplicationEvent event ) ;
void stopCB (TimerId id, void *user_data, unsigned long delta);
void sendAllMessageCB (TimerId id, void *user_data, unsigned long delta);
@@ -442,7 +441,7 @@ double currentTime()
# | |_) | | | | | | | | |____ | |_) |
# |_.__/ |_| |_| |_| \_____| |____/
*/
-void binCB( IvyClientPtr app, void *user_data, int id, char* regexp, IvyBindEvent event )
+void binCB( IvyClientPtr app, void *user_data, int id, const char* regexp, IvyBindEvent event )
{
string appName = IvyGetApplicationName( app );
static MapBindByClnt bindByClnt;