[SR-Dev] git:janakj/flatstore: - migrated to db_bind_api()

Jan Janak jan at iptel.org
Wed Feb 18 23:59:05 CET 2009


Module: sip-router
Branch: janakj/flatstore
Commit: bd3618d9778f0a20423f818b58079eb08663ebd0
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=bd3618d9778f0a20423f818b58079eb08663ebd0

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Wed Mar  5 18:33:15 2008 +0000

- migrated to db_bind_api()


git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@3859 689a6050-402a-0410-94f2-e92a70836424

---

 modules/db_flatstore/km_flatstore.c     |    3 ++-
 modules/db_flatstore/km_flatstore.h     |    3 ++-
 modules/db_flatstore/km_flatstore_mod.c |   24 +++++++++++++++++++-----
 3 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/modules/db_flatstore/km_flatstore.c b/modules/db_flatstore/km_flatstore.c
index 3da8118..714ac3b 100644
--- a/modules/db_flatstore/km_flatstore.c
+++ b/modules/db_flatstore/km_flatstore.c
@@ -143,7 +143,8 @@ void flat_db_close(db_con_t* h)
  * v: values of the keys
  * n: number of key=value pairs
  */
-int flat_db_insert(db_con_t* h, db_key_t* k, db_val_t* v, int n)
+int flat_db_insert(const db_con_t* h, const db_key_t* k, const db_val_t* v,
+		const int n)
 {
 	FILE* f;
 	int i;
diff --git a/modules/db_flatstore/km_flatstore.h b/modules/db_flatstore/km_flatstore.h
index 3ce9efd..9e83472 100644
--- a/modules/db_flatstore/km_flatstore.h
+++ b/modules/db_flatstore/km_flatstore.h
@@ -60,7 +60,8 @@ void flat_db_close(db_con_t* h);
  * v: values of the keys
  * n: number of key=value pairs
  */
-int flat_db_insert(db_con_t* h, db_key_t* k, db_val_t* v, int n);
+int flat_db_insert(const db_con_t* h, const db_key_t* k, const db_val_t* v,
+		const int n);
 
 
 #endif /* _FLATSTORE_H */
diff --git a/modules/db_flatstore/km_flatstore_mod.c b/modules/db_flatstore/km_flatstore_mod.c
index 68d8d20..9bd5bde 100644
--- a/modules/db_flatstore/km_flatstore_mod.c
+++ b/modules/db_flatstore/km_flatstore_mod.c
@@ -29,6 +29,7 @@
 
 #include "../../sr_module.h"
 #include "../../mem/shm_mem.h"
+#include "../../db/db.h"
 #include "flatstore.h"
 #include "flat_mi.h"
 #include "flatstore_mod.h"
@@ -41,6 +42,7 @@ static int mod_init(void);
 
 static void mod_destroy(void);
 
+int db_flat_bind_api(db_func_t *dbb);
 
 /*
  * Process number used in filenames
@@ -71,14 +73,10 @@ time_t local_timestamp;
  * Flatstore database module interface
  */
 static cmd_export_t cmds[] = {
-	{"db_use_table",   (cmd_function)flat_use_table, 2, 0, 0, 0},
-	{"db_init",        (cmd_function)flat_db_init,   1, 0, 0, 0},
-	{"db_close",       (cmd_function)flat_db_close,  2, 0, 0, 0},
-	{"db_insert",      (cmd_function)flat_db_insert, 2, 0, 0, 0},
+	{"db_bind_api",    (cmd_function)db_flat_bind_api,      0, 0, 0, 0},
 	{0, 0, 0, 0, 0, 0}
 };
 
-
 /*
  * Exported parameters
  */
@@ -147,3 +145,19 @@ static int child_init(int rank)
 	}
 	return 0;
 }
+
+int db_flat_bind_api(db_func_t *dbb)
+{
+	if(dbb==NULL)
+		return -1;
+
+	memset(dbb, 0, sizeof(db_func_t));
+
+	dbb->use_table        = flat_use_table;
+	dbb->init             = flat_db_init;
+	dbb->close            = flat_db_close;
+	dbb->insert           = flat_db_insert;
+
+	return 0;
+}
+




More information about the sr-dev mailing list