From: František Dvořák Date: Mon, 7 Aug 2006 09:04:15 +0000 (+0000) Subject: Strip white-space characters from attribute names gathered via gsoap. X-Git-Tag: glite-jp-index_R_1_2_2~13 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=6ea35566f79f9ce6a50dac0530dd1d8d8add8455;p=jra1mw.git Strip white-space characters from attribute names gathered via gsoap. --- diff --git a/org.glite.jp.index/Makefile b/org.glite.jp.index/Makefile index 6f3dd95..0886580 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}ServerLib.c \ - ${ps_prefix}ClientLib.c ${ps_prefix}C.c \ + ${ps_prefix}ClientLib.c ${ps_prefix}C.c EXA_TEST_SRCS:=jpis-test.c ${is_prefix}C.c ${is_prefix}Client.c context.c db_ops.c conf.c EXA_DB_SRCS:=jpis-db-internal.c db_ops.c conf.c context.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 a1b8346..17e1935 100644 --- a/org.glite.jp.index/src/ws_is_typeref.c +++ b/org.glite.jp.index/src/ws_is_typeref.c @@ -80,7 +80,6 @@ static int SoapToQueryCond( glite_jp_query_rec_t **out) { glite_jp_query_rec_t *qr; - int i; assert(in); assert(out);