public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* cluster: STABLE3 - config dump: add usage and options
@ 2009-09-04 9:16 Fabio M. Di Nitto
0 siblings, 0 replies; only message in thread
From: Fabio M. Di Nitto @ 2009-09-04 9:16 UTC (permalink / raw)
To: cluster-cvs-relay
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=da0b095e5195d3d1522c81ac981fa3b24c3cd6f0
Commit: da0b095e5195d3d1522c81ac981fa3b24c3cd6f0
Parent: bebf59e91364f7647ff3d6866df9942570b12398
Author: Fabio M. Di Nitto <fdinitto@redhat.com>
AuthorDate: Fri Sep 4 11:14:48 2009 +0200
Committer: Fabio M. Di Nitto <fdinitto@redhat.com>
CommitterDate: Fri Sep 4 11:14:48 2009 +0200
config dump: add usage and options
Add help text and a few basic options.
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
config/tools/xml/ccs_config_dump.c | 66 +++++++++++++++++++++++++++++++++++-
1 files changed, 65 insertions(+), 1 deletions(-)
diff --git a/config/tools/xml/ccs_config_dump.c b/config/tools/xml/ccs_config_dump.c
index 8525f31..b6fe742 100644
--- a/config/tools/xml/ccs_config_dump.c
+++ b/config/tools/xml/ccs_config_dump.c
@@ -1,8 +1,13 @@
#include <stdio.h>
#include <limits.h>
+#include <unistd.h>
#include <corosync/corotypes.h>
#include <corosync/confdb.h>
+#include "copyright.cf"
+
+#define OPTION_STRING "hVr"
+
static confdb_callbacks_t callbacks = {};
static int dump_objdb_buff(confdb_handle_t dump_handle, hdb_handle_t cluster_handle,
@@ -67,10 +72,69 @@ static int dump_objdb_buff(confdb_handle_t dump_handle, hdb_handle_t cluster_han
return has_children;
}
-int main(void) {
+static void print_usage(void)
+{
+ printf("Usage:\n");
+ printf("\n");
+ printf("ccs_config_dump [options]\n");
+ printf("\n");
+ printf("Options:\n");
+ printf(" -r Force dump of runtime configuration (see man page)\n");
+ printf(" -h Print this help, then exit\n");
+ printf(" -V Print program version information, then exit\n");
+ printf("\n");
+ return;
+}
+
+static void read_arguments(int argc, char **argv)
+{
+ int cont = 1;
+ int optchar;
+
+ while (cont) {
+ optchar = getopt(argc, argv, OPTION_STRING);
+
+ switch (optchar) {
+
+ case 'h':
+ print_usage();
+ exit(EXIT_SUCCESS);
+ break;
+
+ case 'V':
+ printf("ccs_config_dump %s (built %s %s)\n%s\n",
+ RELEASE_VERSION, __DATE__, __TIME__,
+ REDHAT_COPYRIGHT);
+ exit(EXIT_SUCCESS);
+ break;
+
+ case 'r':
+ if(unsetenv("COROSYNC_DEFAULT_CONFIG_IFACE") < 0) {
+ fprintf(stderr, "Unable to unset env vars\n");
+ exit(EXIT_FAILURE);
+ }
+ break;
+
+ case EOF:
+ cont = 0;
+ break;
+
+ default:
+ fprintf(stderr, "unknown option: %c\n", optchar);
+ print_usage();
+ exit(EXIT_FAILURE);
+ break;
+ }
+ }
+}
+
+int main(int argc, char *argv[], char *envp[])
+{
confdb_handle_t handle = 0;
hdb_handle_t cluster_handle;
+ read_arguments(argc, argv);
+
if (confdb_initialize(&handle, &callbacks) != CS_OK)
return -1;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-09-04 9:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-04 9:16 cluster: STABLE3 - config dump: add usage and options Fabio M. Di Nitto
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).