Răsfoiți Sursa

- migrated to db_bind_api()

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@3859 689a6050-402a-0410-94f2-e92a70836424
Daniel-Constantin Mierla 17 ani în urmă
părinte
comite
bd3618d977

+ 2 - 1
modules/db_flatstore/km_flatstore.c

@@ -143,7 +143,8 @@ void flat_db_close(db_con_t* h)
  * v: values of the keys
  * v: values of the keys
  * n: number of key=value pairs
  * 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;
 	FILE* f;
 	int i;
 	int i;

+ 2 - 1
modules/db_flatstore/km_flatstore.h

@@ -60,7 +60,8 @@ void flat_db_close(db_con_t* h);
  * v: values of the keys
  * v: values of the keys
  * n: number of key=value pairs
  * 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 */
 #endif /* _FLATSTORE_H */

+ 19 - 5
modules/db_flatstore/km_flatstore_mod.c

@@ -29,6 +29,7 @@
 
 
 #include "../../sr_module.h"
 #include "../../sr_module.h"
 #include "../../mem/shm_mem.h"
 #include "../../mem/shm_mem.h"
+#include "../../db/db.h"
 #include "flatstore.h"
 #include "flatstore.h"
 #include "flat_mi.h"
 #include "flat_mi.h"
 #include "flatstore_mod.h"
 #include "flatstore_mod.h"
@@ -41,6 +42,7 @@ static int mod_init(void);
 
 
 static void mod_destroy(void);
 static void mod_destroy(void);
 
 
+int db_flat_bind_api(db_func_t *dbb);
 
 
 /*
 /*
  * Process number used in filenames
  * Process number used in filenames
@@ -71,14 +73,10 @@ time_t local_timestamp;
  * Flatstore database module interface
  * Flatstore database module interface
  */
  */
 static cmd_export_t cmds[] = {
 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}
 	{0, 0, 0, 0, 0, 0}
 };
 };
 
 
-
 /*
 /*
  * Exported parameters
  * Exported parameters
  */
  */
@@ -147,3 +145,19 @@ static int child_init(int rank)
 	}
 	}
 	return 0;
 	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;
+}
+