[curl] Stan postepu
Ostatnio zmodyfikowano 2012-02-17 18:02
cwaniakada Temat założony przez niniejszego użytkownika |
» 2012-02-17 18:02:52 #include <stdio.h> #include <fstream> #include <curl/curl.h> #include <iostream> #include <conio.h> #include <string> #include <cstdlib> #include <windows.h>
using namespace std;
static int prog_cb( void * p, double dltotal, double dlnow, double ult, double uln ) { cout << "Pobrano: " << dlnow << "z:" << dltotal << endl; return 0; }
void get_file( const char * url, const char * file_name, const char * mode ) { CURL * easyhandle = curl_easy_init(); curl_easy_setopt( easyhandle, CURLOPT_URL, url ); std::FILE * file = std::fopen( file_name, mode ); curl_easy_setopt( easyhandle, CURLOPT_WRITEDATA, file ); curl_easy_setopt( easyhandle, CURLOPT_NOPROGRESS, FALSE ); curl_easy_setopt( easyhandle, CURLOPT_PROGRESSFUNCTION, prog_cb ); curl_easy_perform( easyhandle ); curl_easy_cleanup( easyhandle ); fclose( file ); }
int main( void ) { CURL * curl; CURLcode res; curl_global_init( CURL_GLOBAL_DEFAULT ); curl = curl_easy_init(); if( curl ) { get_file( "http://cpp0x.pl/!images/default/baner.png", "baner.png", "wb" ); } curl_global_cleanup(); getchar(); return 0; }
|
|
1 « 2 » |