-Wall \
-g \
-fsanitize=address \
--Wl,--wrap,kds_s2000w_client_open_session,\
+-Wl,--wrap,kds_s2000w_client_init,\
+--wrap,kds_s2000w_client_free,\
+--wrap,kds_s2000w_client_open_session,\
--wrap,kds_s2000w_client_close_session,\
--wrap,kds_s2000w_client_start_scan,\
--wrap,kds_s2000w_client_stop_scan,\
char* kds_s2000w_config_read(const char* filename)
{
FILE* config_file = fopen(filename, "r");
+
+ if (config_file == NULL)
+ return NULL;
+
fseek(config_file, 0, SEEK_END);
size_t config_size = ftell(config_file);
rewind(config_file);
config->username = malloc(sizeof(char));
*config->scanner_url = 0;
*config->username = 0;
+ config->log_level = 0;
config->heartbeat = 1;
config->ssl_verify = 0;
return config;
cfg_opt_t opts[] = {
- CFG_STR("username", "", CFGF_NONE),
CFG_STR("scanner_url", "", CFGF_NONE),
+ CFG_STR("username", "", CFGF_NONE),
CFG_INT("default_log_level", 0, CFGF_NONE),
CFG_INT("heartbeat_seconds", 1, CFGF_NONE),
CFG_BOOL("ssl_verify", 0, CFGF_NONE),
void _kds_s2000w_handler_load_config()
{
+ kds_s2000w_debug_printf(ALL, "kds_s2000w_handler_load_config");
+
char* config_stream = kds_s2000w_config_read(CONFIG_FILE);
program_config* config = kds_s2000w_config_load(config_stream);
+#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
resp->size = mock_resp->size;
}
+void __wrap_kds_s2000w_client_init(const char* scanner_url, const char* username, bool ssl_verify, uint8_t heartbeat)
+{
+ return;
+}
+
+void __wrap_kds_s2000w_client_free()
+{
+ return;
+}
+
uint8_t __wrap_kds_s2000w_client_open_session(response* response)
{
function_called();
void mock_response(response* resp);
-void __wrap_kds_s2000w_client_init();
+void __wrap_kds_s2000w_client_init(const char* scanner_url, const char* username, bool ssl_verify, uint8_t heartbeat);
void __wrap_kds_s2000w_client_free();
uint8_t __wrap_kds_s2000w_client_open_session(response* response);