]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - client_common.c
paraslash 0.4.14
[paraslash.git] / client_common.c
index 3e20eafd74338a4196ef994753ee97eef95979bc..1ecba73068f04c4dbf43480f5ccf32a932e01279 100644 (file)
@@ -13,7 +13,6 @@
 #include "error.h"
 #include "list.h"
 #include "sched.h"
-#include "client.cmdline.h"
 #include "crypt.h"
 #include "net.h"
 #include "fd.h"
 #include "client.h"
 #include "buffer_tree.h"
 #include "version.h"
+#include "ggo.h"
 
 /** The size of the receiving buffer. */
 #define CLIENT_BUFSIZE 4000
 
 /**
- * Close the connection to para_server and deallocate per-command ressources.
+ * Close the connection to para_server and deallocate per-command resources.
  *
  * \param ct The client task.
  *
- * This frees all ressources of the current command but keeps the configuration
+ * This frees all resources of the current command but keeps the configuration
  * in \p ct->conf.
  *
  * \sa \ref client_close().
@@ -601,8 +601,7 @@ int client_connect(struct client_task *ct, struct sched *s,
        ct->btrn = btr_new_node(&(struct btr_node_description)
                EMBRACE(.name = "client", .parent = parent, .child = child));
        ct->task.pre_select = client_pre_select;
-       ct->task.new_post_select = client_post_select;
-       ct->task.post_select = NULL;
+       ct->task.post_select = client_post_select;
        ct->task.error = 0;
        sprintf(ct->task.status, "client");
        register_task(s, &ct->task);
@@ -613,6 +612,15 @@ err_out:
        return ret;
 }
 
+__noreturn static void print_help_and_die(struct client_task *ct)
+{
+       struct ggo_help h = DEFINE_GGO_HELP(client);
+       bool d = ct->conf.detailed_help_given;
+
+       ggo_print_help(&h, d? GPH_STANDARD_FLAGS_DETAILED : GPH_STANDARD_FLAGS);
+       exit(0);
+}
+
 /**
  * Parse a client configuration.
  *
@@ -643,7 +651,9 @@ int client_parse_config(int argc, char *argv[], struct client_task **ct_ptr,
        ret = -E_CLIENT_SYNTAX;
        if (client_cmdline_parser(argc, argv, &ct->conf))
                goto out;
-       HANDLE_VERSION_FLAG("client", ct->conf);
+       version_handle_flag("client", ct->conf.version_given);
+       if (ct->conf.help_given || ct->conf.detailed_help_given)
+               print_help_and_die(ct);
 
        ct->config_file = ct->conf.config_file_given?
                para_strdup(ct->conf.config_file_arg) :