<commit_before>#include "all.h"


struct sca_config sca_config = 
{
	.config_file = LIBTLSCA_CONFIG_FILE,

	.application_id = "io.seacat.agent",
	.application_id_suffix = NULL, //TODO: Allow to configure this one

	.var_dir = "./var", //TODO: This is from configuration
};

///

static int sca_config_parse_handler(void * user, const char * section, const char * name, const char * value)
{
	if (false) {}


	return 0;  // unknown section/name, error
}

///

void sca_config_environ()
{
	char * c;

	c = getenv("SEACAT_CONFIG");
	if (c != NULL) sca_config.config_file = c;
}


bool sca_config_load()
{
	if (sca_config.config_file == NULL) return true;

	FT_DEBUG("Loading configuration from '%s'", sca_config.config_file);
	if (ini_parse(sca_config.config_file, sca_config_parse_handler, &sca_config) < 0)
	{
		FT_ERROR("Can't load '%s'", sca_config.config_file);
		return false;
	}

	return true;
}
<commit_msg>Add a configuration option for application id suffix.<commit_after>#include "all.h"


struct sca_config sca_config = 
{
	.config_file = LIBTLSCA_CONFIG_FILE,

	.application_id = "io.seacat.agent",
	.application_id_suffix = NULL, //TODO: Allow to configure this one

	.var_dir = "./var", //TODO: This is from configuration
};

///

static int sca_config_parse_handler(void * user, const char * section, const char * name, const char * value)
{
	if (false) {}

	else if (FT_INI_MATCH("seacatio", "suffix"))
	{
		sca_config.application_id_suffix = strdup(value);
		return 1;
	}

	return 0;  // unknown section/name, error
}

///

void sca_config_environ()
{
	char * c;

	c = getenv("SEACAT_CONFIG");
	if (c != NULL) sca_config.config_file = c;
}


bool sca_config_load()
{
	if (sca_config.config_file == NULL) return true;

	FT_DEBUG("Loading configuration from '%s'", sca_config.config_file);
	if (ini_parse(sca_config.config_file, sca_config_parse_handler, &sca_config) < 0)
	{
		FT_ERROR("Can't load '%s'", sca_config.config_file);
		return false;
	}

	return true;
}

{'fraction_non_alphanumeric': 0.13636363636363635, 'fraction_numerical': 0.0025252525252525255, 'mean_word_length': 4.325268817204301, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2922546', 'n_tokens_mistral': 778, 'n_tokens_neox': 745, 'n_words': 175}