diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-12-13 08:36:35 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-12-13 08:36:35 +0000 |
commit | a41b34a63c52608e7e5c8e6aced613815461f4c2 (patch) | |
tree | 0559c99680217b78c0bda37a131b5f09794f43c6 /funcs/func_curl.c | |
parent | b298a3aa9b396c4055bf75104b4fb89212c44d4a (diff) |
Merge ast_str_opaque branch (discontinue usage of ast_str internals)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@163991 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs/func_curl.c')
-rw-r--r-- | funcs/func_curl.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/funcs/func_curl.c b/funcs/func_curl.c index 3a936e704..d4f34b850 100644 --- a/funcs/func_curl.c +++ b/funcs/func_curl.c @@ -354,14 +354,11 @@ static size_t WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *da register int realsize = size * nmemb; struct ast_str **pstr = (struct ast_str **)data; - ast_debug(3, "Called with data=%p, str=%p, realsize=%d, len=%zu, used=%zu\n", data, *pstr, realsize, (*pstr)->len, (*pstr)->used); + ast_debug(3, "Called with data=%p, str=%p, realsize=%d, len=%zu, used=%zu\n", data, *pstr, realsize, ast_str_size(*pstr), ast_str_strlen(*pstr)); - if (ast_str_make_space(pstr, (((*pstr)->used + realsize + 1) / 512 + 1) * 512 + 230) == 0) { - memcpy(&((*pstr)->str[(*pstr)->used]), ptr, realsize); - (*pstr)->used += realsize; - } + ast_str_append_substr(pstr, 0, ptr, realsize); - ast_debug(3, "Now, len=%zu, used=%zu\n", (*pstr)->len, (*pstr)->used); + ast_debug(3, "Now, len=%zu, used=%zu\n", ast_str_size(*pstr), ast_str_strlen(*pstr)); return realsize; } @@ -467,18 +464,15 @@ static int acf_curl_exec(struct ast_channel *chan, const char *cmd, char *info, curl_easy_setopt(*curl, CURLOPT_POST, 0); } - if (str->used) { - str->str[str->used] = '\0'; - if (str->str[str->used - 1] == '\n') { - str->str[str->used - 1] = '\0'; - } + if (ast_str_strlen(str)) { + ast_str_trim_blanks(str); - ast_log(LOG_NOTICE, "str='%s'\n", str->str); + ast_debug(3, "str='%s'\n", ast_str_buffer(str)); if (hashcompat) { - char *remainder = str->str; + char *remainder = ast_str_buffer(str); char *piece; - struct ast_str *fields = ast_str_create(str->used / 2); - struct ast_str *values = ast_str_create(str->used / 2); + struct ast_str *fields = ast_str_create(ast_str_strlen(str) / 2); + struct ast_str *values = ast_str_create(ast_str_strlen(str) / 2); int rowcount = 0; while ((piece = strsep(&remainder, "&"))) { char *name = strsep(&piece, "="); @@ -488,12 +482,12 @@ static int acf_curl_exec(struct ast_channel *chan, const char *cmd, char *info, ast_str_append(&values, 0, "%s%s", rowcount ? "," : "", piece); rowcount++; } - pbx_builtin_setvar_helper(chan, "~ODBCFIELDS~", fields->str); - ast_copy_string(buf, values->str, len); + pbx_builtin_setvar_helper(chan, "~ODBCFIELDS~", ast_str_buffer(fields)); + ast_copy_string(buf, ast_str_buffer(values), len); ast_free(fields); ast_free(values); } else { - ast_copy_string(buf, str->str, len); + ast_copy_string(buf, ast_str_buffer(str), len); } ret = 0; } |