66 char *stringp, *
pair, *key;
67 unsigned int start = 1;
71 ast_log(
LOG_ERROR,
"func_curl.so must be loaded in order to use res_config_curl.so!!\n");
85 for (field = fields; field; field = field->
next) {
134 struct ast_str *query, *buffer;
137 char *stringp, *line, *
pair, *key, *initfield =
NULL;
144 ast_log(
LOG_ERROR,
"func_curl.so must be loaded in order to use res_config_curl.so!!\n");
158 for (field = fields; field; field = field->
next) {
162 if ((op = strchr(initfield,
' ')))
183 while ((line =
strsep(&stringp,
"\r\n"))) {
200 if (!strcasecmp(key, initfield) &&
pair) {
234 struct ast_str *query, *buffer;
238 int start = 1, rowcount = -1;
241 ast_log(
LOG_ERROR,
"func_curl.so must be loaded in order to use res_config_curl.so!!\n");
257 for (field = fields; field; field = field->
next) {
269 while (*stringp <=
' ') {
272 sscanf(stringp,
"%30d", &rowcount);
275 return (
int)rowcount;
283 struct ast_str *query, *buffer;
287 unsigned int start = 1;
291 ast_log(
LOG_ERROR,
"func_curl.so must be loaded in order to use res_config_curl.so!!\n");
304 for (field = lookup_fields; field; field = field->
next) {
313 for (field = update_fields; field; field = field->
next) {
329 while (*stringp <=
' ') {
332 sscanf(stringp,
"%30d", &rowcount);
335 return (
int)rowcount;
356 struct ast_str *query, *buffer;
360 int start = 1, rowcount = -1;
363 ast_log(
LOG_ERROR,
"func_curl.so must be loaded in order to use res_config_curl.so!!\n");
377 for (field = fields; field; field = field->
next) {
388 while (*stringp <=
' ') {
391 sscanf(stringp,
"%30d", &rowcount);
417 struct ast_str *query, *buffer;
421 int start = 1, rowcount = -1;
424 ast_log(
LOG_ERROR,
"func_curl.so must be loaded in order to use res_config_curl.so!!\n");
440 for (field = fields; field; field = field->
next) {
452 while (*stringp <=
' ') {
455 sscanf(stringp,
"%30d", &rowcount);
458 return (
int)rowcount;
466 struct ast_str *query, *buffer;
467 char *elm, field[256];
468 int type, size, i = 0;
471 ast_log(
LOG_ERROR,
"func_curl.so must be loaded in order to use res_config_curl.so!!\n");
485 while ((elm = va_arg(ap,
char *))) {
487 size = va_arg(ap,
int);
517 struct ast_str *query, *buffer;
519 char *stringp, *line, *
pair, *key;
520 int last_cat_metric = -1, cat_metric = -1;
523 char *category =
"", *var_name =
"", *var_val =
"";
527 ast_log(
LOG_ERROR,
"func_curl.so must be loaded in order to use res_config_curl.so!!\n");
549 while ((line =
strsep(&stringp,
"\r\n"))) {
561 if (!strcasecmp(key,
"category")) {
563 }
else if (!strcasecmp(key,
"var_name")) {
565 }
else if (!strcasecmp(key,
"var_val")) {
567 }
else if (!strcasecmp(key,
"cat_metric")) {
572 if (!strcmp(var_name,
"#include")) {
577 if (!cat || strcmp(category, cur_cat) || last_cat_metric != cat_metric) {
583 last_cat_metric = cat_metric;
624 if (strncmp(
var->name,
"CURLOPT(", 8)) {
626 snprintf(
name,
sizeof(
name),
"CURLOPT(%s)",
var->name);
658 .
requires =
"extconfig,res_curl,func_curl",
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdup(str)
A wrapper for strdup()
General Asterisk PBX channel definitions.
Generic File Format Support. Should be included by clients of the file handling routines....
static struct ast_threadstorage buf2
static struct ast_threadstorage buf1
char * strsep(char **str, const char *delims)
Configuration File Parser.
#define ast_config_load(filename, flags)
Load a config file.
void ast_category_rename(struct ast_category *cat, const char *name)
struct ast_config * ast_config_new(void)
Create a new base configuration structure.
void ast_category_append(struct ast_config *config, struct ast_category *category)
Appends a category to a config.
void ast_variable_append(struct ast_category *category, struct ast_variable *variable)
#define ast_category_new_anonymous()
Create a nameless category that is not backed by a file.
#define ast_variable_new(name, value, filename)
int ast_config_engine_deregister(struct ast_config_engine *del)
Deregister config engine.
struct ast_category * ast_config_get_current_category(const struct ast_config *cfg)
Retrieve the current category name being built.
#define CONFIG_STATUS_FILEINVALID
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
require_type
Types used in ast_realtime_require_field.
struct ast_config * ast_config_internal_load(const char *configfile, struct ast_config *cfg, struct ast_flags flags, const char *suggested_incl_file, const char *who_asked)
#define ast_category_new_dynamic(name)
Create a category that is not backed by a file.
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
int ast_config_engine_register(struct ast_config_engine *newconfig)
Register config engine.
Asterisk locking-related definitions:
Asterisk module definitions.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODPRI_REALTIME_DRIVER
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
Core PBX routines and definitions.
struct ast_custom_function * ast_custom_function_find(const char *name)
void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ)
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.
static struct ast_threadstorage result_buf
static struct ast_config_engine curl_engine
static int require_curl(const char *url, const char *unused, va_list ap)
static struct ast_config * realtime_multi_curl(const char *url, const char *unused, const struct ast_variable *fields)
Execute an Select query and return ast_config list.
static struct ast_config * config_curl(const char *url, const char *unused, const char *file, struct ast_config *cfg, struct ast_flags flags, const char *sugg_incl, const char *who_asked)
static int reload_module(void)
static int update2_curl(const char *url, const char *unused, const struct ast_variable *lookup_fields, const struct ast_variable *update_fields)
static struct ast_threadstorage query_buf
static struct ast_variable * realtime_curl(const char *url, const char *unused, const struct ast_variable *fields)
Execute a curl query and return ast_variable list.
static int load_module(void)
static int unload_module(void)
static int update_curl(const char *url, const char *unused, const char *keyfield, const char *lookup, const struct ast_variable *fields)
Execute an UPDATE query.
static int destroy_curl(const char *url, const char *unused, const char *keyfield, const char *lookup, const struct ast_variable *fields)
Execute an DELETE query.
static int store_curl(const char *url, const char *unused, const struct ast_variable *fields)
Execute an INSERT query.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
#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)
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
struct ast_str * ast_str_thread_get(struct ast_threadstorage *ts, size_t init_len)
Retrieve a thread locally stored dynamic string.
Configuration engine structure, used to define realtime drivers.
Structure used to handle boolean flags.
Support for dynamic strings.
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
Definitions to aid in the use of thread local storage.
#define AST_THREADSTORAGE(name)
Define a thread storage variable.
char * ast_uri_encode(const char *string, char *outbuf, int buflen, struct ast_flags spec)
Turn text string to URI-encoded XX version.
const struct ast_flags ast_uri_http
void ast_uri_decode(char *s, struct ast_flags spec)
Decode URI, URN, URL (overwrite string)