--- funcs/func_curl.c.orig 2010-11-15 08:42:39.000000000 +0100 +++ funcs/func_curl.c 2011-01-06 09:48:15.000000000 +0100 @@ -91,6 +91,12 @@ enum optiontype { OT_ENUM, }; +enum hashcompat { + HASHCOMPAT_NO = 0, + HASHCOMPAT_YES, + HASHCOMPAT_LEGACY, +}; + static int parse_curlopt_key(const char *name, CURLoption *key, enum optiontype *ot) { if (!strcasecmp(name, "header")) { @@ -153,7 +159,7 @@ static int parse_curlopt_key(const char *ot = OT_BOOLEAN; } else if (!strcasecmp(name, "hashcompat")) { *key = CURLOPT_SPECIAL_HASHCOMPAT; - *ot = OT_BOOLEAN; + *ot = OT_ENUM; } else { return -1; } @@ -242,6 +248,10 @@ static int acf_curlopt_write(struct ast_ if ((new = ast_calloc(1, sizeof(*new)))) { new->value = (void *)ptype; } + } else if (key == CURLOPT_SPECIAL_HASHCOMPAT) { + if ((new = ast_calloc(1, sizeof(*new)))) { + new->value = (void *)(long)(!strcasecmp(value, "legacy") ? HASHCOMPAT_LEGACY : ast_true(value) ? HASHCOMPAT_YES : HASHCOMPAT_NO); + } } else { /* Highly unlikely */ goto yuck; @@ -339,6 +349,16 @@ static int acf_curlopt_read(struct ast_c } else { ast_copy_string(buf, "unknown", len); } + } else if (key == CURLOPT_SPECIAL_HASHCOMPAT) { + if ((long)cur->value == HASHCOMPAT_LEGACY) { + ast_copy_string(buf, "legacy", len); + } else if ((long)cur->value == HASHCOMPAT_YES) { + ast_copy_string(buf, "yes", len); + } else if ((long)cur->value == HASHCOMPAT_NO) { + ast_copy_string(buf, "no", len); + } else { + ast_copy_string(buf, "unknown", len); + } } break; } @@ -430,7 +450,7 @@ static int acf_curl_exec(struct ast_chan AST_LIST_LOCK(&global_curl_info); AST_LIST_TRAVERSE(&global_curl_info, cur, list) { if (cur->key == CURLOPT_SPECIAL_HASHCOMPAT) { - hashcompat = (cur->value != NULL) ? 1 : 0; + hashcompat = (long) cur->value; } else { curl_easy_setopt(*curl, cur->key, cur->value); } @@ -441,7 +461,7 @@ static int acf_curl_exec(struct ast_chan AST_LIST_LOCK(list); AST_LIST_TRAVERSE(list, cur, list) { if (cur->key == CURLOPT_SPECIAL_HASHCOMPAT) { - hashcompat = (cur->value != NULL) ? 1 : 0; + hashcompat = (long) cur->value; } else { curl_easy_setopt(*curl, cur->key, cur->value); } @@ -482,6 +502,12 @@ static int acf_curl_exec(struct ast_chan if (!piece) { piece = ""; } + if (hashcompat == HASHCOMPAT_LEGACY) { + char *plus; + while ((plus = strchr(piece, '+')) || (plus = strchr(name, '+'))) { + *plus = ' '; + } + } ast_uri_decode(piece); ast_uri_decode(name); ast_str_append(&fields, 0, "%s%s", rowcount ? "," : "", name); @@ -537,6 +563,7 @@ struct ast_custom_function acf_curlopt = " userpwd - A : to use for authentication\n" " ssl_verifypeer - Whether to verify the peer certificate (boolean)\n" " hashcompat - Result data will be compatible for use with HASH()\n" +" - if value is \"legacy\", will translate '+' to ' '\n" "", .read = acf_curlopt_read, .write = acf_curlopt_write,