Asterisk - The Open Source Telephony Project
18.5.0
|
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) |
Excute 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 int | load_module (void) |
static struct ast_config * | realtime_multi_odbc (const char *database, const char *table, const struct ast_variable *fields) |
Excute 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) |
Excute 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) |
Excute 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) |
Excute 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 = "30ef0c93b36035ec78c9cfd712d36d9b" , .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 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 | ) |
Referenced by require_odbc().
#define ENCODE_CHUNK | ( | buffer, | |
s | |||
) |
Definition at line 65 of file res_config_odbc.c.
Referenced by custom_prepare().
#define SQL_BUF_SIZE 1024 |
Initial SQL query buffer size to allocate.
Definition at line 50 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().
#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 1073 of file res_config_odbc.c.
Referenced by require_odbc().
#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 1074 of file res_config_odbc.c.
Referenced by require_odbc().
#define WARN_TYPE_OR_LENGTH | ( | n | ) |
Referenced by require_odbc().
|
static |
Definition at line 53 of file res_config_odbc.c.
|
static |
Definition at line 52 of file res_config_odbc.c.
|
static |
Definition at line 1277 of file res_config_odbc.c.
|
static |
Definition at line 1277 of file res_config_odbc.c.
struct ast_module* AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 1277 of file res_config_odbc.c.
|
static |
Definition at line 941 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_ODBC_CONNECTED, config_odbc_obj::sql, sql_buf, SQL_BUF_SIZE, config_odbc_obj::var_name, config_odbc_obj::var_val, and config_odbc_obj::var_val_size.
|
static |
Definition at line 914 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 101 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, 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 85 of file res_config_odbc.c.
Referenced by realtime_multi_odbc(), and realtime_odbc().
|
static |
Excute an DELETE query.
database | |
table | |
keyfield | where clause field |
lookup | value of field for where clause |
ap | 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.
number | of rows affected |
-1 | on failure |
Definition at line 824 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, and SQL_BUF_SIZE.
|
inlinestatic |
Definition at line 95 of file res_config_odbc.c.
References odbc_cache_columns::type.
Referenced by update_odbc().
|
static |
Definition at line 890 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 1258 of file res_config_odbc.c.
References ast_config_engine_register().
Referenced by reload_module().
|
static |
Excute an Select query and return ast_config list.
database | |
table | |
ap | 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.
var | on success |
NULL | on failure |
Definition at line 342 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, RES_ODBC_CONNECTED, rowdata_buf, S_OR, custom_prepare_struct::sql, sql_buf, SQL_BUF_SIZE, strcasestr(), strsep(), and var.
|
static |
Excute an SQL query and return ast_variable list.
database | |
table | |
ap | 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.
var | on success |
NULL | on failure |
Definition at line 170 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(), and var.
|
static |
Definition at line 1265 of file res_config_odbc.c.
References AST_MODFLAG_LOAD_ORDER, AST_MODPRI_REALTIME_DRIVER, AST_MODULE_INFO(), AST_MODULE_SUPPORT_CORE, ASTERISK_GPL_KEY, load_module(), reload(), and unload_module().
|
static |
Definition at line 1076 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, odbc_cache_columns::type, type, warn_length, warn_type, and WARN_TYPE_OR_LENGTH.
|
static |
Excute an INSERT query.
database | |
table | |
ap | 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.
number | of rows affected |
-1 | on failure |
Definition at line 741 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, and SQL_BUF_SIZE.
|
static |
Definition at line 1251 of file res_config_odbc.c.
References ast_config_engine_deregister().
Referenced by reload_module().
|
static |
Definition at line 1233 of file res_config_odbc.c.
References ast_odbc_clear_cache().
|
static |
Execute an UPDATE query.
database | |
table | |
ap | 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.
number | of rows affected |
-1 | on failure |
Definition at line 675 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, custom_prepare_struct::sql, sql_buf, SQL_BUF_SIZE, table, update2_prepare_struct::tableptr, update2_prepare(), and update2_prepare_struct::update_fields.
|
static |
Definition at line 604 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 |
Excute an UPDATE query.
database | |
table | |
keyfield | where clause field |
lookup | value of field for where clause |
ap | 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.
number | of rows affected |
-1 | on failure |
Definition at line 516 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, and ast_variable::value.
|
static |
Definition at line 1277 of file res_config_odbc.c.
|
static |
Definition at line 1277 of file res_config_odbc.c.
|
static |
Definition at line 1238 of file res_config_odbc.c.
|
static |
Definition at line 53 of file res_config_odbc.c.
Referenced by realtime_multi_odbc(), and realtime_odbc().
|
static |
Definition at line 52 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().