From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16682 invoked by alias); 4 Sep 2009 09:16:39 -0000 Received: (qmail 16676 invoked by alias); 4 Sep 2009 09:16:39 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_43,J_CHICKENPOX_64,SPF_HELO_PASS X-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_43,J_CHICKENPOX_64,SPF_HELO_PASS X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bastion2.fedora.phx.redhat.com Subject: cluster: STABLE3 - config dump: add usage and options To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/STABLE3 X-Git-Reftype: branch X-Git-Oldrev: bebf59e91364f7647ff3d6866df9942570b12398 X-Git-Newrev: da0b095e5195d3d1522c81ac981fa3b24c3cd6f0 From: "Fabio M. Di Nitto" Message-Id: <20090904091545.58FAE12037F@lists.fedorahosted.org> Date: Fri, 04 Sep 2009 09:16:00 -0000 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2009-q3/txt/msg00308.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=da0b095e5195d3d1522c81ac981fa3b24c3cd6f0 Commit: da0b095e5195d3d1522c81ac981fa3b24c3cd6f0 Parent: bebf59e91364f7647ff3d6866df9942570b12398 Author: Fabio M. Di Nitto AuthorDate: Fri Sep 4 11:14:48 2009 +0200 Committer: Fabio M. Di Nitto 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 --- 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 #include +#include #include #include +#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;