Disclaimer: my C ++ is rusty and I have never used curlpp before, so the code below may need to be massaged a little.
What you need in your callback function is that it can distinguish between two downloads. Since curlpp does not give you this, you will most likely need to use a functor. So, for your progress callback, create a class that looks like:
class ProgressCallback { public: ProgressCallback(int index) : downloadIndex(downloadIndex) { } double operator()(double dltotal, double dlnow, double ultotal, double ulnow) { double progress = (dlnow/dltotal) * 100; std::ostringstream strs; float percent = floorf(progress * 100) / 100; strs << percent; printf("%d: %s\t%d\t%d\t%d\t%d\n", downloadIndex, strs.str().c_str(),dltotal, dlnow, ultotal, ulnow); return 0; } private: int downloadIndex; };
Now you can use this as:
ProgressCallback callback1(1); curlpp::options::ProgressFunction progressBar(callback1);
Of course, you need to think about the lifetime of these callback functors. Leaving them on the stack would probably be a bad idea.
EDIT: There seems to be an easier way to do this. utilspp/functor.h defines two template functions: make_functor () and BindFirst (). Therefore, you can simply add the downloadIndex parameter to your ProgressCallback :
double ProgressCallBack(int dlIdx, double dltotal, double dlnow, double ultotal, double ulnow);
And register as:
curlpp::options::ProgressFunction progressBar(BindFirst(make_functor(ProgressCallback), 1));