Asterisk - The Open Source Telephony Project GIT-master-abe0018
Macros | Functions
geoloc_private.h File Reference
#include "asterisk/module.h"
#include "asterisk/config.h"
#include "asterisk/sorcery.h"
#include "asterisk/lock.h"
#include "asterisk/res_geolocation.h"
Include dependency graph for geoloc_private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CONFIG_ENUM(_object, _stem)
 
#define CONFIG_ENUM_HANDLER(_object, _stem)
 
#define CONFIG_ENUM_TO_STR(_object, _stem)
 
#define CONFIG_STR_TO_ENUM(_stem)
 
#define CONFIG_VAR_LIST(_object, _stem)
 
#define CONFIG_VAR_LIST_DUP(_object, _stem)
 
#define CONFIG_VAR_LIST_HANDLER(_object, _stem)
 
#define CONFIG_VAR_LIST_TO_STR(_object, _stem)
 
#define GEOLOC_ENUM_TO_NAME(_stem)
 

Functions

int geoloc_channel_load (void)
 
int geoloc_channel_reload (void)
 
int geoloc_channel_unload (void)
 
struct ast_xml_node * geoloc_civicaddr_list_to_xml (const struct ast_variable *resolved_location, const char *ref_string)
 
int geoloc_civicaddr_load (void)
 
int geoloc_civicaddr_reload (void)
 
int geoloc_civicaddr_unload (void)
 
int geoloc_config_load (void)
 
int geoloc_config_reload (void)
 
int geoloc_config_unload (void)
 
int geoloc_dialplan_load (void)
 
int geoloc_dialplan_reload (void)
 
int geoloc_dialplan_unload (void)
 
int geoloc_eprofile_load (void)
 
int geoloc_eprofile_reload (void)
 
struct ast_variablegeoloc_eprofile_resolve_varlist (struct ast_variable *source, struct ast_variable *variables, struct ast_channel *chan)
 
int geoloc_eprofile_unload (void)
 
struct ast_sorcerygeoloc_get_sorcery (void)
 
struct ast_xml_node * geoloc_gml_list_to_xml (const struct ast_variable *resolved_location, const char *ref_string)
 
int geoloc_gml_load (void)
 
int geoloc_gml_reload (void)
 
int geoloc_gml_unload (void)
 

Macro Definition Documentation

◆ CONFIG_ENUM

#define CONFIG_ENUM (   _object,
  _stem 
)
Value:
GEOLOC_ENUM_TO_NAME(_stem) \
CONFIG_ENUM_HANDLER(_object, _stem) \
CONFIG_ENUM_TO_STR(_object, _stem)
#define CONFIG_STR_TO_ENUM(_stem)

Definition at line 75 of file geoloc_private.h.

◆ CONFIG_ENUM_HANDLER

#define CONFIG_ENUM_HANDLER (   _object,
  _stem 
)

Definition at line 40 of file geoloc_private.h.

◆ CONFIG_ENUM_TO_STR

#define CONFIG_ENUM_TO_STR (   _object,
  _stem 
)

Definition at line 63 of file geoloc_private.h.

◆ CONFIG_STR_TO_ENUM

#define CONFIG_STR_TO_ENUM (   _stem)

Definition at line 28 of file geoloc_private.h.

◆ CONFIG_VAR_LIST

#define CONFIG_VAR_LIST (   _object,
  _stem 
)
Value:
CONFIG_VAR_LIST_HANDLER(_object, _stem) \
CONFIG_VAR_LIST_DUP(_object, _stem) \
CONFIG_VAR_LIST_TO_STR(_object, _stem)
#define CONFIG_VAR_LIST_HANDLER(_object, _stem)

Definition at line 123 of file geoloc_private.h.

◆ CONFIG_VAR_LIST_DUP

#define CONFIG_VAR_LIST_DUP (   _object,
  _stem 
)

Definition at line 103 of file geoloc_private.h.

◆ CONFIG_VAR_LIST_HANDLER

#define CONFIG_VAR_LIST_HANDLER (   _object,
  _stem 
)

Definition at line 81 of file geoloc_private.h.

◆ CONFIG_VAR_LIST_TO_STR

#define CONFIG_VAR_LIST_TO_STR (   _object,
  _stem 
)

Definition at line 113 of file geoloc_private.h.

◆ GEOLOC_ENUM_TO_NAME

#define GEOLOC_ENUM_TO_NAME (   _stem)

Definition at line 53 of file geoloc_private.h.

Function Documentation

◆ geoloc_channel_load()

int geoloc_channel_load ( void  )

Definition at line 316 of file geoloc_datastore.c.

317{
320}
struct ast_sorcery * geoloc_get_sorcery(void)
struct ast_sorcery * geoloc_sorcery
@ AST_MODULE_LOAD_SUCCESS
Definition: module.h:70

References AST_MODULE_LOAD_SUCCESS, geoloc_get_sorcery(), and geoloc_sorcery.

Referenced by load_module().

◆ geoloc_channel_reload()

int geoloc_channel_reload ( void  )

Definition at line 322 of file geoloc_datastore.c.

323{
325}

References AST_MODULE_LOAD_SUCCESS.

Referenced by reload_module().

◆ geoloc_channel_unload()

int geoloc_channel_unload ( void  )

Definition at line 308 of file geoloc_datastore.c.

309{
310 if (geoloc_sorcery) {
312 }
314}
#define ast_sorcery_unref(sorcery)
Decrease the reference count of a sorcery structure.
Definition: sorcery.h:1500

References AST_MODULE_LOAD_SUCCESS, ast_sorcery_unref, and geoloc_sorcery.

Referenced by unload_module().

◆ geoloc_civicaddr_list_to_xml()

struct ast_xml_node * geoloc_civicaddr_list_to_xml ( const struct ast_variable resolved_location,
const char *  ref_string 
)

Definition at line 89 of file geoloc_civicaddr.c.

91{
92 char *lang = NULL;
93 char *s = NULL;
94 struct ast_variable *var;
95 struct ast_xml_node *ca_node;
96 struct ast_xml_node *child_node;
97 int rc = 0;
98 SCOPE_ENTER(3, "%s", ref_string);
99
100 lang = (char *)ast_variable_find_in_list(resolved_location, "lang");
101 if (ast_strlen_zero(lang)) {
103 for (s = lang; *s; s++) {
104 if (*s == '_') {
105 *s = '-';
106 }
107 }
108 }
109
110 ca_node = ast_xml_new_node("civicAddress");
111 if (!ca_node) {
112 SCOPE_EXIT_LOG_RTN_VALUE(NULL, LOG_ERROR, "%s: Unable to create 'civicAddress' XML node\n", ref_string);
113 }
114 rc = ast_xml_set_attribute(ca_node, "lang", lang);
115 if (rc != 0) {
116 ast_xml_free_node(ca_node);
117 SCOPE_EXIT_LOG_RTN_VALUE(NULL, LOG_ERROR, "%s: Unable to create 'lang' XML attribute\n", ref_string);
118 }
119
120 for (var = (struct ast_variable *)resolved_location; var; var = var->next) {
121 if (ast_strings_equal(var->name, "lang")) {
122 continue;
123 }
124 child_node = ast_xml_new_child(ca_node, var->name);
125 if (!child_node) {
126 ast_xml_free_node(ca_node);
127 SCOPE_EXIT_LOG_RTN_VALUE(NULL, LOG_ERROR, "%s: Unable to create '%s' XML node\n", var->name, ref_string);
128 }
129 ast_xml_set_text(child_node, var->value);
130 }
131
132 SCOPE_EXIT_RTN_VALUE(ca_node, "%s: Done\n", ref_string);
133}
#define var
Definition: ast_expr2f.c:605
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define SCOPE_EXIT_RTN_VALUE(__return_value,...)
#define SCOPE_EXIT_LOG_RTN_VALUE(__value, __log_level,...)
#define SCOPE_ENTER(level,...)
const char * ast_variable_find_in_list(const struct ast_variable *list, const char *variable)
Gets the value of a variable from a variable list by name.
Definition: main/config.c:919
#define LOG_ERROR
char ast_defaultlanguage[]
Definition: options.c:98
#define NULL
Definition: resample.c:96
int ast_strings_equal(const char *str1, const char *str2)
Compare strings for equality checking for NULL.
Definition: strings.c:238
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
Structure for variables, used for configurations and for channel variables.
struct ast_xml_node * ast_xml_new_child(struct ast_xml_node *parent, const char *child_name)
Add a child node inside a passed parent node.
Definition: xml.c:158
struct ast_xml_node * ast_xml_new_node(const char *name)
Create a XML node.
Definition: xml.c:146
int ast_xml_set_attribute(struct ast_xml_node *node, const char *name, const char *value)
Set an attribute to a node.
Definition: xml.c:286
void ast_xml_set_text(struct ast_xml_node *node, const char *content)
Set an element content string.
Definition: xml.c:364
void ast_xml_free_node(struct ast_xml_node *node)
Free node.
Definition: xml.c:245

References ast_defaultlanguage, ast_strdupa, ast_strings_equal(), ast_strlen_zero(), ast_variable_find_in_list(), ast_xml_free_node(), ast_xml_new_child(), ast_xml_new_node(), ast_xml_set_attribute(), ast_xml_set_text(), LOG_ERROR, NULL, SCOPE_ENTER, SCOPE_EXIT_LOG_RTN_VALUE, SCOPE_EXIT_RTN_VALUE, and var.

Referenced by geoloc_eprofile_to_intermediate().

◆ geoloc_civicaddr_load()

int geoloc_civicaddr_load ( void  )

Definition at line 140 of file geoloc_civicaddr.c.

141{
142 qsort(addr_code_name_entries, ARRAY_LEN(addr_code_name_entries), sizeof(const char *),
144
146}
static int compare_civicaddr_codes(const void *_a, const void *_b)
static const char * addr_code_name_entries[]
#define ARRAY_LEN(a)
Definition: utils.h:666

References addr_code_name_entries, ARRAY_LEN, AST_MODULE_LOAD_SUCCESS, and compare_civicaddr_codes().

Referenced by load_module().

◆ geoloc_civicaddr_reload()

int geoloc_civicaddr_reload ( void  )

Definition at line 148 of file geoloc_civicaddr.c.

149{
151}

References AST_MODULE_LOAD_SUCCESS.

Referenced by reload_module().

◆ geoloc_civicaddr_unload()

int geoloc_civicaddr_unload ( void  )

Definition at line 135 of file geoloc_civicaddr.c.

136{
138}

References AST_MODULE_LOAD_SUCCESS.

Referenced by unload_module().

◆ geoloc_config_load()

int geoloc_config_load ( void  )

Definition at line 659 of file geoloc_config.c.

660{
662 int rc = 0;
663
664 if (!(geoloc_sorcery = ast_sorcery_open())) {
665 ast_log(LOG_ERROR, "Failed to open geolocation sorcery\n");
667 }
668
670 result = ast_sorcery_apply_default(geoloc_sorcery, "location", "config", "geolocation.conf,criteria=type=location");
672 ast_log(LOG_ERROR, "Failed to apply defaults for geoloc location object with sorcery\n");
674 }
675
677 if (rc != 0) {
678 ast_log(LOG_ERROR, "Failed to register geoloc location object with sorcery\n");
680 }
681
682 ast_sorcery_object_field_register(geoloc_sorcery, "location", "type", "", OPT_NOOP_T, 0, 0);
684 location_format_handler, location_format_to_str, NULL, 0, 0);
686 location_location_info_handler, location_location_info_to_str, location_location_info_dup, 0, 0);
688 location_confidence_handler, location_confidence_to_str, location_confidence_dup, 0, 0);
689 ast_sorcery_object_field_register(geoloc_sorcery, "location", "location_source", "", OPT_STRINGFIELD_T,
690 0, STRFLDSET(struct ast_geoloc_location, location_source));
693
694
696 /*
697 * The memory backend is used to contain the built-in profiles.
698 */
701 ast_log(LOG_ERROR, "Failed to add memory wizard mapping to geoloc profile object\n");
703 }
704
706 "geolocation.conf,criteria=type=profile", 0);
708 ast_log(LOG_ERROR, "Failed to add memory wizard mapping to geoloc profile object\n");
710 }
712 if (rc != 0) {
713 ast_log(LOG_ERROR, "Failed to register geoloc profile object with sorcery\n");
715 }
716
717 ast_sorcery_object_field_register(geoloc_sorcery, "profile", "type", "", OPT_NOOP_T, 0, 0);
719 pidf_element_names[AST_PIDF_ELEMENT_DEVICE], profile_pidf_element_handler, profile_pidf_element_to_str, NULL, 0, 0);
720 ast_sorcery_object_field_register(geoloc_sorcery, "profile", "location_reference", "", OPT_STRINGFIELD_T,
721 0, STRFLDSET(struct ast_geoloc_profile, location_reference));
722 ast_sorcery_object_field_register_custom(geoloc_sorcery, "profile", "profile_precedence", "discard_incoming",
723 profile_precedence_handler, profile_precedence_to_str, NULL, 0, 0);
725 profile_usage_rules_handler, profile_usage_rules_to_str, profile_usage_rules_dup, 0, 0);
726 ast_sorcery_object_field_register_custom(geoloc_sorcery, "profile", "location_info_refinement", NULL,
727 profile_location_refinement_handler, profile_location_refinement_to_str, profile_location_refinement_dup, 0, 0);
728 ast_sorcery_object_field_register_custom(geoloc_sorcery, "profile", "location_variables", NULL,
729 profile_location_variables_handler, profile_location_variables_to_str, profile_location_variables_dup, 0, 0);
732 ast_sorcery_object_field_register(geoloc_sorcery, "profile", "allow_routing_use",
733 "no", OPT_BOOL_T, 1, FLDSET(struct ast_geoloc_profile, allow_routing_use));
734 ast_sorcery_object_field_register(geoloc_sorcery, "profile", "suppress_empty_ca_elements",
735 "no", OPT_BOOL_T, 1, FLDSET(struct ast_geoloc_profile, suppress_empty_ca_elements));
736
738 profile_format_handler, profile_format_to_str, NULL, 0, 0);
740 profile_location_info_handler, profile_location_info_to_str, profile_location_info_dup, 0, 0);
742 profile_confidence_handler, profile_confidence_to_str, profile_confidence_dup, 0, 0);
743 ast_sorcery_object_field_register(geoloc_sorcery, "profile", "location_source", "", OPT_STRINGFIELD_T,
744 0, STRFLDSET(struct ast_geoloc_profile, location_source));
747
748
750
752 if (rc != 0) {
753 ast_log(LOG_ERROR, "Failed to load default geoloc profiles\n");
755 }
756
757
759
761}
#define ast_log
Definition: astobj2.c:42
static PGresult * result
Definition: cel_pgsql.c:84
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
#define STRFLDSET(type,...)
Convert a struct and a list of stringfield fields to an argument list of field offsets.
#define FLDSET(type,...)
Convert a struct and list of fields to an argument list of field offsets.
@ OPT_NOOP_T
Type for a default handler that should do nothing.
@ OPT_BOOL_T
Type for default option handler for bools (ast_true/ast_false)
@ OPT_STRINGFIELD_T
Type for default option handler for stringfields.
static void * geoloc_location_alloc(const char *name)
Definition: geoloc_config.c:60
static struct ast_sorcery * geoloc_sorcery
Definition: geoloc_config.c:25
static void * geoloc_profile_alloc(const char *name)
Definition: geoloc_config.c:92
static int geoloc_location_apply_handler(const struct ast_sorcery *sorcery, void *obj)
static const char * pidf_element_names[]
Definition: geoloc_config.c:27
static int geoloc_profile_apply_handler(const struct ast_sorcery *sorcery, void *obj)
static int geoloc_load_default_profiles(void)
static struct ast_cli_entry geoloc_location_cli_commands[]
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
static int notes
Definition: pval.c:66
@ AST_PIDF_ELEMENT_DEVICE
@ AST_GEOLOC_FORMAT_NONE
const char * method
Definition: res_pjsip.c:1279
#define ast_sorcery_apply_wizard_mapping(sorcery, type, name, data, caching)
Apply additional object wizard mappings.
Definition: sorcery.h:510
void ast_sorcery_load(const struct ast_sorcery *sorcery)
Inform any wizards to load persistent objects.
Definition: sorcery.c:1377
#define ast_sorcery_object_register(sorcery, type, alloc, transform, apply)
Register an object type.
Definition: sorcery.h:837
#define ast_sorcery_object_field_register_custom(sorcery, type, name, default_val, config_handler, sorcery_handler, multiple_handler, flags,...)
Register a field within an object with custom handlers.
Definition: sorcery.h:1005
#define ast_sorcery_apply_config(sorcery, name)
Definition: sorcery.h:455
#define ast_sorcery_object_field_register(sorcery, type, name, default_val, opt_type, flags,...)
Register a field within an object.
Definition: sorcery.h:955
#define ast_sorcery_apply_default(sorcery, type, name, data)
Definition: sorcery.h:476
#define ast_sorcery_open()
Open a new sorcery structure.
Definition: sorcery.h:406
ast_sorcery_apply_result
Definition: sorcery.h:423
@ AST_SORCERY_APPLY_SUCCESS
Definition: sorcery.h:427
@ AST_SORCERY_APPLY_FAIL
Definition: sorcery.h:425

References ast_geoloc_profile::allow_routing_use, ARRAY_LEN, ast_cli_register_multiple, AST_GEOLOC_FORMAT_NONE, ast_log, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, AST_PIDF_ELEMENT_DEVICE, ast_sorcery_apply_config, ast_sorcery_apply_default, AST_SORCERY_APPLY_FAIL, AST_SORCERY_APPLY_SUCCESS, ast_sorcery_apply_wizard_mapping, ast_sorcery_load(), ast_sorcery_object_field_register, ast_sorcery_object_field_register_custom, ast_sorcery_object_register, ast_sorcery_open, FLDSET, geoloc_load_default_profiles(), geoloc_location_alloc(), geoloc_location_apply_handler(), geoloc_location_cli_commands, geoloc_profile_alloc(), geoloc_profile_apply_handler(), geoloc_sorcery, ast_geoloc_profile::location_reference, ast_geoloc_profile::location_source, LOG_ERROR, method, notes, NULL, OPT_BOOL_T, OPT_NOOP_T, OPT_STRINGFIELD_T, pidf_element_names, result, STRFLDSET, and ast_geoloc_profile::suppress_empty_ca_elements.

Referenced by load_module().

◆ geoloc_config_reload()

int geoloc_config_reload ( void  )

Definition at line 598 of file geoloc_config.c.

599{
600 if (geoloc_sorcery) {
602 }
604}
void ast_sorcery_reload(const struct ast_sorcery *sorcery)
Inform any wizards to reload persistent objects.
Definition: sorcery.c:1408

References AST_MODULE_LOAD_SUCCESS, ast_sorcery_reload(), and geoloc_sorcery.

Referenced by geoloc_config_cli_reload(), and reload_module().

◆ geoloc_config_unload()

int geoloc_config_unload ( void  )

Definition at line 606 of file geoloc_config.c.

607{
609
612
613 if (geoloc_sorcery) {
615 }
617
618 return 0;
619}
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: clicompat.c:30
int ast_sorcery_object_unregister(struct ast_sorcery *sorcery, const char *type)
Unregister an object type.
Definition: sorcery.c:1061

References ARRAY_LEN, ast_cli_unregister_multiple(), ast_sorcery_object_unregister(), ast_sorcery_unref, geoloc_location_cli_commands, geoloc_sorcery, and NULL.

Referenced by unload_module().

◆ geoloc_dialplan_load()

int geoloc_dialplan_load ( void  )

Definition at line 363 of file geoloc_dialplan.c.

364{
365 int res = 0;
366
368
370}
static struct ast_custom_function geoloc_function
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1558

References ast_custom_function_register, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, and geoloc_function.

Referenced by load_module().

◆ geoloc_dialplan_reload()

int geoloc_dialplan_reload ( void  )

Definition at line 372 of file geoloc_dialplan.c.

373{
375}

References AST_MODULE_LOAD_SUCCESS.

Referenced by reload_module().

◆ geoloc_dialplan_unload()

int geoloc_dialplan_unload ( void  )

Definition at line 356 of file geoloc_dialplan.c.

357{
359
361}
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.

References ast_custom_function_unregister(), AST_MODULE_LOAD_SUCCESS, and geoloc_function.

Referenced by unload_module().

◆ geoloc_eprofile_load()

int geoloc_eprofile_load ( void  )

Definition at line 1178 of file geoloc_eprofile.c.

1179{
1182
1185
1186 pidf_to_eprofile_xslt = ast_xslt_read_memory(
1188 if (!pidf_to_eprofile_xslt) {
1189 ast_log(LOG_ERROR, "Unable to read pidf_to_eprofile_xslt from memory\n");
1191 }
1192
1195
1196 eprofile_to_pidf_xslt = ast_xslt_read_memory(
1198 if (!eprofile_to_pidf_xslt) {
1199 ast_log(LOG_ERROR, "Unable to read eprofile_to_pidf_xslt from memory\n");
1200// geoloc_eprofile_unload();
1202 }
1203
1205
1206 load_tests();
1207
1209}
const uint8_t _binary_res_geolocation_eprofile_to_pidf_xslt_start[]
static size_t pidf_lo_test_xml_size
static struct ast_xslt_doc * pidf_to_eprofile_xslt
static struct ast_sorcery * geoloc_sorcery
const uint8_t _binary_res_geolocation_eprofile_to_pidf_xslt_end[]
const uint8_t _binary_res_geolocation_pidf_to_eprofile_xslt_end[]
static size_t eprofile_to_pidf_xslt_size
const uint8_t _binary_res_geolocation_pidf_lo_test_xml_end[]
const uint8_t _binary_res_geolocation_pidf_to_eprofile_xslt_start[]
const uint8_t _binary_res_geolocation_pidf_lo_test_xml_start[]
static size_t pidf_to_eprofile_xslt_size
static struct ast_xslt_doc * eprofile_to_pidf_xslt
static void load_tests(void)

References _binary_res_geolocation_eprofile_to_pidf_xslt_end, _binary_res_geolocation_eprofile_to_pidf_xslt_start, _binary_res_geolocation_pidf_lo_test_xml_end, _binary_res_geolocation_pidf_lo_test_xml_start, _binary_res_geolocation_pidf_to_eprofile_xslt_end, _binary_res_geolocation_pidf_to_eprofile_xslt_start, ast_log, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, eprofile_to_pidf_xslt, eprofile_to_pidf_xslt_size, geoloc_get_sorcery(), geoloc_sorcery, load_tests(), LOG_ERROR, pidf_lo_test_xml_size, pidf_to_eprofile_xslt, and pidf_to_eprofile_xslt_size.

Referenced by load_module().

◆ geoloc_eprofile_reload()

int geoloc_eprofile_reload ( void  )

Definition at line 1211 of file geoloc_eprofile.c.

1212{
1214}

References AST_MODULE_LOAD_SUCCESS.

Referenced by reload_module().

◆ geoloc_eprofile_resolve_varlist()

struct ast_variable * geoloc_eprofile_resolve_varlist ( struct ast_variable source,
struct ast_variable variables,
struct ast_channel chan 
)

Definition at line 351 of file geoloc_eprofile.c.

353{
354 struct ast_variable *dest = NULL;
355 struct ast_variable *var = NULL;
356 struct varshead *vh = NULL;
357 struct ast_str *buf = ast_str_alloca(256);
358
359 if (!source || !chan) {
360 return NULL;
361 }
362
363 /*
364 * ast_str_substitute_variables does only minimal recursive resolution so we need to
365 * pre-resolve each variable in the "variables" list, then use that result to
366 * do the final pass on the "source" variable list.
367 */
368 if (variables) {
369 var = variables;
370 vh = ast_var_list_create();
371 if (!vh) {
372 return NULL;
373 }
374 for ( ; var; var = var->next) {
375 ast_str_substitute_variables_full2(&buf, 0, chan, vh, var->value, NULL, 1);
378 }
379 }
380
381 var = source;
382 for ( ; var; var = var->next) {
383 struct ast_variable *newvar = NULL;
384 ast_str_substitute_variables_full2(&buf, 0, chan, vh, var->value, NULL, 1);
385 newvar = ast_variable_new(var->name, ast_str_buffer(buf), "");
386 if (!newvar) {
389 return NULL;
390 }
391 ast_variable_list_append(&dest, newvar);
393 }
395
396 return dest;
397}
void ast_var_list_destroy(struct varshead *head)
Definition: chanvars.c:109
static void AST_VAR_LIST_INSERT_TAIL(struct varshead *head, struct ast_var_t *var)
Definition: chanvars.h:51
#define ast_var_assign(name, value)
Definition: chanvars.h:40
struct varshead * ast_var_list_create(void)
Definition: chanvars.c:97
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define ast_variable_new(name, value, filename)
#define ast_variable_list_append(head, new_var)
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Definition: extconf.c:1262
void ast_str_substitute_variables_full2(struct ast_str **buf, ssize_t maxlen, struct ast_channel *c, struct varshead *headp, const char *templ, size_t *used, int use_both)
Perform variable/function/expression substitution on an ast_str.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:761
#define ast_str_alloca(init_len)
Definition: strings.h:848
void ast_str_reset(struct ast_str *buf)
Reset the content of a dynamic string. Useful before a series of ast_str_append.
Definition: strings.h:693
Support for dynamic strings.
Definition: strings.h:623

References ast_str_alloca, ast_str_buffer(), ast_str_reset(), ast_str_substitute_variables_full2(), ast_var_assign, ast_var_list_create(), ast_var_list_destroy(), AST_VAR_LIST_INSERT_TAIL(), ast_variable_list_append, ast_variable_new, ast_variables_destroy(), buf, NULL, and var.

Referenced by ast_geoloc_eprofile_to_uri(), and geoloc_eprofile_to_intermediate().

◆ geoloc_eprofile_unload()

int geoloc_eprofile_unload ( void  )

Definition at line 1160 of file geoloc_eprofile.c.

1161{
1162 unload_tests();
1164 ast_xslt_close(pidf_to_eprofile_xslt);
1165 }
1166
1168 ast_xslt_close(eprofile_to_pidf_xslt);
1169 }
1170
1171 if (geoloc_sorcery) {
1173 }
1174
1176}
static void unload_tests(void)

References AST_MODULE_LOAD_SUCCESS, ast_sorcery_unref, eprofile_to_pidf_xslt, geoloc_sorcery, pidf_to_eprofile_xslt, and unload_tests().

Referenced by unload_module().

◆ geoloc_get_sorcery()

struct ast_sorcery * geoloc_get_sorcery ( void  )

Definition at line 244 of file geoloc_config.c.

245{
247 return geoloc_sorcery;
248}
void ast_sorcery_ref(struct ast_sorcery *sorcery)
Increase the reference count of a sorcery structure.
Definition: sorcery.c:1473

References ast_sorcery_ref(), and geoloc_sorcery.

Referenced by geoloc_channel_load(), and geoloc_eprofile_load().

◆ geoloc_gml_list_to_xml()

struct ast_xml_node * geoloc_gml_list_to_xml ( const struct ast_variable resolved_location,
const char *  ref_string 
)

Definition at line 238 of file geoloc_gml.c.

240{
241 const char *shape;
242 char *crs;
243 struct ast_variable *var;
244 struct ast_xml_node *gml_node;
245 struct ast_xml_node *child_node;
246 int rc = 0;
247
248 SCOPE_ENTER(3, "%s", ref_string);
249
250 if (!resolved_location) {
251 SCOPE_EXIT_LOG_RTN_VALUE(NULL, LOG_ERROR, "%s: resolved_location was NULL\n",
252 ref_string);
253 }
254
255 shape = ast_variable_find_in_list(resolved_location, "shape");
256 if (ast_strlen_zero(shape)) {
257 SCOPE_EXIT_LOG_RTN_VALUE(NULL, LOG_ERROR, "%s: There's no 'shape' parameter\n",
258 ref_string);
259 }
260 crs = (char *)ast_variable_find_in_list(resolved_location, "crs");
261 if (ast_strlen_zero(crs)) {
262 crs = "2d";
263 }
264
265 gml_node = ast_xml_new_node(shape);
266 if (!gml_node) {
267 SCOPE_EXIT_LOG_RTN_VALUE(NULL, LOG_ERROR, "%s: Unable to create '%s' XML node\n", shape, ref_string);
268 }
269 rc = ast_xml_set_attribute(gml_node, "crs", crs);
270 if (rc != 0) {
271 ast_xml_free_node(gml_node);
272 SCOPE_EXIT_LOG_RTN_VALUE(NULL, LOG_ERROR, "%s: Unable to create 'crs' XML attribute\n", ref_string);
273 }
274
275 for (var = (struct ast_variable *)resolved_location; var; var = var->next) {
276 RAII_VAR(char *, value, NULL, ast_free);
277 char *uom = NULL;
278
279 if (ast_strings_equal(var->name, "shape") || ast_strings_equal(var->name, "crs")) {
280 continue;
281 }
282 value = ast_strdup(var->value);
283
284 if (ast_strings_equal(var->name, "orientation") || ast_strings_equal(var->name, "startAngle")
285 || ast_strings_equal(var->name, "openingAngle")) {
286 char *a = NULL;
287 char *junk = NULL;
288 float angle;
289 uom = value;
290
291 /* 'a' should now be the angle and 'uom' should be the uom */
292 a = strsep(&uom, " ");
293 angle = strtof(a, &junk);
294 /*
295 * strtof sets junk to the first non-valid character so if it's
296 * not empty after the conversion, there were unrecognized
297 * characters in the angle. It'll point to the NULL terminator
298 * if angle was completely converted.
299 */
300 if (!ast_strlen_zero(junk)) {
301 ast_xml_free_node(gml_node);
302 SCOPE_EXIT_LOG_RTN_VALUE(NULL, LOG_ERROR, "%s: The angle portion of parameter '%s' ('%s') is malformed\n",
303 ref_string, var->name, var->value);
304 }
305
306 if (ast_strlen_zero(uom)) {
307 uom = "degrees";
308 }
309
310 if (ast_begins_with(uom, "deg")) {
311 if (angle > 360.0) {
312 ast_xml_free_node(gml_node);
313 SCOPE_EXIT_LOG_RTN_VALUE(NULL, LOG_ERROR, "%s: Parameter '%s': '%s' is malformed. "
314 "Degrees can't be > 360.0\n",
315 ref_string, var->name, var->value);
316 }
317 } else if (ast_begins_with(uom, "rad")) {
318 if(angle > 100.0) {
319 ast_xml_free_node(gml_node);
320 SCOPE_EXIT_LOG_RTN_VALUE(NULL, LOG_ERROR, "%s: Parameter '%s': '%s' is malformed. "
321 "Radians can't be > 100.0\n",
322 ref_string, var->name, var->value);
323 }
324 } else {
325 ast_xml_free_node(gml_node);
326 SCOPE_EXIT_LOG_RTN_VALUE(NULL, LOG_ERROR, "%s: Parameter '%s': '%s' is malformed. "
327 "The unit of measure must be 'deg[rees]' or 'rad[ians]'\n",
328 ref_string, var->name, var->value);
329 }
330 }
331
332 child_node = ast_xml_new_child(gml_node, var->name);
333 if (!child_node) {
334 ast_xml_free_node(gml_node);
335 SCOPE_EXIT_LOG_RTN_VALUE(NULL, LOG_ERROR, "%s: Unable to create '%s' XML node\n", var->name, ref_string);
336 }
337 if (!ast_strlen_zero(uom)) {
338 rc = ast_xml_set_attribute(child_node, "uom", uom);
339 if (rc != 0) {
340 ast_xml_free_node(gml_node);
341 SCOPE_EXIT_LOG_RTN_VALUE(NULL, LOG_ERROR, "%s: Unable to create 'uom' XML attribute\n", ref_string);
342 }
343 }
344 ast_xml_set_text(child_node, value);
345 }
346
347 SCOPE_EXIT_RTN_VALUE(gml_node, "%s: Done\n", ref_string);
348}
#define ast_free(a)
Definition: astmm.h:180
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
char * strsep(char **str, const char *delims)
static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)
Checks whether a string begins with another.
Definition: strings.h:97
int value
Definition: syslog.c:37
static struct test_val a
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:941

References a, ast_begins_with(), ast_free, ast_strdup, ast_strings_equal(), ast_strlen_zero(), ast_variable_find_in_list(), ast_xml_free_node(), ast_xml_new_child(), ast_xml_new_node(), ast_xml_set_attribute(), ast_xml_set_text(), LOG_ERROR, NULL, RAII_VAR, SCOPE_ENTER, SCOPE_EXIT_LOG_RTN_VALUE, SCOPE_EXIT_RTN_VALUE, strsep(), value, and var.

Referenced by geoloc_eprofile_to_intermediate().

◆ geoloc_gml_load()

int geoloc_gml_load ( void  )

Definition at line 357 of file geoloc_gml.c.

358{
360
362}
static struct ast_cli_entry geoloc_gml_cli[]
Definition: geoloc_gml.c:234

References ARRAY_LEN, ast_cli_register_multiple, AST_MODULE_LOAD_SUCCESS, and geoloc_gml_cli.

Referenced by load_module().

◆ geoloc_gml_reload()

int geoloc_gml_reload ( void  )

Definition at line 364 of file geoloc_gml.c.

365{
367}

References AST_MODULE_LOAD_SUCCESS.

Referenced by reload_module().

◆ geoloc_gml_unload()

int geoloc_gml_unload ( void  )