|
Asterisk - The Open Source Telephony Project GIT-master-80b953f
|
Common config file handling for res_cdrel_custom. More...
#include "cdrel.h"#include "asterisk/config.h"#include "asterisk/module.h"#include "asterisk/paths.h"
Go to the source code of this file.
Data Structures | |
| struct | field_parse_result |
Functions | |
| struct cdrel_configs * | cdrel_load_module (enum cdrel_backend_type backend_type, enum cdrel_record_type record_type, const char *filename, const char *backend_name, void *log_cb) |
| Perform initial module load. | |
| int | cdrel_reload_module (enum cdrel_backend_type output_type, enum cdrel_record_type record_type, struct cdrel_configs **configs, const char *filename) |
| Perform module reload. | |
| int | cdrel_unload_module (enum cdrel_backend_type backend_type, enum cdrel_record_type record_type, struct cdrel_configs *configs, const char *backend_name) |
| Perform module unload. | |
| static struct cdrel_config * | config_alloc (enum cdrel_record_type record_type, enum cdrel_backend_type backend_type, enum cdrel_config_type config_type, const char *config_filename, const char *output_filename, const char *template) |
| static void | config_free (struct cdrel_config *config) |
| static struct cdrel_field * | field_alloc (struct cdrel_config *config, const char *input_field_template) |
| static void | field_template_vector_free (struct ast_vector_string *fields) |
| static int | load_config_file (enum cdrel_backend_type output_type, enum cdrel_record_type record_type, struct cdrel_configs *configs, const char *filename, int reload) |
| static int | load_database_columns (struct cdrel_config *config, const char *columns, int *column_count) |
| static struct cdrel_config * | load_database_config (enum cdrel_record_type record_type, struct ast_category *category, const char *config_filename) |
| static int | load_database_config_file (enum cdrel_record_type record_type, struct cdrel_configs *configs, const char *config_filename, int reload) |
| static int | load_fields (struct cdrel_config *config, struct ast_vector_string *fields) |
| static struct cdrel_config * | load_text_file_advanced_config (enum cdrel_record_type record_type, struct ast_category *category, const char *config_filename) |
| static int | load_text_file_config_file (enum cdrel_record_type record_type, struct cdrel_configs *configs, const char *config_filename, int reload) |
| static struct cdrel_config * | load_text_file_legacy_config (enum cdrel_record_type record_type, const char *config_filename, const char *output_filename, const char *template) |
| static int | load_text_file_legacy_mappings (enum cdrel_record_type record_type, struct cdrel_configs *configs, struct ast_category *category, const char *config_filename) |
| static char * | make_stmt_placeholders (int columns) |
| static int | open_database (struct cdrel_config *config) |
| static struct field_parse_result | parse_field (enum cdrel_record_type record_type, char *input_field_template) |
| static int | parse_legacy_template (enum cdrel_record_type record_type, const char *config_filename, const char *output_filename, const char *input_template, struct ast_vector_string *fields) |
| static int | register_backend (enum cdrel_record_type record_type, const char *backend_name, void *log_cb) |
| static int | unregister_backend (enum cdrel_record_type record_type, const char *backend_name) |
Variables | |
| static const char * | allowed_functions [] |
| static const char * | dirname_map [cdrel_backend_type_end][cdrel_record_type_end] |
| static const char * | special_vars [] |
Common config file handling for res_cdrel_custom.
This file is a 'bit' complex. The reasoning is that the functions do as much work as possible at module load time to reduce the workload at run time.
Definition in file res/cdrel_custom/config.c.
| struct cdrel_configs * cdrel_load_module | ( | enum cdrel_backend_type | backend_type, |
| enum cdrel_record_type | record_type, | ||
| const char * | config_filename, | ||
| const char * | backend_name, | ||
| void * | logging_cb | ||
| ) |
Perform initial module load.
Needs to be called by each "custom" module
| backend_type | One of cdrel_backend_type. |
| record_type | One of cdrel_record_type. |
| config_filename | The config file name. |
| backend_name | The name to register the backend as. |
| logging_cb | The logging callback to register with CDR or CEL. |
Definition at line 1431 of file res/cdrel_custom/config.c.
References ast_calloc, ast_debug, AST_VECTOR_INIT, cdrel_unload_module(), load_config_file(), MODULE_TYPE_STR, NULL, RECORD_TYPE_STR, and register_backend().
Referenced by load_module(), load_module(), load_module(), and load_module().
| int cdrel_reload_module | ( | enum cdrel_backend_type | backend_type, |
| enum cdrel_record_type | record_type, | ||
| struct cdrel_configs ** | configs, | ||
| const char * | config_filename | ||
| ) |
Perform module reload.
Needs to be called by each "custom" module
| backend_type | One of cdrel_backend_type. |
| record_type | One of cdrel_record_type. |
| configs | A pointer to the VECTOR of config objects returned by cdrel_load_module. |
| config_filename | The config file name. |
| AST_MODULE_LOAD_SUCCESS | |
| AST_MODULE_LOAD_DECLINE |
Definition at line 1391 of file res/cdrel_custom/config.c.
References ast_malloc, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, AST_VECTOR_INIT, AST_VECTOR_PTR_FREE, AST_VECTOR_RESET, AST_VECTOR_SIZE, config_free(), load_config_file(), and NULL.
| int cdrel_unload_module | ( | enum cdrel_backend_type | backend_type, |
| enum cdrel_record_type | record_type, | ||
| struct cdrel_configs * | configs, | ||
| const char * | backend_name | ||
| ) |
Perform module unload.
Needs to be called by each "custom" module
| backend_type | One of cdrel_backend_type. |
| record_type | One of cdrel_record_type. |
| configs | A pointer to the VECTOR of config objects returned by cdrel_load_module. |
| backend_name | The backend name to unregister. |
| 0 | Success. |
| -1 | Failure. |
Definition at line 1459 of file res/cdrel_custom/config.c.
References AST_VECTOR_PTR_FREE, AST_VECTOR_RESET, config_free(), and unregister_backend().
Referenced by cdrel_load_module(), unload_module(), unload_module(), unload_module(), and unload_module().
|
static |
Definition at line 655 of file res/cdrel_custom/config.c.
References ast_calloc_with_stringfields, ast_config_AST_LOG_DIR, ast_debug, ast_ends_with(), ast_log, ast_mutex_init, ast_string_field_build, ast_string_field_set, ast_strlen_zero(), cdrel_backend_db, cdrel_backend_text, cdrel_basename(), cdrel_dummy_channel_allocators, cdrel_format_dsv, cdrel_format_sql, cdrel_quoting_method_all, cdrel_quoting_method_none, config, config_filename, config_free(), dirname_map, LOG_ERROR, NULL, RAII_VAR, and S_OR.
|
static |
Definition at line 618 of file res/cdrel_custom/config.c.
References ast_free, ast_mutex_destroy, ast_string_field_free_memory, AST_VECTOR_FREE, AST_VECTOR_RESET, config, and NULL.
Referenced by cdrel_reload_module(), cdrel_unload_module(), config_alloc(), load_database_config(), load_database_config_file(), load_text_file_advanced_config(), load_text_file_config_file(), and load_text_file_legacy_mappings().
|
static |
Definition at line 336 of file res/cdrel_custom/config.c.
References ast_assert, ast_calloc, ast_clear_flag, ast_debug, ast_free, ast_log, ast_set_flag, ast_str_tmp, ast_strdupa, ast_strip_quoted(), ast_strlen_zero(), ast_strsep(), AST_STRSEP_STRIP, AST_STRSEP_TRIM, ast_test_flag, cdrel_backend_db, cdrel_basename(), cdrel_config_legacy, cdrel_data_type_end, cdrel_data_type_from_str(), cdrel_data_type_strings_end, cdrel_flag_format_spec, cdrel_flag_literal, cdrel_flag_noquote, cdrel_flag_quote, cdrel_flag_type_forced, cdrel_flag_uservar, cdrel_format_json, cdrel_get_field_flags(), cdrel_quoting_method_all, cdrel_quoting_method_non_numeric, cdrel_quoting_method_none, cdrel_type_literal, cdrel_type_string, cdrel_type_timeval, cdrel_type_uservar, config, cdrel_field::data, DATA_TYPE_STR, get_registered_field_by_name(), cdrel_field::input_data_type, LOG_WARNING, NULL, and RAII_VAR.
Referenced by load_fields().
|
static |
Definition at line 577 of file res/cdrel_custom/config.c.
References ast_free, AST_VECTOR_PTR_FREE, and AST_VECTOR_RESET.
Referenced by load_database_config(), load_text_file_advanced_config(), and load_text_file_legacy_config().
|
static |
Definition at line 1378 of file res/cdrel_custom/config.c.
References cdrel_backend_db, cdrel_backend_text, load_database_config_file(), load_text_file_config_file(), cdrel_config::record_type, and reload().
Referenced by cdrel_load_module(), and cdrel_reload_module().
|
static |
Definition at line 735 of file res/cdrel_custom/config.c.
References ast_debug, ast_free, ast_str_append(), ast_str_buffer(), ast_str_create, ast_strdupa, ast_string_field_set, ast_strip(), ast_strip_quoted(), ast_strsep(), AST_STRSEP_TRIM, cdrel_basename(), config, NULL, and RAII_VAR.
Referenced by load_database_config().
|
static |
Definition at line 896 of file res/cdrel_custom/config.c.
References ast_calloc, ast_category_get_name(), ast_free, ast_log, ast_parse_arg(), ast_strdup, ast_strdupa, ast_string_field_set, ast_strlen_zero(), ast_strsep(), AST_STRSEP_TRIM, ast_variable_find(), AST_VECTOR_APPEND, AST_VECTOR_INIT, AST_VECTOR_RESET, AST_VECTOR_SIZE, cdrel_backend_db, cdrel_basename(), cdrel_config_advanced, cdrel_config_legacy, cdrel_record_cdr, config, config_alloc(), config_filename, config_free(), field_template_vector_free(), load_database_columns(), load_fields(), LOG_NOTICE, LOG_WARNING, NULL, open_database(), PARSE_DEFAULT, PARSE_INT32, parse_legacy_template(), RAII_VAR, RECORD_TYPE_STR, S_OR, and value.
Referenced by load_database_config_file().
|
static |
Definition at line 1041 of file res/cdrel_custom/config.c.
References ast_category_browse_filtered(), ast_config_destroy(), ast_config_load, ast_debug, ast_log, AST_VECTOR_APPEND, AST_VECTOR_SIZE, config, config_filename, CONFIG_FLAG_FILEUNCHANGED, config_free(), CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEUNCHANGED, load_database_config(), LOG_ERROR, LOG_NOTICE, NULL, RECORD_TYPE_STR, and reload().
Referenced by load_config_file().
|
static |
Definition at line 591 of file res/cdrel_custom/config.c.
References ast_debug, ast_free, AST_VECTOR_APPEND, AST_VECTOR_GET, AST_VECTOR_SIZE, cdrel_basename(), config, field_alloc(), and NULL.
Referenced by load_database_config(), load_text_file_advanced_config(), and load_text_file_legacy_config().
|
static |
Definition at line 1158 of file res/cdrel_custom/config.c.
References ast_calloc, ast_category_get_name(), ast_copy_string(), ast_log, ast_strdup, ast_strdupa, ast_strings_equal(), ast_strlen_zero(), ast_strsep(), AST_STRSEP_TRIM, ast_unescape_c(), ast_variable_find(), AST_VECTOR_APPEND, AST_VECTOR_INIT, AST_VECTOR_SIZE, cdrel_backend_text, cdrel_basename(), cdrel_config_advanced, cdrel_format_dsv, cdrel_format_json, cdrel_quoting_method_all, cdrel_quoting_method_minimal, cdrel_quoting_method_non_numeric, cdrel_quoting_method_none, config, config_alloc(), config_filename, config_free(), field_template_vector_free(), cdrel_config::fields, load_fields(), LOG_NOTICE, LOG_WARNING, NULL, RAII_VAR, cdrel_config::record_type, RECORD_TYPE_STR, and value.
Referenced by load_text_file_config_file().
|
static |
Definition at line 1310 of file res/cdrel_custom/config.c.
References ast_category_browse_filtered(), ast_category_get_name(), ast_config_destroy(), ast_config_load, ast_debug, ast_log, ast_strings_equal(), AST_VECTOR_APPEND, AST_VECTOR_SIZE, config, config_filename, CONFIG_FLAG_FILEUNCHANGED, config_free(), CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEUNCHANGED, load_text_file_advanced_config(), load_text_file_legacy_mappings(), LOG_ERROR, LOG_NOTICE, NULL, cdrel_config::record_type, RECORD_TYPE_STR, and reload().
Referenced by load_config_file().
|
static |
Definition at line 1091 of file res/cdrel_custom/config.c.
References ast_calloc, ast_log, AST_VECTOR_INIT, AST_VECTOR_SIZE, cdrel_backend_text, cdrel_basename(), cdrel_config_advanced, cdrel_config_legacy, cdrel_format_dsv, cdrel_quoting_method_all, config, config_alloc(), config_filename, field_template_vector_free(), cdrel_config::fields, load_fields(), LOG_NOTICE, NULL, cdrel_config::output_filename, parse_legacy_template(), RAII_VAR, cdrel_config::record_type, and RECORD_TYPE_STR.
Referenced by load_text_file_legacy_mappings().
|
static |
Definition at line 1271 of file res/cdrel_custom/config.c.
References ast_category_first(), ast_log, ast_strlen_zero(), AST_VECTOR_APPEND, cdrel_basename(), config, config_filename, config_free(), load_text_file_legacy_config(), LOG_WARNING, ast_variable::next, NULL, cdrel_config::record_type, RECORD_TYPE_STR, and var.
Referenced by load_text_file_config_file().
|
static |
Definition at line 767 of file res/cdrel_custom/config.c.
References ast_malloc, and c.
Referenced by open_database().
|
static |
Definition at line 788 of file res/cdrel_custom/config.c.
References ast_debug, ast_free, ast_log, AST_VECTOR_SIZE, cdrel_basename(), config, LOG_ERROR, LOG_WARNING, make_stmt_placeholders(), and NULL.
Referenced by load_database_config().
|
static |
Definition at line 95 of file res/cdrel_custom/config.c.
References allowed_functions, ast_copy_string(), ast_strdup, ast_strdupa, ast_strip(), ast_strip_quoted(), MIN, NULL, result, field_parse_result::result, and special_vars.
Referenced by parse_legacy_template().
|
static |
Definition at line 265 of file res/cdrel_custom/config.c.
References ast_asprintf, ast_debug, ast_free, ast_strdupa, ast_strsep(), AST_STRSEP_TRIM, AST_VECTOR_APPEND, cdrel_basename(), config_filename, get_registered_field_by_name(), NULL, parse_field(), result, and S_OR.
Referenced by load_database_config(), and load_text_file_legacy_config().
|
static |
Definition at line 1354 of file res/cdrel_custom/config.c.
References ast_cdr_register(), ast_cel_backend_register(), cdrel_backend_db, cdrel_record_cdr, and cdrel_config::record_type.
Referenced by cdrel_load_module().
|
static |
Definition at line 1366 of file res/cdrel_custom/config.c.
References ast_cdr_unregister(), ast_cel_backend_unregister(), cdrel_record_cdr, cdrel_record_cel, and cdrel_config::record_type.
Referenced by cdrel_unload_module().
|
static |
Definition at line 67 of file res/cdrel_custom/config.c.
Referenced by parse_field().
|
static |
Definition at line 41 of file res/cdrel_custom/config.c.
Referenced by config_alloc().
|
static |
Definition at line 72 of file res/cdrel_custom/config.c.
Referenced by parse_field().