19 #ifndef GEOLOC_PRIVATE_H_
20 #define GEOLOC_PRIVATE_H_
26 #include "asterisk/res_geolocation.h"
28 #define CONFIG_STR_TO_ENUM(_stem) \
29 int ast_geoloc_ ## _stem ## _str_to_enum(const char *str) \
32 for (i = 0; i < ARRAY_LEN(_stem ## _names); i++) { \
33 if (ast_strings_equal(str, _stem ## _names[i])) { \
40 #define CONFIG_ENUM_HANDLER(_object, _stem) \
41 static int _object ## _ ## _stem ## _handler(const struct aco_option *opt, struct ast_variable *var, void *obj) \
43 struct ast_geoloc_ ## _object *_thisobject = obj; \
44 int enumval = ast_geoloc_ ## _stem ## _str_to_enum(var->value); \
45 if (enumval == -1) { \
48 _thisobject->_stem = enumval; \
53 #define GEOLOC_ENUM_TO_NAME(_stem) \
54 const char * ast_geoloc_ ## _stem ## _to_name(int ix) \
56 if (!ARRAY_IN_BOUNDS(ix, _stem ## _names)) { \
59 return _stem ## _names[ix]; \
63 #define CONFIG_ENUM_TO_STR(_object, _stem) \
64 static int _object ## _ ## _stem ## _to_str(const void *obj, const intptr_t *args, char **buf) \
66 const struct ast_geoloc_ ## _object *_thisobject = obj; \
67 if (!ARRAY_IN_BOUNDS(_thisobject->_stem, _stem ## _names)) { \
68 *buf = ast_strdup("none"); \
70 *buf = ast_strdup(_stem ## _names[_thisobject->_stem]); \
75 #define CONFIG_ENUM(_object, _stem) \
76 CONFIG_STR_TO_ENUM(_stem) \
77 GEOLOC_ENUM_TO_NAME(_stem) \
78 CONFIG_ENUM_HANDLER(_object, _stem) \
79 CONFIG_ENUM_TO_STR(_object, _stem)
81 #define CONFIG_VAR_LIST_HANDLER(_object, _stem) \
82 static int _object ## _ ## _stem ## _handler(const struct aco_option *opt, struct ast_variable *var, void *obj) \
84 struct ast_geoloc_ ## _object *_thisobject = obj; \
85 struct ast_variable *new_var; \
86 char *item_string, *item, *item_name, *item_value; \
88 if (ast_strlen_zero(var->value)) { return 0; } \
89 item_string = ast_strdupa(var->value); \
90 while ((item = ast_strsep(&item_string, ',', AST_STRSEP_ALL))) { \
91 item_name = ast_strsep(&item, '=', AST_STRSEP_ALL); \
92 item_value = ast_strsep(&item, '=', AST_STRSEP_ALL); \
93 new_var = ast_variable_new(item_name, S_OR(item_value, ""), ""); \
98 ast_variable_list_append(&_thisobject->_stem, new_var); \
103 #define CONFIG_VAR_LIST_DUP(_object, _stem) \
104 static int _object ## _ ## _stem ## _dup(const void *obj, struct ast_variable **fields) \
106 const struct ast_geoloc_ ## _object *_thisobject = obj; \
107 if (_thisobject->_stem) { \
108 *fields = ast_variables_dup(_thisobject->_stem); \
113 #define CONFIG_VAR_LIST_TO_STR(_object, _stem) \
114 static int _object ## _ ## _stem ## _to_str(const void *obj, const intptr_t *args, char **buf) \
116 const struct ast_geoloc_ ## _object *_thisobject = obj; \
117 struct ast_str *str = ast_variable_list_join(_thisobject->_stem, ",", "=", "\"", NULL); \
118 *buf = ast_strdup(ast_str_buffer(str)); \
123 #define CONFIG_VAR_LIST(_object, _stem) \
124 CONFIG_VAR_LIST_HANDLER(_object, _stem) \
125 CONFIG_VAR_LIST_DUP(_object, _stem) \
126 CONFIG_VAR_LIST_TO_STR(_object, _stem)
128 int geoloc_config_load(
void);
129 int geoloc_config_reload(
void);
130 int geoloc_config_unload(
void);
132 struct ast_xml_node *geoloc_civicaddr_list_to_xml(
const struct ast_variable *resolved_location,
133 const char *ref_string);
134 int geoloc_civicaddr_load(
void);
135 int geoloc_civicaddr_unload(
void);
136 int geoloc_civicaddr_reload(
void);
138 struct ast_xml_node *geoloc_gml_list_to_xml(
const struct ast_variable *resolved_location,
139 const char *ref_string);
140 int geoloc_gml_unload(
void);
141 int geoloc_gml_load(
void);
142 int geoloc_gml_reload(
void);
144 int geoloc_dialplan_unload(
void);
145 int geoloc_dialplan_load(
void);
146 int geoloc_dialplan_reload(
void);
148 int geoloc_channel_unload(
void);
149 int geoloc_channel_load(
void);
150 int geoloc_channel_reload(
void);
152 int geoloc_eprofile_unload(
void);
153 int geoloc_eprofile_load(
void);
154 int geoloc_eprofile_reload(
void);
Main Channel structure associated with a channel.
Asterisk locking-related definitions:
Structure for variables, used for configurations and for channel variables.
Full structure for sorcery.
Configuration File Parser.
Asterisk module definitions.
Sorcery Data Access Layer API.