From 47d9380809c5cdea1ce62f5d703f5e4aafa8aaef Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Mon, 7 Aug 2006 09:03:10 +0000 Subject: [PATCH] Strip white-space characters from attribute names gathered via gsoap. --- org.glite.jp.index/Makefile | 5 +++-- org.glite.jp.index/examples/jpis-client.c | 9 +++++++++ org.glite.jp.index/src/common.c | 25 +++++++++++++++++++++++++ org.glite.jp.index/src/common.h | 8 ++++++++ org.glite.jp.index/src/ws_is_typeref.c | 1 - 5 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 org.glite.jp.index/src/common.c create mode 100644 org.glite.jp.index/src/common.h diff --git a/org.glite.jp.index/Makefile b/org.glite.jp.index/Makefile index 9c0b3d4..87a7776 100644 --- a/org.glite.jp.index/Makefile +++ b/org.glite.jp.index/Makefile @@ -61,11 +61,12 @@ ps_prefix:=jpps_ SRCS:= conf.c bones_server.c soap_ops.c soap_ps_calls.c \ ws_ps_typeref.c ws_is_typeref.c db_ops.c context.c common_server.c \ ${is_prefix}Server.c ${is_prefix}C.c\ - ${ps_prefix}ClientLib.c \ + ${ps_prefix}ClientLib.c EXA_TEST_SRCS:=jpis-test.c ${is_prefix}C.c ${is_prefix}Client.c context.c db_ops.c conf.c ws_is_typeref.c EXA_DB_SRCS:=jpis-db-internal.c db_ops.c conf.c context.c ws_is_typeref.c -EXA_CLIENT_SRCS:=jpis-client.c ${is_client_prefix}C.c ${is_client_prefix}Client.c +EXA_CLIENT_SRCS:=jpis-client.c common.c \ + ${is_client_prefix}C.c ${is_client_prefix}Client.c # ${is_prefix}C.c OBJS:=${SRCS:.c=.o} diff --git a/org.glite.jp.index/examples/jpis-client.c b/org.glite.jp.index/examples/jpis-client.c index 1703d53..fb551ce 100644 --- a/org.glite.jp.index/examples/jpis-client.c +++ b/org.glite.jp.index/examples/jpis-client.c @@ -9,6 +9,7 @@ #include "soap_version.h" #include "jpis_client_.nsmap" +#include "common.h" /* 'jpisclient' as future namespace */ @@ -190,6 +191,8 @@ static void query_example_fill(struct soap *soap, struct _jpisclient__QueryJobs * read the XML query */ static int query_recv(struct soap *soap, int fd, struct _jpisclient__QueryJobs *qj) { + int i; + memset(qj, 0, sizeof(*qj)); soap->recvfd = fd; @@ -203,6 +206,12 @@ static int query_recv(struct soap *soap, int fd, struct _jpisclient__QueryJobs * soap_end_recv(soap); soap_free(soap); /* don't destroy the data we want */ + /* strip white-space characters from attributes */ + for (i = 0; i < qj->__sizeattributes; i++) + glite_jpis_trim_soap(soap, &qj->attributes[i]); + for (i = 0; i < qj->__sizeconditions; i++) + glite_jpis_trim_soap(soap, &qj->conditions[i]->attr); + return 0; } diff --git a/org.glite.jp.index/src/common.c b/org.glite.jp.index/src/common.c new file mode 100644 index 0000000..8ffdaeb --- /dev/null +++ b/org.glite.jp.index/src/common.c @@ -0,0 +1,25 @@ +#ident "$Header$" + +#include +#include + +#include "common.h" + +#define WHITE_SPACE_SET "\n\r \t" + + +void glite_jpis_trim_soap(struct soap *soap, char **soap_str) { + size_t pos, len; + char *s; + + if (!*soap_str) return; + + pos = strspn(*soap_str, WHITE_SPACE_SET); + len = strcspn(*soap_str + pos, WHITE_SPACE_SET); + s = soap_malloc(soap, len + 1); + memcpy(s, *soap_str + pos, len); + s[len] = '\0'; + + soap_dealloc(soap, *soap_str); + *soap_str = s; +} diff --git a/org.glite.jp.index/src/common.h b/org.glite.jp.index/src/common.h new file mode 100644 index 0000000..04ef8bf --- /dev/null +++ b/org.glite.jp.index/src/common.h @@ -0,0 +1,8 @@ +#ident "$Header$" + +#ifndef GLITE_JPIS_COMMON_H +#define GLITE_JPIS_COMMON_H + +void glite_jpis_trim_soap(struct soap *soap, char **soap_str); + +#endif diff --git a/org.glite.jp.index/src/ws_is_typeref.c b/org.glite.jp.index/src/ws_is_typeref.c index 9788a47..c51c98c 100644 --- a/org.glite.jp.index/src/ws_is_typeref.c +++ b/org.glite.jp.index/src/ws_is_typeref.c @@ -152,7 +152,6 @@ static int SoapToPrimaryQueryCond( glite_jp_query_rec_t **out) { glite_jp_query_rec_t *qr; - int i; assert(in); assert(out); -- 1.8.2.3