22 #include "asterisk/res_geolocation.h"
24 #include "geoloc_private.h"
26 static const char *addr_code_name_entries[] = {
61 static int compare_civicaddr_codes(
const void *_a,
const void *_b)
64 int rc = strcmp(*(
const char **)_a, *(
const char **)_b);
68 int ast_geoloc_civicaddr_is_code_valid(
const char *code)
70 const char **
entry = bsearch(&code, addr_code_name_entries, ARRAY_LEN(addr_code_name_entries),
71 sizeof(
const char *), compare_civicaddr_codes);
72 return (entry != NULL);
75 enum ast_geoloc_validate_result ast_geoloc_civicaddr_validate_varlist(
79 for (; var; var = var->
next) {
80 int valid = ast_geoloc_civicaddr_is_code_valid(var->
name);
83 return AST_GEOLOC_VALIDATE_INVALID_VARNAME;
86 return AST_GEOLOC_VALIDATE_SUCCESS;
89 struct ast_xml_node *geoloc_civicaddr_list_to_xml(
const struct ast_variable *resolved_location,
90 const char *ref_string)
95 struct ast_xml_node *ca_node;
96 struct ast_xml_node *child_node;
98 SCOPE_ENTER(3,
"%s", ref_string);
101 if (ast_strlen_zero(lang)) {
103 for (s = lang; *s; s++) {
112 SCOPE_EXIT_LOG_RTN_VALUE(NULL, LOG_ERROR,
"%s: Unable to create 'civicAddress' XML node\n", ref_string);
117 SCOPE_EXIT_LOG_RTN_VALUE(NULL, LOG_ERROR,
"%s: Unable to create 'lang' XML attribute\n", ref_string);
120 for (var = (
struct ast_variable *)resolved_location; var; var = var->
next) {
127 SCOPE_EXIT_LOG_RTN_VALUE(NULL, LOG_ERROR,
"%s: Unable to create '%s' XML node\n", var->
name, ref_string);
132 SCOPE_EXIT_RTN_VALUE(ca_node,
"%s: Done\n", ref_string);
135 int geoloc_civicaddr_unload(
void)
140 int geoloc_civicaddr_load(
void)
142 qsort(addr_code_name_entries, ARRAY_LEN(addr_code_name_entries),
sizeof(
const char *),
143 compare_civicaddr_codes);
148 int geoloc_civicaddr_reload(
void)
struct ast_variable * next
Asterisk main include file. File version handling, generic pbx functions.
void ast_xml_free_node(struct ast_xml_node *node)
Free node.
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.
Configuration File Parser.
#define ast_strdupa(s)
duplicate a string in memory from the stack
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.
struct ast_xml_node * ast_xml_new_node(const char *name)
Create a XML node.
Asterisk XML abstraction layer.
int ast_strings_equal(const char *str1, const char *str2)
Compare strings for equality checking for NULL.
void ast_xml_set_text(struct ast_xml_node *node, const char *content)
Set an element content string.
int ast_xml_set_attribute(struct ast_xml_node *node, const char *name, const char *value)
Set an attribute to a node.
Standard Command Line Interface.