Avoid unwanted log messages during startup.
[paraslash.git] / recv.c
diff --git a/recv.c b/recv.c
index c021b17bdbefdbcc7e562f496b6ae14917d3d681..bc727de0cb65a102c8f1861d75d31c713b748a19 100644 (file)
--- a/recv.c
+++ b/recv.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2012 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2005-2013 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
 #include "list.h"
 #include "sched.h"
 #include "ggo.h"
+#include "buffer_tree.h"
 #include "recv.h"
 #include "recv.cmdline.h"
 #include "fd.h"
 #include "string.h"
 #include "error.h"
 #include "stdout.h"
-#include "buffer_tree.h"
 #include "version.h"
 
+extern void afh_recv_init(struct receiver *r);
+#undef AFH_RECEIVER
+#define AFH_RECEIVER {.name = "afh", .init = afh_recv_init},
+DEFINE_RECEIVER_ARRAY;
+
 /** The gengetopt args info struct. */
 static struct recv_args_info conf;
 
@@ -47,17 +52,6 @@ __noreturn static void print_help_and_die(void)
        exit(0);
 }
 
-static void *parse_config(int argc, char *argv[], int *receiver_num)
-{
-       if (recv_cmdline_parser(argc, argv, &conf))
-               return NULL;
-       HANDLE_VERSION_FLAG("recv", conf);
-       if (conf.help_given || conf.detailed_help_given)
-               print_help_and_die();
-       loglevel = get_loglevel_by_name(conf.loglevel_arg);
-       return check_receiver_arg(conf.receiver_arg, receiver_num);
-}
-
 /**
  * The main function of para_recv.
  *
@@ -77,16 +71,18 @@ int main(int argc, char *argv[])
        struct stdout_task sot;
        static struct sched s;
 
-       s.default_timeout.tv_sec = 1;
-       s.default_timeout.tv_usec = 0;
+       recv_cmdline_parser(argc, argv, &conf);
+       loglevel = get_loglevel_by_name(conf.loglevel_arg);
+       HANDLE_VERSION_FLAG("recv", conf);
+       recv_init();
+       if (conf.help_given || conf.detailed_help_given)
+               print_help_and_die();
 
-       memset(&sot, 0, sizeof(struct stdout_task));
        memset(&rn, 0, sizeof(struct receiver_node));
-       recv_init();
-       ret = -E_RECV_SYNTAX;
-       rn.conf = parse_config(argc, argv, &receiver_num);
+       rn.conf = check_receiver_arg(conf.receiver_arg, &receiver_num);
        if (!rn.conf) {
-               PARA_EMERG_LOG("parse failed\n");
+               PARA_EMERG_LOG("invalid receiver specifier\n");
+               ret = -E_RECV_SYNTAX;
                goto out;
        }
        r = &receivers[receiver_num];
@@ -98,6 +94,7 @@ int main(int argc, char *argv[])
                goto out;
        r_opened = 1;
 
+       memset(&sot, 0, sizeof(struct stdout_task));
        sot.btrn = btr_new_node(&(struct btr_node_description)
                EMBRACE(.parent = rn.btrn, .name = "stdout"));
        stdout_set_defaults(&sot);
@@ -108,6 +105,8 @@ int main(int argc, char *argv[])
        sprintf(rn.task.status, "%s", r->name);
        register_task(&s, &rn.task);
 
+       s.default_timeout.tv_sec = 1;
+       s.default_timeout.tv_usec = 0;
        ret = schedule(&s);
 out:
        if (r_opened)