Source Code for Me (s-c.me)

Allows you to paste souce code to blogs! Adapted for Twitter! Here is Search Form in case you missed your code.
Tags: CSharp, Created At: 10/24/2016 8:26:12 PMViews:

HTML view:
Copy Source | Copy HTML
// ÐœÐµÑ‚оды Ð²Ð·ÑÑ‚Ñ‹ Ð¸Ð· Ð¿Ñ€Ð¸Ð¼ÐµÑ€Ð¾Ð² ÐºÐ¾Ð´Ð° Ñ CURL http://curl.haxx.se/libcurl/c/example.html
// Ð˜ Ð¿Ð¾Ð´ÐºÑ€ÑƒÑ‡ÐµÐ½Ñ‹ Ð´Ð»Ñ ÑÐ²Ð¾Ð¸Ñ… Ð½ÑƒÐ¶Ð´ Ð¸ ÑÑ‚иля
static void *myrealloc(void* ptr, size_t size)
{
    /* There might be a realloc() out there that doesn't like reallocing
    NULL pointers, so we take care of it here */
    if(ptr)
        return realloc(ptr, size);
    else
        return malloc(size);
}
 
//////////////////////////////////////////////////////////////////////////
// Ð“отов ÐºÑƒÑÐ¾Ðº Ð´Ð»Ñ Ð·Ð°Ð¿Ð¸ÑÐ¸ Ð² Ð±ÑƒÑ„фер
//////////////////////////////////////////////////////////////////////////
size_t Downloader::DFile::CallbackWriteMemory(void* pNewData, size_t size, size_t nmemb, Downloader::DFile *pDFile )
{
    size_t realsize = size * nmemb;
 
    pDFile->_pData = (UCHAR*)myrealloc(pDFile->_pData, pDFile->_iLength + realsize + 1);
    if (pDFile->_pData) {
        memcpy( &(pDFile->_pData[pDFile->_iLength]), pNewData, realsize );
        pDFile->_iLength += realsize;
        pDFile->_pData[pDFile->_iLength] =  0; // Ð—апишем Ð½Ð¾Ð»ÑŒ Ð±Ð°Ð¹Ñ‚, Ð½ÑƒÐ¶Ð½Ð¾ Ð´Ð»Ñ Ð¸ÑÐ¿Ð¾Ð»ÑŒÐ·Ð¾Ð²Ð°Ð½Ð¸Ñ Ð´Ð°Ð½Ð½Ñ‹Ðµ ÐºÐ°Ðº C ÑÑ‚роки
    }
    return realsize;
}
 
 
//////////////////////////////////////////////////////////////////////////
// Ð“отов ÐºÑƒÑÐ¾Ðº Ð´Ð»Ñ Ð·Ð°Ð¿Ð¸ÑÐ¸ Ð² Ñ„айл
//////////////////////////////////////////////////////////////////////////
size_t Downloader::DFile::CallbackWriteStream( void* pNewData, size_t size, size_t nmemb, FILE *stream )
{
    return fwrite( pNewData, size, nmemb, stream );
}
 
 
//////////////////////////////////////////////////////////////////////////
// ÐžÐ±Ð½Ð¾Ð²Ð¸Ð»ÑÑ ÑÑ‚атус Ð³Ð¾Ñ‚овности ÑÐºÐ°Ñ‡ÐºÐ¸
//////////////////////////////////////////////////////////////////////////
int Downloader::DFile::CallbackProgress( Downloader::DFile* pDFile, double t, double d, double ultotal, double ulnow )
{
    pDFile->_fPercentComplete = (float)d/t;
    return  0;
}

Based on Manoli.Net's CodeFormatter. Made by Topbot (c) 2008-2017