# Libcurl - Progress Data

**URL:** <https://community.unix.com/t/libcurl-progress-data/171298>\
**Category:** Programming\
**Created:** [May 16, 2007, 4:03pm UTC](https://community.unix.com/t/libcurl-progress-data/171298 "2007-05-16T16:03:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![canerbulut](https://community.unix.com/user_avatar/community.unix.com/canerbulut/32/3545_2.png) [@canerbulut](https://community.unix.com/u/canerbulut)\
**Post date:** [May 16, 2007, 4:03pm UTC](https://community.unix.com/t/libcurl-progress-data/171298/1 "2007-05-16T16:03:07Z")

</div>

Hi,

I codding a download manager,use libcurl library.i can download any file easily.But i want to show file detail in console.Some of them,

- File Size
- Percent
- Left Time

Libcurl has some functions to use,but there isnt good documentation to understand them. i cant find any example to understand.Please help me,Thank you.

Caner Bulut

---

<div class="post-metadata">

**Author:** ![canerbulut](https://community.unix.com/user_avatar/community.unix.com/canerbulut/32/3545_2.png) [@canerbulut](https://community.unix.com/u/canerbulut)\
**Post date:** [May 27, 2007, 5:03am UTC](https://community.unix.com/t/libcurl-progress-data/171298/2 "2007-05-27T05:03:17Z")

</div>

i solve the problem and want to share with you.

#include \<stdio.h\>  
#include \<pthread.h\>  
#include \<curl/curl.h\>  
#include \<curl/types.h\>  
#include \<curl/easy.h\>

struct FtpFile {  
char \*filename;  
FILE \*stream;  
};

double \*Bar;

int my\_fwrite(void \*buffer, size\_t size, size\_t nmemb, void \*stream)  
{  
struct FtpFile \*out=(struct FtpFile _)stream;  
if(out && !out-\>stream) {  
/_ open file for writing _/  
out-\>stream=fopen(out-\>filename, "wb");  
if(!out-\>stream)  
return -1; /_ failure, can't open file to write \*/  
}  
return fwrite(buffer, size, nmemb, out-\>stream);  
}

size\_t my\_read\_func(void \*ptr, size\_t size, size\_t nmemb, FILE \*stream)  
{  
return fread(ptr, size, nmemb, stream);  
}

int progress\_callback( char _Bar,double t,double d,double ultotal,double ulnow)  
{  
printf("deneme : %f \n",d/t_100);  
return 0;  
}

void thred(char \*url)  
{  
CURL \*curl;  
CURLcode res;  
struct FtpFile ftpfile={  
"curl.tar.gz",  
NULL  
};

```
curl\_global\_init\(CURL\_GLOBAL_DEFAULT\);

curl = curl\_easy_init\(\);
if\(curl\) \{

```

// printf("%s Indiriliyor...\n",url);  
curl\_easy\_setopt(curl, CURLOPT\_URL,url);  
curl\_easy\_setopt(curl, CURLOPT\_WRITEDATA, &ftpfile);  
curl\_easy\_setopt(curl, CURLOPT\_WRITEFUNCTION, my\_fwrite);  
curl\_easy\_setopt(curl, CURLOPT\_READFUNCTION, my\_read\_func);  
curl\_easy\_setopt(curl, CURLOPT\_NOPROGRESS, 0);  
curl\_easy\_setopt(curl, CURLOPT\_PROGRESSFUNCTION, progress\_callback);  
curl\_easy\_setopt(curl, CURLOPT\_PROGRESSDATA, &Bar);  
res = curl\_easy\_perform(curl);  
curl\_easy\_cleanup(curl);

```
  if\(CURLE_OK != res\) \{
    /* we failed */
    fprintf\(stderr, "curl told us %d\\n", res\);
  \}
\}

if\(ftpfile.stream\)
  fclose\(ftpfile.stream\); /* close the local file */

curl\_global_cleanup\(\);

return 0;

```

}

int main( int argc,  
char \*argv[] )  
{

pthread\_t tid[25];  
int error,t\_count=0,temp\_count=0;  
int a=0,sabit=0,i=0;  
char \*dosadi[5];  
dosadi[1]="ftp://ftp.sunet.se/pub/www/utilities/curl/curl-7.9.2.tar.gz";  
dosadi[2]="ftp://ftp.tugraz.at/mirror/devil-linux/devel/sources/1.0/cipe-1.5.4.tar.gz";  
dosadi[3]="ftp://ftp.gnu.org/gnu/bash/bash-1.14.7.tar.gz";  
dosadi[4]="ftp://ftp.keystealth.org/pub/gnu/gnu/gnu.ps.gz";  
dosadi[5]="ftp://ftp.tugraz.at/mirror/devil-linux/devel/sources/1.0/attr-2.4.8.src.tar.gz";

for(i=1; i\<=5; i++)  
{  
error = pthread\_create(&tid[i],  
NULL,  
thred,  
dosadi[i]);  
}  
//  
for(i=1; i\<=5; i++) {  
error = pthread\_join(tid[i], NULL);  
fprintf(stderr, "Thread %d Yokedildi.\n", i);  
}

}

Regards  
Caner

---

<div class="post-metadata">

**Author:** ![india](https://community.unix.com/letter_avatar/india/32/6_449c533f586939b6e5f246632a46421f.png) [@india](https://community.unix.com/u/india)\
**Post date:** [November 4, 2008, 12:01pm UTC](https://community.unix.com/t/libcurl-progress-data/171298/3 "2008-11-04T12:01:22Z")

</div>

hello  
hi facing problem since 6days to geeting upload a file to ftp server.  
pls anyone have source code
