60 for (node = xml; node; node = node->
next) {
117 for (; enum_options->
key; enum_options++) {
118 if (!strcasecmp(value, enum_options->
key)) {
119 *out = enum_options->
value;
129 for (; enum_options->
key; enum_options++) {
130 if (value == enum_options->
value) {
131 return enum_options->
key;
141 int matched_count = 0;
143 for (item = instructions; item->
key; item++) {
147 void *ptr = item->
ptr;
164 switch (item->
type) {
168 int *dest = (
int *) ptr;
172 intval = atoi(value);
176 value, item->
key, intval);
181 if ((int_options->
enforce_min && !(intval >= int_options->
min)) || (int_options->
enforce_max && !(intval <= int_options->max))) {
187 "Invalid value [%s] for parameter [%s], should be between [%d] and [%d], setting default [%d]\n", value,
188 item->
key, int_options->
min, int_options->
max, intval);
191 "Invalid value [%s] for parameter [%s], should be %s [%d], setting default [%d]\n", value, item->
key,
201 if (*dest != intval) {
214 uintval = (uint32_t) strtol(value, NULL, 10);
218 value, item->
key, uintval);
221 if (atomic_options) {
223 if ((atomic_options->
enforce_min && !(uintval >= atomic_options->
min)) || (atomic_options->
enforce_max && !(uintval <= atomic_options->max))) {
229 "Invalid value [%s] for parameter [%s], should be between [%u] and [%u], setting default [%u]\n", value,
230 item->
key, atomic_options->
min, atomic_options->
max, uintval);
233 "Invalid value [%s] for parameter [%s], should be %s [%u], setting default [%u]\n", value, item->
key,
234 atomic_options->
enforce_min ?
"at least" :
"at max",
235 atomic_options->
enforce_min ? atomic_options->
min : atomic_options->
max, uintval);
254 const char *newstring = NULL;
265 value, item->
key, newstring);
278 if (string_options->
length > 0) {
280 char *dest = (
char *) ptr;
283 if (strncasecmp(dest, newstring, string_options->
length)) {
293 }
else if (string_options->
pool) {
295 char **dest = (
char **) ptr;
298 if (!*dest || strcmp(*dest, newstring)) {
309 char **dest = (
char **) ptr;
312 if (!*dest || strcmp(*dest, newstring)) {
314 *dest = strdup(newstring);
339 value, item->
key, newval ?
"true" :
"false");
345 if (*dest != newval) {
356 int *dest = (
int *) ptr;
372 if (*dest != newval) {
380 int32_t *dest = (int32_t *) ptr;
382 int8_t currentval = (int8_t) ! !(*dest & index);
391 if (newval != currentval) {
394 *dest |= (1 <<
index);
396 *dest &= ~(1 <<
index);
403 int8_t *dest = (int8_t *) ptr;
404 unsigned int index = (
unsigned int) (intptr_t) item->
data;
406 if (dest[index] != newval) {
408 dest[
index] = newval;
423 if (count != matched_count) {
426 for (header = event->
headers; header; header = header->
next) {
428 for (item = instructions; item->
key; item++) {
429 if (!strcasecmp(header->
name, item->
key)) {
438 "Configuration parameter [%s] is unfortunately not valid, you might want to double-check that.\n", header->
name);
451 for (item = instructions; item->
key; item++) {
454 switch (item->
type) {
457 char **ptr = (
char **) item->
ptr;
460 if (!string_options || (!string_options->pool && !string_options->length)) {
479 const char *helptext)
void switch_xml_free(_In_opt_ switch_xml_t xml)
frees the memory allocated for an switch_xml structure
const char * switch_xml_attr_soft(_In_ switch_xml_t xml, _In_z_ const char *attr)
returns the value of the requested tag attribute, or "" if not found
static switch_bool_t switch_true(const char *expr)
Evaluate the truthfullness of a string expression.
switch_memory_pool_t * pool
#define SWITCH_CHANNEL_LOG
static switch_xml_config_enum_item_t switch_config_types_enum[]
switch_status_t switch_xml_config_parse_event(switch_event_t *event, int count, switch_bool_t reload, switch_xml_config_item_t *instructions)
Parses all of an event's elements, following a ruleset defined by an array of switch_xml_config_item_...
void switch_xml_config_item_print_doc(int level, switch_xml_config_item_t *item)
Prints out an item's documentation on the console.
switch_bool_t enforce_min
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
void switch_xml_config_cleanup(switch_xml_config_item_t *instructions)
Free any memory allocated by the configuration.
Representation of an event.
const char *const const char *const const cJSON *const value
switch_bool_t switch_is_number(const char *str)
void switch_config_perform_set_item(switch_xml_config_item_t *item, const char *key, switch_xml_config_type_t type, int flags, void *ptr, const void *defaultvalue, void *data, switch_xml_config_callback_t function, const char *syntax, const char *helptext)
A representation of an XML tree.
switch_xml_config_type_t type
A configuration instruction read by switch_xml_config_parse.
switch_bool_t enforce_min
if((uint32_t)(unpack->cur - unpack->buf) > unpack->buflen)
switch_status_t switch_xml_config_parse(switch_xml_t xml, switch_bool_t reload, switch_xml_config_item_t *instructions)
Parses all the xml elements, following a ruleset defined by an array of switch_xml_config_item_t.
switch_xml_config_callback_t function
const char * switch_xml_config_enum_int2str(switch_xml_config_enum_item_t *enum_options, int value)
Gets the string representation of an enum.
void switch_atomic_set(volatile switch_atomic_t *mem, uint32_t val)
switch_status_t switch_event_add_header_string(switch_event_t *event, switch_stack_t stack, const char *header_name, const char *data)
Add a string header to an event.
#define switch_safe_free(it)
Free a pointer and set it to NULL unless it already is NULL.
switch_xml_config_string_options_t switch_config_string_strdup
#define SWITCH_CHANNEL_LOG_CLEAN
switch_xml_config_type_t
Type of value to parse.
switch_status_t(* switch_xml_config_callback_t)(switch_xml_config_item_t *item, const char *newvalue, switch_config_callback_type_t callback_type, switch_bool_t changed)
char * switch_copy_string(_Out_z_cap_(dst_size) char *dst, _In_z_ const char *src, _In_ switch_size_t dst_size)
switch_bool_t enforce_max
switch_size_t switch_event_import_xml(switch_xml_t xml, const char *keyname, const char *valuename, switch_event_t **event)
Parses a list of xml elements into an event.
switch_status_t
Common return values.
switch_status_t switch_xml_config_enum_str2int(switch_xml_config_enum_item_t *enum_options, const char *value, int *out)
Gets the int representation of an enum.
switch_xml_t switch_xml_open_cfg(_In_z_ const char *file_path, _Out_ switch_xml_t *node, _In_opt_ switch_event_t *params)
open a config in the core registry
#define switch_event_create(event, id)
Create a new event assuming it will not be custom event and therefore hiding the unused parameters...
#define switch_event_get_header(_e, _h)
switch_xml_t switch_xml_child(_In_ switch_xml_t xml, _In_z_ const char *name)
returns the first child tag (one level deeper) with the given name or NULL \ if not found ...
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
uint32_t switch_atomic_read(volatile switch_atomic_t *mem)
static int switch_false(const char *expr)
Evaluate the falsefullness of a string expression.
void switch_event_destroy(switch_event_t **event)
Destroy an event.
switch_bool_t enforce_max
const void * defaultvalue
switch_status_t switch_regex_match(const char *target, const char *expression)
Function to evaluate an expression against a string.
switch_event_header_t * headers
switch_status_t switch_xml_config_parse_module_settings(const char *file, switch_bool_t reload, switch_xml_config_item_t *instructions)
Parses a module's settings.