From: František Dvořák Date: Wed, 14 May 2008 16:01:35 +0000 (+0000) Subject: Trimming of the feeded values, cleanup. X-Git-Tag: glite-yaim-lb_R_4_0_2_1~43 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=ef7431bb39321773017c47e8d51d3a7bb1c11a05;p=jra1mw.git Trimming of the feeded values, cleanup. --- diff --git a/org.glite.jp.index/examples/jpis-client.c b/org.glite.jp.index/examples/jpis-client.c index a8eb355..6e1a26a 100644 --- a/org.glite.jp.index/examples/jpis-client.c +++ b/org.glite.jp.index/examples/jpis-client.c @@ -174,9 +174,9 @@ static int query_recv(struct soap *soap, int fd, struct _jpelem__QueryJobs *qj) /* strip white-space characters from attributes */ for (i = 0; i < qj->__sizeattributes; i++) - glite_jpis_trim_soap(soap, &qj->attributes[i]); + glite_jpis_trim(qj->attributes[i]); for (i = 0; i < qj->__sizeconditions; i++) - glite_jpis_trim_soap(soap, &GLITE_SECURITY_GSOAP_LIST_GET(qj->conditions, i)->attr); + glite_jpis_trim(GLITE_SECURITY_GSOAP_LIST_GET(qj->conditions, i)->attr); return 0; } diff --git a/org.glite.jp.index/src/common.c b/org.glite.jp.index/src/common.c index caa0f89..f6e8291 100644 --- a/org.glite.jp.index/src/common.c +++ b/org.glite.jp.index/src/common.c @@ -13,20 +13,15 @@ #define WHITE_SPACE_SET "\n\r \t" -void glite_jpis_trim_soap(struct soap *soap, char **soap_str) { +void glite_jpis_trim(char *str) { size_t pos, len; - char *s; - if (!*soap_str) return; + if (!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; + pos = strspn(str, WHITE_SPACE_SET); + len = strcspn(str + pos, WHITE_SPACE_SET); + if (pos) memmove(str, str + pos, len); + str[len] = '\0'; } diff --git a/org.glite.jp.index/src/common.h b/org.glite.jp.index/src/common.h index 4a38bb8..c0756c2 100644 --- a/org.glite.jp.index/src/common.h +++ b/org.glite.jp.index/src/common.h @@ -6,7 +6,7 @@ #include #include -void glite_jpis_trim_soap(struct soap *soap, char **soap_str); +void glite_jpis_trim(char *str); int glite_jpis_stack_error_source(glite_jp_context_t ctx, int code, const char *func, int line, const char *desc, ...); diff --git a/org.glite.jp.index/src/db_ops.c b/org.glite.jp.index/src/db_ops.c index c642097..ad465a9 100644 --- a/org.glite.jp.index/src/db_ops.c +++ b/org.glite.jp.index/src/db_ops.c @@ -748,9 +748,11 @@ int glite_jpis_feeding(glite_jpis_context_t ctx, const char *fname, const char * avs[i].name = ctx->conf->attrs[iname]; iname++; } while (strcasecmp(avs[i].name, GLITE_JP_ATTR_JOBID) == 0 || strcasecmp(avs[i].name, GLITE_JP_ATTR_OWNER) == 0); + glite_jpis_trim(token); avs[i].value = token; avs[i].timestamp = time(NULL); -// printf(stderr, "\t %d: %s = '%s'\n", i, avs[i].name, avs[i].value); + avs[i].origin = GLITE_JP_ATTR_ORIG_FILE; +// printf("\t %d: %s = '%s'\n", i, avs[i].name, avs[i].value); i++; token = strtok_r(NULL, FEEDING_SEPARATORS, &lasts);