39#define RESOLVE_FOR_READ(_param) \ 
   41    if (ast_test_flag(&opts, OPT_GEOLOC_RESOLVE)) { \ 
   42        struct ast_variable *resolved = geoloc_eprofile_resolve_varlist( \ 
   43            eprofile->_param, eprofile->location_variables, chan); \ 
   45            ast_log(LOG_ERROR, "%s: Unable to resolve " #_param "\n", chan_name); \ 
   46            pbx_builtin_setvar_helper(chan, "GEOLOCPROFILESTATUS", "-3"); \ 
   49        varlist_to_str(resolved, buf, len); \ 
   50        ast_variables_destroy(resolved); \ 
   52        varlist_to_str(eprofile->_param, buf, len); \ 
 
   68    const char *cmd, 
char *data, 
struct ast_str **
buf, ssize_t 
len)
 
  107        ast_log(
LOG_NOTICE, 
"%s: There is no geoloc profile on this channel\n", chan_name);
 
  113    if (!orig_eprofile) {
 
  114        ast_log(
LOG_NOTICE, 
"%s: There is no geoloc profile on this channel\n", chan_name);
 
 
  175#define VAR_LIST_REPLACE(_old, _new) \ 
  176    ast_variables_destroy(_old); \ 
 
  179#define TEST_ENUM_VALUE(_chan_name, _ep, _field, _value) \ 
  181    enum ast_geoloc_ ## _field v; \ 
  182    v = ast_geoloc_ ## _field ## _str_to_enum(_value); \ 
  183    if (v == AST_GEOLOC_INVALID_VALUE) { \ 
  184        ast_log(LOG_ERROR, "%s: %s '%s' is invalid\n", _chan_name, #_field, value); \ 
  185        pbx_builtin_setvar_helper(chan, "GEOLOCPROFILESTATUS", "-3"); \ 
 
  191#define TEST_VARLIST(_chan_name, _ep, _field, _value) \ 
  193    struct ast_variable *_list; \ 
  194    _list = ast_variable_list_from_quoted_string(_value, ",", "=", "\"" ); \ 
  196        ast_log(LOG_ERROR, "%s: %s '%s' is malformed or contains invalid values", _chan_name, #_field, _value); \ 
  197        pbx_builtin_setvar_helper(chan, "GEOLOCPROFILESTATUS", "-3"); \ 
  200    if (ast_test_flag(&opts, OPT_GEOLOC_APPEND)) { \ 
  201        ast_variable_list_append(&_ep->_field, _list); \ 
  203        VAR_LIST_REPLACE(_ep->_field, _list); \ 
 
  208#define RESOLVE_FOR_WRITE(_param) \ 
  210if (ast_test_flag(&opts, OPT_GEOLOC_RESOLVE)) { \ 
  211    struct ast_variable *resolved = geoloc_eprofile_resolve_varlist( \ 
  212        eprofile->_param, eprofile->location_variables, chan); \ 
  214        ast_log(LOG_ERROR, "%s: Unable to resolve " #_param " %p %p\n", chan_name, eprofile->_param, eprofile->location_variables); \ 
  215        pbx_builtin_setvar_helper(chan, "GEOLOCPROFILESTATUS", "-3"); \ 
  218    VAR_LIST_REPLACE(eprofile->_param, resolved); \ 
 
  259    ast_debug(1, 
"%s: name: %s value: %s  options: %s append: %s resolve: %s\n", chan_name,
 
 
  351    .
name = 
"GEOLOC_PROFILE",
 
 
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
General Asterisk PBX channel definitions.
const char * ast_channel_name(const struct ast_channel *chan)
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Standard Command Line Interface.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static int geoloc_profile_read(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
static const struct ast_app_option action_options[128]
#define RESOLVE_FOR_WRITE(_param)
#define TEST_ENUM_VALUE(_chan_name, _ep, _field, _value)
int geoloc_dialplan_reload(void)
int geoloc_dialplan_unload(void)
#define RESOLVE_FOR_READ(_param)
int geoloc_dialplan_load(void)
static struct ast_custom_function geoloc_function
static void varlist_to_str(struct ast_variable *list, struct ast_str **buf, size_t len)
#define TEST_VARLIST(_chan_name, _ep, _field, _value)
static int geoloc_profile_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
Configuration File Parser.
#define ast_debug(level,...)
Log a DEBUG message.
Asterisk module definitions.
@ AST_MODULE_LOAD_SUCCESS
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Core PBX routines and definitions.
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name.
#define ast_custom_function_register(acf)
Register a custom function.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
int ast_geoloc_eprofile_refresh_location(struct ast_geoloc_eprofile *eprofile)
Refresh the effective profile with any changed info.
struct ast_geoloc_eprofile * ast_geoloc_eprofile_dup(struct ast_geoloc_eprofile *src)
Duplicate an effective profile.
struct ast_geoloc_eprofile * ast_geoloc_datastore_get_eprofile(struct ast_datastore *ds, int ix)
Retrieve a specific eprofile from a datastore by index.
struct ast_geoloc_location *AST_OPTIONAL_API_NAME() ast_geoloc_get_location(const char *id)
Retrieve a geolocation location object by id.
struct ast_datastore * ast_geoloc_datastore_create(const char *id)
Create an empty geoloc datastore.
struct ast_geoloc_eprofile * ast_geoloc_eprofile_alloc(const char *name)
Geolocation Effective Profile Functions.
int ast_geoloc_datastore_set_inheritance(struct ast_datastore *ds, int inherit)
Sets the inheritance flag on the datastore.
int ast_geoloc_datastore_add_eprofile(struct ast_datastore *ds, struct ast_geoloc_eprofile *eprofile)
Add an eprofile to a datastore.
struct ast_datastore * ast_geoloc_datastore_find(struct ast_channel *chan)
Retrieves the geoloc datastore from a channel, if any.
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
String manipulation functions.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
int ast_strings_equal(const char *str1, const char *str2)
Compare strings for equality checking for NULL.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Main Channel structure associated with a channel.
Data structure associated with a custom dialplan function.
Structure for a data store object.
Structure used to handle boolean flags.
struct ast_variable * effective_location
const ast_string_field location_reference
enum ast_geoloc_format format
enum ast_geoloc_pidf_element pidf_element
const ast_string_field method
enum ast_geoloc_precedence precedence
const ast_string_field notes
const ast_string_field id
int suppress_empty_ca_elements
struct ast_variable * confidence
const ast_string_field location_source
enum ast_geoloc_format format
struct ast_variable * confidence
const ast_string_field location_source
struct ast_variable * location_info
Support for dynamic strings.
Structure for variables, used for configurations and for channel variables.
#define ast_test_flag(p, flag)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.