cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curlopt_seekfunction

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Sun, 2 Oct 2016 19:15:31 +0200

On Sun, Oct 02, 2016 at 10:12:28AM -0400, Biju N wrote:
> 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);

This is going to pass in an undefined value as the data. For the rest of the
code to make sense, this has to be equal to a valid FILE*

> 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;
> }

>>> Dan
-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-10-02