[PATCH] Database type enum values (such as DB_INT) renamed to DB1_*.

Jan Janak jan at iptel.org
Thu Feb 12 20:21:15 CET 2009


Both database libraries define the same database value type names. We
need to rename them in one of the libraries so that both libraries can
be used at the same time. Here we chose to rename the enum values in
libsrdb1 to DB1_*. The same change needs to be done in SER modules
using this version of the database library.
---
 lib/srdb1/db.c     |    4 ++--
 lib/srdb1/db_row.c |    6 +++---
 lib/srdb1/db_val.c |   42 +++++++++++++++++++++---------------------
 lib/srdb1/db_val.h |   16 ++++++++--------
 4 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/lib/srdb1/db.c b/lib/srdb1/db.c
index c705aea..49f08a8 100644
--- a/lib/srdb1/db.c
+++ b/lib/srdb1/db.c
@@ -356,7 +356,7 @@ int db_table_version(const db_func_t* dbf, db1_con_t* connection, const str* tab
 	str tmp1 = str_init(TABLENAME_COLUMN);
 	key[0] = &tmp1;
 
-	VAL_TYPE(val) = DB_STR;
+	VAL_TYPE(val) = DB1_STR;
 	VAL_NULL(val) = 0;
 	VAL_STR(val) = *table;
 	
@@ -382,7 +382,7 @@ int db_table_version(const db_func_t* dbf, db1_con_t* connection, const str* tab
 	}
 
 	ver = ROW_VALUES(RES_ROWS(res));
-	if ( VAL_TYPE(ver)!=DB_INT || VAL_NULL(ver) ) {
+	if ( VAL_TYPE(ver)!=DB1_INT || VAL_NULL(ver) ) {
 		LM_ERR("invalid type (%d) or nul (%d) version "
 			"columns for %.*s\n", VAL_TYPE(ver), VAL_NULL(ver),
 			table->len, ZSW(table->s));
diff --git a/lib/srdb1/db_row.c b/lib/srdb1/db_row.c
index 449f3fd..83aca8f 100644
--- a/lib/srdb1/db_row.c
+++ b/lib/srdb1/db_row.c
@@ -61,7 +61,7 @@ inline int db_free_row(db_row_t* _r)
 	for (col = 0; col < ROW_N(_r); col++) {
 		_val = &(ROW_VALUES(_r)[col]);
 		switch (VAL_TYPE(_val)) {
-			case DB_STRING:
+			case DB1_STRING:
 				if ( (!VAL_NULL(_val)) && VAL_FREE(_val)) {
 					LM_DBG("free VAL_STRING[%d] '%s' at %p\n", col,
 							(char *)VAL_STRING(_val),
@@ -70,7 +70,7 @@ inline int db_free_row(db_row_t* _r)
 					VAL_STRING(_val) = NULL;
 				}
 				break;
-			case DB_STR:
+			case DB1_STR:
 				if ( (!VAL_NULL(_val)) && VAL_FREE(_val)) {
 					LM_DBG("free VAL_STR[%d] '%.*s' at %p\n", col,
 							VAL_STR(_val).len,
@@ -79,7 +79,7 @@ inline int db_free_row(db_row_t* _r)
 					VAL_STR(_val).s = NULL;
 				}
 				break;
-			case DB_BLOB:
+			case DB1_BLOB:
 				if ( (!VAL_NULL(_val)) && VAL_FREE(_val)) {
 					LM_DBG("free VAL_BLOB[%d] at %p\n", col, VAL_BLOB(_val).s);
 					pkg_free(VAL_BLOB(_val).s);
diff --git a/lib/srdb1/db_val.c b/lib/srdb1/db_val.c
index 2d6ebc9..88a7a4f 100644
--- a/lib/srdb1/db_val.c
+++ b/lib/srdb1/db_val.c
@@ -69,51 +69,51 @@ int db_str2val(const db_type_t _t, db_val_t* _v, const char* _s, const int _l,
 	VAL_NULL(_v) = 0;
 
 	switch(_t) {
-	case DB_INT:
+	case DB1_INT:
 		LM_DBG("converting INT [%s]\n", _s);
 		if (db_str2int(_s, &VAL_INT(_v)) < 0) {
 			LM_ERR("error while converting integer value from string\n");
 			return -2;
 		} else {
-			VAL_TYPE(_v) = DB_INT;
+			VAL_TYPE(_v) = DB1_INT;
 			return 0;
 		}
 		break;
 
-	case DB_BIGINT:
+	case DB1_BIGINT:
 		LM_DBG("converting BIGINT [%s]\n", _s);
 		if (db_str2longlong(_s, &VAL_BIGINT(_v)) < 0) {
 			LM_ERR("error while converting big integer value from string\n");
 			return -3;
 		} else {
-			VAL_TYPE(_v) = DB_BIGINT;
+			VAL_TYPE(_v) = DB1_BIGINT;
 			return 0;
 		}
 		break;
 
-	case DB_BITMAP:
+	case DB1_BITMAP:
 		LM_DBG("converting BITMAP [%s]\n", _s);
 		if (db_str2int(_s, &VAL_INT(_v)) < 0) {
 			LM_ERR("error while converting bitmap value from string\n");
 			return -4;
 		} else {
-			VAL_TYPE(_v) = DB_BITMAP;
+			VAL_TYPE(_v) = DB1_BITMAP;
 			return 0;
 		}
 		break;
 	
-	case DB_DOUBLE:
+	case DB1_DOUBLE:
 		LM_DBG("converting DOUBLE [%s]\n", _s);
 		if (db_str2double(_s, &VAL_DOUBLE(_v)) < 0) {
 			LM_ERR("error while converting double value from string\n");
 			return -5;
 		} else {
-			VAL_TYPE(_v) = DB_DOUBLE;
+			VAL_TYPE(_v) = DB1_DOUBLE;
 			return 0;
 		}
 		break;
 
-	case DB_STRING:
+	case DB1_STRING:
 		LM_DBG("converting STRING [%s]\n", _s);
 
 		if (_cpy == 0) {
@@ -130,10 +130,10 @@ int db_str2val(const db_type_t _t, db_val_t* _v, const char* _s, const int _l,
 			VAL_FREE(_v) = 1;
 		}
 
-		VAL_TYPE(_v) = DB_STRING;
+		VAL_TYPE(_v) = DB1_STRING;
 		return 0;
 
-	case DB_STR:
+	case DB1_STR:
 		LM_DBG("converting STR [%.*s]\n", _l, _s);
 
 		if (_cpy == 0) {
@@ -150,21 +150,21 @@ int db_str2val(const db_type_t _t, db_val_t* _v, const char* _s, const int _l,
 		}
 
 		VAL_STR(_v).len = _l;
-		VAL_TYPE(_v) = DB_STR;
+		VAL_TYPE(_v) = DB1_STR;
 		return 0;
 
-	case DB_DATETIME:
+	case DB1_DATETIME:
 		LM_DBG("converting DATETIME [%s]\n", _s);
 		if (db_str2time(_s, &VAL_TIME(_v)) < 0) {
 			LM_ERR("error while converting datetime value from string\n");
 			return -8;
 		} else {
-			VAL_TYPE(_v) = DB_DATETIME;
+			VAL_TYPE(_v) = DB1_DATETIME;
 			return 0;
 		}
 		break;
 
-	case DB_BLOB:
+	case DB1_BLOB:
 		LM_DBG("converting BLOB [%.*s]\n", _l, _s);
 
 		if (_cpy == 0) {
@@ -181,7 +181,7 @@ int db_str2val(const db_type_t _t, db_val_t* _v, const char* _s, const int _l,
 		}
 
 		VAL_BLOB(_v).len = _l;
-		VAL_TYPE(_v) = DB_BLOB;
+		VAL_TYPE(_v) = DB1_BLOB;
 		return 0;
 	}
 	return -10;
@@ -216,7 +216,7 @@ int db_val2str(const db1_con_t* _c, const db_val_t* _v, char* _s, int* _len)
 	}
 	
 	switch(VAL_TYPE(_v)) {
-	case DB_INT:
+	case DB1_INT:
 		if (db_int2str(VAL_INT(_v), _s, _len) < 0) {
 			LM_ERR("error while converting string to int\n");
 			return -2;
@@ -225,7 +225,7 @@ int db_val2str(const db1_con_t* _c, const db_val_t* _v, char* _s, int* _len)
 		}
 		break;
 
-	case DB_BIGINT:
+	case DB1_BIGINT:
 		if (db_longlong2str(VAL_BIGINT(_v), _s, _len) < 0) {
 			LM_ERR("error while converting string to big int\n");
 			return -3;
@@ -234,7 +234,7 @@ int db_val2str(const db1_con_t* _c, const db_val_t* _v, char* _s, int* _len)
 		}
 		break;
 
-	case DB_BITMAP:
+	case DB1_BITMAP:
 		if (db_int2str(VAL_BITMAP(_v), _s, _len) < 0) {
 			LM_ERR("error while converting string to int\n");
 			return -4;
@@ -243,7 +243,7 @@ int db_val2str(const db1_con_t* _c, const db_val_t* _v, char* _s, int* _len)
 		}
 		break;
 
-	case DB_DOUBLE:
+	case DB1_DOUBLE:
 		if (db_double2str(VAL_DOUBLE(_v), _s, _len) < 0) {
 			LM_ERR("error while converting string to double\n");
 			return -5;
@@ -252,7 +252,7 @@ int db_val2str(const db1_con_t* _c, const db_val_t* _v, char* _s, int* _len)
 		}
 		break;
 
-	case DB_DATETIME:
+	case DB1_DATETIME:
 		if (db_time2str(VAL_TIME(_v), _s, _len) < 0) {
 			LM_ERR("failed to convert string to time_t\n");
 			return -8;
diff --git a/lib/srdb1/db_val.h b/lib/srdb1/db_val.h
index 3e56c0b..a8133c5 100644
--- a/lib/srdb1/db_val.h
+++ b/lib/srdb1/db_val.h
@@ -49,14 +49,14 @@
  * API.
  */
 typedef enum {
-	DB_INT,        /**< represents an 32 bit integer number      */
-	DB_BIGINT,     /**< represents an 64 bit integer number      */
-	DB_DOUBLE,     /**< represents a floating point number       */
-	DB_STRING,     /**< represents a zero terminated const char* */
-	DB_STR,        /**< represents a string of 'str' type        */
-	DB_DATETIME,   /**< represents date and time                 */
-	DB_BLOB,       /**< represents a large binary object         */
-	DB_BITMAP      /**< an one-dimensional array of 32 flags     */
+	DB1_INT,        /**< represents an 32 bit integer number      */
+	DB1_BIGINT,     /**< represents an 64 bit integer number      */
+	DB1_DOUBLE,     /**< represents a floating point number       */
+	DB1_STRING,     /**< represents a zero terminated const char* */
+	DB1_STR,        /**< represents a string of 'str' type        */
+	DB1_DATETIME,   /**< represents date and time                 */
+	DB1_BLOB,       /**< represents a large binary object         */
+	DB1_BITMAP      /**< an one-dimensional array of 32 flags     */
 } db_type_t;
 
 
-- 
1.5.6.5


--7ZAtKRhVyVSsbBD2
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="0006-Renamed-type-names-DB_-DB1_-in-comments-and-doc.patch"



More information about the sr-dev mailing list