public inbox for cluster-cvs@sourceware.org help / color / mirror / Atom feed
From: "Fabio M. Di Nitto" <fabbione@fedoraproject.org> To: cluster-cvs-relay@redhat.com Subject: cluster: STABLE3 - config dump: add usage and options Date: Fri, 04 Sep 2009 09:16:00 -0000 [thread overview] Message-ID: <20090904091545.58FAE12037F@lists.fedorahosted.org> (raw) 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;
reply other threads:[~2009-09-04 9:16 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20090904091545.58FAE12037F@lists.fedorahosted.org \ --to=fabbione@fedoraproject.org \ --cc=cluster-cvs-relay@redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).