summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/Makemodule.am1
-rw-r--r--cmd/shutdown.c15
-rw-r--r--cmd/syslog.c15
-rw-r--r--lib/Makemodule.am3
-rw-r--r--lib/include/util.h3
-rw-r--r--lib/util/print_version.c37
-rw-r--r--syslogd/Makemodule.am1
-rw-r--r--syslogd/klogd.c11
-rw-r--r--syslogd/syslogd.c14
9 files changed, 49 insertions, 51 deletions
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 <http://gnu.org/licenses/gpl.html>.\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 <https://gnu.org/licenses/gpl.html>.\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);
}
diff --git a/lib/Makemodule.am b/lib/Makemodule.am
index b8a1c17..8a5ee8e 100644
--- a/lib/Makemodule.am
+++ b/lib/Makemodule.am
@@ -3,7 +3,8 @@ HEADRS = lib/include/util.h lib/include/service.h lib/include/telinit.h
libinit_a_SOURCES = lib/util/delsvc.c lib/util/svcmap.c lib/util/enum_by_name.c
libinit_a_SOURCES += lib/util/rdsvc.c lib/util/svcscan.c lib/util/mksock.c
libinit_a_SOURCES += lib/util/del_svc_list.c lib/util/svc_tsort.c
-libinit_a_SOURCES += lib/util/opensock.c lib/util/enum_to_name.c $(HEADRS)
+libinit_a_SOURCES += lib/util/opensock.c lib/util/enum_to_name.c
+libinit_a_SOURCES += lib/util/print_version.c $(HEADRS)
libinit_a_CPPFLAGS = $(AM_CPPFLAGS)
libinit_a_CFLAGS = $(AM_CFLAGS)
diff --git a/lib/include/util.h b/lib/include/util.h
index 18133a8..6d2bf5d 100644
--- a/lib/include/util.h
+++ b/lib/include/util.h
@@ -70,5 +70,8 @@ const char *enum_to_name(const enum_map_t *map, int value);
*/
int mksock(const char *path, int flags);
+/* print a default version info and license string */
+NORETURN void print_version(const char *program);
+
#endif /* UTIL_H */
diff --git a/lib/util/print_version.c b/lib/util/print_version.c
new file mode 100644
index 0000000..cda2742
--- /dev/null
+++ b/lib/util/print_version.c
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-3.0-or-later */
+/*
+ * Copyright (C) 2018 - David Oberhollenzer
+ *
+ * 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 3 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, see <https://www.gnu.org/licenses/>.
+ */
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "config.h"
+#include "util.h"
+
+#define GPL_URL "https://gnu.org/licenses/gpl.html"
+
+static const char *version_string =
+"%s (pygos init) " PACKAGE_VERSION "\n"
+"Copyright (C) 2018 David Oberhollenzer\n\n"
+"License GPLv3+: GNU GPL version 3 or later <" GPL_URL ">.\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";
+
+void print_version(const char *program)
+{
+ fprintf(stdout, version_string, program);
+ exit(EXIT_SUCCESS);
+}
diff --git a/syslogd/Makemodule.am b/syslogd/Makemodule.am
index ab61b87..f6c19fd 100644
--- a/syslogd/Makemodule.am
+++ b/syslogd/Makemodule.am
@@ -14,6 +14,7 @@ klogd_SOURCES = syslogd/klogd.c
klogd_CPPFLAGS = $(AM_CPPFLAGS)
klogd_CFLAGS = $(AM_CFLAGS)
klogd_LDFLAGS = $(AM_LDFLAGS)
+klogd_LDADD = libinit.a
sbin_PROGRAMS += klogd
endif
diff --git a/syslogd/klogd.c b/syslogd/klogd.c
index ca16e4e..d2301ee 100644
--- a/syslogd/klogd.c
+++ b/syslogd/klogd.c
@@ -25,6 +25,7 @@
#include <errno.h>
#include "config.h"
+#include "util.h"
enum {
KLOG_CLOSE = 0,
@@ -48,13 +49,6 @@ static const struct option options[] = {
static const char *shortopt = "hVl:";
-static const char *versiontext =
-"klogd (Pygos init) "PACKAGE_VERSION"\n"
-"Copyright (C) 2018 David Oberhollenzer\n"
-"License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.\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: klogd [OPTION]... \n\n"
"Collect printk() messages from the kernel and forward them to syslogd.\n"
@@ -82,8 +76,7 @@ static void process_options(int argc, char **argv)
fputs(helptext, stdout);
exit(EXIT_SUCCESS);
case 'V':
- fputs(versiontext, stdout);
- exit(EXIT_SUCCESS);
+ print_version("klogd");
default:
fputs("Try `klogd --help' for more information\n",
stderr);
diff --git a/syslogd/syslogd.c b/syslogd/syslogd.c
index d2433e9..3b88299 100644
--- a/syslogd/syslogd.c
+++ b/syslogd/syslogd.c
@@ -32,10 +32,6 @@
#include "syslogd.h"
#include "util.h"
-
-#define GPL_URL "https://gnu.org/licenses/gpl.html"
-
-
static const struct option long_opts[] = {
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
@@ -49,13 +45,6 @@ static const struct option long_opts[] = {
static const char *short_opts = "hVcrm:u:g:";
-const char *version_string =
-"usyslogd (pygos init) " PACKAGE_VERSION "\n"
-"Copyright (C) 2018 David Oberhollenzer\n\n"
-"License GPLv3+: GNU GPL version 3 or later <" GPL_URL ">.\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";
-
const char *usage_string =
"Usage: usyslogd [OPTIONS..]\n\n"
"The following options are supported:\n"
@@ -183,8 +172,7 @@ static void process_options(int argc, char **argv)
fputs(usage_string, stdout);
exit(EXIT_SUCCESS);
case 'V':
- fputs(version_string, stdout);
- exit(EXIT_SUCCESS);
+ print_version("usyslogd");
default:
goto fail;
}