cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: write callback issues (was Re: A new problem)

From: Prasad J Pandit <prasad.pandit_at_comat.com>
Date: Thu, 3 Apr 2008 18:27:43 +0530 (IST)

On Thu, 3 Apr 2008, Daniel Stenberg wrote:
> I changed to a somewhat more descriptive subject.

   Hey, thanks for that.

> Can you please provide source code to an example that repeats this problem?
> And what do you mean with "all I get is an empty string"? You get a zero
> byte write callback and then the transfer is completed? If so, what does
> curl_easy_perform() return?

   Well, my code looks something like this

size_t
recv_data (void *buf, size_t unit_sz, size_t no_of_units, void *usrp)
{
      int ret = 0;
      Curldata *rsp = NULL; /* it's the WRITE_DATA struct from example */

      if (buf && (rsp = new Curldata))
      {
          rsp->len = unit_sz * no_of_units;
          rsp->data = new char[rsp->len];

          if (rsp->data)
          {
              memset (rsp->data, '\0', rsp->len);
              _snprintf (rsp->data, rsp->len, "%s", (char *)buf);

              *(Curldata **)usrp = rsp;
              ret = (*(Curldata **)usrp)->len;
          }
      }

      return ret;
}

And...about empty string, I was wrong there, it's not an empty string, but
few(3 to 10) non-printable characters I assume, as I cann't see them in
the usual win32 MessageBox.

Also, curl_easy_perfrom() returns 23, which is a WRITE error I guess, but
it seems to return 23 all the time, even when everything works well.

> Is that a question in there?

   Yes, will curl_easy_pause() help in any way?

Thank you!

--
Regards
   - Prasad
Received on 2008-04-03