Prechádzať zdrojové kódy

Make km_sources compile within the db_berkeley sip-router module.

List of changes:
 * Field type names DB_* renamed to DB1_*
 * Linked with libkmi, the module uses kamailio management interface
 * Updated paths to headers in libsrdb1
 * db_con_t renamed to db1_con_t
 * db_res_t renamed to db1_res_t
 * cmd_export_t renamed to kam_cmd_export_t
 * structure module_exports renamed to kam_module_exports
 * Variable exports renamed to kam_exports to avoid conflict with the
   same variable in bdb_mod.c
Jan Janak 16 rokov pred
rodič
commit
f8605335db

+ 5 - 5
modules/db_berkeley/km_bdb_lib.c

@@ -826,19 +826,19 @@ int load_metadata_columns(table_p _tp)
 		
 		
 		/*set column type*/
 		/*set column type*/
 		if(strncmp(ct, "str", 3)==0)
 		if(strncmp(ct, "str", 3)==0)
-		{	col->type = DB_STRING;
+		{	col->type = DB1_STRING;
 		}
 		}
 		else if(strncmp(ct, "int", 3)==0)
 		else if(strncmp(ct, "int", 3)==0)
-		{	col->type = DB_INT;
+		{	col->type = DB1_INT;
 		}
 		}
 		else if(strncmp(ct, "double", 6)==0)
 		else if(strncmp(ct, "double", 6)==0)
-		{	col->type = DB_DOUBLE;
+		{	col->type = DB1_DOUBLE;
 		}
 		}
 		else if(strncmp(ct, "datetime", 8)==0)
 		else if(strncmp(ct, "datetime", 8)==0)
-		{	col->type = DB_DATETIME;
+		{	col->type = DB1_DATETIME;
 		}
 		}
 		else
 		else
-		{	col->type = DB_STRING;
+		{	col->type = DB1_STRING;
 		}
 		}
 		
 		
 		col->flag = 0;
 		col->flag = 0;

+ 2 - 2
modules/db_berkeley/km_bdb_lib.h

@@ -37,8 +37,8 @@
 #include <db.h>
 #include <db.h>
 
 
 #include "../../str.h"
 #include "../../str.h"
-#include "../../db/db.h"
-#include "../../db/db_val.h"
+#include "../../lib/srdb1/db.h"
+#include "../../lib/srdb1/db_val.h"
 #include "../../locking.h"
 #include "../../locking.h"
 
 
 /*max number of columns in a table*/
 /*max number of columns in a table*/

+ 1 - 1
modules/db_berkeley/km_bdb_mi.c

@@ -28,7 +28,7 @@
 
 
 
 
 #include "../../dprint.h"
 #include "../../dprint.h"
-#include "../../db/db.h"
+#include "../../lib/srdb1/db.h"
 #include "km_db_berkeley.h"
 #include "km_db_berkeley.h"
 #include "km_bdb_mi.h"
 #include "km_bdb_mi.h"
 
 

+ 38 - 38
modules/db_berkeley/km_bdb_res.c

@@ -34,7 +34,7 @@
 #include "km_bdb_res.h"
 #include "km_bdb_res.h"
 
 
 
 
-int bdb_get_columns(table_p _tp, db_res_t* _res, int* _lres, int _nc)
+int bdb_get_columns(table_p _tp, db1_res_t* _res, int* _lres, int _nc)
 {
 {
 	int col;
 	int col;
 
 
@@ -94,7 +94,7 @@ int bdb_get_columns(table_p _tp, db_res_t* _res, int* _lres, int _nc)
 /**
 /**
  * Convert rows from Berkeley DB to db API representation
  * Convert rows from Berkeley DB to db API representation
  */
  */
-int bdb_convert_row(db_res_t* _res, char *bdb_result, int* _lres)
+int bdb_convert_row(db1_res_t* _res, char *bdb_result, int* _lres)
 {
 {
 	int col, len, i, j;
 	int col, len, i, j;
 	char **row_buf, *s;
 	char **row_buf, *s;
@@ -205,8 +205,8 @@ int bdb_convert_row(db_res_t* _res, char *bdb_result, int* _lres)
 	for (col = 0; col < RES_COL_N(_res); col++) {
 	for (col = 0; col < RES_COL_N(_res); col++) {
 		switch (RES_TYPES(_res)[col]) 
 		switch (RES_TYPES(_res)[col]) 
 		{
 		{
-			case DB_STRING:
-			case DB_STR:
+			case DB1_STRING:
+			case DB1_STR:
 				break;
 				break;
 			default:
 			default:
 			LM_DBG("col[%d] Col[%.*s] Type[%d] Freeing row_buf[%p]\n", col
 			LM_DBG("col[%d] Col[%.*s] Type[%d] Freeing row_buf[%p]\n", col
@@ -216,11 +216,11 @@ int bdb_convert_row(db_res_t* _res, char *bdb_result, int* _lres)
 			pkg_free(row_buf[col]);
 			pkg_free(row_buf[col]);
 		}
 		}
 		/* The following housekeeping may not be technically required, but it is a good practice
 		/* The following housekeeping may not be technically required, but it is a good practice
-		 * to NULL pointer fields that are no longer valid.  Note that DB_STRING fields have not
-		 * been pkg_free(). NULLing DB_STRING fields would normally not be good to do because a memory
-		 * leak would occur.  However, the pg_convert_row() routine has saved the DB_STRING pointer
+		 * to NULL pointer fields that are no longer valid.  Note that DB1_STRING fields have not
+		 * been pkg_free(). NULLing DB1_STRING fields would normally not be good to do because a memory
+		 * leak would occur.  However, the pg_convert_row() routine has saved the DB1_STRING pointer
 		 * in the db_val_t structure.  The db_val_t structure will eventually be used to pkg_free()
 		 * in the db_val_t structure.  The db_val_t structure will eventually be used to pkg_free()
-		 * the DB_STRING storage.
+		 * the DB1_STRING storage.
 		 */
 		 */
 		row_buf[col] = (char *)NULL;
 		row_buf[col] = (char *)NULL;
 	}
 	}
@@ -233,7 +233,7 @@ int bdb_convert_row(db_res_t* _res, char *bdb_result, int* _lres)
 }
 }
 
 
 /*rx is row index*/
 /*rx is row index*/
-int bdb_append_row(db_res_t* _res, char *bdb_result, int* _lres, int _rx)
+int bdb_append_row(db1_res_t* _res, char *bdb_result, int* _lres, int _rx)
 {
 {
 	int col, len, i, j;
 	int col, len, i, j;
 	char **row_buf, *s;
 	char **row_buf, *s;
@@ -341,7 +341,7 @@ int bdb_append_row(db_res_t* _res, char *bdb_result, int* _lres, int _rx)
 	 * is eventually called.
 	 * is eventually called.
 	 */
 	 */
 	for (col = 0; col < RES_COL_N(_res); col++) {
 	for (col = 0; col < RES_COL_N(_res); col++) {
-		if (RES_TYPES(_res)[col] != DB_STRING) {
+		if (RES_TYPES(_res)[col] != DB1_STRING) {
 			LM_DBG("col[%d] Col[%.*s] Type[%d] Freeing row_buf[%p]\n", col
 			LM_DBG("col[%d] Col[%.*s] Type[%d] Freeing row_buf[%p]\n", col
 				, RES_NAMES(_res)[col]->len, RES_NAMES(_res)[col]->s,
 				, RES_NAMES(_res)[col]->len, RES_NAMES(_res)[col]->s,
 				  RES_TYPES(_res)[col], row_buf[col]);
 				  RES_TYPES(_res)[col], row_buf[col]);
@@ -349,11 +349,11 @@ int bdb_append_row(db_res_t* _res, char *bdb_result, int* _lres, int _rx)
 			pkg_free(row_buf[col]);
 			pkg_free(row_buf[col]);
 		}
 		}
 		/* The following housekeeping may not be technically required, but it is a good practice
 		/* The following housekeeping may not be technically required, but it is a good practice
-		 * to NULL pointer fields that are no longer valid.  Note that DB_STRING fields have not
-		 * been pkg_free(). NULLing DB_STRING fields would normally not be good to do because a memory
-		 * leak would occur.  However, the pg_convert_row() routine has saved the DB_STRING pointer
+		 * to NULL pointer fields that are no longer valid.  Note that DB1_STRING fields have not
+		 * been pkg_free(). NULLing DB1_STRING fields would normally not be good to do because a memory
+		 * leak would occur.  However, the pg_convert_row() routine has saved the DB1_STRING pointer
 		 * in the db_val_t structure.  The db_val_t structure will eventually be used to pkg_free()
 		 * in the db_val_t structure.  The db_val_t structure will eventually be used to pkg_free()
-		 * the DB_STRING storage.
+		 * the DB1_STRING storage.
 		 */
 		 */
 		row_buf[col] = (char *)NULL;
 		row_buf[col] = (char *)NULL;
 	}
 	}
@@ -402,30 +402,30 @@ int bdb_is_neq_type(db_type_t _t0, db_type_t _t1)
 	
 	
 	switch(_t1)
 	switch(_t1)
 	{
 	{
-		case DB_INT:
-			if(_t0==DB_DATETIME || _t0==DB_BITMAP)
+		case DB1_INT:
+			if(_t0==DB1_DATETIME || _t0==DB1_BITMAP)
 				return 0;
 				return 0;
-		case DB_BIGINT:
+		case DB1_BIGINT:
 				LM_ERR("BIGINT not supported");
 				LM_ERR("BIGINT not supported");
 				return 0;
 				return 0;
-		case DB_DATETIME:
-			if(_t0==DB_INT)
+		case DB1_DATETIME:
+			if(_t0==DB1_INT)
 				return 0;
 				return 0;
-			if(_t0==DB_BITMAP)
+			if(_t0==DB1_BITMAP)
 				return 0;
 				return 0;
-		case DB_DOUBLE:
+		case DB1_DOUBLE:
 			break;
 			break;
-		case DB_STRING:
-			if(_t0==DB_STR)
+		case DB1_STRING:
+			if(_t0==DB1_STR)
 				return 0;
 				return 0;
-		case DB_STR:
-			if(_t0==DB_STRING || _t0==DB_BLOB)
+		case DB1_STR:
+			if(_t0==DB1_STRING || _t0==DB1_BLOB)
 				return 0;
 				return 0;
-		case DB_BLOB:
-			if(_t0==DB_STR)
+		case DB1_BLOB:
+			if(_t0==DB1_STR)
 				return 0;
 				return 0;
-		case DB_BITMAP:
-			if (_t0==DB_INT)
+		case DB1_BITMAP:
+			if (_t0==DB1_INT)
 				return 0;
 				return 0;
 	}
 	}
 	return 1;
 	return 1;
@@ -434,7 +434,7 @@ int bdb_is_neq_type(db_type_t _t0, db_type_t _t1)
 
 
 /*
 /*
 */
 */
-int bdb_row_match(db_key_t* _k, db_op_t* _op, db_val_t* _v, int _n, db_res_t* _r, int* _lkey )
+int bdb_row_match(db_key_t* _k, db_op_t* _op, db_val_t* _v, int _n, db1_res_t* _r, int* _lkey )
 {
 {
 	int i, res;
 	int i, res;
 	db_row_t* row = NULL;
 	db_row_t* row = NULL;
@@ -495,19 +495,19 @@ int bdb_cmp_val(db_val_t* _vp, db_val_t* _v)
 	
 	
 	switch(VAL_TYPE(_v))
 	switch(VAL_TYPE(_v))
 	{
 	{
-		case DB_INT:
+		case DB1_INT:
 			return (_vp->val.int_val<_v->val.int_val)?-1:
 			return (_vp->val.int_val<_v->val.int_val)?-1:
 					(_vp->val.int_val>_v->val.int_val)?1:0;
 					(_vp->val.int_val>_v->val.int_val)?1:0;
-		case DB_BIGINT:
+		case DB1_BIGINT:
 			LM_ERR("BIGINT not supported");
 			LM_ERR("BIGINT not supported");
 			return -1;
 			return -1;
-		case DB_DOUBLE:
+		case DB1_DOUBLE:
 			return (_vp->val.double_val<_v->val.double_val)?-1:
 			return (_vp->val.double_val<_v->val.double_val)?-1:
 					(_vp->val.double_val>_v->val.double_val)?1:0;
 					(_vp->val.double_val>_v->val.double_val)?1:0;
-		case DB_DATETIME:
+		case DB1_DATETIME:
 			return (_vp->val.int_val<_v->val.time_val)?-1:
 			return (_vp->val.int_val<_v->val.time_val)?-1:
 					(_vp->val.int_val>_v->val.time_val)?1:0;
 					(_vp->val.int_val>_v->val.time_val)?1:0;
-		case DB_STRING:
+		case DB1_STRING:
 			_l = strlen(_v->val.string_val);
 			_l = strlen(_v->val.string_val);
 			_l = (_l>_vp->val.str_val.len)?_vp->val.str_val.len:_l;
 			_l = (_l>_vp->val.str_val.len)?_vp->val.str_val.len:_l;
 			_n = strncasecmp(_vp->val.str_val.s, _v->val.string_val, _l);
 			_n = strncasecmp(_vp->val.str_val.s, _v->val.string_val, _l);
@@ -518,7 +518,7 @@ int bdb_cmp_val(db_val_t* _vp, db_val_t* _v)
 			if(_l==_vp->val.str_val.len)
 			if(_l==_vp->val.str_val.len)
 				return -1;
 				return -1;
 			return 1;
 			return 1;
-		case DB_STR:
+		case DB1_STR:
 			_l = _v->val.str_val.len;
 			_l = _v->val.str_val.len;
 			_l = (_l>_vp->val.str_val.len)?_vp->val.str_val.len:_l;
 			_l = (_l>_vp->val.str_val.len)?_vp->val.str_val.len:_l;
 			_n = strncasecmp(_vp->val.str_val.s, _v->val.str_val.s, _l);
 			_n = strncasecmp(_vp->val.str_val.s, _v->val.str_val.s, _l);
@@ -529,7 +529,7 @@ int bdb_cmp_val(db_val_t* _vp, db_val_t* _v)
 			if(_l==_vp->val.str_val.len)
 			if(_l==_vp->val.str_val.len)
 				return -1;
 				return -1;
 			return 1;
 			return 1;
-		case DB_BLOB:
+		case DB1_BLOB:
 			_l = _v->val.blob_val.len;
 			_l = _v->val.blob_val.len;
 			_l = (_l>_vp->val.str_val.len)?_vp->val.str_val.len:_l;
 			_l = (_l>_vp->val.str_val.len)?_vp->val.str_val.len:_l;
 			_n = strncasecmp(_vp->val.str_val.s, _v->val.blob_val.s, _l);
 			_n = strncasecmp(_vp->val.str_val.s, _v->val.blob_val.s, _l);
@@ -540,7 +540,7 @@ int bdb_cmp_val(db_val_t* _vp, db_val_t* _v)
 			if(_l==_vp->val.str_val.len)
 			if(_l==_vp->val.str_val.len)
 				return -1;
 				return -1;
 			return 1;
 			return 1;
-		case DB_BITMAP:
+		case DB1_BITMAP:
 			return (_vp->val.int_val<_v->val.bitmap_val)?-1:
 			return (_vp->val.int_val<_v->val.bitmap_val)?-1:
 				(_vp->val.int_val>_v->val.bitmap_val)?1:0;
 				(_vp->val.int_val>_v->val.bitmap_val)?1:0;
 	}
 	}

+ 8 - 8
modules/db_berkeley/km_bdb_res.h

@@ -31,16 +31,16 @@
 #ifndef _KM_BDB_RES_H_
 #ifndef _KM_BDB_RES_H_
 #define _KM_BDB_RES_H_
 #define _KM_BDB_RES_H_
 
 
-#include "../../db/db_op.h"
-#include "../../db/db_res.h"
-#include "../../db/db_con.h"
+#include "../../lib/srdb1/db_op.h"
+#include "../../lib/srdb1/db_res.h"
+#include "../../lib/srdb1/db_con.h"
 #include "km_bdb_lib.h"
 #include "km_bdb_lib.h"
 #include "km_bdb_val.h"
 #include "km_bdb_val.h"
 
 
 typedef struct _con
 typedef struct _con
 {
 {
 	database_p con;
 	database_p con;
-	db_res_t*  res;
+	db1_res_t*  res;
 	row_p row;
 	row_p row;
 } bdb_con_t, *bdb_con_p;
 } bdb_con_t, *bdb_con_p;
 
 
@@ -48,13 +48,13 @@ typedef struct _con
 #define BDB_CON_RESULT(db_con)     (((bdb_con_p)((db_con)->tail))->res)
 #define BDB_CON_RESULT(db_con)     (((bdb_con_p)((db_con)->tail))->res)
 #define BDB_CON_ROW(db_con)        (((bdb_con_p)((db_con)->tail))->row)
 #define BDB_CON_ROW(db_con)        (((bdb_con_p)((db_con)->tail))->row)
 
 
-int bdb_get_columns(table_p _tp, db_res_t* _res, int* _lres, int _nc);
-int bdb_convert_row( db_res_t* _res, char *bdb_result, int* _lres);
-int bdb_append_row(db_res_t* _res, char *bdb_result, int* _lres, int _rx);
+int bdb_get_columns(table_p _tp, db1_res_t* _res, int* _lres, int _nc);
+int bdb_convert_row( db1_res_t* _res, char *bdb_result, int* _lres);
+int bdb_append_row(db1_res_t* _res, char *bdb_result, int* _lres, int _rx);
 int* bdb_get_colmap(table_p _tp, db_key_t* _k, int _n);
 int* bdb_get_colmap(table_p _tp, db_key_t* _k, int _n);
 
 
 int bdb_is_neq_type(db_type_t _t0, db_type_t _t1);
 int bdb_is_neq_type(db_type_t _t0, db_type_t _t1);
-int bdb_row_match(db_key_t* _k, db_op_t* _op, db_val_t* _v, int _n, db_res_t* _r, int* lkey );
+int bdb_row_match(db_key_t* _k, db_op_t* _op, db_val_t* _v, int _n, db1_res_t* _r, int* lkey );
 int bdb_cmp_val(db_val_t* _vp, db_val_t* _v);
 int bdb_cmp_val(db_val_t* _vp, db_val_t* _v);
 
 
 #endif
 #endif

+ 24 - 24
modules/db_berkeley/km_bdb_val.c

@@ -28,8 +28,8 @@
  */
  */
  
  
 
 
-#include "../../db/db_val.h"
-#include "../../db/db_ut.h"
+#include "../../lib/srdb1/db_val.h"
+#include "../../lib/srdb1/db_ut.h"
 #include "km_db_berkeley.h"
 #include "km_db_berkeley.h"
 #include "km_bdb_res.h"
 #include "km_bdb_res.h"
 #include "km_bdb_val.h"
 #include "km_bdb_val.h"
@@ -102,43 +102,43 @@ int bdb_str2val(db_type_t _t, db_val_t* _v, char* _s, int _l)
 	VAL_NULL(_v) = 0;
 	VAL_NULL(_v) = 0;
 
 
 	switch(_t) {
 	switch(_t) {
-	case DB_INT:
+	case DB1_INT:
 		if (db_str2int(_s, &VAL_INT(_v)) < 0) {
 		if (db_str2int(_s, &VAL_INT(_v)) < 0) {
 			LM_ERR("Error while converting INT value from string\n");
 			LM_ERR("Error while converting INT value from string\n");
 			return -2;
 			return -2;
 		} else {
 		} else {
-			VAL_TYPE(_v) = DB_INT;
+			VAL_TYPE(_v) = DB1_INT;
 			return 0;
 			return 0;
 		}
 		}
 		break;
 		break;
 
 
-	case DB_BIGINT:
+	case DB1_BIGINT:
 			LM_ERR("BIGINT not supported");
 			LM_ERR("BIGINT not supported");
 			return -1;
 			return -1;
 
 
-	case DB_BITMAP:
+	case DB1_BITMAP:
 		if (db_str2int(_s, &VAL_INT(_v)) < 0) {
 		if (db_str2int(_s, &VAL_INT(_v)) < 0) {
 			LM_ERR("Error while converting BITMAP value from string\n");
 			LM_ERR("Error while converting BITMAP value from string\n");
 			return -3;
 			return -3;
 		} else {
 		} else {
-			VAL_TYPE(_v) = DB_BITMAP;
+			VAL_TYPE(_v) = DB1_BITMAP;
 			return 0;
 			return 0;
 		}
 		}
 		break;
 		break;
 
 
-	case DB_DOUBLE:
+	case DB1_DOUBLE:
 		if (db_str2double(_s, &VAL_DOUBLE(_v)) < 0) {
 		if (db_str2double(_s, &VAL_DOUBLE(_v)) < 0) {
 			LM_ERR("Error while converting DOUBLE value from string\n");
 			LM_ERR("Error while converting DOUBLE value from string\n");
 			return -4;
 			return -4;
 		} else {
 		} else {
-			VAL_TYPE(_v) = DB_DOUBLE;
+			VAL_TYPE(_v) = DB1_DOUBLE;
 			return 0;
 			return 0;
 		}
 		}
 		break;
 		break;
 
 
-	case DB_STRING:
+	case DB1_STRING:
 		VAL_STRING(_v) = _s;
 		VAL_STRING(_v) = _s;
-		VAL_TYPE(_v) = DB_STRING;
+		VAL_TYPE(_v) = DB1_STRING;
 		VAL_FREE(_v) = 1;
 		VAL_FREE(_v) = 1;
 		
 		
 		if( strlen(_s)==4 && !strncasecmp(_s, "NULL", 4) )
 		if( strlen(_s)==4 && !strncasecmp(_s, "NULL", 4) )
@@ -146,10 +146,10 @@ int bdb_str2val(db_type_t _t, db_val_t* _v, char* _s, int _l)
 		
 		
 		return 0;
 		return 0;
 
 
-	case DB_STR:
+	case DB1_STR:
 		VAL_STR(_v).s = (char*)_s;
 		VAL_STR(_v).s = (char*)_s;
 		VAL_STR(_v).len = _l;
 		VAL_STR(_v).len = _l;
-		VAL_TYPE(_v) = DB_STR;
+		VAL_TYPE(_v) = DB1_STR;
 		VAL_FREE(_v) = 1;
 		VAL_FREE(_v) = 1;
 
 
 		if( strlen(_s)==4 && !strncasecmp(_s, "NULL", 4) )
 		if( strlen(_s)==4 && !strncasecmp(_s, "NULL", 4) )
@@ -157,19 +157,19 @@ int bdb_str2val(db_type_t _t, db_val_t* _v, char* _s, int _l)
 
 
 		return 0;
 		return 0;
 
 
-	case DB_DATETIME:
+	case DB1_DATETIME:
 		if (db_str2time(_s, &VAL_TIME(_v)) < 0) {
 		if (db_str2time(_s, &VAL_TIME(_v)) < 0) {
 			LM_ERR("Error converting datetime\n");
 			LM_ERR("Error converting datetime\n");
 			return -5;
 			return -5;
 		} else {
 		} else {
-			VAL_TYPE(_v) = DB_DATETIME;
+			VAL_TYPE(_v) = DB1_DATETIME;
 			return 0;
 			return 0;
 		}
 		}
 		break;
 		break;
 
 
-	case DB_BLOB:
+	case DB1_BLOB:
 		VAL_BLOB(_v).s = _s;
 		VAL_BLOB(_v).s = _s;
-		VAL_TYPE(_v) = DB_BLOB;
+		VAL_TYPE(_v) = DB1_BLOB;
 		LM_DBG("got blob len %d\n", _l);
 		LM_DBG("got blob len %d\n", _l);
 		return 0;
 		return 0;
 	}
 	}
@@ -192,7 +192,7 @@ int bdb_val2str(db_val_t* _v, char* _s, int* _len)
 	}
 	}
 	
 	
 	switch(VAL_TYPE(_v)) {
 	switch(VAL_TYPE(_v)) {
-	case DB_INT:
+	case DB1_INT:
 		if (db_int2str(VAL_INT(_v), _s, _len) < 0) {
 		if (db_int2str(VAL_INT(_v), _s, _len) < 0) {
 			LM_ERR("Error while converting int to string\n");
 			LM_ERR("Error while converting int to string\n");
 			return -2;
 			return -2;
@@ -202,7 +202,7 @@ int bdb_val2str(db_val_t* _v, char* _s, int* _len)
 		}
 		}
 		break;
 		break;
 
 
-	case DB_BITMAP:
+	case DB1_BITMAP:
 		if (db_int2str(VAL_INT(_v), _s, _len) < 0) {
 		if (db_int2str(VAL_INT(_v), _s, _len) < 0) {
 			LM_ERR("Error while converting bitmap to string\n");
 			LM_ERR("Error while converting bitmap to string\n");
 			return -3;
 			return -3;
@@ -212,7 +212,7 @@ int bdb_val2str(db_val_t* _v, char* _s, int* _len)
 		}
 		}
 		break;
 		break;
 
 
-	case DB_DOUBLE:
+	case DB1_DOUBLE:
 		if (db_double2str(VAL_DOUBLE(_v), _s, _len) < 0) {
 		if (db_double2str(VAL_DOUBLE(_v), _s, _len) < 0) {
 			LM_ERR("Error while converting double  to string\n");
 			LM_ERR("Error while converting double  to string\n");
 			return -3;
 			return -3;
@@ -222,7 +222,7 @@ int bdb_val2str(db_val_t* _v, char* _s, int* _len)
 		}
 		}
 		break;
 		break;
 
 
-	case DB_STRING:
+	case DB1_STRING:
 		l = strlen(VAL_STRING(_v));
 		l = strlen(VAL_STRING(_v));
 		if (*_len < l ) 
 		if (*_len < l ) 
 		{	LM_ERR("Destination buffer too short for string\n");
 		{	LM_ERR("Destination buffer too short for string\n");
@@ -237,7 +237,7 @@ int bdb_val2str(db_val_t* _v, char* _s, int* _len)
 		}
 		}
 		break;
 		break;
 
 
-	case DB_STR:
+	case DB1_STR:
 		l = VAL_STR(_v).len;
 		l = VAL_STR(_v).len;
 		if (*_len < l) 
 		if (*_len < l) 
 		{
 		{
@@ -253,7 +253,7 @@ int bdb_val2str(db_val_t* _v, char* _s, int* _len)
 		}
 		}
 		break;
 		break;
 
 
-	case DB_DATETIME:
+	case DB1_DATETIME:
 		if (bdb_time2str(VAL_TIME(_v), _s, _len) < 0) {
 		if (bdb_time2str(VAL_TIME(_v), _s, _len) < 0) {
 			LM_ERR("Error while converting time_t to string\n");
 			LM_ERR("Error while converting time_t to string\n");
 			return -6;
 			return -6;
@@ -263,7 +263,7 @@ int bdb_val2str(db_val_t* _v, char* _s, int* _len)
 		}
 		}
 		break;
 		break;
 
 
-	case DB_BLOB:
+	case DB1_BLOB:
 		l = VAL_BLOB(_v).len;
 		l = VAL_BLOB(_v).len;
 		if (*_len < l) 
 		if (*_len < l) 
 		{
 		{

+ 3 - 3
modules/db_berkeley/km_bdb_val.h

@@ -31,9 +31,9 @@
 #ifndef _KM_BDB_VAL_H_
 #ifndef _KM_BDB_VAL_H_
 #define _KM_BDB_VAL_H_
 #define _KM_BDB_VAL_H_
 
 
-#include "../../db/db_op.h"
-#include "../../db/db_res.h"
-#include "../../db/db_con.h"
+#include "../../lib/srdb1/db_op.h"
+#include "../../lib/srdb1/db_res.h"
+#include "../../lib/srdb1/db_con.h"
 
 
 int bdb_val2str(db_val_t* _v, char* _s, int* _len);
 int bdb_val2str(db_val_t* _v, char* _s, int* _len);
 int bdb_str2val(db_type_t _t, db_val_t* _v, char* _s, int _l);
 int bdb_str2val(db_type_t _t, db_val_t* _v, char* _s, int _l);

+ 29 - 29
modules/db_berkeley/km_db_berkeley.c

@@ -37,8 +37,8 @@
 #include "../../mem/mem.h"
 #include "../../mem/mem.h"
 
 
 #include "../../sr_module.h"
 #include "../../sr_module.h"
-#include "../../db/db_res.h"
-#include "../../db/db.h"
+#include "../../lib/srdb1/db_res.h"
+#include "../../lib/srdb1/db.h"
 #include "km_db_berkeley.h"
 #include "km_db_berkeley.h"
 #include "km_bdb_lib.h"
 #include "km_bdb_lib.h"
 #include "km_bdb_res.h"
 #include "km_bdb_res.h"
@@ -69,7 +69,7 @@ int bdb_bind_api(db_func_t *dbb);
 /*
 /*
  * Exported functions
  * Exported functions
  */
  */
-static cmd_export_t cmds[] = {
+static kam_cmd_export_t cmds[] = {
 	{"db_bind_api",    (cmd_function)bdb_bind_api,   0, 0, 0, 0},
 	{"db_bind_api",    (cmd_function)bdb_bind_api,   0, 0, 0, 0},
 	{0, 0, 0, 0, 0, 0}
 	{0, 0, 0, 0, 0, 0}
 };
 };
@@ -93,7 +93,7 @@ static mi_export_t mi_cmds[] = {
 	{ 0, 0, 0, 0, 0}
 	{ 0, 0, 0, 0, 0}
 };
 };
 
 
-struct module_exports exports = {	
+struct kam_module_exports kam_exports = {	
 	"db_berkeley",
 	"db_berkeley",
 	DEFAULT_DLFLAGS, /* dlopen flags */
 	DEFAULT_DLFLAGS, /* dlopen flags */
 	cmds,     /* Exported functions */
 	cmds,     /* Exported functions */
@@ -148,7 +148,7 @@ int bdb_bind_api(db_func_t *dbb)
 	return 0;
 	return 0;
 }
 }
 
 
-int bdb_use_table(db_con_t* _h, const str* _t)
+int bdb_use_table(db1_con_t* _h, const str* _t)
 {
 {
 	return db_use_table(_h, _t);
 	return db_use_table(_h, _t);
 }
 }
@@ -156,9 +156,9 @@ int bdb_use_table(db_con_t* _h, const str* _t)
 /*
 /*
  * Initialize database connection
  * Initialize database connection
  */
  */
-db_con_t* bdb_init(const str* _sqlurl)
+db1_con_t* bdb_init(const str* _sqlurl)
 {
 {
-	db_con_t* _res;
+	db1_con_t* _res;
 	str _s;
 	str _s;
 	char bdb_path[BDB_PATH_LEN];
 	char bdb_path[BDB_PATH_LEN];
 	
 	
@@ -192,14 +192,14 @@ db_con_t* bdb_init(const str* _sqlurl)
 		_s.s = bdb_path;
 		_s.s = bdb_path;
 	}
 	}
 	
 	
-	_res = pkg_malloc(sizeof(db_con_t)+sizeof(bdb_con_t));
+	_res = pkg_malloc(sizeof(db1_con_t)+sizeof(bdb_con_t));
 	if (!_res)
 	if (!_res)
 	{
 	{
 		LM_ERR("No private memory left\n");
 		LM_ERR("No private memory left\n");
 		return NULL;
 		return NULL;
 	}
 	}
-	memset(_res, 0, sizeof(db_con_t) + sizeof(bdb_con_t));
-	_res->tail = (unsigned long)((char*)_res+sizeof(db_con_t));
+	memset(_res, 0, sizeof(db1_con_t) + sizeof(bdb_con_t));
+	_res->tail = (unsigned long)((char*)_res+sizeof(db1_con_t));
 
 
 	LM_INFO("using database at: %.*s", _s.len, _s.s);
 	LM_INFO("using database at: %.*s", _s.len, _s.s);
 	BDB_CON_CONNECTION(_res) = bdblib_get_db(&_s);
 	BDB_CON_CONNECTION(_res) = bdblib_get_db(&_s);
@@ -216,7 +216,7 @@ db_con_t* bdb_init(const str* _sqlurl)
 /*
 /*
  * Close a database connection
  * Close a database connection
  */
  */
-void bdb_close(db_con_t* _h)
+void bdb_close(db1_con_t* _h)
 {
 {
 	if(BDB_CON_RESULT(_h))
 	if(BDB_CON_RESULT(_h))
 		db_free_result(BDB_CON_RESULT(_h));
 		db_free_result(BDB_CON_RESULT(_h));
@@ -253,7 +253,7 @@ int bdb_reload(char* _n)
 /*
 /*
  * Attempts to reload a Berkeley database; reloads when the inode changes
  * Attempts to reload a Berkeley database; reloads when the inode changes
  */
  */
-void bdb_check_reload(db_con_t* _con)
+void bdb_check_reload(db1_con_t* _con)
 {
 {
 	str s;
 	str s;
 	char* p;
 	char* p;
@@ -331,7 +331,7 @@ void bdb_check_reload(db_con_t* _con)
 /*
 /*
  * Free all memory allocated by get_result
  * Free all memory allocated by get_result
  */
  */
-int bdb_free_query(db_con_t* _h, db_res_t* _r)
+int bdb_free_query(db1_con_t* _h, db1_res_t* _r)
 {
 {
 	if(_r)
 	if(_r)
 		db_free_result(_r);
 		db_free_result(_r);
@@ -352,8 +352,8 @@ int bdb_free_query(db_con_t* _h, db_res_t* _r)
  * _nc: number of columns to return
  * _nc: number of columns to return
  * _o: order by the specified column
  * _o: order by the specified column
  */
  */
-int bdb_query(db_con_t* _con, db_key_t* _k, db_op_t* _op, db_val_t* _v, 
-			db_key_t* _c, int _n, int _nc, db_key_t _o, db_res_t** _r)
+int bdb_query(db1_con_t* _con, db_key_t* _k, db_op_t* _op, db_val_t* _v, 
+			db_key_t* _c, int _n, int _nc, db_key_t _o, db1_res_t** _r)
 {
 {
 	tbl_cache_p _tbc = NULL;
 	tbl_cache_p _tbc = NULL;
 	table_p _tp = NULL;
 	table_p _tp = NULL;
@@ -479,7 +479,7 @@ int bdb_query(db_con_t* _con, db_key_t* _k, db_op_t* _op, db_val_t* _v,
 		RES_ROWS(*_r) = (db_row_t*)pkg_malloc( len );
 		RES_ROWS(*_r) = (db_row_t*)pkg_malloc( len );
 		memset(RES_ROWS(*_r), 0, len);
 		memset(RES_ROWS(*_r), 0, len);
 		
 		
-		/*fill in the column part of db_res_t (metadata) */
+		/*fill in the column part of db1_res_t (metadata) */
 		if ((ret = bdb_get_columns(_tbc->dtp, *_r, lres, _nc)) < 0) 
 		if ((ret = bdb_get_columns(_tbc->dtp, *_r, lres, _nc)) < 0) 
 		{	LM_ERR("Error while getting column names\n");
 		{	LM_ERR("Error while getting column names\n");
 			goto error;
 			goto error;
@@ -506,7 +506,7 @@ int bdb_query(db_con_t* _con, db_key_t* _k, db_op_t* _op, db_val_t* _v,
 			, (char *)data.data);
 			, (char *)data.data);
 #endif
 #endif
 
 
-			/*fill in the row part of db_res_t */
+			/*fill in the row part of db1_res_t */
 			if ((ret=bdb_append_row( *_r, dbuf, lres, i)) < 0) 
 			if ((ret=bdb_append_row( *_r, dbuf, lres, i)) < 0) 
 			{	LM_ERR("Error while converting row\n");
 			{	LM_ERR("Error while converting row\n");
 				goto error;
 				goto error;
@@ -533,7 +533,7 @@ int bdb_query(db_con_t* _con, db_key_t* _k, db_op_t* _op, db_val_t* _v,
 	data.ulen = MAX_ROW_SIZE;
 	data.ulen = MAX_ROW_SIZE;
 	data.flags = DB_DBT_USERMEM;
 	data.flags = DB_DBT_USERMEM;
 
 
-	/*create an empty db_res_t which gets returned even if no result*/
+	/*create an empty db1_res_t which gets returned even if no result*/
 	*_r = db_new_result();
 	*_r = db_new_result();
 	if (!*_r) 
 	if (!*_r) 
 	{	LM_ERR("no memory left for result \n");
 	{	LM_ERR("no memory left for result \n");
@@ -560,12 +560,12 @@ int bdb_query(db_con_t* _con, db_key_t* _k, db_op_t* _op, db_val_t* _v,
 			, (char *)data.data);
 			, (char *)data.data);
 #endif
 #endif
 
 
-		/*fill in the col part of db_res_t */
+		/*fill in the col part of db1_res_t */
 		if ((ret = bdb_get_columns(_tbc->dtp, *_r, lres, _nc)) < 0) 
 		if ((ret = bdb_get_columns(_tbc->dtp, *_r, lres, _nc)) < 0) 
 		{	LM_ERR("Error while getting column names\n");
 		{	LM_ERR("Error while getting column names\n");
 			goto error;
 			goto error;
 		}
 		}
-		/*fill in the row part of db_res_t */
+		/*fill in the row part of db1_res_t */
 		if ((ret=bdb_convert_row( *_r, dbuf, lres)) < 0) 
 		if ((ret=bdb_convert_row( *_r, dbuf, lres)) < 0) 
 		{	LM_ERR("Error while converting row\n");
 		{	LM_ERR("Error while converting row\n");
 			goto error;
 			goto error;
@@ -623,7 +623,7 @@ error:
 /*
 /*
  * Raw SQL query
  * Raw SQL query
  */
  */
-int bdb_raw_query(db_con_t* _h, char* _s, db_res_t** _r)
+int bdb_raw_query(db1_con_t* _h, char* _s, db1_res_t** _r)
 {
 {
 	LM_CRIT("DB RAW QUERY not implemented!\n");
 	LM_CRIT("DB RAW QUERY not implemented!\n");
 	return -1;
 	return -1;
@@ -632,7 +632,7 @@ int bdb_raw_query(db_con_t* _h, char* _s, db_res_t** _r)
 /*
 /*
  * Insert a row into table
  * Insert a row into table
  */
  */
-int bdb_insert(db_con_t* _h, db_key_t* _k, db_val_t* _v, int _n)
+int bdb_insert(db1_con_t* _h, db_key_t* _k, db_val_t* _v, int _n)
 {
 {
 	tbl_cache_p _tbc = NULL;
 	tbl_cache_p _tbc = NULL;
 	table_p _tp = NULL;
 	table_p _tp = NULL;
@@ -768,7 +768,7 @@ error:
  *   do Not specify any keys, or values, and _n <=0
  *   do Not specify any keys, or values, and _n <=0
  *
  *
  */
  */
-int bdb_delete(db_con_t* _h, db_key_t* _k, db_op_t* _op, db_val_t* _v, int _n)
+int bdb_delete(db1_con_t* _h, db_key_t* _k, db_op_t* _op, db_val_t* _v, int _n)
 {
 {
 	tbl_cache_p _tbc = NULL;
 	tbl_cache_p _tbc = NULL;
 	table_p _tp = NULL;
 	table_p _tp = NULL;
@@ -894,11 +894,11 @@ _bdb_delete_cursor -- called from bdb_delete when the query involves operators
   In this case, the keys _k are not the actually schema keys, so we need to 
   In this case, the keys _k are not the actually schema keys, so we need to 
   iterate via cursor to perform this operation.
   iterate via cursor to perform this operation.
 */
 */
-int _bdb_delete_cursor(db_con_t* _h, db_key_t* _k, db_op_t* _op, db_val_t* _v, int _n)
+int _bdb_delete_cursor(db1_con_t* _h, db_key_t* _k, db_op_t* _op, db_val_t* _v, int _n)
 {
 {
 	tbl_cache_p _tbc = NULL;
 	tbl_cache_p _tbc = NULL;
 	table_p _tp = NULL;
 	table_p _tp = NULL;
-	db_res_t* _r   = NULL;
+	db1_res_t* _r   = NULL;
 	char kbuf[MAX_ROW_SIZE];
 	char kbuf[MAX_ROW_SIZE];
 	char dbuf[MAX_ROW_SIZE];
 	char dbuf[MAX_ROW_SIZE];
 	int i, ret, klen=MAX_ROW_SIZE;
 	int i, ret, klen=MAX_ROW_SIZE;
@@ -936,7 +936,7 @@ int _bdb_delete_cursor(db_con_t* _h, db_key_t* _k, db_op_t* _op, db_val_t* _v, i
 		}
 		}
 	}
 	}
 	
 	
-	/* create an empty db_res_t which gets returned even if no result */
+	/* create an empty db1_res_t which gets returned even if no result */
 	_r = db_new_result();
 	_r = db_new_result();
 	if (!_r) 
 	if (!_r) 
 	{	LM_ERR("no memory for result \n");
 	{	LM_ERR("no memory for result \n");
@@ -944,7 +944,7 @@ int _bdb_delete_cursor(db_con_t* _h, db_key_t* _k, db_op_t* _op, db_val_t* _v, i
 	
 	
 	RES_ROW_N(_r) = 0;
 	RES_ROW_N(_r) = 0;
 	
 	
-	/* fill in the col part of db_res_t */
+	/* fill in the col part of db1_res_t */
 	if ((ret = bdb_get_columns(_tp, _r, 0, 0)) != 0) 
 	if ((ret = bdb_get_columns(_tp, _r, 0, 0)) != 0) 
 	{	LM_ERR("Error while getting column names\n");
 	{	LM_ERR("Error while getting column names\n");
 		goto error;
 		goto error;
@@ -970,7 +970,7 @@ int _bdb_delete_cursor(db_con_t* _h, db_key_t* _k, db_op_t* _op, db_val_t* _v, i
 		if(!strncasecmp((char*)key.data,"METADATA",8))
 		if(!strncasecmp((char*)key.data,"METADATA",8))
 			continue;
 			continue;
 		
 		
-		/*fill in the row part of db_res_t */
+		/*fill in the row part of db1_res_t */
 		if ((ret=bdb_convert_row( _r, dbuf, 0)) < 0) 
 		if ((ret=bdb_convert_row( _r, dbuf, 0)) < 0) 
 		{	LM_ERR("Error while converting row\n");
 		{	LM_ERR("Error while converting row\n");
 			goto error;
 			goto error;
@@ -1021,7 +1021,7 @@ error:
  * _uv: update values; col values that need to be commited
  * _uv: update values; col values that need to be commited
  * _un: number of rows to update
  * _un: number of rows to update
  */
  */
-int bdb_update(db_con_t* _con, db_key_t* _k, db_op_t* _op, db_val_t* _v,
+int bdb_update(db1_con_t* _con, db_key_t* _k, db_op_t* _op, db_val_t* _v,
 	      db_key_t* _uk, db_val_t* _uv, int _n, int _un)
 	      db_key_t* _uk, db_val_t* _uv, int _n, int _un)
 {
 {
 	char *c, *t;
 	char *c, *t;

+ 17 - 17
modules/db_berkeley/km_db_berkeley.h

@@ -31,65 +31,65 @@
 #ifndef _KM_BDB_H_
 #ifndef _KM_BDB_H_
 #define _KM_BDB_H_
 #define _KM_BDB_H_
 
 
-#include "../../db/db_con.h"
-#include "../../db/db_res.h"
-#include "../../db/db_key.h"
-#include "../../db/db_op.h"
-#include "../../db/db_val.h"
+#include "../../lib/srdb1/db_con.h"
+#include "../../lib/srdb1/db_res.h"
+#include "../../lib/srdb1/db_key.h"
+#include "../../lib/srdb1/db_op.h"
+#include "../../lib/srdb1/db_val.h"
 
 
 /* reloads the berkeley db */
 /* reloads the berkeley db */
 int bdb_reload(char* _n);
 int bdb_reload(char* _n);
 
 
-void bdb_check_reload(db_con_t* _con);
-int  bdb_use_table(db_con_t* _h, const str* _t);
+void bdb_check_reload(db1_con_t* _con);
+int  bdb_use_table(db1_con_t* _h, const str* _t);
 
 
 /*
 /*
  * Initialize database connection
  * Initialize database connection
  */
  */
-db_con_t* bdb_init(const str* _sqlurl);
+db1_con_t* bdb_init(const str* _sqlurl);
 
 
 
 
 /*
 /*
  * Close a database connection
  * Close a database connection
  */
  */
-void bdb_close(db_con_t* _h);
+void bdb_close(db1_con_t* _h);
 
 
 
 
 /*
 /*
  * Free all memory allocated by get_result
  * Free all memory allocated by get_result
  */
  */
-int bdb_free_query(db_con_t* _h, db_res_t* _r);
+int bdb_free_query(db1_con_t* _h, db1_res_t* _r);
 
 
 
 
 /*
 /*
  * Do a query
  * Do a query
  */
  */
-int bdb_query(db_con_t* _h, db_key_t* _k, db_op_t* _op, db_val_t* _v, 
-			db_key_t* _c, int _n, int _nc, db_key_t _o, db_res_t** _r);
+int bdb_query(db1_con_t* _h, db_key_t* _k, db_op_t* _op, db_val_t* _v, 
+			db_key_t* _c, int _n, int _nc, db_key_t _o, db1_res_t** _r);
 
 
 
 
 /*
 /*
  * Raw SQL query
  * Raw SQL query
  */
  */
-int bdb_raw_query(db_con_t* _h, char* _s, db_res_t** _r);
+int bdb_raw_query(db1_con_t* _h, char* _s, db1_res_t** _r);
 
 
 
 
 /*
 /*
  * Insert a row into table
  * Insert a row into table
  */
  */
-int bdb_insert(db_con_t* _h, db_key_t* _k, db_val_t* _v, int _n);
+int bdb_insert(db1_con_t* _h, db_key_t* _k, db_val_t* _v, int _n);
 
 
 
 
 /*
 /*
  * Delete a row from table
  * Delete a row from table
  */
  */
-int bdb_delete(db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v, int _n);
-int _bdb_delete_cursor(db_con_t* _h, db_key_t* _k, db_op_t* _op, db_val_t* _v, int _n);
+int bdb_delete(db1_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v, int _n);
+int _bdb_delete_cursor(db1_con_t* _h, db_key_t* _k, db_op_t* _op, db_val_t* _v, int _n);
 
 
 /*
 /*
  * Update a row in table
  * Update a row in table
  */
  */
-int bdb_update(db_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v,
+int bdb_update(db1_con_t* _h, db_key_t* _k, db_op_t* _o, db_val_t* _v,
 	      db_key_t* _uk, db_val_t* _uv, int _n, int _un);
 	      db_key_t* _uk, db_val_t* _uv, int _n, int _un);
 
 
 #endif
 #endif