From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30469 invoked by alias); 4 Sep 2009 07:08:48 -0000 Received: (qmail 30463 invoked by alias); 4 Sep 2009 07:08:48 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS X-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,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: beautify output 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: 015f6e441998848d4c32a95d99ba273497c02c37 X-Git-Newrev: b230e89a309c61806b1a21ae8bde672f8d8d9e6b From: "Fabio M. Di Nitto" Message-Id: <20090904070822.44034120338@lists.fedorahosted.org> Date: Fri, 04 Sep 2009 07:08:00 -0000 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 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/msg00306.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=b230e89a309c61806b1a21ae8bde672f8d8d9e6b Commit: b230e89a309c61806b1a21ae8bde672f8d8d9e6b Parent: 015f6e441998848d4c32a95d99ba273497c02c37 Author: Fabio M. Di Nitto AuthorDate: Fri Sep 4 09:07:46 2009 +0200 Committer: Fabio M. Di Nitto CommitterDate: Fri Sep 4 09:07:46 2009 +0200 config dump: beautify output make config dump output human readable Signed-off-by: Fabio M. Di Nitto --- config/tools/xml/ccs_config_dump.c | 36 ++++++++++++++++++++++++++---------- 1 files changed, 26 insertions(+), 10 deletions(-) diff --git a/config/tools/xml/ccs_config_dump.c b/config/tools/xml/ccs_config_dump.c index 7723c40..a5ddf50 100644 --- a/config/tools/xml/ccs_config_dump.c +++ b/config/tools/xml/ccs_config_dump.c @@ -6,11 +6,13 @@ static confdb_callbacks_t callbacks = {}; static int dump_objdb_buff(confdb_handle_t dump_handle, hdb_handle_t cluster_handle, - hdb_handle_t parent_object_handle) + hdb_handle_t parent_object_handle, int level) { hdb_handle_t object_handle; char object_name[PATH_MAX], key_name[PATH_MAX], key_value[PATH_MAX]; size_t key_value_len = 0, key_name_len = 0, object_name_len = 0; + int current_level = level+1; + int has_childs = 0; if (confdb_key_iter_start(dump_handle, parent_object_handle) != CS_OK) return -1; @@ -23,9 +25,6 @@ static int dump_objdb_buff(confdb_handle_t dump_handle, hdb_handle_t cluster_han printf(" %s=\"%s\"", key_name, key_value); } - if (parent_object_handle > 0) - printf(">\n"); - if (confdb_object_iter_start(dump_handle, parent_object_handle) != CS_OK) return -1; @@ -33,22 +32,39 @@ static int dump_objdb_buff(confdb_handle_t dump_handle, hdb_handle_t cluster_han &object_handle, object_name, &object_name_len) == CS_OK) { hdb_handle_t parent; + int i; + int found_childs; + + if ((!has_childs) && (parent_object_handle > 0)) + printf(">\n"); + + has_childs = 1; if (confdb_object_parent_get(dump_handle, object_handle, &parent) != CS_OK) return -1; object_name[object_name_len] = '\0'; + for (i=0; i\n", object_name); - else - printf(">\n"); + } } - return 0; + + if(!has_childs) + printf("/>\n"); + + return has_childs; } int main(void) { @@ -66,7 +82,7 @@ int main(void) { printf("\n\n");