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 | 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) |
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, va_list ap) |
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, va_list ap) |
Excute an Select query and return ast_config list. More... | |
static struct ast_variable * | realtime_odbc (const char *database, const char *table, va_list ap) |
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, va_list ap) |
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, va_list ap) |
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, va_list ap) |
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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_REALTIME_DRIVER, } |
static 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 63 of file res_config_odbc.c.
Referenced by custom_prepare().
#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 1099 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 1100 of file res_config_odbc.c.
Referenced by require_odbc().
#define WARN_TYPE_OR_LENGTH | ( | n | ) |
Referenced by require_odbc().
|
static |
Definition at line 51 of file res_config_odbc.c.
|
static |
Definition at line 50 of file res_config_odbc.c.
|
static |
Definition at line 1302 of file res_config_odbc.c.
|
static |
Definition at line 1302 of file res_config_odbc.c.
|
static |
Definition at line 962 of file res_config_odbc.c.
References ast_build_string(), ast_category_append(), ast_category_new(), 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_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, RES_ODBC_CONNECTED, config_odbc_obj::sql, config_odbc_obj::var_name, config_odbc_obj::var_val, and config_odbc_obj::var_val_size.
|
static |
Definition at line 935 of file res_config_odbc.c.
References ast_verb, config_odbc_obj::cat_metric, config_odbc_obj::category, odbc_obj::con, config_odbc_obj::err, 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 99 of file res_config_odbc.c.
References custom_prepare_struct::ap, ast_debug, ast_log(), ast_string_field_set, ast_strlen_zero(), odbc_obj::con, ENCODE_CHUNK, encoding, custom_prepare_struct::encoding, custom_prepare_struct::extra, LOG_WARNING, custom_prepare_struct::skip, and custom_prepare_struct::sql.
Referenced by destroy_odbc(), realtime_multi_odbc(), realtime_odbc(), store_odbc(), and update_odbc().
|
static |
Definition at line 83 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 840 of file res_config_odbc.c.
References custom_prepare_struct::ap, ast_log(), ast_odbc_prepare_and_execute(), ast_odbc_release_obj(), ast_odbc_request_obj2, ast_string_field_free_memory, ast_string_field_init, custom_prepare(), LOG_WARNING, RES_ODBC_CONNECTED, and custom_prepare_struct::sql.
|
inlinestatic |
Definition at line 93 of file res_config_odbc.c.
References odbc_cache_columns::type.
Referenced by update_odbc().
|
static |
Definition at line 911 of file res_config_odbc.c.
References ast_verb, odbc_obj::con, config_odbc_obj::err, config_odbc_obj::sql, and config_odbc_obj::var_val_size.
Referenced by config_odbc().
|
static |
Definition at line 1285 of file res_config_odbc.c.
References ast_config_engine_register(), and ast_verb.
|
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 335 of file res_config_odbc.c.
References custom_prepare_struct::ap, ast_category_append(), ast_category_destroy(), ast_category_new(), 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_buffer(), ast_str_make_space(), ast_str_reset(), 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(), LOG_WARNING, RES_ODBC_CONNECTED, rowdata_buf, custom_prepare_struct::sql, 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 166 of file res_config_odbc.c.
References custom_prepare_struct::ap, ast_log(), ast_odbc_backslash_is_escape(), ast_odbc_prepare_and_execute(), ast_odbc_release_obj(), ast_odbc_request_obj2, 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(), LOG_ERROR, LOG_WARNING, RES_ODBC_CONNECTED, rowdata_buf, custom_prepare_struct::sql, strcasestr(), strsep(), and var.
|
static |
Definition at line 1292 of file res_config_odbc.c.
|
static |
Definition at line 1102 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, type, odbc_cache_columns::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 754 of file res_config_odbc.c.
References custom_prepare_struct::ap, ast_copy_string(), ast_log(), ast_odbc_prepare_and_execute(), ast_odbc_release_obj(), ast_odbc_request_obj2, ast_string_field_free_memory, ast_string_field_init, custom_prepare(), LOG_WARNING, RES_ODBC_CONNECTED, and custom_prepare_struct::sql.
|
static |
Definition at line 1277 of file res_config_odbc.c.
References ast_config_engine_deregister(), and ast_verb.
|
static |
Definition at line 1259 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 702 of file res_config_odbc.c.
References update2_prepare_struct::ap, ast_log(), ast_odbc_prepare_and_execute(), ast_odbc_release_obj(), ast_odbc_request_obj, ast_str_buffer(), ast_str_thread_get(), update2_prepare_struct::database, LOG_WARNING, sql_buf, table, and update2_prepare().
|
static |
Definition at line 604 of file res_config_odbc.c.
References update2_prepare_struct::ap, ast_log(), ast_odbc_find_column(), ast_odbc_find_table(), ast_odbc_release_table, 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, sql_buf, and update2_prepare_struct::table.
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 514 of file res_config_odbc.c.
References custom_prepare_struct::ap, ast_log(), ast_odbc_allow_empty_string_in_nontext(), 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_string_field_free_memory, ast_string_field_init, ast_strlen_zero(), custom_prepare(), is_text(), LOG_WARNING, odbc_cache_columns::nullable, RES_ODBC_CONNECTED, custom_prepare_struct::skip, and custom_prepare_struct::sql.
|
static |
Definition at line 1302 of file res_config_odbc.c.
|
static |
Definition at line 1302 of file res_config_odbc.c.
|
static |
Definition at line 1264 of file res_config_odbc.c.
|
static |
Definition at line 51 of file res_config_odbc.c.
Referenced by realtime_multi_odbc(), and realtime_odbc().
|
static |
Definition at line 50 of file res_config_odbc.c.
Referenced by update2_odbc(), and update2_prepare().