summaryrefslogtreecommitdiff
path: root/Ivy/IvyCbindings.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Ivy/IvyCbindings.cxx')
-rw-r--r--Ivy/IvyCbindings.cxx129
1 files changed, 129 insertions, 0 deletions
diff --git a/Ivy/IvyCbindings.cxx b/Ivy/IvyCbindings.cxx
new file mode 100644
index 0000000..8876bbf
--- /dev/null
+++ b/Ivy/IvyCbindings.cxx
@@ -0,0 +1,129 @@
+
+#include "IvyStdAfx.h"
+#include <stdarg.h>
+#include "Ivy.h"
+#include "IvyApplication.h"
+
+#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 */
+ IvyCApplicationCallback callback, /* callback appele sur connection deconnection d'une appli */
+ void *data, /* user data passe au callback */
+ 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 IvySetFilter( int argc, const char **argv)
+{
+ bus->SetFilter( argc, argv );
+}
+
+void IvyStart (const char* domain)
+{
+ bus->start(domain);
+}
+void IvyStop ()
+{
+ bus->stop();
+}
+
+/* query sur les applications connectees */
+const char *IvyGetApplicationName( IvyClientPtr app )
+{
+ return ((IvyApplication*)app)->GetName();
+}
+const char *IvyGetApplicationHost( IvyClientPtr app )
+{
+ ivy::string host;
+ UINT port;
+ ((IvyApplication*)app)->GetPeerName(host,port);
+ return host.c_str();
+}
+IvyClientPtr IvyGetApplication( char *name )
+{
+ return NULL;
+}
+const char *IvyGetApplicationList()
+{
+ return "Not yiet implemented";
+}
+const char **IvyGetApplicationMessages( IvyClientPtr app)
+{
+ return NULL;
+}
+
+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 );
+ _vsnprintf_s( buf_regexp, sizeof(buf_regexp), sizeof(buf_regexp)-1, 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 );
+ _vsnprintf_s( buf, sizeof(buf), sizeof(buf)-1, 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 );
+ _vsnprintf_s( buf, sizeof(buf), sizeof(buf)-1, fmt_message, args );
+ count = bus->SendMsg(buf);
+ va_end( args );
+ return count;
+}
+
+void IvyBindDirectMsg( IvyCMsgDirectCallback callback, void *user_data)
+{
+}
+void IvySendDirectMsg( IvyClientPtr app, int id, char *msg )
+{
+}
+void IvyMainLoop( void(*hook)(void) )
+{
+ Sleep( INFINITE );
+}