46 #define CUSTOM_LOG_DIR "/cel_custom"
47 #define CONFIG "cel_custom.conf"
51 static const char name[] =
"cel-custom";
62 #define CUSTOM_BACKEND_NAME "CEL Custom CSV Logging"
66 static void free_config(
void)
70 while ((sink = AST_RWLIST_REMOVE_HEAD(&
sinks, list))) {
71 ast_mutex_destroy(&sink->lock);
77 static int load_config(
void)
86 if (!cfg || cfg == CONFIG_STATUS_FILEINVALID) {
87 ast_log(LOG_ERROR,
"Unable to load " CONFIG
". Not logging CEL to custom CSVs.\n");
91 if (!(var = ast_variable_browse(cfg,
"mappings"))) {
92 ast_log(LOG_NOTICE,
"No mappings found in " CONFIG
". Not logging CEL to custom CSVs.\n");
96 if (!ast_strlen_zero(var->
name) && !ast_strlen_zero(var->
value)) {
100 ast_log(LOG_ERROR,
"Unable to allocate memory for configuration settings.\n");
107 ast_mutex_init(&sink->lock);
109 ast_verb(3,
"Added CEL CSV mapping for '%s'.\n", sink->filename);
111 AST_RWLIST_INSERT_TAIL(&
sinks, sink, list);
113 ast_log(LOG_NOTICE,
"Mapping must have both a filename and a format at line %d\n", var->lineno);
119 ast_verb(1,
"Added CEL CSV mapping for %d files.\n", mappings);
137 ast_log(LOG_ERROR,
"Unable to fabricate channel from CEL event.\n");
152 ast_mutex_lock(&config->lock);
157 if ((out = fopen(config->filename,
"a"))) {
162 ast_log(LOG_ERROR,
"Unable to re-open master file %s : %s\n", config->filename, strerror(errno));
165 ast_mutex_unlock(&config->lock);
173 static int unload_module(
void)
177 ast_log(LOG_ERROR,
"Unable to lock sink list. Unload failed.\n");
190 ast_log(LOG_ERROR,
"Unable to lock sink list. Load failed.\n");
204 static int reload(
void)
207 ast_log(LOG_ERROR,
"Unable to lock sink list. Load failed.\n");
217 AST_MODULE_INFO(
ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER,
"Customizable Comma Separated Values CEL Backend",
218 .support_level = AST_MODULE_SUPPORT_CORE,
220 .unload = unload_module,
struct ast_variable * next
#define AST_THREADSTORAGE(name)
Define a thread storage variable.
Main Channel structure associated with a channel.
A container that holds all config-related information.
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
String manipulation functions.
#define ast_channel_unref(c)
Decrease channel reference count.
int ast_cel_backend_register(const char *name, ast_cel_backend_cb backend_callback)
Register a CEL backend.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Structure for variables, used for configurations and for channel variables.
void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ)
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
#define ast_calloc_with_stringfields(n, type, size)
Allocate a structure with embedded stringfields in a single allocation.
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
Definitions to aid in the use of thread local storage.
#define AST_RWLIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a read/write list of specified type, statically initialized...
Configuration File Parser.
#define ast_config_load(filename, flags)
Load a config file.
General Asterisk PBX channel definitions.
Asterisk file paths, configured in asterisk.conf.
#define AST_STRING_FIELD(name)
Declare a string field.
Core PBX routines and definitions.
int ast_cel_backend_unregister(const char *name)
Unregister a CEL backend.
Support for dynamic strings.
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
struct ast_channel * ast_cel_fabricate_channel_from_event(const struct ast_event *event)
Create a fake channel from data in a CEL event.
Module has failed to load, may be in an inconsistent state.
#define ast_string_field_build(x, field, fmt, args...)
Set a field to a complex (built) value.
Structure used to handle boolean flags.
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
struct ast_str * ast_str_thread_get(struct ast_threadstorage *ts, size_t init_len)
Retrieve a thread locally stored dynamic string.
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
Structure for mutex and tracking information.