title: libcurl console progress bar for file download
body: <p>Here I implemented code for file download from server. its working fine.
  Now I want to make my own progress bar function which calculates some data like remaining seconds data Rate per second etc.
  So from <a href="https://stackoverflow.com/questions/1637587/c-libcurl-console-progress-bar/1639047#comment13750148_1639047">here</a> I found one way to use curl progress bar option. how we can enable this option.
  I completely done with this.</p>
  
  <p>I put my code below. here in this code <code>my_progress_func</code> calls frequently as per curl library time interval. I want to change this interval time and make it to 1 second. is it possible in curl library using to set some options for curl library?</p>
  
  <p>I want to call this <code>my_progress_func</code> function after every 1 second.</p>
  
  <p>Code :</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;curl/curl.h&gt;
  
  long test =0;
  
  struct FtpFile {
    const char *filename;
    FILE *stream;
    long iAppend;
  };
  
  static size_t my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream)
  {
    struct FtpFile *out=(struct FtpFile *)stream;
    if(out &amp;&amp; !out-&gt;stream) {
      /* open file for writing */
        out-&gt;stream=fopen(out-&gt;filename, out-&gt;iAppend ? "ab":"wb");
      if(!out-&gt;stream)
        return -1; /* failure, can't open file to write */
    }
    out-&gt;iAppend += nmemb;
    return fwrite(buffer, size, nmemb, out-&gt;stream);
  }
  
  int my_progress_func(void *bar,
                       double t, /* dltotal */ 
                       double d, /* dlnow */ 
                       double ultotal,
                       double ulnow)
  {
      printf("%f : %f \n", d, t);
  
    return 0;
  }
  
  int main(void)
  {
    CURL *curl;
    CURLcode res;
    int c;
  
    struct FtpFile ftpfile={
      "dev.zip", /* name to store the file as if succesful */
      NULL,
    };
  
    curl_global_init(CURL_GLOBAL_DEFAULT);
  
    curl = curl_easy_init();
    if(curl) {
      curl_easy_setopt(curl, CURLOPT_URL,
                       "sftp://root:xyz_@192.170.10.1/mnt/xyz.tar");
  
  
      curl_easy_setopt(curl, CURLOPT_TIMEOUT, 120L);
  
  
      /* Define our callback to get called when there's data to be written */
      curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite);
      /* Set a pointer to our struct to pass to the callback */
      curl_easy_setopt(curl, CURLOPT_WRITEDATA, &amp;ftpfile);
  
  
      curl_easy_setopt(curl, CURLOPT_FTPPORT, "-");
  
      /* Switch on full protocol/debug output */
  
      curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
  
      curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
      curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, my_progress_func);
  
      res = curl_easy_perform(curl);
  
      printf("res is %d\n, data get %ld\n", res, ftpfile.iAppend);
  
  
      ///Retry upto 100 times it timeout or connection drop occur
      for (c = 0; (res != CURLE_OK) &amp;&amp; (c &lt; 100); c++) {
  
  
  
          curl_easy_setopt(curl, CURLOPT_RESUME_FROM , ftpfile.iAppend);
          res = curl_easy_perform(curl);
          if(res == CURLE_OK) c =0;
          printf("%d res is %d\n, data get %ld\n",c, res, ftpfile.iAppend);
  
      }
      /* always cleanup */
      curl_easy_cleanup(curl);
    }
    if(ftpfile.stream)
      fclose(ftpfile.stream); /* close the local file */
    curl_global_cleanup();
     return 0;
  }
  </code></pre>