Hello,
I try to modify the callback function. but at this time the ftp server get
this file with wrong format and can not open it.
So I open this upload file with hex and if the BUFFER_SIZE is 100, I find
the first byte is right. the other 99 bytes are wrong.
Can you tell me how to modify this function. And how to set the third
parameter - nmemb
Thanks

#define BUFFER_SIZE 100
static size_t ReadMemoryCallback(void *ptr, size_t size, size_t nmemb, void
*pMem)
{
    struct MemoryStruct *pRead = (struct MemoryStruct *)pMem;

    if ((size * nmemb) < 1)
        return 0;

    if (pRead->size > BUFFER_SIZE)
    {
        *(char *)ptr = pRead->memory[0];
        pRead->memory += BUFFER_SIZE;
        pRead->size -= BUFFER_SIZE;
        return BUFFER_SIZE;
    }
    else
    {
        size_t size_left = pRead->size;

        *(char *)ptr = pRead->memory[0];
        pRead->memory += pRead->size;
        pRead->size = 0;
        return(size_left);
    }
    return 0; // no more data left to deliver
}



2009/4/24 Daniel Stenberg <[email protected]>

> On Fri, 24 Apr 2009, huafeng wu wrote:
>
>    if (pRead->size)
>>   {
>>       *(char *)ptr = pRead->memory[0]; // copy one single byte
>>       pRead->memory++; // advance pointer
>>       pRead->size--; // less data left */
>>       return 1;
>>   }
>>
>
> This is the reason. It returns one byte at a time. You should rewrite it to
> fill as much as possible of the buffer in each invoke.
>
> --
>
>  / daniel.haxx.se
>

Reply via email to