From 42fba964c9e23830454fbfdd3895da315356bd27 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sat, 1 Sep 2018 17:22:24 +0200 Subject: Centralize/unify version string printing Signed-off-by: David Oberhollenzer --- cmd/Makemodule.am | 1 + cmd/shutdown.c | 15 +-------------- cmd/syslog.c | 15 +-------------- 3 files changed, 3 insertions(+), 28 deletions(-) (limited to 'cmd') diff --git a/cmd/Makemodule.am b/cmd/Makemodule.am index 492057b..d19894f 100644 --- a/cmd/Makemodule.am +++ b/cmd/Makemodule.am @@ -2,6 +2,7 @@ shutdown_SOURCES = cmd/shutdown.c shutdown_CPPFLAGS = $(AM_CPPFLAGS) shutdown_CFLAGS = $(AM_CFLAGS) shutdown_LDFLAGS = $(AM_LDFLAGS) +shutdown_LDADD = libinit.a runsvc_SOURCES = cmd/runsvc/runsvc.c cmd/runsvc/env.c cmd/runsvc/runsvc.h runsvc_CPPFLAGS = $(AM_CPPFLAGS) diff --git a/cmd/shutdown.c b/cmd/shutdown.c index 39145ec..9baaef2 100644 --- a/cmd/shutdown.c +++ b/cmd/shutdown.c @@ -63,19 +63,6 @@ static NORETURN void usage(const char *progname, int status) exit(status); } -static NORETURN void version(const char *progname) -{ - fprintf(stdout, -"%s (Pygos init) %s\n" -"Copyright (C) 2018 David Oberhollenzer\n" -"License GPLv3+: GNU GPL version 3 or later .\n" -"This is free software: you are free to change and redistribute it.\n" -"There is NO WARRANTY, to the extent permitted by law.\n", - progname, PACKAGE_VERSION); - - exit(EXIT_SUCCESS); -} - int main(int argc, char **argv) { int c, ret, flags = 0; @@ -108,7 +95,7 @@ int main(int argc, char **argv) defact = RB_AUTOBOOT; break; case 'V': - version(ptr); + print_version(ptr); case 'h': usage(ptr, EXIT_SUCCESS); default: diff --git a/cmd/syslog.c b/cmd/syslog.c index d225921..48c9343 100644 --- a/cmd/syslog.c +++ b/cmd/syslog.c @@ -72,13 +72,6 @@ static const struct option options[] = { static const char *shortopt = "hVcf:l:i:"; -static const char *versiontext = -"syslog (Pygos init) "PACKAGE_VERSION"\n" -"Copyright (C) 2018 David Oberhollenzer\n" -"License GPLv3+: GNU GPL version 3 or later .\n" -"This is free software: you are free to change and redistribute it.\n" -"There is NO WARRANTY, to the extent permitted by law.\n"; - static const char *helptext = "Usage: syslog [OPTION]... [STRING]...\n\n" "Concatenate the given STRINGs and send a log message to the syslog daemon.\n" @@ -125,12 +118,6 @@ static NORETURN void usage(int status) exit(status); } -static NORETURN void version(void) -{ - fputs(versiontext, stdout); - exit(EXIT_SUCCESS); -} - static int readint(const char *str) { int x = 0; @@ -188,7 +175,7 @@ static void process_options(int argc, char **argv) case 'h': usage(EXIT_SUCCESS); case 'V': - version(); + print_version("syslog"); default: usage(EXIT_FAILURE); } -- cgit v1.2.3