gpAux/extensions/gps3ext/src/s3restful_service.cpp
// curl's reading function callback.
curl's reading function callback.
curl ' s reading function callback .
size_t RESTfulServiceReadFuncCallback(char *ptr, size_t size, size_t nmemb, void *userp) {
    if (QueryCancelPending) {
        return -1;
    }
    UploadData *data = (UploadData *)userp;
    uint64_t dataLeft = data->buffer.size() - data->currentPosition;
    size_t requestedSize = size * nmemb;
    size_t copiedItemNum = requestedSize < dataLeft ? nmemb : (dataLeft / size);
    size_t copiedDataSize = copiedItemNum * size;
    if (copiedDataSize == 0) return 0;
    memcpy(ptr, data->buffer.data() + data->currentPosition, copiedDataSize);
    data->currentPosition += copiedDataSize;
    return copiedItemNum;
}
size_t RESTfulServiceReadFuncCallback ( char * ptr , size_t size , size_t nmemb , void * userp ) { if ( QueryCancelPending ) { return -1 ; } UploadData * data = ( UploadData * ) userp ; uint64_t dataLeft = data -> buffer . size ( ) - data -> currentPosition ; size_t requestedSize = size * nmemb ; size_t copiedItemNum = requestedSize < dataLeft ? nmemb : ( dataLeft / size ) ; size_t copiedDataSize = copiedItemNum * size ; if ( copiedDataSize == 0 ) return 0 ; memcpy ( ptr , data -> buffer . data ( ) + data -> currentPosition , copiedDataSize ) ; data -> currentPosition += copiedDataSize ; return copiedItemNum ; }
curl's reading function callback.
curl ' s reading function callback .