Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
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 | __init_rowdata_buf (void) |
static void | __init_sql_buf (void) |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Realtime ODBC configuration" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .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" |
static struct ast_threadstorage | rowdata_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_rowdata_buf , .custom_init = NULL , } |
static struct ast_threadstorage | sql_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_sql_buf , .custom_init = NULL , } |
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 1078 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 1079 of file res_config_odbc.c.
#define WARN_TYPE_OR_LENGTH | ( | n | ) |
|
static |
Definition at line 56 of file res_config_odbc.c.
|
static |
Definition at line 55 of file res_config_odbc.c.
|
static |
Definition at line 1307 of file res_config_odbc.c.
|
static |
Definition at line 1307 of file res_config_odbc.c.
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 1307 of file res_config_odbc.c.
|
static |
Definition at line 946 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(), make_ari_stubs::file, last, length_determination_odbc_prepare(), LOG_NOTICE, LOG_WARNING, NULL, res_config_odbc_conf, RES_ODBC_CONNECTED, config_odbc_obj::sql, sql_buf, SQL_BUF_SIZE, table, config_odbc_obj::var_name, config_odbc_obj::var_val, and config_odbc_obj::var_val_size.
|
static |
Definition at line 919 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 829 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, sql_buf, SQL_BUF_SIZE, and table.
|
inlinestatic |
Definition at line 98 of file res_config_odbc.c.
References odbc_cache_columns::type.
Referenced by update_odbc().
|
static |
Definition at line 895 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 1257 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.
Referenced by load_module(), and reload_module().
|
static |
Definition at line 1279 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 345 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, rowdata_buf, S_OR, custom_prepare_struct::sql, sql_buf, SQL_BUF_SIZE, strcasestr(), strsep(), table, 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 173 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(), custom_prepare(), decode_chunk(), custom_prepare_struct::fields, indicator, LOG_ERROR, LOG_WARNING, ast_variable::name, ast_variable::next, NULL, RES_ODBC_CONNECTED, rowdata_buf, S_OR, custom_prepare_struct::sql, sql_buf, SQL_BUF_SIZE, strcasestr(), strsep(), table, and var.
|
static |
Definition at line 1288 of file res_config_odbc.c.
References load_config(), and res_config_odbc_conf.
|
static |
Definition at line 1081 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, 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, 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 746 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, keys, LOG_WARNING, ast_variable::name, ast_variable::next, RES_ODBC_CONNECTED, custom_prepare_struct::sql, sql_buf, SQL_BUF_SIZE, and table.
|
static |
Definition at line 1294 of file res_config_odbc.c.
References ast_config_engine_deregister(), and odbc_engine.
|
static |
Definition at line 1239 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 680 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, SQL_BUF_SIZE, table, update2_prepare_struct::tableptr, update2_prepare(), and update2_prepare_struct::update_fields.
|
static |
Definition at line 610 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, 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 522 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, SQL_BUF_SIZE, table, and ast_variable::value.
|
static |
Definition at line 1307 of file res_config_odbc.c.
|
static |
Definition at line 1307 of file res_config_odbc.c.
|
static |
Definition at line 1244 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().
|
static |
Definition at line 56 of file res_config_odbc.c.
Referenced by realtime_multi_odbc(), and realtime_odbc().
|
static |
Definition at line 55 of file res_config_odbc.c.
Referenced by config_odbc(), destroy_odbc(), realtime_multi_odbc(), realtime_odbc(), store_odbc(), update2_odbc(), update2_prepare(), and update_odbc().