From: Andre Noll Date: Sun, 4 Feb 2007 19:19:21 +0000 (+0100) Subject: use own version handler for all commands. X-Git-Tag: v0.2.15~41 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=ce2bb6c458275ec6c0a115a2c814a15761474f11 use own version handler for all commands. This makes the man pages generated by help2man look much nicer. --- diff --git a/Makefile.in b/Makefile.in index e1e6c9a9..7dd99ac2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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 $< > $@ diff --git a/audioc.c b/audioc.c index 1679335d..216afa2f 100644 --- 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)) { diff --git a/audiod.c b/audiod.c index 2798ad26..8eb425da 100644 --- 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) { diff --git a/client_common.c b/client_common.c index 12c83656..48b46da4 100644 --- a/client_common.c +++ b/client_common.c @@ -31,21 +31,45 @@ #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; } - } diff --git a/command.c b/command.c index 21131248..9ef62925 100644 --- 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 55c62a74..7445aa68 100644 --- a/fade.c +++ b/fade.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1998-2005 Andre Noll + * Copyright (C) 1998-2007 Andre Noll * * 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", diff --git a/filter.c b/filter.c index ee3d9655..d1f88539 100644 --- 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 06641f75..9ad5aa98 100644 --- a/gui.c +++ b/gui.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1998-2006 Andre Noll + * Copyright (C) 1998-2007 Andre Noll * * 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 8e1c7215..10931aaf 100644 --- a/para.h +++ b/para.h @@ -119,8 +119,18 @@ } -#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 .\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 1bbef743..a7a957dd 100644 --- 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++) diff --git a/sdl_gui.c b/sdl_gui.c index 97d0573a..ca3bcc1f 100644 --- a/sdl_gui.c +++ b/sdl_gui.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2006 Andre Noll + * Copyright (C) 2003-2007 Andre Noll * * 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); diff --git a/sdl_gui.ggo b/sdl_gui.ggo index 8ea49287..de7bbdda 100644 --- a/sdl_gui.ggo +++ b/sdl_gui.ggo @@ -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" diff --git a/server.c b/server.c index 43f2010b..f67efa6e 100644 --- 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 89831a2e..683a91b0 100644 --- 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();