Guest User

Untitled

a guest
Jul 20th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.96 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<curl/curl.h>
  4. #include<string.h>
  5.  
  6. int channelDownload(char *ch_name, char *ch_address)
  7. {
  8.         CURL *curl;
  9.         char *f_name = malloc(100*sizeof(char));
  10.         char path[100] = "./channels/";
  11.  
  12.         strcpy(f_name, ch_name);
  13.         strcat(f_name, ".xml");
  14.         strcat(path, f_name);
  15.  
  16.         printf("Trwa pobieranie kanalu %s... \n", ch_name);
  17.  
  18.         FILE *tmp = fopen(path, "w");
  19.         CURLcode curl_res;
  20.         CURLINFO info;
  21.         curl = curl_easy_init();
  22.         if(curl)
  23.         {
  24.                 curl_easy_setopt(curl, CURLOPT_URL, ch_address);
  25.                 curl_easy_setopt(curl, CURLOPT_WRITEDATA, tmp);
  26.                 curl_res = curl_easy_perform(curl);
  27.                 curl_easy_cleanup(curl);
  28.         }
  29.         if(curl_res == 0)
  30.                 printf("Pobieranie zakonczone!\n");
  31.         else
  32.                 printf("Nie udalo sie pobrac danych!\n");
  33.         return 0;
  34. }
  35. ~
Add Comment
Please, Sign In to add comment