Module: sip-router Branch: janakj/flatstore Commit: a35e28152a68a49490029ed37150f05f881fb654 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a35e2815...
Author: Jan Janak jan@iptel.org Committer: Jan Janak jan@iptel.org Date: Wed Feb 18 23:10:33 2009 +0100
Make km_ sources compile:
List of changes: * Rename flat_pid variable to km_flat_pid to avoid conflict with sources originating from ser * Rename db_con_t to db1_con_t * Rename db type names DB_* to DB1_* * Rename flat_delimiter variable to km_flat_delimiter * Fix paths to headers in lib/srdb1 * Rename cmd_export_t to kam_cmd_export_t * Rename module_exports to kam_module_exports * Rename exports structure to kam_exports
---
modules/db_flatstore/km_flat_con.c | 2 +- modules/db_flatstore/km_flatstore.c | 35 ++++++++++++++++--------------- modules/db_flatstore/km_flatstore.h | 14 ++++++------ modules/db_flatstore/km_flatstore_mod.c | 25 ++++++++------------- modules/db_flatstore/km_flatstore_mod.h | 10 +------- 5 files changed, 38 insertions(+), 48 deletions(-)
diff --git a/modules/db_flatstore/km_flat_con.c b/modules/db_flatstore/km_flat_con.c index 7321b65..c4f38bb 100644 --- a/modules/db_flatstore/km_flat_con.c +++ b/modules/db_flatstore/km_flat_con.c @@ -72,7 +72,7 @@ static char* get_name(struct flat_id* id)
*ptr++ = '_'; - num = int2str(flat_pid, &num_len); + num = int2str(km_flat_pid, &num_len); if (buf_len<(total_len+num_len)){ LM_ERR("the path is too long (%d and PATHMAX is" " %d)\n", total_len+num_len, buf_len); diff --git a/modules/db_flatstore/km_flatstore.c b/modules/db_flatstore/km_flatstore.c index 1f85482..499a98e 100644 --- a/modules/db_flatstore/km_flatstore.c +++ b/modules/db_flatstore/km_flatstore.c @@ -35,6 +35,7 @@ #include "km_flat_con.h" #include "km_flatstore_mod.h" #include "km_flatstore.h" +#include "flatstore_mod.h"
static int parse_flat_url(const str* url, str* path) @@ -54,9 +55,9 @@ static int parse_flat_url(const str* url, str* path) * Initialize database module * No function should be called before this */ -db_con_t* flat_db_init(const str* url) +db1_con_t* flat_db_init(const str* url) { - db_con_t* res; + db1_con_t* res; str* path;
if (!url || !url->s) { @@ -72,13 +73,13 @@ db_con_t* flat_db_init(const str* url) /* as the table (path) is a substring of the received str, we need to * allocate a separate str struct for it -bogdan */ - res = pkg_malloc(sizeof(db_con_t)+sizeof(struct flat_con*)+sizeof(str)); + res = pkg_malloc(sizeof(db1_con_t)+sizeof(struct flat_con*)+sizeof(str)); if (!res) { LM_ERR("no pkg memory left\n"); return 0; } - memset(res, 0, sizeof(db_con_t) + sizeof(struct flat_con*) + sizeof(str)); - path = (str*)(((char*)res) + sizeof(db_con_t) + sizeof(struct flat_con*)); + memset(res, 0, sizeof(db1_con_t) + sizeof(struct flat_con*) + sizeof(str)); + path = (str*)(((char*)res) + sizeof(db1_con_t) + sizeof(struct flat_con*));
if (parse_flat_url(url, path) < 0) { pkg_free(res); @@ -94,7 +95,7 @@ db_con_t* flat_db_init(const str* url) * Store name of table that will be used by * subsequent database functions */ -int flat_use_table(db_con_t* h, const str* t) +int flat_use_table(db1_con_t* h, const str* t) { struct flat_con* con;
@@ -124,7 +125,7 @@ int flat_use_table(db_con_t* h, const str* t) }
-void flat_db_close(db_con_t* h) +void flat_db_close(db1_con_t* h) { struct flat_con* con;
@@ -149,7 +150,7 @@ void flat_db_close(db_con_t* h) * v: values of the keys * n: number of key=value pairs */ -int flat_db_insert(const db_con_t* h, const db_key_t* k, const db_val_t* v, +int flat_db_insert(const db1_con_t* h, const db_key_t* k, const db_val_t* v, const int n) { FILE* f; @@ -170,31 +171,31 @@ int flat_db_insert(const db_con_t* h, const db_key_t* k, const db_val_t* v,
for(i = 0; i < n; i++) { switch(VAL_TYPE(v + i)) { - case DB_INT: + case DB1_INT: fprintf(f, "%d", VAL_INT(v + i)); break;
- case DB_BIGINT: + case DB1_BIGINT: LM_ERR("BIGINT not supported"); return -1;
- case DB_DOUBLE: + case DB1_DOUBLE: fprintf(f, "%f", VAL_DOUBLE(v + i)); break;
- case DB_STRING: + case DB1_STRING: fprintf(f, "%s", VAL_STRING(v + i)); break;
- case DB_STR: + case DB1_STR: fprintf(f, "%.*s", VAL_STR(v + i).len, VAL_STR(v + i).s); break;
- case DB_DATETIME: + case DB1_DATETIME: fprintf(f, "%u", (unsigned int)VAL_TIME(v + i)); break;
- case DB_BLOB: + case DB1_BLOB: l = VAL_BLOB(v+i).len; s = p = VAL_BLOB(v+i).s; while (l--) { @@ -208,13 +209,13 @@ int flat_db_insert(const db_con_t* h, const db_key_t* k, const db_val_t* v, fprintf(f,"%.*s",(int)(s-p),p); break;
- case DB_BITMAP: + case DB1_BITMAP: fprintf(f, "%u", VAL_BITMAP(v + i)); break; }
if (i < (n - 1)) { - fprintf(f, "%c", *flat_delimiter); + fprintf(f, "%c", *km_flat_delimiter); } }
diff --git a/modules/db_flatstore/km_flatstore.h b/modules/db_flatstore/km_flatstore.h index fa79a34..c6e82f9 100644 --- a/modules/db_flatstore/km_flatstore.h +++ b/modules/db_flatstore/km_flatstore.h @@ -31,26 +31,26 @@ #ifndef _KM_FLATSTORE_H #define _KM_FLATSTORE_H
-#include "../../db/db_val.h" -#include "../../db/db_key.h" -#include "../../db/db_con.h" +#include "../../lib/srdb1/db_val.h" +#include "../../lib/srdb1/db_key.h" +#include "../../lib/srdb1/db_con.h"
/* * Initialize database module * No function should be called before this */ -db_con_t* flat_db_init(const str* _url); +db1_con_t* flat_db_init(const str* _url);
/* * Store name of table that will be used by * subsequent database functions */ -int flat_use_table(db_con_t* h, const str* t); +int flat_use_table(db1_con_t* h, const str* t);
-void flat_db_close(db_con_t* h); +void flat_db_close(db1_con_t* h);
/* @@ -60,7 +60,7 @@ void flat_db_close(db_con_t* h); * v: values of the keys * n: number of key=value pairs */ -int flat_db_insert(const db_con_t* h, const db_key_t* k, const db_val_t* v, +int flat_db_insert(const db1_con_t* h, const db_key_t* k, const db_val_t* v, const int n);
diff --git a/modules/db_flatstore/km_flatstore_mod.c b/modules/db_flatstore/km_flatstore_mod.c index c24343a..d968594 100644 --- a/modules/db_flatstore/km_flatstore_mod.c +++ b/modules/db_flatstore/km_flatstore_mod.c @@ -29,12 +29,13 @@
#include "../../sr_module.h" #include "../../mem/shm_mem.h" -#include "../../db/db.h" +#include "../../lib/srdb1/db.h" #include "km_flatstore.h" #include "km_flat_mi.h" #include "km_flatstore_mod.h" +#include "flatstore_mod.h"
-MODULE_VERSION +/*MODULE_VERSION*/
static int child_init(int rank);
@@ -47,18 +48,13 @@ int db_flat_bind_api(db_func_t *dbb); /* * Process number used in filenames */ -int flat_pid; - -/* - * Should we flush after each write to the database ? - */ -int flat_flush = 1; +int km_flat_pid;
/* * Delimiter delimiting columns */ -char* flat_delimiter = "|"; +char* km_flat_delimiter = "|";
/* @@ -72,7 +68,7 @@ time_t local_timestamp; /* * Flatstore database module interface */ -static cmd_export_t cmds[] = { +static kam_cmd_export_t cmds[] = { {"db_bind_api", (cmd_function)db_flat_bind_api, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0} }; @@ -81,7 +77,6 @@ static cmd_export_t cmds[] = { * Exported parameters */ static param_export_t params[] = { - {"flush", INT_PARAM, &flat_flush}, {0, 0, 0} };
@@ -94,7 +89,7 @@ static mi_export_t mi_cmds[] = { { 0, 0, 0, 0, 0} };
-struct module_exports exports = { +struct kam_module_exports km_exports = { "db_flatstore", DEFAULT_DLFLAGS, /* dlopen flags */ cmds, @@ -112,7 +107,7 @@ struct module_exports exports = {
static int mod_init(void) { - if (strlen(flat_delimiter) != 1) { + if (strlen(km_flat_delimiter) != 1) { LM_ERR("delimiter has to be exactly one character\n"); return -1; } @@ -139,9 +134,9 @@ static void mod_destroy(void) static int child_init(int rank) { if (rank <= 0) { - flat_pid = - rank; + km_flat_pid = - rank; } else { - flat_pid = rank - PROC_TCP_MAIN; + km_flat_pid = rank - PROC_TCP_MAIN; } return 0; } diff --git a/modules/db_flatstore/km_flatstore_mod.h b/modules/db_flatstore/km_flatstore_mod.h index 7a71406..b605c11 100644 --- a/modules/db_flatstore/km_flatstore_mod.h +++ b/modules/db_flatstore/km_flatstore_mod.h @@ -35,19 +35,13 @@ /* * Process number used in filenames */ -extern int flat_pid; - - -/* - * Should we flush after each write to the database ? - */ -extern int flat_flush; +extern int km_flat_pid;
/* * Delmiter delimiting columns */ -extern char* flat_delimiter; +extern char* km_flat_delimiter;
/*