use own version handler for all commands.
authorAndre Noll <maan@systemlinux.org>
Sun, 4 Feb 2007 19:19:21 +0000 (20:19 +0100)
committerAndre Noll <maan@systemlinux.org>
Sun, 4 Feb 2007 19:19:21 +0000 (20:19 +0100)
This makes the man pages generated by help2man look much nicer.

14 files changed:
Makefile.in
audioc.c
audiod.c
client_common.c
command.c
fade.c
filter.c
gui.c
para.h
recv.c
sdl_gui.c
sdl_gui.ggo
server.c
write.c

index e1e6c9a97ab89983ad9e717b7ca2e9a4fb4a1b1b..7dd99ac2b7fbd70965c1004934b8ddecc3e0cd8d 100644 (file)
@@ -1,6 +1,3 @@
-COPYRIGHT = Copyright (c) 1997-2007 by Andre Noll
-DISCLAIMER = This is free software with ABSOLUTELY NO WARRANTY. See COPYING for details.
-
 prefix = @prefix@
 exec_prefix = @exec_prefix@
 
@@ -102,7 +99,6 @@ slider_objs = slider.o string.o
 
 include Makefile.deps
 
-V := (@PACKAGE_STRING@, $(codename))\n$(COPYRIGHT)\n$(DISCLAIMER)
 module_ggo_opts := --set-version="(@PACKAGE_STRING@, $(codename))"
 
 grab_client.cmdline.h grab_client.cmdline.c: grab_client.ggo
@@ -141,12 +137,13 @@ grab_client.cmdline.h grab_client.cmdline.c: grab_client.ggo
                audioc.ggo) O="--unamed-opts=command";; \
        esac; \
        gengetopt $$O \
+               --no-handle-version \
                --conf-parser \
                --file-name=$(*F).cmdline \
                --func-name $(*F)_cmdline_parser \
                --arg-struct-name=$(*F)_args_info \
                --set-package="para_$(subst .cmdline,,$(*F))" \
-               --set-version="$V"  < $<
+               --set-version="@PACKAGE_VERSION@"  < $<
 
 %_command_list.c %_command_list.h: %.cmd
        ./command_util.sh c < $< >$@
@@ -165,7 +162,7 @@ man/man1/para_audiod.1: para_audiod audiod_command_list.man
        help2man -N -i audiod_command_list.man ./para_audiod > $@
 
 man/man1/%.1: %
-       help2man -N $< > $@
+       help2man -N ./$< > $@
 
 man/html/%.html: man/man1/%.1
        man2html $< > $@
index 1679335d7cf737d37413a158d347d16cb2054357..216afa2f11aeebc132d23ad2a96664daf9e384cd 100644 (file)
--- a/audioc.c
+++ b/audioc.c
@@ -69,6 +69,7 @@ int main(int argc, char *argv[])
 
        if (audioc_cmdline_parser(argc, argv, &conf))
                goto out;
+       HANDLE_VERSION_FLAG("audioc", conf);
        cf = configfile_exists();
        if (cf) {
                if (audioc_cmdline_parser_configfile(cf, &conf, 0, 0, 0)) {
index 2798ad26d57387c65779d9435b5ac471b901a54d..8eb425da95af4701879e0e077efc496a20bbdeb7 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -1094,6 +1094,7 @@ int main(int argc, char *argv[])
 
        valid_fd_012();
        audiod_cmdline_parser(argc, argv, &conf);
+       HANDLE_VERSION_FLAG("audiod", conf);
        para_drop_privileges(conf.user_arg, conf.group_arg);
        cf = configfile_exists();
        if (cf) {
index 12c8365661e6c8f7e0608c66cd7d65a659e219cb..48b46da44e73768335724790a2cb973459dd66de 100644 (file)
 #include "client.h"
 #include "error.h"
 
-void rc4_send(unsigned long len, const unsigned char *indata,
+/*
+ * rc4 encrypt data before sending
+ *
+ * \param len the number of bytes to encrypt
+ * \param indata pointer to the input data of length \a len to be encrypted
+ * \param outdata pointer that holds the encrypted data after return
+ * \param private_data pointer to the private client data containing
+ * the rc4 key
+ * */
+static void rc4_send(unsigned long len, const unsigned char *indata,
                unsigned char *outdata, void *private_data)
 {
        struct private_client_data *pcd = private_data;
        RC4(&pcd->rc4_send_key, len, indata, outdata);
 }
 
-void rc4_recv(unsigned long len, const unsigned char *indata,
+/*
+ * rc4 decrypt received data
+ *
+ * \param len the number of bytes to decrypt
+ * \param indata pointer to the input data of length \a len
+ * \param outdata pointer that holds the decrypted data after return
+ * \param private_data pointer to the private client data containing
+ * the rc4 key
+ * */
+static void rc4_recv(unsigned long len, const unsigned char *indata,
                unsigned char *outdata, void *private_data)
 {
        struct private_client_data *pcd = private_data;
        RC4(&pcd->rc4_recv_key, len, indata, outdata);
 }
 
-
+/**
+ * close the connection to para_server and free all resources
+ *
+ * \param pcd pointer to the client data
+ *
+ * \sa client_open.
+ * */
 void client_close(struct private_client_data *pcd)
 {
        if (!pcd)
@@ -96,6 +120,20 @@ err_out:
        return ret;
 }
 
+/**
+ * open connection to para_server
+ *
+ * \param argc usual argument count
+ * \param argv usual argument vector
+ * \param pcd_ptr points to dynamically allocated and initialized private client data
+ * upon successful return
+ *
+ * Check the command line options given by \a argc and argv, set default values
+ * for user name and rsa key file, read further option from the config file.
+ * Finally, establish a connection to para_server.
+ *
+ * \return Positive on success, negative on errors.
+ */
 int client_open(int argc, char *argv[], struct private_client_data **pcd_ptr)
 {
        char *home = para_homedir();
@@ -107,6 +145,7 @@ int client_open(int argc, char *argv[], struct private_client_data **pcd_ptr)
        *pcd_ptr = pcd;
        pcd->fd = -1;
        ret = client_cmdline_parser(argc, argv, &pcd->conf);
+       HANDLE_VERSION_FLAG("client", pcd->conf);
        ret = -E_CLIENT_SYNTAX;
        if (!pcd->conf.inputs_num)
                goto out;
@@ -144,6 +183,20 @@ out:
        return ret;
 }
 
+/**
+ * the preselect hook for server commands
+ *
+ * \param s pointer to the scheduler
+ * \param t pointer to the task struct for this command
+ *
+ * The task pointer must contain a pointer to the initialized client data
+ * structure as it is returned by client_open().
+ *
+ * This function checks the state of the connection and adds the file descriptor
+ * of the connection to the read or write fd set of \a s accordingly.
+ *
+ * \sa register_task() client_open(), struct sched, struct task
+ */
 void client_pre_select(struct sched *s, struct task *t)
 {
        struct private_client_data *pcd = t->private_data;
@@ -203,6 +256,19 @@ static ssize_t client_recv_buffer(struct private_client_data *pcd)
 
 }
 
+/**
+ * the post select hook for client commands
+ *
+ * \param s pointer to the scheduler
+ * \param t pointer to the task struct for this command
+ *
+ * Depending on the current state of the connection and the status of the read
+ * and write fd sets of \a s, this function performs the neccessary steps to
+ * authenticate the connection, to send the commmand given by \a
+ * t->private_data and to receive para_server's output, if any.
+ *
+ * \sa struct sched, struct task
+ */
 void client_post_select(struct sched *s, struct task *t)
 {
        struct private_client_data *pcd = t->private_data;
@@ -324,5 +390,4 @@ void client_post_select(struct sched *s, struct task *t)
                t->ret = client_recv_buffer(pcd);
                return;
        }
-
 }
index 21131248c29cd894c8bb74cb13801cd54205e066..9ef629257134e4d8cad97fc344b30e0be473956d 100644 (file)
--- a/command.c
+++ b/command.c
@@ -345,12 +345,10 @@ int com_version(int socket_fd, int argc, __a_unused char **argv)
 {
        if (argc != 1)
                return -E_COMMAND_SYNTAX;
-       return send_buffer(socket_fd, "para_server-" PACKAGE_VERSION ", \""
-                       CODENAME "\"\n"
-                       COPYRIGHT "\n"
-                       "built: " BUILD_DATE "\n"
-                       SYSTEM ", " CC_VERSION "\n"
-               );
+       return send_buffer(socket_fd, VERSION_TEXT("server")
+               "built: " BUILD_DATE "\n"
+               SYSTEM ", " CC_VERSION "\n"
+       );
 }
 
 /* sc */
diff --git a/fade.c b/fade.c
index 55c62a7444b64430920aaf5d2b4521b8bf2050e6..7445aa68f5d1bb795036f75648704347bed97386 100644 (file)
--- a/fade.c
+++ b/fade.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1998-2005 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 1998-2007 Andre Noll <maan@systemlinux.org>
  *
  *     This program is free software; you can redistribute it and/or modify
  *     it under the terms of the GNU General Public License as published by
@@ -287,6 +287,7 @@ int main(int argc, char *argv[])
 
        if (fade_cmdline_parser(argc, argv, &args_info))
                exit(EXIT_FAILURE);
+       HANDLE_VERSION_FLAG("fade", args_info);
        ret = configfile_exists();
        if (!ret && args_info.config_file_given) {
                PARA_EMERG_LOG("can not read config file %s\n",
index ee3d965596a37069b17cab629216cbf08a05229f..d1f88539b946b571339902bbc9d950a2555365a8 100644 (file)
--- a/filter.c
+++ b/filter.c
@@ -114,6 +114,7 @@ static int parse_config(int argc, char *argv[])
 
        if (filter_cmdline_parser(argc, argv, &conf))
                return -E_FILTER_SYNTAX;
+       HANDLE_VERSION_FLAG("filter", conf);
        if (!cf) {
                char *home = para_homedir();
                cf = make_message("%s/.paraslash/filter.conf", home);
diff --git a/gui.c b/gui.c
index 06641f756dafdb3fc5aa77ebcf6b89038f9f7bf9..9ad5aa985703c8371eb15e5cc2f94a3c7a64ad01 100644 (file)
--- a/gui.c
+++ b/gui.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1998-2006 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 1998-2007 Andre Noll <maan@systemlinux.org>
  *
  *     This program is free software; you can redistribute it and/or modify
  *     it under the terms of the GNU General Public License as published by
@@ -1327,6 +1327,7 @@ int main(int argc, char *argv[])
                fprintf(stderr, "parse error while reading command line\n");
                exit(EXIT_FAILURE);
        }
+       HANDLE_VERSION_FLAG("gui", conf);
        init_theme(0, &theme);
        top.lines = theme.top_lines_default;
        if (check_key_map_args() < 0) {
diff --git a/para.h b/para.h
index 8e1c72159748f923a02f975f309a8a94cfc1afce..10931aaf08461cef768d95720a833e0f86f8139e 100644 (file)
--- a/para.h
+++ b/para.h
        }
 
 
-#define COPYRIGHT "Copyright (c) 1997-2006 by Andre Noll"
-
+#define VERSION_TEXT(prefix) "para_" prefix " " PACKAGE_VERSION "\n" \
+       "Copyright (C) 2007 Andre Noll\n" \
+       "This is free software with ABSOLUTELY NO WARRANTY." \
+       " See COPYING for details.\n" \
+       "Written by Andre Noll.\n" \
+       "Report bugs to <maan@systemlinux.org>.\n"
+
+#define HANDLE_VERSION_FLAG(_prefix, _args_info_struct) \
+       if (_args_info_struct.version_given) { \
+               printf("%s", VERSION_TEXT(_prefix)); \
+               exit(EXIT_SUCCESS); \
+       }
 
 #define AWAITING_DATA_MSG "\nAwaiting Data."
 #define PROCEED_MSG "\nProceed.\n"
diff --git a/recv.c b/recv.c
index 1bbef74358aee51e75b8806a6eef9697d6c31696..a7a957dddde4188381ec042896f75792d965402e 100644 (file)
--- a/recv.c
+++ b/recv.c
@@ -43,6 +43,7 @@ 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.list_receivers_given) {
                printf("available receivers: ");
                for (i = 0; receivers[i].name; i++)
index 97d0573a8e3b455a95e26139a9c1ee30c30682e8..ca3bcc1f2b15cd3921af3b6647b3bdcf3f3337f3 100644 (file)
--- a/sdl_gui.c
+++ b/sdl_gui.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003-2006 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2003-2007 Andre Noll <maan@systemlinux.org>
  *
  *     This program is free software; you can redistribute it and/or modify
  *     it under the terms of the GNU General Public License as published by
@@ -743,6 +743,7 @@ int main(int argc, char *argv[])
        SDLKey sym;
 
        sdl_gui_cmdline_parser(argc, argv, &args_info);
+       HANDLE_VERSION_FLAG("sdl_gui", args_info);
        ret = configfile_exists();
 //     printf("w=%i,h=%i,ret=%i, cf=%s\n", width, height, ret, args_info.config_file_arg);
 
index 8ea4928784ae97e94afd2886f7f228bf06226bca..de7bbddaca94d45504fae7e627d1f7031733f17d 100644 (file)
@@ -6,3 +6,4 @@ option "config_file" c "(default='~/.paraslash/sdl_gui.conf')" string typestr="f
 option "window-id" w "(currently ignored)" string typestr="filename" optional
 option "stat_cmd" s "command to read server and audiod status data from" string typestr="command" default="para_audioc stat" optional
 option "pic_cmd" p "command to read pic from" string typestr="command" default="para_client pic" optional
+text "Written by Andre Noll"
index 43f2010b21e193655765afd0799f4813f4e8fd69..f67efa6e233e6bc1bcdd2716f29b94027f3a1b41 100644 (file)
--- a/server.c
+++ b/server.c
@@ -349,6 +349,7 @@ static unsigned do_inits(int argc, char **argv)
        init_random_seed();
        /* parse command line options */
        server_cmdline_parser(argc, argv, &conf);
+       HANDLE_VERSION_FLAG("server", conf);
        para_drop_privileges(conf.user_arg, conf.group_arg);
        /* parse config file, open log and set defaults */
        parse_config(0);
diff --git a/write.c b/write.c
index 89831a2e448f40129e5ed6d51f8bebd863d9123b..683a91b0a78c6f93d19dae229a3fbf510a0fb2e8 100644 (file)
--- a/write.c
+++ b/write.c
@@ -226,6 +226,7 @@ int main(int argc, char *argv[])
        struct sched s;
 
        write_cmdline_parser(argc, argv, &conf);
+       HANDLE_VERSION_FLAG("write", conf);
        init_supported_writers();
 
        wng = check_args();