У меня есть программное обеспечение, которое использует libcurl версии 7.59.Мне нужно экспортировать URL-адрес, который он использует, и записать его в текстовый файл.URL задается как
CURLcode curl_easy_setopt(struct Curl_easy *data, CURLoption tag, ...)
В соответствии с документацией libcurl тип параметра char * и он устанавливается как curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
Тип параметра в libcurl va_list arg
Я добавил код в curl_easy_setopt
if (tag == CURLOPT_URL) {
FILE *f = fopen("file.txt", "a+");
if (f == NULL)
{
printf("Error opening file!\n");
exit(1);
}
int len = strlen(&arg);
for (int i = 0; i < len; i++) {
fprintf(f, "Some text: %c\n", &arg[i]);
}
fclose(f);
}
Но у меня есть некоторые проблемы с кодировкой.
Some text:
Some text:
Some text:
Some text:
Some text:
Some text:
Some text: !
Some text: "
Some text: #
Some text: $
Some text: %
Some text: D
Я знаю, что могу проверить адреспо Wireshark, но мне нужно сделать это именно так, потому что мне нужно будет изменить этот адрес позже.Код скручивания
CURLcode curl_easy_setopt(struct Curl_easy *data, CURLoption tag, ...)
{
va_list arg;
CURLcode result;
if(!data)
return CURLE_BAD_FUNCTION_ARGUMENT;
va_start(arg, tag);
result = Curl_vsetopt(data, tag, arg);
va_end(arg);
return result;
}