diff options
Diffstat (limited to 'Ivy/IvyCbindings.cxx')
-rw-r--r-- | Ivy/IvyCbindings.cxx | 76 |
1 files changed, 64 insertions, 12 deletions
diff --git a/Ivy/IvyCbindings.cxx b/Ivy/IvyCbindings.cxx index de87db4..07becfc 100644 --- a/Ivy/IvyCbindings.cxx +++ b/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 )
|