#include "db_con.h"
#include <time.h>
#include "../str.h"


Go to the source code of this file.
Data Structures | |
| struct | db_val_t |
Defines | |
| #define | VAL_BIGINT(dv) ((dv)->val.ll_val) |
| #define | VAL_BITMAP(dv) ((dv)->val.bitmap_val) |
| #define | VAL_BLOB(dv) ((dv)->val.blob_val) |
| #define | VAL_DOUBLE(dv) ((dv)->val.double_val) |
| #define | VAL_FREE(dv) ((dv)->free) |
| #define | VAL_INT(dv) ((dv)->val.int_val) |
| #define | VAL_NULL(dv) ((dv)->nul) |
| #define | VAL_STR(dv) ((dv)->val.str_val) |
| #define | VAL_STRING(dv) ((dv)->val.string_val) |
| #define | VAL_TIME(dv) ((dv)->val.time_val) |
| #define | VAL_TYPE(dv) ((dv)->type) |
Enumerations | |
| enum | db_type_t { DB_INT, DB_BIGINT, DB_DOUBLE, DB_STRING, DB_STR, DB_DATETIME, DB_BLOB, DB_BITMAP } |
Functions | |
| int | db_str2val (const db_type_t _t, db_val_t *_v, const char *_s, const int _l, const unsigned int _cpy) |
| Convert a str to a db value. | |
| int | db_val2str (const db_con_t *_c, const db_val_t *_v, char *_s, int *_len) |
| Convert a numerical value to a string. | |
This file defines data structures that represents values in the database. Several datatypes are recognized and converted by the database API. Available types: DB_INT, DB_DOUBLE, DB_STRING, DB_STR, DB_DATETIME, DB_BLOB and DB_BITMAP It also provides some macros for convenient access to this values, and a function to convert a str to a value.
Definition in file db_val.h.
| #define VAL_BIGINT | ( | dv | ) | ((dv)->val.ll_val) |
Use this macro if you need to access the long long value in the db_val_t structure.
Definition at line 131 of file db_val.h.
Referenced by db_str2val(), and db_val2str().
| #define VAL_BITMAP | ( | dv | ) | ((dv)->val.bitmap_val) |
Use this macro if you need to access the bitmap value in the db_val_t structure.
Definition at line 167 of file db_val.h.
Referenced by convert_row(), db_oracle_val2bind(), db_val2str(), dbrow2info(), flat_db_insert(), get_all_db_ucontacts(), get_columns(), and valdata().
| #define VAL_BLOB | ( | dv | ) | ((dv)->val.blob_val) |
Use this macro if you need to access the blob value in the db_val_t structure.
Definition at line 161 of file db_val.h.
Referenced by bdb_str2val(), bdb_val2str(), convert_row(), db_free_row(), db_mysql_val2str(), db_oracle_val2bind(), db_postgres_str2val(), db_postgres_val2str(), db_str2val(), db_unixodbc_str2val(), db_unixodbc_val2str(), flat_db_insert(), and valdata().
| #define VAL_DOUBLE | ( | dv | ) | ((dv)->val.double_val) |
Use this macro if you need to access the double value in the db_val_t structure.
Definition at line 137 of file db_val.h.
Referenced by bdb_str2val(), bdb_val2str(), convert_row(), db_oracle_val2bind(), db_str2val(), db_val2str(), dbrow2info(), dbt_convert_row(), flat_db_insert(), get_columns(), and valdata().
| #define VAL_FREE | ( | dv | ) | ((dv)->free) |
Use this macro if you need to set/ get the free flag. A non-zero flag means that the corresponding cell in the database contains data that must be freed from the DB API.
Definition at line 119 of file db_val.h.
Referenced by bdb_str2val(), convert_row(), db_free_row(), db_postgres_str2val(), db_str2val(), and dbt_convert_row().
| #define VAL_INT | ( | dv | ) | ((dv)->val.int_val) |
Use this macro if you need to access the integer value in the db_val_t structure.
Definition at line 125 of file db_val.h.
Referenced by bdb_str2val(), bdb_val2str(), build_rule(), convert_row(), db_oracle_val2bind(), db_str2val(), db_table_version(), db_val2str(), dbrow2info(), dbt_convert_row(), dialog_update_db(), ds_load_db(), flat_db_insert(), generate_avps(), get_columns(), load_dialog_info_from_db(), load_user_carrier(), reload_address_table(), reload_gws_and_lcrs(), remove_dialog_from_db(), update_dialog_dbinfo(), and valdata().
| #define VAL_NULL | ( | dv | ) | ((dv)->nul) |
Use this macro if you need to set/get the null flag. A non-zero flag means that the corresponding cell in the database contains no data (a NULL value in MySQL terminology).
Definition at line 111 of file db_val.h.
Referenced by allow_trusted(), bdb_str2val(), bdb_val2str(), check_rule(), check_username(), convert_row(), create_socket_info(), db_build_userbl_tree(), db_free_row(), db_oracle_val2bind(), db_str2val(), db_table_version(), db_unixodbc_str2val(), db_val2str(), dbrow2info(), does_uri_exist(), generate_avps(), get_all_db_ucontacts(), get_ha1(), is_domain_local(), is_user_in(), load_dialog_info_from_db(), load_user_carrier(), match_res(), preload_udomain(), reload_address_table(), reload_domain_table(), reload_gws_and_lcrs(), reload_trusted_table(), remove_dialog_from_db(), testdb_udomain(), and update_dialog_dbinfo().
| #define VAL_STR | ( | dv | ) | ((dv)->val.str_val) |
Use this macro if you need to access the str structure in the db_val_t structure.
Definition at line 155 of file db_val.h.
Referenced by bdb_str2val(), bdb_val2str(), check_rule(), check_username(), convert_row(), create_socket_info(), db_build_userbl_tree(), db_free_row(), db_mysql_val2str(), db_oracle_val2bind(), db_postgres_val2str(), db_str2val(), db_table_version(), db_unixodbc_str2val(), db_unixodbc_val2str(), dbt_convert_row(), does_uri_exist(), ds_load_db(), flat_db_insert(), generate_avps(), get_ha1(), is_domain_local(), is_user_in(), load_user_carrier(), and valdata().
| #define VAL_STRING | ( | dv | ) | ((dv)->val.string_val) |
Use this macro if you need to access the string value in the db_val_t structure.
Definition at line 149 of file db_val.h.
Referenced by allow_trusted(), bdb_str2val(), bdb_val2str(), check_rule(), convert_row(), db_free_row(), db_mysql_val2str(), db_oracle_val2bind(), db_postgres_val2str(), db_str2val(), db_unixodbc_str2val(), db_unixodbc_val2str(), dbrow2info(), flat_db_insert(), generate_avps(), get_all_db_ucontacts(), match_res(), preload_udomain(), reload_address_table(), reload_domain_table(), reload_gws_and_lcrs(), reload_trusted_table(), testdb_udomain(), and valdata().
| #define VAL_TIME | ( | dv | ) | ((dv)->val.time_val) |
Use this macro if you need to access the time_t value in the db_val_t structure.
Definition at line 143 of file db_val.h.
Referenced by bdb_str2val(), bdb_val2str(), convert_row(), db_oracle_val2bind(), db_str2val(), db_val2str(), dbrow2info(), flat_db_insert(), and valdata().
| #define VAL_TYPE | ( | dv | ) | ((dv)->type) |
Useful macros for accessing attributes of db_val structure. All macros expect a reference to a db_val_t variable as parameter. Use this macro if you need to set/get the type of the value.
Definition at line 103 of file db_val.h.
Referenced by allow_trusted(), bdb_cmp_val(), bdb_str2val(), bdb_val2str(), check_rule(), check_username(), convert_row(), db_build_userbl_tree(), db_free_row(), db_mysql_val2str(), db_oracle_val2bind(), db_postgres_str2val(), db_postgres_val2str(), db_str2val(), db_table_version(), db_unixodbc_str2val(), db_unixodbc_val2str(), db_val2str(), dbt_cmp_val(), dbt_convert_row(), dialog_update_db(), does_uri_exist(), flat_db_insert(), get_ha1(), is_domain_local(), is_user_in(), load_user_carrier(), match_res(), reload_address_table(), reload_domain_table(), reload_gws_and_lcrs(), reload_trusted_table(), remove_dialog_from_db(), testdb_udomain(), update_dialog_dbinfo(), and valdata().
| enum db_type_t |
Each cell in a database table can be of a different type. To distinguish among these types, the db_type_t enumeration is used. Every value of the enumeration represents one datatype that is recognized by the database API.
| int db_str2val | ( | const db_type_t | _t, | |
| db_val_t * | _v, | |||
| const char * | _s, | |||
| const int | _l, | |||
| const unsigned int | _cpy | |||
| ) |
Convert a str to a db value.
Convert a str to a db value, does not copy strings if _cpy is zero
| _t | destination value type | |
| _v | destination value | |
| _s | source string | |
| _l | string length | |
| _cpy | when set to zero does not copy strings, otherwise copy strings |
| _t | destination value type | |
| _v | destination value | |
| _s | source string | |
| _l | string length | |
| _cpy | when set to zero does not copy strings, otherwise copy strings |
Definition at line 45 of file db_val.c.
References DB_BIGINT, DB_BITMAP, DB_BLOB, DB_DATETIME, DB_DOUBLE, DB_INT, DB_STR, db_str2double(), db_str2int(), db_str2longlong(), db_str2time(), DB_STRING, LM_DBG, LM_ERR, NULL, pkg_malloc, s, _str::s, VAL_BIGINT, VAL_BLOB, VAL_DOUBLE, VAL_FREE, VAL_INT, VAL_NULL, VAL_STR, VAL_STRING, VAL_TIME, and VAL_TYPE.
Referenced by db_mysql_convert_row(), db_postgres_str2val(), and db_unixodbc_str2val().
Convert a numerical value to a string.
Convert a numerical value to a string, used when converting result from a query. Implement common functionality needed from the databases, does parameter checking.
| _c | database connection | |
| _v | source value | |
| _s | target string | |
| _len | target string length |
Definition at line 202 of file db_val.c.
References DB_BIGINT, DB_BITMAP, DB_DATETIME, DB_DOUBLE, db_double2str(), DB_INT, db_int2str(), db_longlong2str(), db_time2str(), LM_ERR, snprintf, VAL_BIGINT, VAL_BITMAP, VAL_DOUBLE, VAL_INT, VAL_NULL, VAL_TIME, and VAL_TYPE.
Referenced by db_mysql_val2str(), db_postgres_val2str(), and db_unixodbc_val2str().
1.5.6