From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1Pp97Q-00058u-S3 for garchives@archives.gentoo.org; Tue, 15 Feb 2011 00:50:17 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 50493E0932; Tue, 15 Feb 2011 00:50:08 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 0F126E0932 for ; Tue, 15 Feb 2011 00:50:07 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 7088F1B40A1 for ; Tue, 15 Feb 2011 00:50:07 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id D312A8006A for ; Tue, 15 Feb 2011 00:50:06 +0000 (UTC) From: "William Hubbs" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "William Hubbs" Message-ID: <73d1a8698e101b1dcf589b27b35ac9b09ea6d02c.williamH@gentoo> Subject: [gentoo-commits] proj/openrc:master commit in: src/rc/ X-VCS-Repository: proj/openrc X-VCS-Files: src/rc/_usage.c src/rc/_usage.h src/rc/rc.c X-VCS-Directories: src/rc/ X-VCS-Committer: williamH X-VCS-Committer-Name: William Hubbs X-VCS-Revision: 73d1a8698e101b1dcf589b27b35ac9b09ea6d02c Date: Tue, 15 Feb 2011 00:50:06 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 72fcb3059d9f310a3bd2beb77424f515 commit: 73d1a8698e101b1dcf589b27b35ac9b09ea6d02c Author: William Hubbs gentoo org> AuthorDate: Sun Feb 13 01:15:29 2011 +0000 Commit: William Hubbs gentoo org> CommitDate: Tue Feb 15 00:40:05 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/openrc.git;a=3D= commit;h=3D73d1a869 make version option common This reworks the code for the version option so that it is part of the parser loop and is a common option to all applets. --- src/rc/_usage.c | 20 +++++++++++++++++++- src/rc/_usage.h | 8 ++++++-- src/rc/rc.c | 16 ++-------------- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/rc/_usage.c b/src/rc/_usage.c index ec1ce1d..175634a 100644 --- a/src/rc/_usage.c +++ b/src/rc/_usage.c @@ -1,7 +1,7 @@ /* * Copyright (c) 2007-2008 Roy Marples * All rights reserved - + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -24,6 +24,8 @@ * SUCH DAMAGE. */ =20 +#include "version.h" + #if lint # define _noreturn #endif @@ -34,6 +36,22 @@ #endif =20 _noreturn static void +show_version(void) +{ + const char *bootlevel =3D NULL; + + printf("%s (OpenRC", applet); + if ((bootlevel =3D rc_sys())) + printf(" [%s]", bootlevel); + printf(") %s", VERSION); +#ifdef BRANDING + printf(" (%s)", BRANDING); +#endif + printf("\n"); + exit(EXIT_SUCCESS); +} + +_noreturn static void usage(int exit_status) { const char * const has_arg[] =3D { "", "", "[arg]" }; diff --git a/src/rc/_usage.h b/src/rc/_usage.h index d65e05e..5e116c9 100644 --- a/src/rc/_usage.h +++ b/src/rc/_usage.h @@ -1,7 +1,7 @@ /* * Copyright (c) 2007-2008 Roy Marples * All rights reserved - + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -24,11 +24,12 @@ * SUCH DAMAGE. */ =20 -#define getoptstring_COMMON "Chqv" +#define getoptstring_COMMON "ChqVv" =20 #define longopts_COMMON \ { "help", 0, NULL, 'h'}, \ { "nocolor", 0, NULL, 'C'}, \ + { "version", 0, NULL, 'V'}, \ { "verbose", 0, NULL, 'v'}, \ { "quiet", 0, NULL, 'q'}, \ { NULL, 0, NULL, 0 } @@ -36,11 +37,13 @@ #define longopts_help_COMMON \ "Display this help output", \ "Disable color output", \ + "Display software version", \ "Run verbosely", \ "Run quietly" =20 #define case_RC_COMMON_getopt_case_C setenv ("EINFO_COLOR", "NO", 1); #define case_RC_COMMON_getopt_case_h usage (EXIT_SUCCESS); +#define case_RC_COMMON_getopt_case_V if (argc =3D=3D 2) show_version(); #define case_RC_COMMON_getopt_case_v setenv ("EINFO_VERBOSE", "YES", 1)= ; #define case_RC_COMMON_getopt_case_q setenv ("EINFO_QUIET", "YES", 1); #define case_RC_COMMON_getopt_default usage (EXIT_FAILURE); @@ -48,6 +51,7 @@ #define case_RC_COMMON_GETOPT \ case 'C': case_RC_COMMON_getopt_case_C; break; \ case 'h': case_RC_COMMON_getopt_case_h; break; \ + case 'V': case_RC_COMMON_getopt_case_V; break; \ case 'v': case_RC_COMMON_getopt_case_v; break; \ case 'q': case_RC_COMMON_getopt_case_q; break; \ default: case_RC_COMMON_getopt_default; break; diff --git a/src/rc/rc.c b/src/rc/rc.c index bdda2ef..525ccdc 100644 --- a/src/rc/rc.c +++ b/src/rc/rc.c @@ -837,18 +837,6 @@ main(int argc, char **argv) if (!applet) eerrorx("arguments required"); =20 - if (argc > 1 && (strcmp(argv[1], "--version") =3D=3D 0)) { - printf("%s (OpenRC", applet); - if ((bootlevel =3D rc_sys())) - printf(" [%s]", bootlevel); - printf(") " VERSION -#ifdef BRANDING - " (" BRANDING ")" -#endif - "\n"); - exit(EXIT_SUCCESS); - } - /* Run our built in applets. If we ran one, we don't return. */ run_applets(argc, argv); =20 @@ -905,8 +893,8 @@ main(int argc, char **argv) } exit(EXIT_SUCCESS); /* NOTREACHED */ - case_RC_COMMON_GETOPT - } + case_RC_COMMON_GETOPT + } } =20 newlevel =3D argv[optind++];