Browse Source

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

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.
Jan Janak 16 years ago
parent
commit
70fc66d970
4 changed files with 34 additions and 34 deletions
  1. 2 2
      lib/srdb1/db.c
  2. 3 3
      lib/srdb1/db_row.c
  3. 21 21
      lib/srdb1/db_val.c
  4. 8 8
      lib/srdb1/db_val.h

+ 2 - 2
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);
 	str tmp1 = str_init(TABLENAME_COLUMN);
 	key[0] = &tmp1;
 	key[0] = &tmp1;
 
 
-	VAL_TYPE(val) = DB_STR;
+	VAL_TYPE(val) = DB1_STR;
 	VAL_NULL(val) = 0;
 	VAL_NULL(val) = 0;
 	VAL_STR(val) = *table;
 	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));
 	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 "
 		LM_ERR("invalid type (%d) or nul (%d) version "
 			"columns for %.*s\n", VAL_TYPE(ver), VAL_NULL(ver),
 			"columns for %.*s\n", VAL_TYPE(ver), VAL_NULL(ver),
 			table->len, ZSW(table->s));
 			table->len, ZSW(table->s));

+ 3 - 3
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++) {
 	for (col = 0; col < ROW_N(_r); col++) {
 		_val = &(ROW_VALUES(_r)[col]);
 		_val = &(ROW_VALUES(_r)[col]);
 		switch (VAL_TYPE(_val)) {
 		switch (VAL_TYPE(_val)) {
-			case DB_STRING:
+			case DB1_STRING:
 				if ( (!VAL_NULL(_val)) && VAL_FREE(_val)) {
 				if ( (!VAL_NULL(_val)) && VAL_FREE(_val)) {
 					LM_DBG("free VAL_STRING[%d] '%s' at %p\n", col,
 					LM_DBG("free VAL_STRING[%d] '%s' at %p\n", col,
 							(char *)VAL_STRING(_val),
 							(char *)VAL_STRING(_val),
@@ -70,7 +70,7 @@ inline int db_free_row(db_row_t* _r)
 					VAL_STRING(_val) = NULL;
 					VAL_STRING(_val) = NULL;
 				}
 				}
 				break;
 				break;
-			case DB_STR:
+			case DB1_STR:
 				if ( (!VAL_NULL(_val)) && VAL_FREE(_val)) {
 				if ( (!VAL_NULL(_val)) && VAL_FREE(_val)) {
 					LM_DBG("free VAL_STR[%d] '%.*s' at %p\n", col,
 					LM_DBG("free VAL_STR[%d] '%.*s' at %p\n", col,
 							VAL_STR(_val).len,
 							VAL_STR(_val).len,
@@ -79,7 +79,7 @@ inline int db_free_row(db_row_t* _r)
 					VAL_STR(_val).s = NULL;
 					VAL_STR(_val).s = NULL;
 				}
 				}
 				break;
 				break;
-			case DB_BLOB:
+			case DB1_BLOB:
 				if ( (!VAL_NULL(_val)) && VAL_FREE(_val)) {
 				if ( (!VAL_NULL(_val)) && VAL_FREE(_val)) {
 					LM_DBG("free VAL_BLOB[%d] at %p\n", col, VAL_BLOB(_val).s);
 					LM_DBG("free VAL_BLOB[%d] at %p\n", col, VAL_BLOB(_val).s);
 					pkg_free(VAL_BLOB(_val).s);
 					pkg_free(VAL_BLOB(_val).s);

+ 21 - 21
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;
 	VAL_NULL(_v) = 0;
 
 
 	switch(_t) {
 	switch(_t) {
-	case DB_INT:
+	case DB1_INT:
 		LM_DBG("converting INT [%s]\n", _s);
 		LM_DBG("converting INT [%s]\n", _s);
 		if (db_str2int(_s, &VAL_INT(_v)) < 0) {
 		if (db_str2int(_s, &VAL_INT(_v)) < 0) {
 			LM_ERR("error while converting integer value from string\n");
 			LM_ERR("error while converting integer 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_DBG("converting BIGINT [%s]\n", _s);
 		LM_DBG("converting BIGINT [%s]\n", _s);
 		if (db_str2longlong(_s, &VAL_BIGINT(_v)) < 0) {
 		if (db_str2longlong(_s, &VAL_BIGINT(_v)) < 0) {
 			LM_ERR("error while converting big integer value from string\n");
 			LM_ERR("error while converting big integer value from string\n");
 			return -3;
 			return -3;
 		} else {
 		} else {
-			VAL_TYPE(_v) = DB_BIGINT;
+			VAL_TYPE(_v) = DB1_BIGINT;
 			return 0;
 			return 0;
 		}
 		}
 		break;
 		break;
 
 
-	case DB_BITMAP:
+	case DB1_BITMAP:
 		LM_DBG("converting BITMAP [%s]\n", _s);
 		LM_DBG("converting BITMAP [%s]\n", _s);
 		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 -4;
 			return -4;
 		} else {
 		} else {
-			VAL_TYPE(_v) = DB_BITMAP;
+			VAL_TYPE(_v) = DB1_BITMAP;
 			return 0;
 			return 0;
 		}
 		}
 		break;
 		break;
 	
 	
-	case DB_DOUBLE:
+	case DB1_DOUBLE:
 		LM_DBG("converting DOUBLE [%s]\n", _s);
 		LM_DBG("converting DOUBLE [%s]\n", _s);
 		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 -5;
 			return -5;
 		} else {
 		} else {
-			VAL_TYPE(_v) = DB_DOUBLE;
+			VAL_TYPE(_v) = DB1_DOUBLE;
 			return 0;
 			return 0;
 		}
 		}
 		break;
 		break;
 
 
-	case DB_STRING:
+	case DB1_STRING:
 		LM_DBG("converting STRING [%s]\n", _s);
 		LM_DBG("converting STRING [%s]\n", _s);
 
 
 		if (_cpy == 0) {
 		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_FREE(_v) = 1;
 		}
 		}
 
 
-		VAL_TYPE(_v) = DB_STRING;
+		VAL_TYPE(_v) = DB1_STRING;
 		return 0;
 		return 0;
 
 
-	case DB_STR:
+	case DB1_STR:
 		LM_DBG("converting STR [%.*s]\n", _l, _s);
 		LM_DBG("converting STR [%.*s]\n", _l, _s);
 
 
 		if (_cpy == 0) {
 		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_STR(_v).len = _l;
-		VAL_TYPE(_v) = DB_STR;
+		VAL_TYPE(_v) = DB1_STR;
 		return 0;
 		return 0;
 
 
-	case DB_DATETIME:
+	case DB1_DATETIME:
 		LM_DBG("converting DATETIME [%s]\n", _s);
 		LM_DBG("converting DATETIME [%s]\n", _s);
 		if (db_str2time(_s, &VAL_TIME(_v)) < 0) {
 		if (db_str2time(_s, &VAL_TIME(_v)) < 0) {
 			LM_ERR("error while converting datetime value from string\n");
 			LM_ERR("error while converting datetime value from string\n");
 			return -8;
 			return -8;
 		} else {
 		} else {
-			VAL_TYPE(_v) = DB_DATETIME;
+			VAL_TYPE(_v) = DB1_DATETIME;
 			return 0;
 			return 0;
 		}
 		}
 		break;
 		break;
 
 
-	case DB_BLOB:
+	case DB1_BLOB:
 		LM_DBG("converting BLOB [%.*s]\n", _l, _s);
 		LM_DBG("converting BLOB [%.*s]\n", _l, _s);
 
 
 		if (_cpy == 0) {
 		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_BLOB(_v).len = _l;
-		VAL_TYPE(_v) = DB_BLOB;
+		VAL_TYPE(_v) = DB1_BLOB;
 		return 0;
 		return 0;
 	}
 	}
 	return -10;
 	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)) {
 	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 string to int\n");
 			LM_ERR("error while converting string to int\n");
 			return -2;
 			return -2;
@@ -225,7 +225,7 @@ int db_val2str(const db1_con_t* _c, const db_val_t* _v, char* _s, int* _len)
 		}
 		}
 		break;
 		break;
 
 
-	case DB_BIGINT:
+	case DB1_BIGINT:
 		if (db_longlong2str(VAL_BIGINT(_v), _s, _len) < 0) {
 		if (db_longlong2str(VAL_BIGINT(_v), _s, _len) < 0) {
 			LM_ERR("error while converting string to big int\n");
 			LM_ERR("error while converting string to big int\n");
 			return -3;
 			return -3;
@@ -234,7 +234,7 @@ int db_val2str(const db1_con_t* _c, const db_val_t* _v, char* _s, int* _len)
 		}
 		}
 		break;
 		break;
 
 
-	case DB_BITMAP:
+	case DB1_BITMAP:
 		if (db_int2str(VAL_BITMAP(_v), _s, _len) < 0) {
 		if (db_int2str(VAL_BITMAP(_v), _s, _len) < 0) {
 			LM_ERR("error while converting string to int\n");
 			LM_ERR("error while converting string to int\n");
 			return -4;
 			return -4;
@@ -243,7 +243,7 @@ int db_val2str(const db1_con_t* _c, const 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 string to double\n");
 			LM_ERR("error while converting string to double\n");
 			return -5;
 			return -5;
@@ -252,7 +252,7 @@ int db_val2str(const db1_con_t* _c, const db_val_t* _v, char* _s, int* _len)
 		}
 		}
 		break;
 		break;
 
 
-	case DB_DATETIME:
+	case DB1_DATETIME:
 		if (db_time2str(VAL_TIME(_v), _s, _len) < 0) {
 		if (db_time2str(VAL_TIME(_v), _s, _len) < 0) {
 			LM_ERR("failed to convert string to time_t\n");
 			LM_ERR("failed to convert string to time_t\n");
 			return -8;
 			return -8;

+ 8 - 8
lib/srdb1/db_val.h

@@ -49,14 +49,14 @@
  * API.
  * API.
  */
  */
 typedef enum {
 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;
 } db_type_t;