From 3fbdc96d45fbf2abcc93ed2e8ad206bc540be92b Mon Sep 17 00:00:00 2001 Message-Id: <3fbdc96d45fbf2abcc93ed2e8ad206bc540be92b.1714115868.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sun, 9 Mar 2008 10:21:58 +0000 Subject: [PATCH] Adjust --version output to more closely match GNU standards Organization: Straylight/Edgeware From: Richard Kettlewell --- .bzrignore | 2 +- clients/disorder.c | 10 ++------ clients/disorderfm.c | 10 ++------ clients/playrtp.c | 10 ++------ disobedience/disobedience.c | 10 ++------ lib/Makefile.am | 7 +++--- lib/defs.c | 2 +- lib/version.c | 47 +++++++++++++++++++++++++++++++++++++ lib/version.h | 34 +++++++++++++++++++++++++++ scripts/make-version-string | 8 ++++++- server/dbupgrade.c | 10 ++------ server/deadlock.c | 10 ++------ server/decode.c | 10 ++------ server/disorderd.c | 10 ++------ server/dump.c | 10 ++------ server/normalize.c | 10 ++------ server/rescan.c | 10 ++------ server/speaker.c | 12 +++------- server/trackname.c | 10 ++------ 19 files changed, 121 insertions(+), 111 deletions(-) create mode 100644 lib/version.c create mode 100644 lib/version.h diff --git a/.bzrignore b/.bzrignore index ffea199..a08805f 100644 --- a/.bzrignore +++ b/.bzrignore @@ -140,7 +140,7 @@ server/index.html .DS_Store tests/disorder-udplog lib/version-string -lib/version.h +lib/versionstring.h scripts/setup examples/disorder.rc scripts/teardown diff --git a/clients/disorder.c b/clients/disorder.c index 15bd107..caeac18 100644 --- a/clients/disorder.c +++ b/clients/disorder.c @@ -53,6 +53,7 @@ #include "defs.h" #include "authorize.h" #include "vector.h" +#include "version.h" static disorder_client *client; @@ -84,13 +85,6 @@ static void help(void) { exit(0); } -/* display version number and terminate */ -static void version(void) { - xprintf("%s", disorder_version_string); - xfclose(stdout); - exit(0); -} - static disorder_client *getclient(void) { if(!client) { if(!(client = disorder_new(1))) exit(EXIT_FAILURE); @@ -622,7 +616,7 @@ int main(int argc, char **argv) { switch(n) { case 'h': help(); case 'H': help_commands(); - case 'V': version(); + case 'V': version("disorder"); case 'c': configfile = optarg; break; case 'd': debugging = 1; break; case 'l': local = 1; break; diff --git a/clients/disorderfm.c b/clients/disorderfm.c index d8dffb6..a55cc44 100644 --- a/clients/disorderfm.c +++ b/clients/disorderfm.c @@ -38,6 +38,7 @@ #include "charset.h" #include "defs.h" #include "mem.h" +#include "version.h" /* Arguments etc ----------------------------------------------------------- */ @@ -127,13 +128,6 @@ static void help(void) { exit(0); } -/* display version number and terminate */ -static void version(void) { - xprintf("%s", disorder_version_string); - xfclose(stdout); - exit(0); -} - /* Utilities --------------------------------------------------------------- */ /* Copy FROM to TO. Has the same signature as link/symlink. */ @@ -356,7 +350,7 @@ int main(int argc, char **argv) { while((n = getopt_long(argc, argv, "hVdf:t:i:e:ET:u:wlscn", options, 0)) >= 0) { switch(n) { case 'h': help(); - case 'V': version(); + case 'V': version("disorderfm"); case 'd': debugging = 1; break; case 'f': fromencoding = optarg; break; case 't': toencoding = optarg; break; diff --git a/clients/playrtp.c b/clients/playrtp.c index 484d265..4f6e57a 100644 --- a/clients/playrtp.c +++ b/clients/playrtp.c @@ -85,6 +85,7 @@ #include "client.h" #include "playrtp.h" #include "inputline.h" +#include "version.h" #define readahead linux_headers_are_borked @@ -531,13 +532,6 @@ static void help(void) { exit(0); } -/* display version number and terminate */ -static void version(void) { - xprintf("%s", disorder_version_string); - xfclose(stdout); - exit(0); -} - int main(int argc, char **argv) { int n, err; struct addrinfo *res; @@ -574,7 +568,7 @@ int main(int argc, char **argv) { while((n = getopt_long(argc, argv, "hVdD:m:b:x:L:R:M:aocC:r", options, 0)) >= 0) { switch(n) { case 'h': help(); - case 'V': version(); + case 'V': version("disorder-playrtp"); case 'd': debugging = 1; break; case 'D': device = optarg; break; case 'm': minbuffer = 2 * atol(optarg); break; diff --git a/disobedience/disobedience.c b/disobedience/disobedience.c index 338b5af..42eb190 100644 --- a/disobedience/disobedience.c +++ b/disobedience/disobedience.c @@ -23,6 +23,7 @@ #include "disobedience.h" #include "mixer.h" +#include "version.h" #include #include @@ -407,13 +408,6 @@ static void help(void) { exit(0); } -/* display version number and terminate */ -static void version(void) { - xprintf("%s", disorder_version_string); - xfclose(stdout); - exit(0); -} - /* reset state */ void reset(void) { struct reset_callback_node *r; @@ -454,7 +448,7 @@ int main(int argc, char **argv) { while((n = getopt_long(argc, argv, "hVc:dtHC", options, 0)) >= 0) { switch(n) { case 'h': help(); - case 'V': version(); + case 'V': version("disobedience"); case 'c': configfile = optarg; break; case 'd': debugging = 1; break; case 't': goesupto = 11; break; diff --git a/lib/Makefile.am b/lib/Makefile.am index d28a3b0..8715bb0 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -74,6 +74,7 @@ libdisorder_a_SOURCES=charset.c charset.h \ unidata.h unidata.c \ vacopy.h \ vector.c vector.h \ + version.c version.h \ wav.h wav.c \ wstat.c wstat.h \ disorder.h @@ -84,7 +85,7 @@ version-string: ../config.status ${top_srcdir}/scripts/make-version-string echo rm -f $@.new; rm -f $@.new; else \ echo mv $@.new $@; mv $@.new $@; fi -version.h: version-string ${top_srcdir}/scripts/text2c +versionstring.h: version-string ${top_srcdir}/scripts/text2c ${top_srcdir}/scripts/text2c -extern disorder_version_string \ version-string > $@.new @if cmp $@.new $@; then \ @@ -104,8 +105,8 @@ definitions.h: Makefile @if cmp $@.new $@; then \ echo rm -f $@.new; rm -f $@.new; else \ echo mv $@.new $@; mv $@.new $@; fi -defs.o: definitions.h version.h -defs.lo: definitions.h version.h +defs.o: definitions.h versionstring.h +defs.lo: definitions.h versionstring.h test_SOURCES=test.c memgc.c test.h t-addr.c t-basen.c t-cache.c \ t-casefold.c t-cookies.c t-filepart.c t-hash.c t-heap.c \ diff --git a/lib/defs.c b/lib/defs.c index 19987cb..fd323ad 100644 --- a/lib/defs.c +++ b/lib/defs.c @@ -59,7 +59,7 @@ const char finkbindir[] = FINKBINDIR; /** @brief Package documentation directory */ const char docdir[] = DOCDIR; -#include "version.h" +#include "versionstring.h" /* Local Variables: diff --git a/lib/version.c b/lib/version.c new file mode 100644 index 0000000..f92e0c7 --- /dev/null +++ b/lib/version.c @@ -0,0 +1,47 @@ +/* + * This file is part of DisOrder + * Copyright (C) 2008 Richard Kettlewell + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ + +#include +#include "types.h" + +#include +#include + +#include "syscalls.h" +#include "version.h" +#include "defs.h" + +/** @brief Display version string and exit + * @param name Name of this program + */ +void version(const char *name) { + xprintf(disorder_version_string, name); + xfclose(stdout); + exit(0); +} + +/* +Local Variables: +c-basic-offset:2 +comment-column:40 +fill-column:79 +indent-tabs-mode:nil +End: +*/ diff --git a/lib/version.h b/lib/version.h new file mode 100644 index 0000000..4930bfd --- /dev/null +++ b/lib/version.h @@ -0,0 +1,34 @@ +/* + * This file is part of DisOrder + * Copyright (C) 2008 Richard Kettlewell + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ +#ifndef VERSION_H +#define VERSION_H + +void version(const char *name); + +#endif /* VERSION_H */ + +/* +Local Variables: +c-basic-offset:2 +comment-column:40 +fill-column:79 +indent-tabs-mode:nil +End: +*/ diff --git a/scripts/make-version-string b/scripts/make-version-string index 210e84f..dfcca41 100755 --- a/scripts/make-version-string +++ b/scripts/make-version-string @@ -24,8 +24,14 @@ if(exists $ENV{CC}) { $compiler = $cv[0]; } die "no version found\n" unless defined $version; -output("DisOrder $version\n"); +output("%s (DisOrder) $version\n"); output(" configure options: $options\n") if defined $options; output(" compiler: $cc\n") if defined $compiler; output(" version: $compiler\n") if defined $cc; +output("Copyright (C) 2003-2008 Richard Kettlewell et al\n"); +output("License GPLv2+: GNU GPL version 2 or later:\n"); +output(" http://www.gnu.org/licenses/old-licenses/gpl-2.0.html\n"); +output("This is free software: you are free to change and redistribute it.\n"); +output("There is NO WARRANTY, to the extent permitted by law.\n"); + close STDOUT or die "$0: stdout: $!\n"; diff --git a/server/dbupgrade.c b/server/dbupgrade.c index 0d8600d..7f4eeac 100644 --- a/server/dbupgrade.c +++ b/server/dbupgrade.c @@ -40,6 +40,7 @@ #include "mem.h" #include "configuration.h" #include "unicode.h" +#include "version.h" static DB_TXN *global_tid; @@ -85,13 +86,6 @@ static void help(void) { exit(0); } -/* display version number and terminate */ -static void version(void) { - xprintf("%s", disorder_version_string); - xfclose(stdout); - exit(0); -} - /** @brief Visit each key in a database and call @p callback * @return 0 or DB_LOCK_DEADLOCK * @@ -343,7 +337,7 @@ int main(int argc, char **argv) { while((n = getopt_long(argc, argv, "hVc:dDSsxX", options, 0)) >= 0) { switch(n) { case 'h': help(); - case 'V': version(); + case 'V': version("disorder-dbupgrade"); case 'c': configfile = optarg; break; case 'd': debugging = 1; break; case 'D': debugging = 0; break; diff --git a/server/deadlock.c b/server/deadlock.c index 99359b2..6aa130c 100644 --- a/server/deadlock.c +++ b/server/deadlock.c @@ -42,6 +42,7 @@ #include "rights.h" #include "trackdb.h" #include "trackdb-int.h" +#include "version.h" static const struct option options[] = { { "help", no_argument, 0, 'h' }, @@ -71,13 +72,6 @@ static void help(void) { exit(0); } -/* display version number and terminate */ -static void version(void) { - xprintf("%s", disorder_version_string); - xfclose(stdout); - exit(0); -} - int main(int argc, char **argv) { int n, err, aborted, logsyslog = !isatty(2); @@ -86,7 +80,7 @@ int main(int argc, char **argv) { while((n = getopt_long(argc, argv, "hVc:dDSs", options, 0)) >= 0) { switch(n) { case 'h': help(); - case 'V': version(); + case 'V': version("disorder-deadlock"); case 'c': configfile = optarg; break; case 'd': debugging = 1; break; case 'D': debugging = 0; break; diff --git a/server/decode.c b/server/decode.c index b609d4e..36d98ca 100644 --- a/server/decode.c +++ b/server/decode.c @@ -50,6 +50,7 @@ #include "defs.h" #include "wav.h" #include "speaker-protocol.h" +#include "version.h" /** @brief Encoding lookup table type */ struct decoder { @@ -444,13 +445,6 @@ static void help(void) { exit(0); } -/* Display version number and terminate. */ -static void version(void) { - xprintf("%s", disorder_version_string); - xfclose(stdout); - exit(0); -} - int main(int argc, char **argv) { int n; const char *e; @@ -460,7 +454,7 @@ int main(int argc, char **argv) { while((n = getopt_long(argc, argv, "hV", options, 0)) >= 0) { switch(n) { case 'h': help(); - case 'V': version(); + case 'V': version("disorder-decode"); default: fatal(0, "invalid option"); } } diff --git a/server/disorderd.c b/server/disorderd.c index e03e4d7..913721b 100644 --- a/server/disorderd.c +++ b/server/disorderd.c @@ -57,6 +57,7 @@ #include "mixer.h" #include "eventlog.h" #include "printf.h" +#include "version.h" static ev_source *ev; @@ -93,13 +94,6 @@ static void help(void) { exit(0); } -/* display version number and terminate */ -static void version(void) { - xprintf("%s", disorder_version_string); - xfclose(stdout); - exit(0); -} - /* SIGHUP callback */ static int handle_sighup(ev_source attribute((unused)) *ev_, int attribute((unused)) sig, @@ -217,7 +211,7 @@ int main(int argc, char **argv) { while((n = getopt_long(argc, argv, "hVc:dfP:Ns", options, 0)) >= 0) { switch(n) { case 'h': help(); - case 'V': version(); + case 'V': version("disorderd"); case 'c': configfile = optarg; break; case 'd': debugging = 1; break; case 'f': background = 0; break; diff --git a/server/dump.c b/server/dump.c index 3be14be..64a3d8d 100644 --- a/server/dump.c +++ b/server/dump.c @@ -46,6 +46,7 @@ #include "trackdb.h" #include "trackdb-int.h" #include "charset.h" +#include "version.h" static const struct option options[] = { { "help", no_argument, 0, 'h' }, @@ -82,13 +83,6 @@ static void help(void) { exit(0); } -/* display version number and terminate */ -static void version(void) { - xprintf("%s", disorder_version_string); - xfclose(stdout); - exit(0); -} - /* dump prefs to FP, return nonzero on error */ static void do_dump(FILE *fp, const char *tag, int tracksdb, int searchdb) { @@ -454,7 +448,7 @@ int main(int argc, char **argv) { while((n = getopt_long(argc, argv, "hVc:dDutsrRaP", options, 0)) >= 0) { switch(n) { case 'h': help(); - case 'V': version(); + case 'V': version("disorder-dump"); case 'c': configfile = optarg; break; case 'd': dump = 1; break; case 'u': undump = 1; break; diff --git a/server/normalize.c b/server/normalize.c index 28faa81..8b871c8 100644 --- a/server/normalize.c +++ b/server/normalize.c @@ -42,6 +42,7 @@ #include "configuration.h" #include "speaker-protocol.h" #include "defs.h" +#include "version.h" static const struct option options[] = { { "help", no_argument, 0, 'h' }, @@ -71,13 +72,6 @@ static void help(void) { exit(0); } -/* display version number and terminate */ -static void version(void) { - xprintf("%s", disorder_version_string); - xfclose(stdout); - exit(0); -} - /** @brief Copy bytes from one file descriptor to another * @param infd File descriptor read from * @param outfd File descriptor to write to @@ -157,7 +151,7 @@ int main(int argc, char attribute((unused)) **argv) { while((n = getopt_long(argc, argv, "hVc:dDSs", options, 0)) >= 0) { switch(n) { case 'h': help(); - case 'V': version(); + case 'V': version("disorder-normalize"); case 'c': configfile = optarg; break; case 'd': debugging = 1; break; case 'D': debugging = 0; break; diff --git a/server/rescan.c b/server/rescan.c index e1193c9..c715e91 100644 --- a/server/rescan.c +++ b/server/rescan.c @@ -52,6 +52,7 @@ #include "trackdb-int.h" #include "trackname.h" #include "unicode.h" +#include "version.h" static DB_TXN *global_tid; @@ -86,13 +87,6 @@ static void help(void) { exit(0); } -/* display version number and terminate */ -static void version(void) { - xprintf("%s", disorder_version_string); - xfclose(stdout); - exit(0); -} - static volatile sig_atomic_t signalled; static void signal_handler(int sig) { @@ -398,7 +392,7 @@ int main(int argc, char **argv) { while((n = getopt_long(argc, argv, "hVc:dDSsKC", options, 0)) >= 0) { switch(n) { case 'h': help(); - case 'V': version(); + case 'V': version("disorder-rescan"); case 'c': configfile = optarg; break; case 'd': debugging = 1; break; case 'D': debugging = 0; break; diff --git a/server/speaker.c b/server/speaker.c index 7411a8e..4a8966d 100644 --- a/server/speaker.c +++ b/server/speaker.c @@ -35,7 +35,7 @@ * this is arranged by the @c disorder-normalize program (see @ref * server/normalize.c). * - * @b Garbage @b Collection. This program deliberately does not use the +7 * @b Garbage @b Collection. This program deliberately does not use the * garbage collector even though it might be convenient to do so. This is for * two reasons. Firstly some sound APIs use thread threads and we do not want * to have to deal with potential interactions between threading and garbage @@ -80,6 +80,7 @@ #include "user.h" #include "speaker.h" #include "printf.h" +#include "version.h" /** @brief Linked list of all prepared tracks */ struct track *tracks; @@ -142,13 +143,6 @@ static void help(void) { exit(0); } -/* Display version number and terminate. */ -static void version(void) { - xprintf("%s", disorder_version_string); - xfclose(stdout); - exit(0); -} - /** @brief Return the number of bytes per frame in @p format */ static size_t bytes_per_frame(const struct stream_header *format) { return format->channels * format->bits / 8; @@ -620,7 +614,7 @@ int main(int argc, char **argv) { while((n = getopt_long(argc, argv, "hVc:dDSs", options, 0)) >= 0) { switch(n) { case 'h': help(); - case 'V': version(); + case 'V': version("disorder-speaker"); case 'c': configfile = optarg; break; case 'd': debugging = 1; break; case 'D': debugging = 0; break; diff --git a/server/trackname.c b/server/trackname.c index b14e9e5..8777475 100644 --- a/server/trackname.c +++ b/server/trackname.c @@ -33,6 +33,7 @@ #include "mem.h" #include "charset.h" #include "defs.h" +#include "version.h" static const struct option options[] = { { "help", no_argument, 0, 'h' }, @@ -55,13 +56,6 @@ static void help(void) { exit(0); } -/* display version number and terminate */ -static void version(void) { - xprintf("%s", disorder_version_string); - xfclose(stdout); - exit(0); -} - int main(int argc, char **argv) { int n; const char *s; @@ -70,7 +64,7 @@ int main(int argc, char **argv) { while((n = getopt_long(argc, argv, "hVc:d", options, 0)) >= 0) { switch(n) { case 'h': help(); - case 'V': version(); + case 'V': version("trackname"); case 'c': configfile = optarg; break; case 'd': debugging = 1; break; default: fatal(0, "invalid option"); -- [mdw]