| Asterisk - The Open Source Telephony Project GIT-master-27fb039
    | 
odbc+odbc plugin for portable configuration engine More...
#include "asterisk.h"#include "asterisk/file.h"#include "asterisk/channel.h"#include "asterisk/pbx.h"#include "asterisk/config.h"#include "asterisk/module.h"#include "asterisk/lock.h"#include "asterisk/res_odbc.h"#include "asterisk/utils.h"#include "asterisk/stringfields.h"
Go to the source code of this file.
| Data Structures | |
| struct | config_odbc_obj | 
| struct | custom_prepare_struct | 
| struct | update2_prepare_struct | 
| Macros | |
| #define | CHECK_SIZE(n) | 
| #define | ENCODE_CHUNK(buffer, s) | 
| #define | SQL_BUF_SIZE 1024 | 
| #define | warn_length(col, size) ast_log(LOG_WARNING, "Realtime table %s@%s: column '%s' is not long enough to contain realtime data (needs %d)\n", table, database, col->name, size) | 
| #define | warn_type(col, type) ast_log(LOG_WARNING, "Realtime table %s@%s: column '%s' is of the incorrect type (%d) to contain the required realtime data\n", table, database, col->name, col->type) | 
| #define | WARN_TYPE_OR_LENGTH(n) | 
| Functions | |
| static void | __reg_module (void) | 
| static void | __unreg_module (void) | 
| struct ast_module * | AST_MODULE_SELF_SYM (void) | 
| AST_THREADSTORAGE_CUSTOM_SCOPE (rowdata_buf, NULL, ast_free_ptr, static) | |
| AST_THREADSTORAGE_CUSTOM_SCOPE (sql_buf, NULL, ast_free_ptr, static) | |
| static struct ast_config * | config_odbc (const char *database, const char *table, const char *file, struct ast_config *cfg, struct ast_flags flags, const char *sugg_incl, const char *who_asked) | 
| static SQLHSTMT | config_odbc_prepare (struct odbc_obj *obj, void *data) | 
| static SQLHSTMT | custom_prepare (struct odbc_obj *obj, void *data) | 
| static void | decode_chunk (char *chunk) | 
| static int | destroy_odbc (const char *database, const char *table, const char *keyfield, const char *lookup, const struct ast_variable *fields) | 
| Execute an DELETE query. | |
| static int | is_text (const struct odbc_cache_columns *column) | 
| static SQLHSTMT | length_determination_odbc_prepare (struct odbc_obj *obj, void *data) | 
| static void | load_config (const char *filename) | 
| static int | load_module (void) | 
| static struct ast_config * | realtime_multi_odbc (const char *database, const char *table, const struct ast_variable *fields) | 
| Execute an Select query and return ast_config list. | |
| static struct ast_variable * | realtime_odbc (const char *database, const char *table, const struct ast_variable *fields) | 
| Execute an SQL query and return ast_variable list. | |
| static int | reload_module (void) | 
| static int | require_odbc (const char *database, const char *table, va_list ap) | 
| static int | store_odbc (const char *database, const char *table, const struct ast_variable *fields) | 
| Execute an INSERT query. | |
| static int | unload_module (void) | 
| static int | unload_odbc (const char *a, const char *b) | 
| static int | update2_odbc (const char *database, const char *table, const struct ast_variable *lookup_fields, const struct ast_variable *update_fields) | 
| Execute an UPDATE query. | |
| static SQLHSTMT | update2_prepare (struct odbc_obj *obj, void *data) | 
| static int | update_odbc (const char *database, const char *table, const char *keyfield, const char *lookup, const struct ast_variable *fields) | 
| Execute an UPDATE query. | |
| Variables | |
| static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Realtime ODBC configuration" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_REALTIME_DRIVER, .requires = "extconfig,res_odbc", } | 
| static const struct ast_module_info * | ast_module_info = &__mod_info | 
| static struct ast_config_engine | odbc_engine | 
| static int | order_multi_row_results_by_initial_column = 1 | 
| static const char * | res_config_odbc_conf = "res_config_odbc.conf" | 
odbc+odbc plugin for portable configuration engine
Definition in file res_config_odbc.c.
| #define CHECK_SIZE | ( | n | ) | 
| #define ENCODE_CHUNK | ( | buffer, | |
| s | |||
| ) | 
Definition at line 68 of file res_config_odbc.c.
| #define SQL_BUF_SIZE 1024 | 
Initial SQL query buffer size to allocate.
Definition at line 50 of file res_config_odbc.c.
| #define warn_length | ( | col, | |
| size | |||
| ) | ast_log(LOG_WARNING, "Realtime table %s@%s: column '%s' is not long enough to contain realtime data (needs %d)\n", table, database, col->name, size) | 
Definition at line 1083 of file res_config_odbc.c.
| #define warn_type | ( | col, | |
| type | |||
| ) | ast_log(LOG_WARNING, "Realtime table %s@%s: column '%s' is of the incorrect type (%d) to contain the required realtime data\n", table, database, col->name, col->type) | 
Definition at line 1084 of file res_config_odbc.c.
| #define WARN_TYPE_OR_LENGTH | ( | n | ) | 
| 
 | static | 
Definition at line 1312 of file res_config_odbc.c.
| 
 | static | 
Definition at line 1312 of file res_config_odbc.c.
| struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) | 
Definition at line 1312 of file res_config_odbc.c.
| AST_THREADSTORAGE_CUSTOM_SCOPE | ( | rowdata_buf | , | 
| NULL | , | ||
| ast_free_ptr | , | ||
| static | |||
| ) | 
| AST_THREADSTORAGE_CUSTOM_SCOPE | ( | sql_buf | , | 
| NULL | , | ||
| ast_free_ptr | , | ||
| static | |||
| ) | 
| 
 | static | 
Definition at line 951 of file res_config_odbc.c.
References ast_category_append(), ast_category_new_dynamic, ast_config_get_current_category(), ast_config_internal_load(), ast_free, ast_log, ast_malloc, ast_odbc_prepare_and_execute(), ast_odbc_release_obj(), ast_odbc_request_obj2, ast_str_append(), ast_str_buffer(), ast_str_set(), ast_str_thread_get(), ast_variable_append(), ast_variable_new, config_odbc_obj::cat_metric, config_odbc_obj::category, config_odbc_prepare(), last, length_determination_odbc_prepare(), LOG_NOTICE, LOG_WARNING, NULL, res_config_odbc_conf, RES_ODBC_CONNECTED, config_odbc_obj::sql, SQL_BUF_SIZE, config_odbc_obj::var_name, config_odbc_obj::var_val, and config_odbc_obj::var_val_size.
| 
 | static | 
Definition at line 924 of file res_config_odbc.c.
References ast_odbc_prepare(), ast_verb, config_odbc_obj::cat_metric, config_odbc_obj::category, odbc_obj::con, config_odbc_obj::err, NULL, config_odbc_obj::sql, config_odbc_obj::var_name, config_odbc_obj::var_val, and config_odbc_obj::var_val_size.
Referenced by config_odbc().
| 
 | static | 
Definition at line 104 of file res_config_odbc.c.
References ast_debug, ast_log, ast_odbc_prepare(), ast_odbc_print_errors(), ast_string_field_set, ast_strlen_zero(), odbc_obj::con, ENCODE_CHUNK, encoding, custom_prepare_struct::encoding, custom_prepare_struct::extra, custom_prepare_struct::fields, LOG_WARNING, ast_variable::name, ast_variable::next, NULL, custom_prepare_struct::skip, custom_prepare_struct::sql, and ast_variable::value.
Referenced by destroy_odbc(), realtime_multi_odbc(), realtime_odbc(), store_odbc(), and update_odbc().
| 
 | static | 
Definition at line 88 of file res_config_odbc.c.
Referenced by realtime_multi_odbc(), and realtime_odbc().
| 
 | static | 
Execute an DELETE query.
| database | |
| table | |
| keyfield | where clause field | 
| lookup | value of field for where clause | 
| fields | list containing one or more field/value set(s) | 
Delete a row from a database table, prepare the sql statement using keyfield and lookup control the number of records to change. Additional params to match rows are stored in ap list. Sub-in the values to the prepared statement and execute it.
| -1 | on failure | 
Definition at line 834 of file res_config_odbc.c.
References ast_log, ast_odbc_prepare_and_execute(), ast_odbc_release_obj(), ast_odbc_request_obj2, ast_str_append(), ast_str_buffer(), ast_str_set(), ast_str_thread_get(), ast_string_field_free_memory, ast_string_field_init, custom_prepare(), custom_prepare_struct::extra, custom_prepare_struct::fields, LOG_WARNING, ast_variable::name, ast_variable::next, RES_ODBC_CONNECTED, custom_prepare_struct::sql, and SQL_BUF_SIZE.
| 
 | inlinestatic | 
Definition at line 98 of file res_config_odbc.c.
References odbc_cache_columns::type.
Referenced by update_odbc().
| 
 | static | 
Definition at line 900 of file res_config_odbc.c.
References ast_odbc_prepare(), ast_verb, odbc_obj::con, config_odbc_obj::err, NULL, config_odbc_obj::sql, and config_odbc_obj::var_val_size.
Referenced by config_odbc().
| 
 | static | 
Definition at line 1262 of file res_config_odbc.c.
References ast_config_destroy(), ast_config_load, ast_log, ast_true(), ast_variable_retrieve(), config, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEMISSING, LOG_WARNING, and order_multi_row_results_by_initial_column.
| 
 | static | 
Definition at line 1284 of file res_config_odbc.c.
References ast_config_engine_register(), load_config(), odbc_engine, and res_config_odbc_conf.
| 
 | static | 
Execute an Select query and return ast_config list.
| database | |
| table | |
| fields | list containing one or more field/operator/value set. | 
Select database and preform query on table, prepare the sql statement Sub-in the values to the prepared statement and execute it. Execute this prepared query against several ODBC connected databases. Return results as an ast_config variable.
| NULL | on failure | 
Definition at line 350 of file res_config_odbc.c.
References ast_category_append(), ast_category_destroy(), ast_category_new_anonymous, ast_category_rename(), ast_config_new(), ast_log, ast_odbc_backslash_is_escape(), ast_odbc_prepare_and_execute(), ast_odbc_release_obj(), ast_odbc_request_obj2, ast_str_append(), ast_str_buffer(), ast_str_make_space, ast_str_reset(), ast_str_set(), ast_str_size(), ast_str_strlen(), ast_str_thread_get(), ast_str_update(), ast_strdupa, ast_string_field_free_memory, ast_string_field_init, ast_strip(), ast_strlen_zero(), ast_variable_append(), ast_variable_new, custom_prepare(), decode_chunk(), custom_prepare_struct::fields, indicator, LOG_WARNING, ast_variable::name, ast_variable::next, NULL, order_multi_row_results_by_initial_column, RES_ODBC_CONNECTED, S_OR, custom_prepare_struct::sql, SQL_BUF_SIZE, strcasestr(), strsep(), and var.
| 
 | static | 
Execute an SQL query and return ast_variable list.
| database | |
| table | |
| fields | list containing one or more field/operator/value set. | 
Select database and preform query on table, prepare the sql statement Sub-in the values to the prepared statement and execute it. Return results as a ast_variable list.
| NULL | on failure | 
Definition at line 174 of file res_config_odbc.c.
References ast_log, ast_odbc_backslash_is_escape(), ast_odbc_prepare_and_execute(), ast_odbc_release_obj(), ast_odbc_request_obj2, ast_str_append(), ast_str_buffer(), ast_str_make_space, ast_str_reset(), ast_str_set(), ast_str_size(), ast_str_strlen(), ast_str_thread_get(), ast_str_update(), ast_string_field_free_memory, ast_string_field_init, ast_strip(), ast_strlen_zero(), ast_variable_new, ast_variables_destroy(), CONFIG_RT_NOT_FOUND, custom_prepare(), decode_chunk(), custom_prepare_struct::fields, indicator, LOG_ERROR, LOG_WARNING, ast_variable::name, ast_variable::next, NULL, RES_ODBC_CONNECTED, S_OR, custom_prepare_struct::sql, SQL_BUF_SIZE, strcasestr(), strsep(), and var.
| 
 | static | 
Definition at line 1293 of file res_config_odbc.c.
References load_config(), and res_config_odbc_conf.
| 
 | static | 
Definition at line 1086 of file res_config_odbc.c.
References ast_log, ast_odbc_find_table(), ast_rq_is_int(), AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, CHECK_SIZE, odbc_cache_tables::columns, odbc_cache_columns::list, LOG_WARNING, odbc_cache_columns::name, RQ_CHAR, RQ_DATE, RQ_DATETIME, RQ_FLOAT, RQ_INTEGER1, RQ_INTEGER2, RQ_INTEGER3, RQ_INTEGER4, RQ_INTEGER8, RQ_UINTEGER1, RQ_UINTEGER2, RQ_UINTEGER3, RQ_UINTEGER4, RQ_UINTEGER8, odbc_cache_columns::size, odbc_cache_tables::table, type, odbc_cache_columns::type, warn_length, warn_type, and WARN_TYPE_OR_LENGTH.
| 
 | static | 
Execute an INSERT query.
| database | |
| table | |
| fields | list containing one or more field/value set(s) | 
Insert a new record into database table, prepare the sql statement. All values to be changed are stored in ap list. Sub-in the values to the prepared statement and execute it.
| -1 | on failure | 
Definition at line 751 of file res_config_odbc.c.
References ast_free, ast_log, ast_odbc_prepare_and_execute(), ast_odbc_release_obj(), ast_odbc_request_obj2, ast_str_append(), ast_str_buffer(), ast_str_create, ast_str_set(), ast_str_thread_get(), ast_string_field_free_memory, ast_string_field_init, custom_prepare(), custom_prepare_struct::fields, LOG_WARNING, ast_variable::name, ast_variable::next, RES_ODBC_CONNECTED, custom_prepare_struct::sql, and SQL_BUF_SIZE.
| 
 | static | 
Definition at line 1299 of file res_config_odbc.c.
References ast_config_engine_deregister(), and odbc_engine.
| 
 | static | 
Definition at line 1244 of file res_config_odbc.c.
References a, ast_odbc_clear_cache(), and b.
| 
 | static | 
Execute an UPDATE query.
| database,table,lookup_fields | |
| update_fields | list containing one or more field/value set(s). | 
Update a database table, preparing the sql statement from a list of key/value pairs specified in ap. The lookup pairs are specified first and are separated from the update pairs by a sentinel value. Sub-in the values to the prepared statement and execute it.
| -1 | on failure | 
Definition at line 685 of file res_config_odbc.c.
References ast_assert, ast_log, ast_odbc_find_table(), ast_odbc_prepare_and_execute(), ast_odbc_release_obj(), ast_odbc_release_table, ast_odbc_request_obj, ast_str_buffer(), ast_str_thread_get(), update2_prepare_struct::database, LOG_ERROR, LOG_WARNING, update2_prepare_struct::lookup_fields, NULL, SQL_BUF_SIZE, update2_prepare_struct::table, update2_prepare_struct::tableptr, update2_prepare(), and update2_prepare_struct::update_fields.
| 
 | static | 
Definition at line 615 of file res_config_odbc.c.
References ast_log, ast_odbc_find_column(), ast_odbc_prepare(), ast_odbc_print_errors(), ast_str_append(), ast_str_buffer(), ast_str_set(), ast_str_thread_get(), odbc_obj::con, update2_prepare_struct::database, first, LOG_ERROR, LOG_NOTICE, LOG_WARNING, update2_prepare_struct::lookup_fields, ast_variable::name, ast_variable::next, NULL, SQL_BUF_SIZE, update2_prepare_struct::table, update2_prepare_struct::tableptr, update2_prepare_struct::update_fields, and ast_variable::value.
Referenced by update2_odbc().
| 
 | static | 
Execute an UPDATE query.
| database | |
| table | |
| keyfield | where clause field | 
| lookup | value of field for where clause | 
| fields | list containing one or more field/value set(s). | 
Update a database table, prepare the sql statement using keyfield and lookup control the number of records to change. All values to be changed are stored in ap list. Sub-in the values to the prepared statement and execute it.
| -1 | on failure | 
Definition at line 527 of file res_config_odbc.c.
References ast_log, ast_odbc_find_column(), ast_odbc_find_table(), ast_odbc_prepare_and_execute(), ast_odbc_release_obj(), ast_odbc_release_table, ast_odbc_request_obj2, ast_str_append(), ast_str_buffer(), ast_str_set(), ast_str_thread_get(), ast_string_field_free_memory, ast_string_field_init, ast_strlen_zero(), custom_prepare(), custom_prepare_struct::extra, custom_prepare_struct::fields, is_text(), LOG_WARNING, ast_variable::name, ast_variable::next, NULL, odbc_cache_columns::nullable, RES_ODBC_CONNECTED, custom_prepare_struct::skip, custom_prepare_struct::sql, SQL_BUF_SIZE, and ast_variable::value.
| 
 | static | 
Definition at line 1312 of file res_config_odbc.c.
| 
 | static | 
Definition at line 1312 of file res_config_odbc.c.
| 
 | static | 
Definition at line 1249 of file res_config_odbc.c.
Referenced by load_module(), and unload_module().
| 
 | static | 
Definition at line 53 of file res_config_odbc.c.
Referenced by load_config(), and realtime_multi_odbc().
| 
 | static | 
Definition at line 52 of file res_config_odbc.c.
Referenced by config_odbc(), load_module(), and reload_module().