40    size_t nitems, 
void *client_data)
 
   43    size_t realsize = size * nitems;
 
   44    size_t adjusted_size = realsize;
 
   51    SCOPE_ENTER(5, 
"'%s': Header received with %zu bytes\n",
 
   52        debug_info, realsize);
 
   69    while (*start && ((
unsigned char) *start) < 33 && start < data + realsize) {
 
   74    if (adjusted_size < strlen(
"HTTP/") + 1) {
 
   94        int rc = sscanf(start, 
"HTTP/%*s %d %*s", &code);
 
   96            if (code / 100 == 2) {
 
  113    colon = strchr(
header, 
':');
 
  125            "'%s': Unable to allocate memory for header '%s'\n",
 
 
  151    size_t nmemb, 
void *client_data)
 
  154    size_t realsize = size * nmemb;
 
  155    size_t bytes_written = 0;
 
  157    SCOPE_ENTER(5, 
"'%s': Writing data chunk of %zu bytes\n",
 
  161        cb_data->
output = open_memstream(
 
  166                "'%s': Xfer failed. " 
  176            "'%s': Xfer failed. " 
  177            "Exceeded maximum %zu bytes transferred\n", 
debug_info,
 
  181    bytes_written = fwrite(data, 1, realsize, cb_data->
output);
 
  183    if (bytes_written != realsize) {
 
  185            "'%s': Xfer failed. " 
  186            "Expected to write %zu bytes but wrote %zu\n",
 
 
  206    curlsocktype purpose, 
struct curl_sockaddr *
address)
 
  219                "'%s': Unable to apply acl\n", debug_info);
 
  224    if (cb_data->
sockfd < 0) {
 
  226            "'%s': Failed to open socket: %s\n", debug_info, strerror(
errno));
 
 
  251    curl = curl_easy_init();
 
  256    curl_easy_setopt(curl, CURLOPT_URL, 
url);
 
  257    if (request_timeout) {
 
  258        curl_easy_setopt(curl, CURLOPT_TIMEOUT, request_timeout);
 
  260    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, 
curl_write_cb);
 
  261    curl_easy_setopt(curl, CURLOPT_WRITEDATA, write_data);
 
  265        curl_easy_setopt(curl, CURLOPT_HEADERDATA, 
header_data);
 
  270    if (open_socket_data) {
 
  272        curl_easy_setopt(curl, CURLOPT_OPENSOCKETDATA, open_socket_data);
 
  275    curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
 
  279    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 0);
 
  281    rc = curl_easy_perform(curl);
 
  282    if (rc != CURLE_OK) {
 
  287    fflush(write_data->
output);
 
  289        fclose(write_data->
output);
 
  293    curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code);
 
  294    curl_easy_cleanup(curl);
 
 
  333    data.
output = fopen(filename, 
"w");
 
 
enum ast_acl_sense ast_apply_acl(struct ast_acl_list *acl_list, const struct ast_sockaddr *addr, const char *purpose)
Apply a set of rules to a given IP address.
int ast_acl_list_is_empty(struct ast_acl_list *acl_list)
Determines if an ACL is empty or if it contains entries.
Asterisk main include file. File version handling, generic pbx functions.
#define AST_CURL_USER_AGENT
void ast_std_free(void *ptr)
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define CURL_WRITEFUNC_ERROR
#define AST_CURL_DEFAULT_MAX_HEADER_LEN
void curl_write_data_free(void *obj)
size_t curl_write_cb(char *data, size_t size, size_t nmemb, void *client_data)
A default implementation of a write data callback.
curl_socket_t curl_open_socket_cb(void *client_data, curlsocktype purpose, struct curl_sockaddr *address)
A default implementation of an open socket callback.
void curl_open_socket_data_free(void *obj)
#define SCOPE_EXIT_RTN_VALUE(__return_value,...)
#define SCOPE_EXIT_LOG_RTN_VALUE(__value, __log_level,...)
#define SCOPE_ENTER(level,...)
long curl_download_to_file(const char *url, char *filename)
Really simple document retrieval to file.
long curl_download_to_memory(const char *url, size_t *returned_length, char **returned_data, struct ast_variable **headers)
Really simple document retrieval to memory.
long curler(const char *url, int request_timeout, struct curl_write_data *write_data, struct curl_header_data *header_data, struct curl_open_socket_data *open_socket_data)
Perform a curl request.
Configuration File Parser.
#define ast_variable_new(name, value, filename)
#define ast_variable_list_append(head, new_var)
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
static void ast_sockaddr_copy_sockaddr(struct ast_sockaddr *dst, struct sockaddr *src, socklen_t len)
Copies the data from a sockaddr to an ast_sockaddr.
#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)
char * ast_trim_blanks(char *str)
Trims trailing whitespace characters from a string.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)
Checks whether a string begins with another.
char *attribute_pure ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
Wrapper for an ast_acl linked list.
Socket address structure.
Structure for variables, used for configurations and for channel variables.
Context structure passed to ast_curl_open_socket_default_cb.
const struct ast_acl_list * acl
Context structure passed to ast_curl_write_default_cb.
size_t max_download_bytes
size_t stream_bytes_downloaded
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.