From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12584 invoked by alias); 17 Jul 2008 12:25:32 -0000 Received: (qmail 12519 invoked by uid 9452); 17 Jul 2008 12:25:31 -0000 Date: Thu, 17 Jul 2008 12:25:00 -0000 Message-ID: <20080717122531.12499.qmail@sourceware.org> From: ccaulfield@sourceware.org To: cluster-cvs@sources.redhat.com, cluster-devel@redhat.com Subject: Cluster Project branch, master, updated. cluster-2.99.06-20-gf4bcfa1 X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 38149ffe655f0f9c3cc2c03ac111e32a143e0913 X-Git-Newrev: f4bcfa1d8e73f7402545dc60ab8affe96c1b01c8 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: 2008-q3/txt/msg00087.txt.bz2 This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Cluster Project". http://sources.redhat.com/git/gitweb.cgi?p=cluster.git;a=commitdiff;h=f4bcfa1d8e73f7402545dc60ab8affe96c1b01c8 The branch, master has been updated via f4bcfa1d8e73f7402545dc60ab8affe96c1b01c8 (commit) from 38149ffe655f0f9c3cc2c03ac111e32a143e0913 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit f4bcfa1d8e73f7402545dc60ab8affe96c1b01c8 Author: Christine Caulfield Date: Thu Jul 17 13:23:42 2008 +0100 [CCS] Make ccs_tool/ccs_test more consistent After much chatter, these tools are more consistent. ccs_test exists for old and new code, and always returns the old format output. ccs_tool query always returns new format output and the -c flag has been removed. Signed-off-by: Christine Caulfield ----------------------------------------------------------------------- Summary of changes: ccs/ccs_tool/ccs_tool.c | 73 ++++++++++++++++++++++------------------------ 1 files changed, 35 insertions(+), 38 deletions(-) diff --git a/ccs/ccs_tool/ccs_tool.c b/ccs/ccs_tool/ccs_tool.c index dc0e251..b73a546 100644 --- a/ccs/ccs_tool/ccs_tool.c +++ b/ccs/ccs_tool/ccs_tool.c @@ -13,14 +13,27 @@ #include "ccs.h" #endif + +/* + * Old libccs retruned -error (mostly!) but didn't set errno (sigh) + * New libccs sets errno correctly + */ +static char *errstring(int retcode) +{ +#ifdef LEGACY_CODE + return strerror(retcode); +#else + return strerror(errno); +#endif +} + static void tool_print_usage(FILE *stream); int globalverbose=0; -#ifdef LEGACY_CODE static void test_print_usage(FILE *stream); -static int test_main(int argc, char *argv[]){ +static int test_main(int argc, char *argv[], int old_format){ int desc=0; int i=0; int error = 0; @@ -72,7 +85,7 @@ static int test_main(int argc, char *argv[]){ desc = ccs_connect(); } if(desc < 0){ - fprintf(stderr, "ccs_connect failed: %s\n", strerror(-desc)); + fprintf(stderr, "ccs_connect failed: %s\n", errstring(-desc)); exit(EXIT_FAILURE); } else { printf("Connect successful.\n"); @@ -87,7 +100,7 @@ static int test_main(int argc, char *argv[]){ } desc = ccs_connect(); if((error = ccs_disconnect(desc))){ - fprintf(stderr, "ccs_ccs_disconnect failed: %s\n", strerror(-error)); + fprintf(stderr, "ccs_ccs_disconnect failed: %s\n", errstring(-error)); exit(EXIT_FAILURE); } else { printf("Ccs_Disconnect successful.\n"); @@ -100,11 +113,16 @@ static int test_main(int argc, char *argv[]){ } desc = ccs_connect(); if((desc < 0) || (error = ccs_get(desc, argv[3], &str))){ - fprintf(stderr, "ccs_get failed: %s\n", strerror(-error)); + fprintf(stderr, "ccs_get failed: %s\n", errstring(-error)); exit(EXIT_FAILURE); } else { - printf("Get successful.\n"); - printf(" Value = <%s>\n", str); + if (old_format) { + printf("Get successful.\n"); + printf(" Value = <%s>\n", str); + } + else { + printf("%s\n", str); + } if(str)free(str); ccs_disconnect(desc); } @@ -117,9 +135,9 @@ static int test_main(int argc, char *argv[]){ exit(EXIT_SUCCESS); } - -static void test_print_usage(FILE *stream){ - fprintf(stream, +static void test_print_usage(FILE *stream) +{ + fprintf(stream, "Usage:\n" "\n" "ccs_test [Options] \n" @@ -134,28 +152,22 @@ static void test_print_usage(FILE *stream){ " get Get a value from CCS.\n" ); } -#else + +#ifndef LEGACY_CODE static int xpath_query(int argc, char **argv) { int handle; char *ret; int i; - int compat_output = 0; if (argc < 2) { fprintf(stderr, "Usage:\n" "\n" - "ccs_tool query [-c] \n"); + "ccs_tool query \n"); return 1; } - if (strcmp(argv[1], "-c") == 0) { - argc--; - argv++; - compat_output = 1; - } - /* Tell the library we want full XPath parsing */ fullxpath = 1; @@ -164,22 +176,11 @@ static int xpath_query(int argc, char **argv) /* Process all the queries on the command-line */ for (i=1; i\n", ret); - } - else { - printf("%s\n", ret); - } + printf("%s\n", ret); free(ret); } else { - if (compat_output) { - fprintf(stderr, "ccs_get failed: %s\n", strerror(errno)); - } - else { - fprintf(stderr, "Query failed: %s\n", strerror(errno)); - } + fprintf(stderr, "Query failed: %s\n", strerror(errno)); ccs_disconnect(handle); return -1; } @@ -238,7 +239,7 @@ static int tool_main(int argc, char *argv[]) for (i=2; i Query the cluster configuration.\n" #else " query Query the cluster configuration.\n" - " query [-c] Query the cluster configuration, old output format.\n" #endif " addnode Add a node\n" " delnode Delete a node\n" @@ -324,8 +324,6 @@ static void tool_print_usage(FILE *stream){ int main(int argc, char *argv[]) { -#ifdef LEGACY_CODE - /* basename() can alter its argument */ char *name = strdup(argv[0]); /* @@ -337,8 +335,7 @@ int main(int argc, char *argv[]) */ if (strcmp(basename(name), "ccs_test") == 0) - return test_main(argc, argv); + return test_main(argc, argv, 1); else -#endif return tool_main(argc, argv); } hooks/post-receive -- Cluster Project