31#define MAX_SHAPE_ATTRIBUTES 9
38#define SET_RESULT(__result, ...) \
41 __ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, result, __VA_ARGS__); \
64 count = sscanf(
value,
"%f %f %f", &lat, &lon, &alt);
80 if (sscanf(
value,
"%f", &
val) != 1) {
96 char **angle,
char **uom,
char **
result)
98 char *tmp_angle =
NULL;
109 f_angle = strtof(tmp_angle, &junk);
130 SET_RESULT(
result,
"Angle '%s' must be <= 360.0 for UOM '%s' in '%s'", tmp_angle, tmp_uom,
name);
135 SET_RESULT(
result,
"Angle '%s' must be <= 100.0 for UOM '%s' in '%s'", tmp_angle, tmp_uom,
name);
156#define _SENTRY {NULL, -1, -1, NULL}
158#define CRS_OPT {"crs", 0, 1, crs_validator}
159#define CRS_REQ {"crs", 1, 1, crs_validator}
164 {
"Circle",
"2d", {
CRS_OPT, {
"pos", 1, 1,
pos_validator}, {
"radius", 1, 1,
float_validator},
_SENTRY }},
165 {
"Ellipse",
"2d", {
CRS_OPT, {
"pos", 1, 1,
pos_validator}, {
"semiMajorAxis", 1, 1,
float_validator},
167 {
"ArcBand",
"2d", {
CRS_OPT, {
"pos", 1, 1,
pos_validator}, {
"innerRadius", 1, 1,
float_validator},
171 {
"Sphere",
"3d", {
CRS_REQ, {
"pos", 1, 1,
pos_validator}, {
"radius", 1, 1,
float_validator},
_SENTRY }},
172 {
"Ellipsoid",
"3d", {
CRS_REQ, {
"pos", 1, 1,
pos_validator}, {
"semiMajorAxis", 1, 1,
float_validator},
175 {
"Prism",
"3d", {
CRS_REQ, {
"pos", 3, -1,
pos_validator}, {
"height", 1, 1,
float_validator},
_SENTRY }},
183 for (i = 0; i < shape_count; i++) {
213 int vname_index = -1;
219 if (vname_index < 0) {
223 if (!
gml_shape_defs[shape_index].required_attributes[vname_index].validator(
var->name,
var->value,
240 if (count <
gml_shape_defs[shape_index].required_attributes[i].min_required) {
247 if (
gml_shape_defs[shape_index].required_attributes[i].max_allowed > 0 &&
248 count >
gml_shape_defs[shape_index].required_attributes[i].max_allowed) {
264 int shape_index = -1;
273 if (shape_index < 0) {
310 e->
command =
"geoloc show gml_shape_defs";
312 "Usage: geoloc show gml_shape_defs\n"
313 " Show the GML Shape definitions.\n";
319 ast_cli(
a->fd,
"%-16s %-3s %-32s\n",
"Shape",
"CRS",
"Attributes name(min,max)");
320 ast_cli(
a->fd,
"================ === ===============================\n");
350 const char *ref_string)
355 struct ast_xml_node *gml_node;
356 struct ast_xml_node *child_node;
363 if (!resolved_location) {
void ast_cli_unregister_multiple(void)
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
Standard Command Line Interface.
#define AST_CLI_DEFINE(fn, txt,...)
void ast_cli(int fd, const char *fmt,...)
#define ast_cli_register_multiple(e, len)
Register multiple commands.
static enum ast_geoloc_validate_result validate_def_varlist(int shape_index, const struct ast_variable *varlist, char **result)
enum ast_geoloc_validate_result ast_geoloc_gml_validate_varlist(struct ast_variable *varlist, char **result)
Validate that the variables in the list represent a valid GML shape.
static int find_attribute_index(int shape_index, const char *name)
static int angle_validator(const char *name, const char *value, const struct ast_variable *varlist, char **result)
static int crs_validator(const char *name, const char *value, const struct ast_variable *varlist, char **result)
#define SET_RESULT(__result,...)
static int pos_validator(const char *name, const char *value, const struct ast_variable *varlist, char **result)
static int float_validator(const char *name, const char *value, const struct ast_variable *varlist, char **result)
#define MAX_SHAPE_ATTRIBUTES
struct ast_xml_node * geoloc_gml_list_to_xml(struct ast_variable *resolved_location, const char *ref_string)
@ ANGLE_PARSE_ERROR_INVALID_UOM
@ ANGLE_PARSE_ERROR_NO_ANGLE
@ ANGLE_PARSE_RESULT_SUCCESS
@ ANGLE_PARSE_ERROR_ANGLE_OUT_OF_RANGE
@ ANGLE_PARSE_ERROR_INVALID_ANGLE
static int find_shape_index(const char *shape)
static struct ast_cli_entry geoloc_gml_cli[]
int geoloc_gml_reload(void)
static char * handle_gml_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
static struct geoloc_gml_shape_def gml_shape_defs[]
int geoloc_gml_unload(void)
static enum angle_parse_result angle_parser(const char *name, const char *value, char **angle, char **uom, char **result)
int geoloc_gml_load(void)
#define SCOPE_EXIT_RTN_VALUE(__return_value,...)
#define SCOPE_EXIT_LOG_RTN_VALUE(__value, __log_level,...)
#define SCOPE_ENTER(level,...)
Configuration File Parser.
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.
#define ast_variable_new(name, value, filename)
#define ast_variable_list_append(head, new_var)
@ AST_MODULE_LOAD_SUCCESS
ast_geoloc_validate_result
@ AST_GEOLOC_VALIDATE_INVALID_CRS
@ AST_GEOLOC_VALIDATE_TOO_MANY_VARNAMES
@ AST_GEOLOC_VALIDATE_MISSING_SHAPE
@ AST_GEOLOC_VALIDATE_INVALID_VALUE
@ AST_GEOLOC_VALIDATE_SUCCESS
@ AST_GEOLOC_VALIDATE_NOT_ENOUGH_VARNAMES
@ AST_GEOLOC_VALIDATE_INVALID_CRS_FOR_SHAPE
@ AST_GEOLOC_VALIDATE_INVALID_SHAPE
@ AST_GEOLOC_VALIDATE_INVALID_VARNAME
int ast_strings_equal(const char *str1, const char *str2)
Compare strings for equality checking for NULL.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)
Checks whether a string begins with another.
char * ast_strsep(char **s, const char sep, uint32_t flags)
Act like strsep but ignore separators inside quotes.
descriptor for a cli entry.
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
int(* validator)(const char *name, const char *value, const struct ast_variable *varlist, char **result)
struct geoloc_gml_attr required_attributes[MAX_SHAPE_ATTRIBUTES]
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
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.
struct ast_xml_node * ast_xml_new_node(const char *name)
Create a XML node.
int ast_xml_set_attribute(struct ast_xml_node *node, const char *name, const char *value)
Set an attribute to a node.
void ast_xml_set_text(struct ast_xml_node *node, const char *content)
Set an element content string.
void ast_xml_free_node(struct ast_xml_node *node)
Free node.