diff options
author | fcolin | 2007-02-01 13:01:33 +0000 |
---|---|---|
committer | fcolin | 2007-02-01 13:01:33 +0000 |
commit | 2caace63bd4aab20f7084e963061027ef2d02497 (patch) | |
tree | 4d81342fb90aaa17d23b7441662177a262baed60 /Bus/Ivy/IvyCbindings.cxx | |
parent | 04d702b5d135c7f8a3c4fd79dad74c48d2191a7a (diff) | |
download | ivy-cplusplus-2caace63bd4aab20f7084e963061027ef2d02497.zip ivy-cplusplus-2caace63bd4aab20f7084e963061027ef2d02497.tar.gz ivy-cplusplus-2caace63bd4aab20f7084e963061027ef2d02497.tar.bz2 ivy-cplusplus-2caace63bd4aab20f7084e963061027ef2d02497.tar.xz |
Utilisateur : Fcolin Date : 25/10/01 Heure : 18:39 Archivé dans $/Ivy (vss 2)
Diffstat (limited to 'Bus/Ivy/IvyCbindings.cxx')
-rw-r--r-- | Bus/Ivy/IvyCbindings.cxx | 76 |
1 files changed, 64 insertions, 12 deletions
diff --git a/Bus/Ivy/IvyCbindings.cxx b/Bus/Ivy/IvyCbindings.cxx index de87db4..07becfc 100644 --- a/Bus/Ivy/IvyCbindings.cxx +++ b/Bus/Ivy/IvyCbindings.cxx @@ -1,71 +1,123 @@ #include "stdafx.h"
-
+#include <stdarg.h>
#include "Ivy.h"
#include "IvyApplication.h"
-/* filtrage des regexps */
-void IvyClasses( int argc, const char **argv)
+#include "IvyCbindings.h"
+
+static Ivy *bus = NULL;
+
+// application callback wrappers
+IvyCApplicationCallback app_cb = NULL;
+void * app_user_data = NULL;
+void app_conn( IvyApplication *app )
+{
+ (*app_cb)(app, app_user_data, IvyApplicationConnected );
+}
+void app_discon( IvyApplication *app )
{
+ (*app_cb)(app, app_user_data, IvyApplicationDisconnected );
}
void IvyInit(
const char *AppName, /* nom de l'application */
const char *ready, /* ready Message peut etre NULL */
- IvyApplicationCallback callback, /* callback appele sur connection deconnection d'une appli */
+ IvyCApplicationCallback callback, /* callback appele sur connection deconnection d'une appli */
void *data, /* user data passe au callback */
- IvyDieCallback die_callback, /* last change callback before die */
+ IvyCDieCallback die_callback, /* last change callback before die */
void *die_data ) /* user data */
{
+ bus = new Ivy(AppName, ready, BUS_APPLICATION_CALLBACK(app_conn,app_discon) );
+}
+/* filtrage des regexps */
+void IvyClasses( int argc, const char **argv)
+{
+ bus->Classes( argc, argv );
}
-void IvyStart (const char*)
+
+void IvyStart (const char* domain)
{
+ bus->start(domain);
}
void IvyStop ()
{
+ bus->stop();
}
/* query sur les applications connectees */
-char *IvyGetApplicationName( IvyClientPtr app )
+const char *IvyGetApplicationName( IvyClientPtr app )
{
+ return ((IvyApplication*)app)->GetName();
}
-char *IvyGetApplicationHost( IvyClientPtr app )
+const char *IvyGetApplicationHost( IvyClientPtr app )
{
+ string host;
+ UINT port;
+ ((IvyApplication*)app)->GetPeerName(host,port);
+ return host.c_str();
}
IvyClientPtr IvyGetApplication( char *name )
{
+ return NULL;
}
-char *IvyGetApplicationList()
+const char *IvyGetApplicationList()
{
+ return "Not yiet implemented";
}
-char **IvyGetApplicationMessages( IvyClientPtr app)
+const char **IvyGetApplicationMessages( IvyClientPtr app)
{
+ return NULL;
}
-MsgRcvPtr IvyBindMsg( MsgCallback callback, void *user_data, const char *fmt_regexp, ... )
+MsgRcvPtr IvyBindMsg( IvyCMsgCallback callback, void *user_data, const char *fmt_regexp, ... )
{
+ int count;
+ char buf_regexp[2048];
+ va_list args;
+ va_start( args, fmt_regexp );
+ vsprintf( buf_regexp, fmt_regexp, args );
+ count = bus->BindMsg(buf_regexp, BUS_CALLBACK( ((IvyMessageCallbackFunction::IvyMessageCallback_fun)callback), user_data ) );
+ va_end( args );
+ return count;
}
void IvyUnbindMsg( MsgRcvPtr id )
{
+ bus->UnbindMsg( id );
}
/* emission d'un message d'erreur */
void IvySendError( IvyClientPtr app, int id, const char *fmt, ... )
{
+ char buf[2048];
+ va_list args;
+ va_start( args, fmt );
+ vsprintf( buf, fmt, args );
+ ((IvyApplication*)app)->SendMsg( IvyApplication::Error, id, buf );
+ va_end( args );
}
/* emmission d'un message die pour terminer l'application */
void IvySendDieMsg( IvyClientPtr app )
{
+ ((IvyApplication*)app)->SendMsg( IvyApplication::Die, 0 );
}
/* emission d'un message retourne le nb effectivement emis */
int IvySendMsg( const char *fmt_message, ... )
{
+ int count;
+ char buf[2048];
+ va_list args;
+ va_start( args, fmt_message );
+ vsprintf( buf, fmt_message, args );
+ count = bus->SendMsg(buf);
+ va_end( args );
+ return count;
}
-void IvyBindDirectMsg( MsgDirectCallback callback, void *user_data)
+void IvyBindDirectMsg( IvyCMsgDirectCallback callback, void *user_data)
{
}
void IvySendDirectMsg( IvyClientPtr app, int id, char *msg )
|