write_data(...) is callback function which will be called every time each new data portion arrives from internet. So basically you should measure download speed and remaining time in your function write_data():
1. save current time in local variable time1
2. then download speed will be written/(time1-time2)
3. save current time in global variable time2
4. remaining time will be bytes remaining/download speed
Current time you can get with functions in time.h.
As about bytes remaining, i am not sure. It should be => total fize size - current file size. The problem is how to get total file size. Check libcurl documentation - maybe there are some functions which probes file sizes on net before downloading it.
good luck.