cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: problem when using curlopts_writefunction

From: Gisle Vanem <gvanem_at_yahoo.no>
Date: Thu, 9 Jan 2014 13:43:17 +0100

"Joshua Kordani" <jkordani_at_lsa2.com> wrote:

> I am attempting to use the function in the below paste as a
> curlopts_writefunction. Ignoring that the sscanf will probably always
> fail, I am receiving errors when trying to access the data behind the
> pointer passed in by the function. I'm assuming that nmemb represents
> the number of bytes (where the byte size is represented by the size
> param), and so if I am going to treat them like ascii text, am I doing
> my calculations correct? The runtime is telling me, no. Please help!
>
> http://paste.lisp.org/+30O6/1

You'll have to return the "number of bytes actually taken care of" (quote
from the man-page). So do a:
  return (charcounts);

> memmove(parseme, ptr, charcounts);

You could use memcpy() since memmove() takes care of overlapping data.
But 'ptr' and 'parseme' will never overlap. And:
> char parseme[1024];

should be increated to CURL_MAX_WRITE_SIZE (16k).

--gv
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-01-09