Beispiel #1
0
void parameter_queue_free(struct parameter_queue *queue) {
    struct parameter *param, *next;

    for (param = parameter_queue_get(queue); param != NULL; param = next) {
      next = param->next;

      parameter_free(param);
    }
    free(queue);
}
Beispiel #2
0
void config_save(const char *filename) {
	char *tmp;
	PARAMETER *param = parameter_new();

	/* root */
	parameter_add(param, "root", _config.root);

	/* data */
	parameter_add(param, "data", _config.data);

	/* exec */
	parameter_add(param, "exec", _config.exec);

	/* temp */
	parameter_add(param, "temp", _config.temp);

	/* pipe */
	parameter_add(param, "pipe", _config.pipe);

	/* address */
	parameter_add(param, "address", _config.address);

	/* port */
	tmp = number_integerToString(_config.port);
	parameter_add(param, "port", tmp);
	free(tmp);

	/* timeout */
	tmp = number_integerToString(_config.timeout);
	parameter_add(param, "timeout", tmp);
	free(tmp);

	/* challenge */
	parameter_add(param, "challenge", _config.challenge);

	/* debug */
	tmp = boolean_toString(_config.debug);
	parameter_add(param, "debug", tmp);
	free(tmp);

	parameter_saveToFile(param, filename);
	parameter_free(param);
}
Beispiel #3
0
void freeConfig() {
	parameter_saveToFile(_config_param, stringbuffer_getTextPointer(_config_file));
	parameter_free(_config_param);
}
Beispiel #4
0
void config_load(const char *filename) {
	if (!file_exists(filename))
		message_error("properties-file not found");

	memset(&_config, '\0', sizeof(config_t));

	char *tmp;
	PARAMETER *param = parameter_new();
	parameter_loadFromFile(param, filename);

	/* root */
	tmp = parameter_get(param, "root");
	if (tmp == NULL)
		_config.root[0] = '\0';
	else {
		strcpy(_config.root, tmp);
		free(tmp);
	}

	/* data */
	tmp = parameter_get(param, "data");
	if (tmp == NULL)
		_config.data[0] = '\0';
	else {
		strcpy(_config.data, tmp);
		free(tmp);
	}

	/* exec */
	tmp = parameter_get(param, "exec");
	if (tmp == NULL)
		_config.exec[0] = '\0';
	else {
		strcpy(_config.exec, tmp);
		free(tmp);
	}

	/* temp */
	tmp = parameter_get(param, "temp");
	if (tmp == NULL)
		_config.temp[0] = '\0';
	else {
		strcpy(_config.temp, tmp);
		free(tmp);
	}

	/* pipe */
	tmp = parameter_get(param, "pipe");
	if (tmp == NULL)
		_config.pipe[0] = '\0';
	else {
		strcpy(_config.pipe, tmp);
		free(tmp);
	}

	/* address */
	tmp = parameter_get(param, "address");
	if (tmp == NULL)
		_config.address[0] = '\0';
	else {
		strcpy(_config.address, tmp);
		free(tmp);
	}

	/* port */
	tmp = parameter_get(param, "port");
	if (tmp == NULL)
		_config.port = -1;
	else {
		_config.port = number_toInteger(tmp);
		free(tmp);
	}

	/* timeout */
	tmp = parameter_get(param, "timeout");
	if (tmp == NULL)
		_config.timeout = -1;
	else {
		_config.timeout = number_toInteger(tmp);
		free(tmp);
	}

	/* challenge */
	tmp = parameter_get(param, "challenge");
	if (tmp == NULL)
		_config.challenge[0] = '\0';
	else {
		strcpy(_config.challenge, tmp);
		free(tmp);
	}

	/* debug */
	tmp = parameter_get(param, "debug");
	if (tmp == NULL)
		_config.debug = FALSE;
	else {
		_config.debug = boolean_toBoolean(tmp);
		free(tmp);
	}

	parameter_free(param);
}