void _kds_s2000w_client_load_config()
{
const char* config_file = "/etc/sane.d/kds_s2000w_net.conf";
- char* config_stream = NULL;
- read_config_file(config_file, &config_stream);
+ char* config_stream = read_config_file(config_file);
load_config(&p_config, config_stream);
}
#include <confuse.h>
#include "kds_s2000w_config.h"
-void read_config_file(const char* filename, char** config_stream)
+char* read_config_file(const char* filename)
{
- free(*config_stream);
- *config_stream = NULL;
+ char* config_stream = NULL;
FILE* config_file = fopen(filename, "r");
}
fseek(config_file, 0L, SEEK_SET);
- *config_stream = malloc(sizeof(char) * char_count);
- fread(*config_stream, char_count, 1, config_file);
+ config_stream = malloc(sizeof(char) * char_count);
+ fread(config_stream, char_count, 1, config_file);
fclose(config_file);
config_file = NULL;
+
+ return config_stream;
}
void load_config(program_config* config, const char* config_stream)
char* username;
} program_config;
-void read_config_file(const char* filename, char** config_stream);
+char* read_config_file(const char* filename);
void load_config(program_config* config, const char* config_stream);
#endif
\ No newline at end of file
int main(int argc, char** argv)
{
program_config* config = malloc(sizeof(program_config));
- char* config_stream = NULL;
printf("config file %s\n", argv[1]);
- read_config_file(argv[1], &config_stream);
+ char* config_stream = read_config_file(argv[1]);
load_config(config, config_stream);
printf("scanner_url: %s\n", config->scanner_url);