Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <curl/curl.h>
- int ile_razy = 0;
- int progress_func(void* ptr, double TotalToDownload, double NowDownloaded,
- double TotalToUpload, double NowUploaded)
- {
- int totaldotz=40;
- double fractiondownloaded = NowDownloaded / TotalToDownload;
- int dotz = round(fractiondownloaded * totaldotz);
- int ii=0;
- printf("%3.0f%% [",fractiondownloaded*100);
- for ( ; ii < dotz;ii++) {
- printf("=");
- }
- for ( ; ii < totaldotz;ii++) {
- printf(" ");
- }
- printf("] %d razy \r", ile_razy);
- fflush(stdout);
- }
- int main(int argc, char *argv[])
- {
- if (argc<3)
- {
- printf("sposob uzycia programu:\n\n download link_do_pliku ilosc_pobran\n\n");
- return 0;
- }
- CURL *curl;
- CURLcode res;
- curl = curl_easy_init();
- if(curl)
- {
- curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
- // curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
- curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
- curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_func);
- FILE *out = NULL;
- int i=0;
- int loop = atoi(argv[2]);
- // int loop = 1500;
- for (i=0; i<loop; i++)
- {
- // printf("Zadanie wykonano %d razy. \r", ile_razy);
- // fflush(stdout);
- out = fopen("temp", "wb");
- curl_easy_setopt(curl, CURLOPT_WRITEDATA, out);
- res = curl_easy_perform(curl);
- ile_razy++;
- fclose(out);
- }
- curl_easy_cleanup(curl);
- }
- printf("\nwykonano: %d razy. \n", ile_razy);
- return 0;
- }
Add Comment
Please, Sign In to add comment