From patchwork Wed Jul 15 10:26:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 65505 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1jveY8-00Fxhl-NF; Wed, 15 Jul 2020 10:22:05 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731116AbgGOK1C (ORCPT + 1 other); Wed, 15 Jul 2020 06:27:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728132AbgGOK1A (ORCPT ); Wed, 15 Jul 2020 06:27:00 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80F41C061755 for ; Wed, 15 Jul 2020 03:27:00 -0700 (PDT) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6F454E06; Wed, 15 Jul 2020 12:26:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1594808819; bh=akm130KVecOIp6kBJe7Wog8H9i50UiQ6euxHTasVoRI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RHmSut8pJ3pPD6Z+MqaO9VqzN4Tmu8TweTHyUfE5fGwiXovELLKKCA2cBrHIonBFy 9a9laEwPE0oaATqPVma7d0KJ+9YxX2YF0p54gdGlR1uiWjtKIal3Uz0MX0qnJYwCb/ D+bTVj8be2PtBBhJHBg5c3hSAF2kcMsVxmWJ+ySA= From: Paul Elder To: linux-media@vger.kernel.org Cc: Paul Elder , laurent.pinchart@ideasonboard.com, hverkuil@xs4all.nl Subject: [PATCH v5 4/5] cec-ctl: Add version command Date: Wed, 15 Jul 2020 19:26:39 +0900 Message-Id: <20200715102640.17554-4-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200715102640.17554-1-paul.elder@ideasonboard.com> References: <20200715102640.17554-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -2.5 (--) X-LSpam-Report: No, score=-2.5 required=5.0 tests=BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1 autolearn=ham autolearn_force=no Add a --version option to cec-ctl to retrieve the version of cec-ctl. Signed-off-by: Paul Elder --- Changes in v5: - update manpage Changes in v4: - add git commit count to version Changes in v3: - embed PACKAGE_VERSION instead of string concatenation --- utils/cec-ctl/Makefile.am | 2 +- utils/cec-ctl/cec-ctl.1.in | 3 +++ utils/cec-ctl/cec-ctl.cpp | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/utils/cec-ctl/Makefile.am b/utils/cec-ctl/Makefile.am index 24341ed7..278fcc47 100644 --- a/utils/cec-ctl/Makefile.am +++ b/utils/cec-ctl/Makefile.am @@ -2,7 +2,7 @@ bin_PROGRAMS = cec-ctl man_MANS = cec-ctl.1 cec_ctl_SOURCES = cec-ctl.cpp cec-pin.cpp cec-ctl.h -cec_ctl_CPPFLAGS = -I$(top_srcdir)/utils/libcecutil +cec_ctl_CPPFLAGS = -I$(top_srcdir)/utils/libcecutil $(GIT_COMMIT_CNT) cec_ctl_LDADD = -lrt ../libcecutil/libcecutil.la EXTRA_DIST = cec-ctl.1 diff --git a/utils/cec-ctl/cec-ctl.1.in b/utils/cec-ctl/cec-ctl.1.in index f767b479..fac3a92e 100644 --- a/utils/cec-ctl/cec-ctl.1.in +++ b/utils/cec-ctl/cec-ctl.1.in @@ -52,6 +52,9 @@ having to rely on the device node number. \fB\-v\fR, \fB\-\-verbose\fR Turn on verbose reporting. .TP +\fB\-\-version\fR +Show version information. +.TP \fB\-w\fR, \fB\-\-wall\-clock\fR Show timestamps as wall-clock time. This also turns on verbose reporting. .TP diff --git a/utils/cec-ctl/cec-ctl.cpp b/utils/cec-ctl/cec-ctl.cpp index 455cdaeb..47867f87 100644 --- a/utils/cec-ctl/cec-ctl.cpp +++ b/utils/cec-ctl/cec-ctl.cpp @@ -133,6 +133,7 @@ enum Option { OptVendorCommandWithID, OptVendorRemoteButtonDown, OptCustomCommand, + OptVersion, }; struct node { @@ -218,6 +219,8 @@ static struct option long_options[] = { { "unregistered", no_argument, 0, OptUnregistered }, { "help-all", no_argument, 0, OptHelpAll }, + { "version", no_argument, 0, OptVersion }, + CEC_PARSE_LONG_OPTS { "vendor-remote-button-down", required_argument, 0, OptVendorRemoteButtonDown }, \ @@ -231,6 +234,13 @@ static struct option long_options[] = { { 0, 0, 0, 0 } }; +static void print_version() +{ +#define STR(x) #x +#define STRING(x) STR(x) + printf("cec-ctl %s%s\n", PACKAGE_VERSION, STRING(GIT_COMMIT_CNT)); +} + static void usage() { printf("Usage:\n" @@ -262,6 +272,7 @@ static void usage() " --help-all Show all help messages\n" " -T, --trace Trace all called ioctls\n" " -v, --verbose Turn on verbose reporting\n" + " --version Show version information\n" " -w, --wall-clock Show timestamps as wall-clock time (implies -v)\n" " -W, --wait-for-msgs Wait for messages and events for up to --monitor-time secs.\n" " --cec-version-1.4 Use CEC Version 1.4 instead of 2.0\n" @@ -2296,6 +2307,10 @@ int main(int argc, char **argv) break; } + case OptVersion: + print_version(); + std::exit(EXIT_SUCCESS); + default: if (ch >= OptHelpAll) { cec_parse_usage_options(options);