[gnome-keyring] Add support for --version to gnome-keyring-daemon and gnome-keyring



commit 1cc7a50700866fbec45916f33031a3fd063cfbe7
Author: Stef Walter <stef memberwebs com>
Date:   Wed Jan 19 13:43:48 2011 -0600

    Add support for --version to gnome-keyring-daemon and gnome-keyring
    
     * Machine readable output.
     * gnome-keyring version
     * gnome-keyring-daemon --version

 daemon/gkd-main.c       |   15 ++++++++++++++
 tool/Makefile.am        |    3 +-
 tool/gkr-tool-version.c |   48 +++++++++++++++++++++++++++++++++++++++++++++++
 tool/gkr-tool.c         |    3 +-
 tool/gkr-tool.h         |    5 +++-
 5 files changed, 71 insertions(+), 3 deletions(-)
---
diff --git a/daemon/gkd-main.c b/daemon/gkd-main.c
index 7781212..7ea67ff 100644
--- a/daemon/gkd-main.c
+++ b/daemon/gkd-main.c
@@ -112,6 +112,7 @@ static gboolean gpg_started = FALSE;
 
 static gboolean run_foreground = FALSE;
 static gboolean run_daemonized = FALSE;
+static gboolean run_version = FALSE;
 static gboolean run_for_login = FALSE;
 static gboolean run_for_start = FALSE;
 static gboolean run_for_replace = FALSE;
@@ -137,6 +138,8 @@ static GOptionEntry option_entries[] = {
 	  "The optional components to run", DEFAULT_COMPONENTS },
 	{ "control-directory", 'C', 0, G_OPTION_ARG_FILENAME, &control_directory,
 	  "The directory for sockets and control data", NULL },
+	{ "version", 'V', 0, G_OPTION_ARG_NONE, &run_version,
+	  "Show the version number and exit.", NULL },
 	{ NULL }
 };
 
@@ -818,6 +821,18 @@ main (int argc, char *argv[])
 
 	parse_arguments (&argc, &argv);
 
+	/* The --version option. This is machine parseable output */
+	if (run_version) {
+		g_print ("gnome-keyring-daemon: %s\n", VERSION);
+		g_print ("testing: %s\n",
+#ifdef WITH_TESTS
+		         "enabled");
+#else
+		         "disabled");
+#endif
+		exit (0);
+	}
+
 	/* The --start option */
 	if (run_for_start) {
 		if (discover_other_daemon (initialize_daemon_at, TRUE)) {
diff --git a/tool/Makefile.am b/tool/Makefile.am
index 441939e..2960e89 100644
--- a/tool/Makefile.am
+++ b/tool/Makefile.am
@@ -12,7 +12,8 @@ INCLUDES=	\
 gnome_keyring GCR_VERSION_SUFFIX@_SOURCES = \
 	gkr-tool.c gkr-tool.h \
 	gkr-tool-import.c \
-	gkr-tool-trust.c
+	gkr-tool-trust.c \
+	gkr-tool-version.c
 
 gnome_keyring GCR_VERSION_SUFFIX@_CFLAGS = \
 	-DGCR_API_SUBJECT_TO_CHANGE \
diff --git a/tool/gkr-tool-version.c b/tool/gkr-tool-version.c
new file mode 100644
index 0000000..dc1a414
--- /dev/null
+++ b/tool/gkr-tool-version.c
@@ -0,0 +1,48 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* gkr-tool-version.c: Version display
+
+   Copyright (C) 2011 Collabora Ltd.
+
+   The Gnome Keyring Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The Gnome Keyring Library 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the Gnome Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
+
+   Author: Stef Walter <stef memberwebs com>
+*/
+
+#include "config.h"
+
+#include "gkr-tool.h"
+
+#include "gck/gck.h"
+#include "gcr/gcr.h"
+
+#include "egg/egg-hex.h"
+
+static GOptionEntry version_entries[] = {
+	{ NULL }
+};
+
+int
+gkr_tool_version (int argc, char *argv[])
+{
+	int ret;
+
+	ret = gkr_tool_parse_options (&argc, &argv, version_entries);
+	if (ret != 0)
+		return ret;
+
+	g_print ("gnome-keyring: %s\n", VERSION);
+	return 0;
+}
diff --git a/tool/gkr-tool.c b/tool/gkr-tool.c
index 030fb99..73aac6d 100644
--- a/tool/gkr-tool.c
+++ b/tool/gkr-tool.c
@@ -87,8 +87,9 @@ typedef struct _CommandInfo {
 } CommandInfo;
 
 static CommandInfo command_info[] = {
-	{ "import", gkr_tool_import },
 	{ "certificate-exception", gkr_tool_trust },
+	{ "import", gkr_tool_import },
+	{ "version", gkr_tool_version },
 	{ NULL, NULL }
 };
 
diff --git a/tool/gkr-tool.h b/tool/gkr-tool.h
index 217db11..c3a7d18 100644
--- a/tool/gkr-tool.h
+++ b/tool/gkr-tool.h
@@ -44,6 +44,9 @@ int gkr_tool_parse_options (int *argc, char** argv[], GOptionEntry *options);
  */
 
 int gkr_tool_import (int argc, char *argv[]);
-int gkr_tool_trust  (int argc, char *argv[]);
+
+int gkr_tool_trust (int argc, char *argv[]);
+
+int gkr_tool_version (int argc, char *argv[]);
 
 #endif /* GKRTOOL_H_ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]