KiCad PCB EDA Suite
kicad_curl_easy.cpp File Reference
#include <curl/curl.h>
#include <curl/easy.h>
#include <kicad_curl/kicad_curl.h>
#include <kicad_curl/kicad_curl_easy.h>
#include <cstdarg>
#include <cstddef>
#include <exception>
#include <sstream>
#include <wx/app.h>
#include <build_version.h>
#include <ki_exception.h>
#include <kiplatform/app.h>
#include <kiplatform/environment.h>
#include <pgm_base.h>

Go to the source code of this file.

Classes

struct  CURL_PROGRESS
 

Functions

static size_t write_callback (void *aContents, size_t aSize, size_t aNmemb, void *aUserp)
 
static size_t stream_write_callback (void *aContents, size_t aSize, size_t aNmemb, void *aUserp)
 
static int xferinfo (void *aProgress, curl_off_t aDLtotal, curl_off_t aDLnow, curl_off_t aULtotal, curl_off_t aULnow)
 
static int progressinfo (void *aProgress, double aDLtotal, double aDLnow, double aULtotal, double aULnow)
 

Function Documentation

◆ progressinfo()

static int progressinfo ( void *  aProgress,
double  aDLtotal,
double  aDLnow,
double  aULtotal,
double  aULnow 
)
static

Definition at line 104 of file kicad_curl_easy.cpp.

105{
106 return xferinfo( aProgress, static_cast<curl_off_t>( aDLtotal ), static_cast<curl_off_t>( aDLnow ),
107 static_cast<curl_off_t>( aULtotal ), static_cast<curl_off_t>( aULnow ) );
108}
static int xferinfo(void *aProgress, curl_off_t aDLtotal, curl_off_t aDLnow, curl_off_t aULtotal, curl_off_t aULnow)

References xferinfo().

Referenced by KICAD_CURL_EASY::SetTransferCallback().

◆ stream_write_callback()

static size_t stream_write_callback ( void *  aContents,
size_t  aSize,
size_t  aNmemb,
void *  aUserp 
)
static

Definition at line 74 of file kicad_curl_easy.cpp.

75{
76 size_t realsize = aSize * aNmemb;
77
78 std::ostream* p = static_cast<std::ostream*>( aUserp );
79
80 p->write( static_cast<const char*>( aContents ), realsize );
81
82 return realsize;
83}

Referenced by KICAD_CURL_EASY::SetOutputStream().

◆ write_callback()

static size_t write_callback ( void *  aContents,
size_t  aSize,
size_t  aNmemb,
void *  aUserp 
)
static

Definition at line 62 of file kicad_curl_easy.cpp.

63{
64 size_t realsize = aSize * aNmemb;
65
66 std::string* p = static_cast<std::string*>( aUserp );
67
68 p->append( static_cast<const char*>( aContents ), realsize );
69
70 return realsize;
71}

Referenced by KICAD_CURL_EASY::KICAD_CURL_EASY().

◆ xferinfo()

static int xferinfo ( void *  aProgress,
curl_off_t  aDLtotal,
curl_off_t  aDLnow,
curl_off_t  aULtotal,
curl_off_t  aULnow 
)
static

Definition at line 86 of file kicad_curl_easy.cpp.

88{
89 CURL_PROGRESS* progress = static_cast<CURL_PROGRESS*>( aProgress );
90 curl_off_t curtime = 0;
91
92 curl_easy_getinfo( progress->m_Curl->GetCurl(), CURLINFO_TOTAL_TIME, &curtime );
93
94 if( curtime - progress->m_Last_run_time >= progress->m_Interval )
95 {
96 progress->m_Last_run_time = curtime;
97 return progress->m_Callback( aDLtotal, aDLnow, aULtotal, aULnow );
98 }
99
100 return CURLE_OK;
101}
curl_off_t m_Interval
TRANSFER_CALLBACK m_Callback
KICAD_CURL_EASY * m_Curl
curl_off_t m_Last_run_time

References KICAD_CURL_EASY::GetCurl(), CURL_PROGRESS::m_Callback, CURL_PROGRESS::m_Curl, CURL_PROGRESS::m_Interval, and CURL_PROGRESS::m_Last_run_time.

Referenced by progressinfo(), and KICAD_CURL_EASY::SetTransferCallback().