summaryrefslogtreecommitdiff
path: root/Ivy/IvyCbindings.cxx
diff options
context:
space:
mode:
authorfcolin2007-02-01 13:01:33 +0000
committerfcolin2007-02-01 13:01:33 +0000
commit55eaa424173f390b66f3eb392c48f069c357533b (patch)
tree619337e5536b1cb276ee95f3d960821b32150e1f /Ivy/IvyCbindings.cxx
parent8a274412cccd5237e03481028bcfab96a5e85070 (diff)
downloadivy-cplusplus-55eaa424173f390b66f3eb392c48f069c357533b.zip
ivy-cplusplus-55eaa424173f390b66f3eb392c48f069c357533b.tar.gz
ivy-cplusplus-55eaa424173f390b66f3eb392c48f069c357533b.tar.bz2
ivy-cplusplus-55eaa424173f390b66f3eb392c48f069c357533b.tar.xz
Utilisateur : Fcolin Date : 25/10/01 Heure : 18:39 Archivé dans $/Ivy (vss 2)
Diffstat (limited to 'Ivy/IvyCbindings.cxx')
-rw-r--r--Ivy/IvyCbindings.cxx76
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 )