Beispiel #1
0
void grok_db_compound(struct cfg_comp *c)
{
	unsigned int vi;

	use_database = 1;
	for (vi = 0; vi < c->vars; vi++) {
		struct cfg_var *v = c->vlist[vi];
		if (!strcmp(v->key, "log_report_data")) {
			db_log_reports = strtobool(v->value);
		} else if (!prefixcmp(v->key, "log_notification")) {
			db_log_notifications = strtobool(v->value);
		} else if (!prefixcmp(v->key, "track_current")) {
			lwarn("Option '%s' in the database compound is deprecated", v->key);
		} else if (!strcmp(v->key, "enabled")) {
			use_database = strtobool(v->value);
		} else {
			sql_config(v->key, v->value);
		}
	}
}
Beispiel #2
0
int Connector::read_sql_config() {

	int i = 0;
	string line;
	string listCreds[4];
	ifstream sql_config(sql_config_file);
	if (sql_config.is_open()) {
		while (getline(sql_config, line)) {
			if(line.at(0) == '#') continue;
			listCreds[i++] = line;
		}
		sql_config.close();
	} else {
		cout << "Fail " << endl;
		return 1;
	}
	creds.host = listCreds[0];
	creds.usr = listCreds[1];
	creds.pwd = listCreds[2];
	creds.base = listCreds[3];
	cout << listCreds[0] << endl;
	return 0;
}
Beispiel #3
0
static void grok_daemon_compound(struct cfg_comp *comp)
{
	uint i;

	for (i = 0; i < comp->vars; i++) {
		struct cfg_var *v = comp->vlist[i];

		if (!strcmp(v->key, "port")) {
			char *endp;

			default_port = (unsigned short)strtoul(v->value, &endp, 0);
			if (default_port < 1 || *endp)
				cfg_error(comp, v, "Illegal value for port: %s", v->value);
			continue;
		}
		if (!strcmp(v->key, "address")) {
			unsigned int addr;
			if (inet_pton(AF_INET, v->value, &addr) == 1)
				default_addr = addr;
			else
				cfg_error(comp, v, "Illegal value for address: %s", v->value);
			continue;
		}
		if (!strcmp(v->key, "pidfile")) {
			pidfile = strdup(v->value);
			continue;
		}
		if (!strcmp(v->key, "merlin_user")) {
			merlin_user = strdup(v->value);
			continue;
		}
		if (!strcmp(v->key, "import_program")) {
			import_program = strdup(v->value);
			continue;
		}

		if (grok_common_var(comp, v))
			continue;
		if (log_grok_var(v->key, v->value))
			continue;

		cfg_error(comp, v, "Unknown variable");
	}

	for (i = 0; i < comp->nested; i++) {
		struct cfg_comp *c = comp->nest[i];
		uint vi;

		if (!prefixcmp(c->name, "database")) {
			use_database = 1;
			for (vi = 0; vi < c->vars; vi++) {
				struct cfg_var *v = c->vlist[vi];
				if (!strcmp(v->key, "log_report_data")) {
					db_log_reports = strtobool(v->value);
				} else if (!prefixcmp(v->key, "log_notification")) {
					db_log_notifications = strtobool(v->value);
				} else if (!prefixcmp(v->key, "track_current")) {
					db_track_current = strtobool(v->value);
				} else if (!strcmp(v->key, "enabled")) {
					use_database = strtobool(v->value);
				} else {
					sql_config(v->key, v->value);
				}
			}
			continue;
		}
		if (!strcmp(c->name, "object_config")) {
			grok_confsync_compound(c, &csync);
			continue;
		}
	}
}