summaryrefslogtreecommitdiffstats
path: root/src/options.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-08-14 18:55:11 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-08-14 18:55:11 +0200
commit5ebebb3688a0e88fadc6a10219572cbcf3a8603a (patch)
treec93b41cb861dae3fffdbde288d5f79bc308ba7a6 /src/options.c
parent0c6f6e92422b9c86784f45305f20cc652307546a (diff)
downloadfastd-5ebebb3688a0e88fadc6a10219572cbcf3a8603a.tar
fastd-5ebebb3688a0e88fadc6a10219572cbcf3a8603a.zip
Change the order of the option handlers to match the option definion
Diffstat (limited to 'src/options.c')
-rw-r--r--src/options.c93
1 files changed, 49 insertions, 44 deletions
diff --git a/src/options.c b/src/options.c
index d5c823b..fe5b05f 100644
--- a/src/options.c
+++ b/src/options.c
@@ -30,24 +30,6 @@
#include <arpa/inet.h>
-static int parse_log_level(fastd_context_t *ctx, const char *arg) {
- if (!strcmp(arg, "fatal"))
- return LOG_CRIT;
- else if (!strcmp(arg, "error"))
- return LOG_ERR;
- else if (!strcmp(arg, "warn"))
- return LOG_WARNING;
- else if (!strcmp(arg, "info"))
- return LOG_NOTICE;
- else if (!strcmp(arg, "verbose"))
- return LOG_INFO;
- else if (!strcmp(arg, "debug"))
- return LOG_DEBUG;
- else
- exit_error(ctx, "invalid log level `%s'", arg);
-}
-
-
static void print_usage(const char *options, const char *message) {
/* 28 spaces */
static const char spaces[] = " ";
@@ -85,6 +67,36 @@ static void version(fastd_context_t *ctx, fastd_config_t *conf) {
exit(0);
}
+static void option_daemon(fastd_context_t *ctx, fastd_config_t *conf) {
+ conf->daemon = true;
+}
+
+static void option_pid_file(fastd_context_t *ctx, fastd_config_t *conf, const char *arg) {
+ free(conf->pid_file);
+ conf->pid_file = strdup(arg);
+}
+
+
+static void option_config(fastd_context_t *ctx, fastd_config_t *conf, const char *arg) {
+ if (!strcmp(arg, "-"))
+ arg = NULL;
+
+ if (!fastd_read_config(ctx, conf, arg, false, 0))
+ exit(1);
+}
+
+static void option_config_peer(fastd_context_t *ctx, fastd_config_t *conf, const char *arg) {
+ fastd_peer_config_new(ctx, conf);
+
+ if(!fastd_read_config(ctx, conf, arg, true, 0))
+ exit(1);
+}
+
+static void option_config_peer_dir(fastd_context_t *ctx, fastd_config_t *conf, const char *arg) {
+ fastd_add_peer_dir(ctx, conf, arg);
+}
+
+
static void option_user(fastd_context_t *ctx, fastd_config_t *conf, const char *arg) {
free(conf->user);
conf->user = strdup(arg);
@@ -95,6 +107,24 @@ static void option_group(fastd_context_t *ctx, fastd_config_t *conf, const char
conf->group = strdup(arg);
}
+
+static int parse_log_level(fastd_context_t *ctx, const char *arg) {
+ if (!strcmp(arg, "fatal"))
+ return LOG_CRIT;
+ else if (!strcmp(arg, "error"))
+ return LOG_ERR;
+ else if (!strcmp(arg, "warn"))
+ return LOG_WARNING;
+ else if (!strcmp(arg, "info"))
+ return LOG_NOTICE;
+ else if (!strcmp(arg, "verbose"))
+ return LOG_INFO;
+ else if (!strcmp(arg, "debug"))
+ return LOG_DEBUG;
+ else
+ exit_error(ctx, "invalid log level `%s'", arg);
+}
+
static void option_log_level(fastd_context_t *ctx, fastd_config_t *conf, const char *arg) {
conf->log_stderr_level = parse_log_level(ctx, arg);
}
@@ -116,24 +146,6 @@ static void option_hide_mac_addresses(fastd_context_t *ctx, fastd_config_t *conf
conf->hide_mac_addresses = true;
}
-static void option_config(fastd_context_t *ctx, fastd_config_t *conf, const char *arg) {
- if (!strcmp(arg, "-"))
- arg = NULL;
-
- if (!fastd_read_config(ctx, conf, arg, false, 0))
- exit(1);
-}
-
-static void option_config_peer(fastd_context_t *ctx, fastd_config_t *conf, const char *arg) {
- fastd_peer_config_new(ctx, conf);
-
- if(!fastd_read_config(ctx, conf, arg, true, 0))
- exit(1);
-}
-
-static void option_config_peer_dir(fastd_context_t *ctx, fastd_config_t *conf, const char *arg) {
- fastd_add_peer_dir(ctx, conf, arg);
-}
static void option_mode(fastd_context_t *ctx, fastd_config_t *conf, const char *arg) {
if (!strcmp(arg, "tap"))
@@ -233,6 +245,7 @@ static void option_forward(fastd_context_t *ctx, fastd_config_t *conf) {
conf->forward = true;
}
+
static void option_on_pre_up(fastd_context_t *ctx, fastd_config_t *conf, const char *arg) {
free(conf->on_pre_up);
free(conf->on_pre_up_dir);
@@ -289,14 +302,6 @@ static void option_on_verify(fastd_context_t *ctx, fastd_config_t *conf, const c
conf->on_verify_dir = get_current_dir_name();
}
-static void option_daemon(fastd_context_t *ctx, fastd_config_t *conf) {
- conf->daemon = true;
-}
-
-static void option_pid_file(fastd_context_t *ctx, fastd_config_t *conf, const char *arg) {
- free(conf->pid_file);
- conf->pid_file = strdup(arg);
-}
static void option_generate_key(fastd_context_t *ctx, fastd_config_t *conf) {
conf->generate_key = true;