196{
  197    int count = 0;
  200    char *nestchar = "."; 
  201    int index, res, depth = 0;
  202 
  208    );
  209    char *varsubst, *key, *currentkey, *nextkey, *firstkey, *tmp;
  211 
  213 
  217            count = 1;
  218        }
  219    }
  220 
  223        return -1;
  224    }
  225 
  228        return -1;
  229    }
  230 
  233        int seplen = strlen(
args.nestchar);
 
  234        if (seplen != 1) {
  235            ast_log(
LOG_WARNING, 
"Nesting separator '%s' has length %d and is invalid (must be a single character)\n", 
args.nestchar, seplen);
 
  236        } else {
  237            nestchar = 
args.nestchar;
 
  238        }
  239    }
  240 
  242    if (!varsubst) {
  244        return -1;
  245    }
  246    sprintf(varsubst, 
"${%s}", 
args.varname); 
 
  248 
  249    ast_debug(1, 
"Parsing JSON using nesting delimeter '%s'\n", nestchar);
 
  250 
  252        ast_debug(1, 
"Variable '%s' contains no data, nothing to search!\n", 
args.varname);
 
  253        return -1; 
  254    }
  255 
  256    
  257    currentkey = key;
  259    tmp = strstr(firstkey, nestchar);
  260    if (tmp) {
  261        *tmp = '\0';
  262    }
  263 
  264    
  268        return -1;
  269    }
  271        ast_debug(1, 
"JSON node '%s', contains no data, nothing to search!\n", currentkey);
 
  272        return -1; 
  273    }
  274 
  276    if (!json) {
  278        return -1;
  279    }
  280 
  281    
  282    nextkey = 
strsep(&key, nestchar);
 
  285    } else {
  287            ast_debug(1, 
"Requested index '%s' is not numeric or is invalid\n", currentkey);
 
  288            return -1;
  289        }
  291    }
  292 
  295    return res;
  296}
char * strsep(char **str, const char *delims)
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
#define ast_strdupa(s)
duplicate a string in memory from the stack
int ast_str_to_int(const char *str, int *res)
Convert the given string to a signed integer.
static const struct ast_app_option json_options[128]
static int parse_node(char **key, char *currentkey, char *nestchar, int count, struct ast_json *json, char *buf, size_t len, int *depth)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define AST_APP_ARG(name)
Define an application argument.
#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.
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.
#define ast_debug(level,...)
Log a DEBUG message.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
struct ast_json * ast_json_array_get(const struct ast_json *array, size_t index)
Get an element from an array.
struct ast_json * ast_json_load_str(const struct ast_str *input, struct ast_json_error *error)
Parse ast_str into a JSON object or array.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
int ast_json_is_object(const struct ast_json *value)
Check if value is JSON object.
void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ)
size_t attribute_pure ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
char *attribute_pure ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
struct ast_str * ast_str_thread_get(struct ast_threadstorage *ts, size_t init_len)
Retrieve a thread locally stored dynamic string.
Structure used to handle boolean flags.
Abstract JSON element (object, array, string, int, ...).
Support for dynamic strings.
#define ast_test_flag(p, flag)