예제 #1
0
int grok_common_var(struct cfg_comp *config, struct cfg_var *v)
{
	const char *expires;

	if (!strcmp(v->key, "pulse_interval")) {
		pulse_interval = (unsigned)strtoul(v->value, NULL, 10);
		if (!pulse_interval) {
			cfg_warn(config, v, "Illegal pulse_interval. Using default.");
			pulse_interval = 10;
		}
		return 1;
	}

	expires = config_key_expires(v->key);
	if (expires) {
		cfg_warn(config, v, "'%s' is a deprecated variable, scheduled for "
			 "removal at the first release after %s", v->key, expires);
		/* it's understood, in a way */
		return 1;
	}

	if (!prefixcmp(v->key, "ipc_")) {
		if (!ipc_grok_var(v->key, v->value))
			cfg_error(config, v, "Failed to grok IPC option");

		return 1;
	}

	if (!prefixcmp(v->key, "log_") || !strcmp(v->key, "use_syslog")) {
		if (!log_grok_var(v->key, v->value))
			cfg_error(config, v, "Failed to grok logging option");

		return 1;
	}

	if (!prefixcmp(v->key, "binlog_")) {
		if (!grok_binlog_var(v->key, v->value))
			cfg_error(config, v, "Failed to grok binlog option");

		return 1;
	}

	if (!prefixcmp(v->key, "oconfsplit_")) {
#ifdef MERLIN_MODULE_BUILD
		if (!split_grok_var(v->key, v->value))
			cfg_error(config, v, "Failed to grok oconfsplit option");
#endif

		return 1;
	}
	return 0;
}
예제 #2
0
파일: daemon.c 프로젝트: ageric/merlin
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;
		}
	}
}