libcurl
обеспечивает фантастическое количество примеров битов кода here.
Однако, безусловно, лучший способ быстро генерировать код C, который делает то, что вы хотите использовать инструмент командной строки curl
с --libcurl
вариант:
--libcurl <file>
Append this option to any ordinary curl command line, and you
will get a libcurl-using C source code written to the file that
does the equivalent of what your command-line operation does!
If this option is used several times, the last given file name
will be used. (Added in 7.16.1)
Например команда:
curl --silent --libcurl /tmp/test.c http://www.google.com/
дает выход:
/********* Sample code generated by the curl command line tool **********
* All curl_easy_setopt() options are documented at:
* http://curl.haxx.se/libcurl/c/curl_easy_setopt.html
************************************************************************/
#include <curl/curl.h>
int
main (int argc, char *argv[])
{
CURLcode ret;
CURL *hnd;
hnd = curl_easy_init();
curl_easy_setopt (hnd, CURLOPT_URL, "http://www.google.com/");
curl_easy_setopt (hnd, CURLOPT_NOPROGRESS, 1L);
curl_easy_setopt (hnd, CURLOPT_USERAGENT, "curl/7.35.0");
curl_easy_setopt (hnd, CURLOPT_MAXREDIRS, 50L);
curl_easy_setopt (hnd, CURLOPT_TCP_KEEPALIVE, 1L);
/* Here is a list of options the curl code used that cannot get generated
as source easily. You may select to either not use them or implement
them yourself.
CURLOPT_WRITEDATA set to a objectpointer
CURLOPT_WRITEFUNCTION set to a functionpointer
CURLOPT_READDATA set to a objectpointer
CURLOPT_READFUNCTION set to a functionpointer
CURLOPT_SEEKDATA set to a objectpointer
CURLOPT_SEEKFUNCTION set to a functionpointer
CURLOPT_ERRORBUFFER set to a objectpointer
CURLOPT_STDERR set to a objectpointer
CURLOPT_HEADERFUNCTION set to a functionpointer
CURLOPT_HEADERDATA set to a objectpointer
*/
ret = curl_easy_perform (hnd);
curl_easy_cleanup (hnd);
hnd = NULL;
return (int) ret;
}
/**** End of sample code ****/
Я сделал значительные изменения в ваш Qu estion. Пожалуйста, проверьте, что я написал, и убедитесь, что он правильно описывает вашу проблему. – Borodin
Просьба показать код C, который вы написали, и описать проблемы, с которыми вы сталкиваетесь, чтобы заставить его работать. – Borodin
@Borodin Thankyou, но я не думаю, что мой вопрос заслуживает голосования. Я просто искал помощи у вас, ребята. Днем человек учится принимать людей в вашем сообществе. Я знаю, что вы, ребята, лучше программисты, чем я. Но привет почему я прошу о вашей помощи. Всегда получал ответ откуда-то еще, спасибо за помощь. –