git » nmdb » commit 65cd6fd

Update D bindings to reflect TCP support and API changes.

author Alberto Bertogli
2007-06-01 16:44:23 UTC
committer Alberto Bertogli
2007-06-01 16:44:23 UTC
parent 8fe5b2111c5d12f152b59d363e676c939b7b4cec

Update D bindings to reflect TCP support and API changes.

Signed-off-by: Alberto Bertogli <albertito@gmail.com>

bindings/d/nmdb.d +12 -4
bindings/d/nmdb_ll.d +3 -2
bindings/d/test1c.d +2 -1
bindings/d/testt.d +1 -0

diff --git a/bindings/d/nmdb.d b/bindings/d/nmdb.d
index 3706133..ce73191 100644
--- a/bindings/d/nmdb.d
+++ b/bindings/d/nmdb.d
@@ -33,9 +33,9 @@ class DB
 	int mode = MODE_NORMAL;
 
 
-	this(int port = 10)
+	this()
 	{
-		db = nmdb_init(port);
+		db = nmdb_init();
 	}
 
 	~this()
@@ -43,9 +43,17 @@ class DB
 		nmdb_free(db);
 	}
 
-	void add_server(int port)
+	void add_tipc_server(int port = -1)
 	{
-		int r = nmdb_add_server(db, port);
+		int r = nmdb_add_tipc_server(db, port);
+		if (r == 0) {
+			throw new Exception("Can't add server");
+		}
+	}
+
+	void add_tcp_server(char[] addr, int port = -1)
+	{
+		int r = nmdb_add_tcp_server(db, cast(ubyte *) addr.ptr, port);
 		if (r == 0) {
 			throw new Exception("Can't add server");
 		}
diff --git a/bindings/d/nmdb_ll.d b/bindings/d/nmdb_ll.d
index 39524b1..5c8a5b6 100644
--- a/bindings/d/nmdb_ll.d
+++ b/bindings/d/nmdb_ll.d
@@ -36,8 +36,9 @@ version (X86_64) {
 /* nmdb structures and prototypes, these shouldn't need any changes
  * unless libnmdb/nmdb.h is updated */
 
-extern (C) nmdb_t *nmdb_init(int port);
-extern (C) int nmdb_add_server(nmdb_t *db, int port);
+extern (C) nmdb_t *nmdb_init();
+extern (C) int nmdb_add_tipc_server(nmdb_t *db, int port);
+extern (C) int nmdb_add_tcp_server(nmdb_t *db, ubyte *addr, int port);
 extern (C) int nmdb_free(nmdb_t *db);
 
 extern (C) ptrdiff_t nmdb_get(nmdb_t *db, ubyte *key, size_t ksize,
diff --git a/bindings/d/test1c.d b/bindings/d/test1c.d
index 1bbffc9..a3f3caf 100644
--- a/bindings/d/test1c.d
+++ b/bindings/d/test1c.d
@@ -16,7 +16,8 @@ int main(char [][] argv)
 	auto times = atoi(argv[1]);
 	char[] val;
 
-	nmdb.DB db = new nmdb.DB(10);
+	nmdb.DB db = new nmdb.DB();
+	db.add_tipc_server();
 	db.mode = nmdb.MODE_CACHE;
 
 	auto counter = new PerformanceCounter;
diff --git a/bindings/d/testt.d b/bindings/d/testt.d
index 78e080a..e2b820c 100644
--- a/bindings/d/testt.d
+++ b/bindings/d/testt.d
@@ -9,6 +9,7 @@ int main()
 	char[] val1;
 
 	nmdb.DB db = new nmdb.DB();
+	db.add_tipc_server();
 
 	db.mode = MODE_CACHE;
 	db["1"] = "D";