curl-library
Re: curlopt_seekfunction
Date: Sun, 2 Oct 2016 10:12:28 -0400
Thanks Dan and Colin, A curl handler (d_curl) is used. Since I the original
code is restricted, I had to type it myself to be make is more meaningful
to ask the questions. Sorry about the typos.
void* userp;
res = curl_easy_setopt(d_curl, CURLOPT_SEEKDATA, userp);
if (res != CURLE_OK)
throw CurlError(res);
res = curl_easy_setopt(d_curl, CURLOPT_SEEKFUNCTION, seek_callback);
if (res != CURLE_OK)
throw CurlError(res);
int seek_callback(void *userp, curl_off_t offset, int origin){
FILE* in = static_cast<FILE *>(userp);
long f_offset = (long) offset;
int ret = fseek(in, f_offset, origin);
return ret;
}
On Sat, Oct 1, 2016 at 1:35 AM, Dan Fandrich <dan_at_coneharvesters.com> wrote:
> On Fri, Sep 30, 2016 at 11:39:26PM +0000, Colin Ngam wrote:
> > Hi,
> >
> >
> >
> > Why are you using *userp as a curl handle?
> >
> >
> >
> > CURLcode curl_easy_setopt(CURL *handle, CURLoption option, parameter);
>
> Indeed. And even if it is a curl handle (you didn't show that part of your
> code), then it makes no sense to use it as a FILE* handle.
>
> res = curl_easy_setopt(d_curl, CURLOPT_SEEKDATA, *userp);
>
> >>> Dan
> -------------------------------------------------------------------
> List admin: https://cool.haxx.se/list/listinfo/curl-library
> Etiquette: https://curl.haxx.se/mail/etiquette.html
>
-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-10-02