cURL / Mailing Lists / curl-library / Single Mail

curl-library

How to write data in file and read from that file

From: Ajeet kumar.S <ajeetkumar.s_at_jasmin-infotech.com>
Date: Sat, 12 Jul 2008 12:12:55 +0530

Hi all,

Thank you Dan. Actually I have doubt how we can write the data in a
file(like abc.txt) and read data from file using curl api. Is it possible
to to write data in file we can use CURLOPT_WRITEDATA and write callback
function .(or we need to open a file using fopen , fwrite and fread
respectively to read and write a file or any curl api using we can do )

Here I mention one write call back function:

 

Here we set curl option like that.

curl_easy_setopt(curl CURLOPT_WRITEDATA, data_writecallback_fun );

data_writecallback_fun(void *stm_ptr, size_t size, size_t nmemb, void
*data)

{

    int tot_len=0;

    char file_name[]= "abc.txt";

   data= file_name;

    tot_len = size * nmemb;

   memcpy(data _ptr,stm_ptr,tot_len);

 

}

 

void *data point to file name where we are going to write data.

Can it is possible to clear the whole file data using curl api.

As you told curl support .netrc file. But it support the password and user
name which is currently available user name and password.If we want to
frequently clear the .netrc file and periodically write and read username
and password.So how it is passible to clear, read and write the .netrc file.

Please suggest me.

Thank you.

Regards,

Ajeet Kumar Singh

 

 
Received on 2008-07-12