master - libccs: add support for /child::*[%d]/ for xpathlite
Fabio M. Di Nitto
fabbione@fedoraproject.org
Mon Aug 11 13:56:00 GMT 2008
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=e46fc61639a46aacf68277182d8d7ef6a9f6790d
Commit: e46fc61639a46aacf68277182d8d7ef6a9f6790d
Parent: a7e3cf012418c46cd3f55896512dbfd5e2d0a08c
Author: Fabio M. Di Nitto <fdinitto@redhat.com>
AuthorDate: Mon Aug 11 13:23:28 2008 +0200
Committer: Fabio M. Di Nitto <fdinitto@redhat.com>
CommitterDate: Mon Aug 11 13:23:28 2008 +0200
libccs: add support for /child::*[%d]/ for xpathlite
xpathlite did not understand the concept of child::*[%d]
within a path (ex: /cluster/rm/child::*[1]/@name).
This operation is required by rgmanager to load the service tree.
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
config/libs/libccsconfdb/libccs.c | 25 ++++++++++++++++++++++---
1 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/config/libs/libccsconfdb/libccs.c b/config/libs/libccsconfdb/libccs.c
index 1dcca62..3abebd6 100644
--- a/config/libs/libccsconfdb/libccs.c
+++ b/config/libs/libccsconfdb/libccs.c
@@ -338,6 +338,8 @@ static int path_dive(int tokens)
*/
char *start = NULL, *middle = NULL, *end = NULL;
+ char data[PATH_MAX];
+ int datalen;
/*
* those ones should be always good because
@@ -356,7 +358,25 @@ static int path_dive(int tokens)
memset(start, 0, 1);
memset(end, 0, 1);
- if (!strstr(middle, "@")) {
+ if (!strcmp(pos, "child::*")) {
+ int val, i;
+
+ val = atoi(middle);
+
+ if(val < 1)
+ goto fail;
+
+ if(confdb_object_iter_start(handle, query_handle) != SA_AIS_OK)
+ goto fail;
+
+ for (i = 1; i <= val; i++) {
+ if(confdb_object_iter(handle, query_handle, &new_obj_handle, data, &datalen) != SA_AIS_OK)
+ goto fail;
+ }
+
+ query_handle = new_obj_handle;
+
+ } else if (!strstr(middle, "@")) {
/* lookup something with index num = int */
int val, i;
@@ -374,8 +394,7 @@ static int path_dive(int tokens)
} else {
/* lookup something with obj foo = bar */
char *equal = NULL, *value = NULL, *tmp = NULL;
- char data[PATH_MAX];
- int goout = 0, datalen;
+ int goout = 0;
equal=strstr(middle, "=");
if(!equal)
More information about the Cluster-cvs
mailing list