bool ssl = false;
uint8_t wait_seconds = 1;
+void _kds_s2000w_client_set_verbose()
+{
+ uint8_t log_level = kds_s2000w_debug_get_log_level();
+
+ if (log_level < DEBUG)
+ return;
+
+ curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+}
+
size_t _kds_s2000w_client_write_callback(char* ptr, size_t size, size_t nmemb, void* data)
{
response* resp = (response*) data;
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _kds_s2000w_client_write_callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, resp);
+ _kds_s2000w_client_set_verbose();
CURLcode result = curl_easy_perform(curl);
_kds_s2000w_client_add_null_terminate_to_response(resp);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &resp->code);
_kds_s2000w_client_set_ssl_verification_off(curl);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
+ _kds_s2000w_client_set_verbose();
CURLcode result = curl_easy_perform(curl);
_kds_s2000w_client_print_error_result(result);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _kds_s2000w_client_write_callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, resp);
+ _kds_s2000w_client_set_verbose();
CURLcode result = curl_easy_perform(curl);
_kds_s2000w_client_add_null_terminate_to_response(resp);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &resp->code);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _kds_s2000w_client_write_callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, resp);
+ _kds_s2000w_client_set_verbose();
CURLcode result = curl_easy_perform(curl);
_kds_s2000w_client_add_null_terminate_to_response(resp);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &resp->code);
_kds_s2000w_client_set_ssl_verification_off(curl);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
+ _kds_s2000w_client_set_verbose();
CURLcode result = curl_easy_perform(curl);
_kds_s2000w_client_print_error_status(curl);
_kds_s2000w_client_set_ssl_verification_off(curl);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
+ _kds_s2000w_client_set_verbose();
CURLcode result = curl_easy_perform(curl);
_kds_s2000w_client_print_error_status(curl);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _kds_s2000w_client_write_callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, resp);
+ _kds_s2000w_client_set_verbose();
CURLcode result = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &resp->code);
_kds_s2000w_client_set_ssl_verification_off(curl);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
+ _kds_s2000w_client_set_verbose();
CURLcode result = curl_easy_perform(curl);
_kds_s2000w_client_print_error_status(curl);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _kds_s2000w_client_write_callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, resp);
+ _kds_s2000w_client_set_verbose();
CURLcode result = curl_easy_perform(curl);
_kds_s2000w_client_add_null_terminate_to_response(resp);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &resp->code);
_kds_s2000w_client_set_ssl_verification_off(curl);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
+ _kds_s2000w_client_set_verbose();
CURLcode result = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &resp->code);
}
}
-uint8_t _kds_s2000w_debug_get_log_level() {
+uint8_t kds_s2000w_debug_get_log_level() {
char* log_level = getenv("KDS_S2000W_NET_DEBUG");
if (log_level == NULL)
void kds_s2000w_debug_printf(uint8_t level, const char* message)
{
- if (level > _kds_s2000w_debug_get_log_level())
+ if (level > kds_s2000w_debug_get_log_level())
return;
if (level < STDOUT_LEVEL) {
void kds_s2000w_debug_printf_int(uint8_t level, const char* message, uint32_t value)
{
- if (level > _kds_s2000w_debug_get_log_level())
+ if (level > kds_s2000w_debug_get_log_level())
return;
if (level < STDOUT_LEVEL) {
void kds_s2000w_debug_printf_long(uint8_t level, const char* message, uint64_t value)
{
- if (level > _kds_s2000w_debug_get_log_level())
+ if (level > kds_s2000w_debug_get_log_level())
return;
if (level < STDOUT_LEVEL) {
void kds_s2000w_debug_messure_memory_usage(uint8_t level)
{
- if (level > _kds_s2000w_debug_get_log_level())
+ if (level > kds_s2000w_debug_get_log_level())
return;
struct rusage* memory_usage = malloc(sizeof(struct rusage));