From: František Dvořák Date: Wed, 21 Mar 2007 12:29:25 +0000 (+0000) Subject: Final stage - compatibility of JP with gSoap 2.7.96b. X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=ae31a96472ee0fa6ed2bc657bfb628ed107ef91a;p=jra1mw.git Final stage - compatibility of JP with gSoap 2.7.96b. Basic testing passed but certainly not all features was tested. --- diff --git a/org.glite.jp.index/examples/jpis-client.c b/org.glite.jp.index/examples/jpis-client.c index fb551ce..9c9b791 100644 --- a/org.glite.jp.index/examples/jpis-client.c +++ b/org.glite.jp.index/examples/jpis-client.c @@ -4,12 +4,15 @@ #include #include +#include "soap_version.h" + #include #include +#include -#include "soap_version.h" #include "jpis_client_.nsmap" #include "common.h" +#include /* 'jpisclient' as future namespace */ @@ -72,15 +75,9 @@ typedef enum {FORMAT_XML, FORMAT_HR} format_t; * set the value */ static void value_set(struct soap *soap, struct jptype__stringOrBlob **value, const char *str) { -#if GSOAP_VERSION >= 20706 - *value = soap_malloc(soap, sizeof(*value)); - (*value)->__union_1 = SOAP_UNION_jptype__union_1_string; - (*value)->union_1.string = soap_strdup(soap, str); -#else - *value = soap_malloc(soap, sizeof(*value)); - (*value)->string = soap_strdup(soap, str); - (*value)->blob = NULL; -#endif + *value = soap_malloc(soap, sizeof(**value)); + memset(*value, 0, sizeof(*value)); + GSOAP_SETSTRING(*value, soap_strdup(soap, str)); } @@ -92,20 +89,12 @@ static void value_print(FILE *out, const struct jptype__stringOrBlob *value) { unsigned char *ptr; if (value) { -#if GSOAP_VERSION >= 20706 - if (value->__union_1 == SOAP_UNION_jptype__union_1_string) { - fprintf(out, "%s", value->union_1.string); - } else if (value->__union_1 == SOAP_UNION_jptype__union_1_blob) { - fprintf(out, "BLOB("); - ptr = value->union_1.blob->__ptr; - size = value->union_1.blob->__size; -#else - if (value->string) fprintf(out, "%s", value->string); - else if (value->blob) { + if (GSOAP_ISSTRING(value)) fprintf(out, "%s", GSOAP_STRING(value)); + else if (GSOAP_ISBLOB(value)) { fprintf(out, "BLOB("); - ptr = value->blob->__ptr; - size = value->blob->__size; -#endif + ptr = GSOAP_BLOB(value)->__ptr; + size = GSOAP_BLOB(value)->__size; + maxsize = 10; if (ptr) { maxsize = size < 10 ? size : 10; @@ -126,53 +115,42 @@ static void value_print(FILE *out, const struct jptype__stringOrBlob *value) { static void query_example_fill(struct soap *soap, struct _jpisclient__QueryJobs *in) { struct jptype__indexQuery *cond; struct jptype__indexQueryRecord *rec; - - in->__sizeconditions = 2; - in->conditions = soap_malloc(soap, - in->__sizeconditions * - sizeof(*(in->conditions))); + + GLITE_SECURITY_GSOAP_LIST_CREATE(soap, in, conditions, struct jptype__indexQuery, 2); // query status - cond = soap_malloc(soap, sizeof(*cond)); + cond = GLITE_SECURITY_GSOAP_LIST_GET(in->conditions, 0); memset(cond, 0, sizeof(*cond)); cond->attr = soap_strdup(soap, "http://egee.cesnet.cz/en/Schema/LB/Attributes:finalStatus"); cond->origin = NULL; - cond->__sizerecord = 2; - cond->record = soap_malloc(soap, cond->__sizerecord * sizeof(*(cond->record))); + GLITE_SECURITY_GSOAP_LIST_CREATE(soap, cond, record, struct jptype__indexQueryRecord, 2); // equal to Done - rec = soap_malloc(soap, sizeof(*rec)); + rec = GLITE_SECURITY_GSOAP_LIST_GET(cond->record, 0); memset(rec, 0, sizeof(*rec)); rec->op = jptype__queryOp__EQUAL; value_set(soap, &rec->value, "Done"); - cond->record[0] = rec; // OR equal to Ready - rec = soap_malloc(soap, sizeof(*rec)); + rec = GLITE_SECURITY_GSOAP_LIST_GET(cond->record, 1); memset(rec, 0, sizeof(*rec)); rec->op = jptype__queryOp__EQUAL; value_set(soap, &rec->value, "Ready"); - cond->record[1] = rec; - in->conditions[0] = cond; // AND // owner - cond = soap_malloc(soap, sizeof(*cond)); + cond = GLITE_SECURITY_GSOAP_LIST_GET(in->conditions, 0); memset(cond, 0, sizeof(*cond)); cond->attr = soap_strdup(soap, "http://egee.cesnet.cz/en/Schema/LB/Attributes:user"); cond->origin = NULL; - cond->__sizerecord = 1; - cond->record = soap_malloc(soap, cond->__sizerecord * sizeof(*(cond->record))); + GLITE_SECURITY_GSOAP_LIST_CREATE(soap, cond, record, struct jptype__indexQueryRecord, 1); // not equal to CertSubj - rec = soap_malloc(soap, sizeof(*rec)); + rec = GLITE_SECURITY_GSOAP_LIST_GET(cond->record, 0); memset(rec, 0, sizeof(*rec)); rec->op = jptype__queryOp__UNEQUAL; value_set(soap, &rec->value, "God"); - cond->record[0] = rec; - - in->conditions[1] = cond; in->__sizeattributes = 4; @@ -210,7 +188,7 @@ static int query_recv(struct soap *soap, int fd, struct _jpisclient__QueryJobs * 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); + glite_jpis_trim_soap(soap, &GLITE_SECURITY_GSOAP_LIST_GET(qj->conditions, i)->attr); return 0; } @@ -220,14 +198,16 @@ static int query_recv(struct soap *soap, int fd, struct _jpisclient__QueryJobs * * print info from the query soap structure */ static void query_print(FILE *out, const struct _jpisclient__QueryJobs *in) { + struct jptype__indexQuery *cond; struct jptype__indexQueryRecord *rec; int i, j, k; fprintf(out, "Conditions:\n"); for (i = 0; i < in->__sizeconditions; i++) { - fprintf(out, "\t%s\n", in->conditions[i]->attr); - for (j = 0; j < in->conditions[i]->__sizerecord; j++) { - rec = in->conditions[i]->record[j]; + cond = GLITE_SECURITY_GSOAP_LIST_GET(in->conditions, i); + fprintf(out, "\t%s\n", cond->attr); + for (j = 0; j < cond->__sizerecord; j++) { + rec = GLITE_SECURITY_GSOAP_LIST_GET(cond->record, j); for (k = 0; k <= NUMBER_OP; k++) if (operations[k].op == rec->op) break; fprintf(out, "\t\t%s", operations[k].name); @@ -312,14 +292,16 @@ static int queryresult_dump(struct soap *soap, int fd, const struct _jpisclient_ * print the data returned from JP IS */ static void queryresult_print(FILE *out, const struct _jpelem__QueryJobsResponse *in) { + struct jptype__jobRecord *job; struct jptype__attrValue *attr; int i, j, k; fprintf(out, "Result %d jobs:\n", in->__sizejobs); for (j=0; j__sizejobs; j++) { - fprintf(out, "\tjobid = %s, owner = %s\n", in->jobs[j]->jobid, in->jobs[j]->owner); - for (i=0; ijobs[j]->__sizeattributes; i++) { - attr = in->jobs[j]->attributes[i]; + job = GLITE_SECURITY_GSOAP_LIST_GET(in->jobs, j); + fprintf(out, "\tjobid = %s, owner = %s\n", job->jobid, job->owner); + for (i=0; i__sizeattributes; i++) { + attr = GLITE_SECURITY_GSOAP_LIST_GET(job->attributes, i); fprintf(out, "\t\t%s\n", attr->name); fprintf(out, "\t\t\tvalue = "); value_print(out, attr->value); @@ -364,52 +346,7 @@ static void usage(const char *prog_name) { /* * process the result after calling soap */ -static int check_fault(struct soap *soap, int err) { - struct SOAP_ENV__Detail *detail; - struct jptype__genericFault *f; - char *reason,indent[200] = " "; - - switch(err) { - case SOAP_OK: fputs("OK", stderr); - putc('\n', stderr); - break; - case SOAP_FAULT: - case SOAP_SVR_FAULT: - if (soap->version == 2) { - detail = soap->fault->SOAP_ENV__Detail; -#if GSOAP_VERSION >= 20706 - reason = soap->fault->SOAP_ENV__Reason->SOAP_ENV__Text; -#else - reason = soap->fault->SOAP_ENV__Reason; -#endif - } - else { - detail = soap->fault->detail; - reason = soap->fault->faultstring; - } - fputs(reason, stderr); - putc('\n', stderr); - assert(detail->__type == SOAP_TYPE__genericFault); -#if GSOAP_VERSION >= 20700 - f = ((struct _genericFault *) detail->fault) -#else - f = ((struct _genericFault *) detail->value) -#endif - -> jpelem__genericFault; - - while (f) { - fprintf(stderr,"%s%s: %s (%s)\n",indent, - f->source,f->text,f->description); - f = f->reason; - strcat(indent," "); - } - return -1; - - default: soap_print_fault(soap,stderr); - return -1; - } - return 0; -} +#define check_fault(SOAP, ERR) glite_jp_clientCheckFault((SOAP), (ERR), NULL, 0) int main(int argc, char * const argv[]) { diff --git a/org.glite.jp.index/examples/jpis-test.c b/org.glite.jp.index/examples/jpis-test.c index 8337355..e62917d 100644 --- a/org.glite.jp.index/examples/jpis-test.c +++ b/org.glite.jp.index/examples/jpis-test.c @@ -74,17 +74,16 @@ int main(int argc,char *argv[]) struct jptype__jobRecord *rec; struct _jpelem__UpdateJobs in; struct _jpelem__UpdateJobsResponse out; + struct jptype__attrValue *a; memset(&in, 0, sizeof(in)); memset(&out, 0, sizeof(out)); in.feedId = soap_strdup(soap, "12345"); in.feedDone = GLITE_SECURITY_GSOAP_FALSE; - in.__sizejobAttributes = 2; - in.jobAttributes = soap_malloc(soap, - in.__sizejobAttributes * sizeof(*(in.jobAttributes))); + GLITE_SECURITY_GSOAP_LIST_CREATE(soap, &in, jobAttributes, struct jptype__jobRecord, 2); + rec = GLITE_SECURITY_GSOAP_LIST_GET(in.jobAttributes, 0); { - rec = soap_malloc(soap, sizeof(*rec)); memset(rec, 0, sizeof(*rec)); rec->jobid = soap_strdup(soap, "https://localhost:7846/pokus1"); { @@ -101,58 +100,53 @@ int main(int argc,char *argv[]) } rec->__sizeprimaryStorage = 0; rec->primaryStorage = NULL; - rec->__sizeattributes = 2; - rec->attributes = soap_malloc(soap, - rec->__sizeattributes * sizeof(*(rec->attributes))); - rec->attributes[0] = soap_malloc(soap, sizeof(*(rec->attributes[0]))); - rec->attributes[0]->name = soap_strdup(soap, "http://egee.cesnet.cz/en/Schema/LB/Attributes:user"); - rec->attributes[0]->value = soap_malloc(soap, sizeof(*(rec->attributes[0]->value))); - GSOAP_STRING(rec->attributes[0]->value) = soap_strdup(soap, "CertSubj"); - GSOAP_BLOB(rec->attributes[0]->value) = NULL; - rec->attributes[0]->timestamp = 333; - rec->attributes[0]->origin = jptype__attrOrig__SYSTEM; - rec->attributes[0]->originDetail = NULL; - - rec->attributes[1] = soap_malloc(soap, sizeof(*(rec->attributes[1]))); - rec->attributes[1]->name = soap_strdup(soap, "http://egee.cesnet.cz/en/Schema/LB/Attributes:finalStatus"); - rec->attributes[1]->value = soap_malloc(soap, sizeof(*(rec->attributes[0]->value))); - GSOAP_STRING(rec->attributes[1]->value) = soap_strdup(soap, "Done"); - GSOAP_BLOB(rec->attributes[1]->value) = NULL; - rec->attributes[1]->timestamp = 333; - rec->attributes[1]->origin = jptype__attrOrig__SYSTEM; - rec->attributes[1]->originDetail = NULL; + GLITE_SECURITY_GSOAP_LIST_CREATE(soap, rec, attributes, struct jptype__attrValue, 2); + a = GLITE_SECURITY_GSOAP_LIST_GET(rec->attributes, 0); + a->name = soap_strdup(soap, "http://egee.cesnet.cz/en/Schema/LB/Attributes:user"); + a->value = soap_malloc(soap, sizeof(*(a->value))); + memset(a->value, 0, sizeof(a->value)); + GSOAP_SETSTRING(a->value, soap_strdup(soap, "CertSubj")); + a->timestamp = 333; + a->origin = jptype__attrOrig__SYSTEM; + a->originDetail = NULL; + + a = GLITE_SECURITY_GSOAP_LIST_GET(rec->attributes, 1); + a->name = soap_strdup(soap, "http://egee.cesnet.cz/en/Schema/LB/Attributes:finalStatus"); + a->value = soap_malloc(soap, sizeof(*(a->value))); + memset(a->value, 0, sizeof(a->value)); + GSOAP_SETSTRING(a->value, soap_strdup(soap, "Done")); + a->timestamp = 333; + a->origin = jptype__attrOrig__SYSTEM; + a->originDetail = NULL; } - in.jobAttributes[0] = rec; + + rec = GLITE_SECURITY_GSOAP_LIST_GET(in.jobAttributes, 1); { - rec = soap_malloc(soap, sizeof(*rec)); memset(rec, 0, sizeof(*rec)); rec->jobid = soap_strdup(soap, "https://localhost:7846/pokus2"); rec->owner = soap_strdup(soap, "OwnerName"); rec->__sizeprimaryStorage = 0; rec->primaryStorage = NULL; - rec->__sizeattributes = 2; - rec->attributes = soap_malloc(soap, - rec->__sizeattributes * sizeof(*(rec->attributes))); - rec->attributes[0] = soap_malloc(soap, sizeof(*(rec->attributes[0]))); - rec->attributes[0]->name = soap_strdup(soap, "http://egee.cesnet.cz/en/Schema/LB/Attributes:user"); - rec->attributes[0]->value = soap_malloc(soap, sizeof(*(rec->attributes[0]->value))); - GSOAP_STRING(rec->attributes[0]->value) = soap_strdup(soap, "CertSubj"); - GSOAP_BLOB(rec->attributes[0]->value) = NULL; - rec->attributes[0]->timestamp = 333; - rec->attributes[0]->origin = jptype__attrOrig__USER; - rec->attributes[0]->originDetail = NULL; - rec->attributes[1] = soap_malloc(soap, sizeof(*(rec->attributes[1]))); - rec->attributes[1]->name = soap_strdup(soap, "http://egee.cesnet.cz/en/Schema/LB/Attributes:finalStatus"); - rec->attributes[1]->value = soap_malloc(soap, sizeof(*(rec->attributes[0]->value))); - GSOAP_STRING(rec->attributes[1]->value) = soap_strdup(soap, "Ready"); - GSOAP_BLOB(rec->attributes[1]->value) = NULL; - rec->attributes[1]->timestamp = 333; - rec->attributes[1]->origin = jptype__attrOrig__SYSTEM; - rec->attributes[1]->originDetail = NULL; + GLITE_SECURITY_GSOAP_LIST_CREATE(soap, rec, attributes, struct jptype__jobRecord, 2); + a = GLITE_SECURITY_GSOAP_LIST_GET(rec->attributes, 0); + a->name = soap_strdup(soap, "http://egee.cesnet.cz/en/Schema/LB/Attributes:user"); + a->value = soap_malloc(soap, sizeof(*(a->value))); + memset(a->value, 0, sizeof(a->value)); + GSOAP_SETSTRING(a->value, soap_strdup(soap, "CertSubj")); + a->timestamp = 333; + a->origin = jptype__attrOrig__USER; + a->originDetail = NULL; + + a = GLITE_SECURITY_GSOAP_LIST_GET(rec->attributes, 1); + a->name = soap_strdup(soap, "http://egee.cesnet.cz/en/Schema/LB/Attributes:finalStatus"); + a->value = soap_malloc(soap, sizeof(*(a->value))); + memset(a->value, 0, sizeof(a->value)); + GSOAP_SETSTRING(a->value, soap_strdup(soap, "Ready")); + a->timestamp = 333; + a->origin = jptype__attrOrig__SYSTEM; + a->originDetail = NULL; } - in.jobAttributes[1] = rec; - check_fault(soap, soap_call___jpsrv__UpdateJobs(soap,server,"",&in,&out)); @@ -165,61 +159,51 @@ int main(int argc,char *argv[]) struct jptype__indexQuery *cond; struct jptype__indexQueryRecord *rec; struct _jpelem__QueryJobsResponse out; + struct jptype__jobRecord *job; + struct jptype__attrValue *attr; int i, j; - - in.__sizeconditions = 2; - in.conditions = soap_malloc(soap, - in.__sizeconditions * - sizeof(*(in.conditions))); + GLITE_SECURITY_GSOAP_LIST_CREATE(soap, &in, conditions, struct jptype__indexQuery, 2); // query status - cond = soap_malloc(soap, sizeof(*cond)); + cond = GLITE_SECURITY_GSOAP_LIST_GET(in.conditions, 0); memset(cond, 0, sizeof(*cond)); cond->attr = soap_strdup(soap, "http://egee.cesnet.cz/en/Schema/LB/Attributes:finalStatus"); cond->origin = NULL; - cond->__sizerecord = 2; - cond->record = soap_malloc(soap, cond->__sizerecord * sizeof(*(cond->record))); + GLITE_SECURITY_GSOAP_LIST_CREATE(soap, cond, record, struct jptype__indexQueryRecord, 2); // equal to Done - rec = soap_malloc(soap, sizeof(*rec)); + rec = GLITE_SECURITY_GSOAP_LIST_GET(cond->record, 0); memset(rec, 0, sizeof(*rec)); rec->op = jptype__queryOp__EQUAL; rec->value = soap_malloc(soap, sizeof(*(rec->value))); - GSOAP_STRING(rec->value) = soap_strdup(soap, "Done"); - GSOAP_BLOB(rec->value) = NULL; - cond->record[0] = rec; + memset(rec->value, 0, sizeof(*rec->value)); + GSOAP_SETSTRING(rec->value, soap_strdup(soap, "Done")); // OR equal to Ready - rec = soap_malloc(soap, sizeof(*rec)); + rec = GLITE_SECURITY_GSOAP_LIST_GET(cond->record, 1); memset(rec, 0, sizeof(*rec)); rec->op = jptype__queryOp__EQUAL; rec->value = soap_malloc(soap, sizeof(*(rec->value))); - GSOAP_STRING(rec->value) = soap_strdup(soap, "Ready"); - GSOAP_BLOB(rec->value) = NULL; - cond->record[1] = rec; + memset(rec->value, 0, sizeof(*rec->value)); + GSOAP_SETSTRING(rec->value, soap_strdup(soap, "Ready")); - in.conditions[0] = cond; // AND // owner - cond = soap_malloc(soap, sizeof(*cond)); + cond = GLITE_SECURITY_GSOAP_LIST_GET(in.conditions, 1); memset(cond, 0, sizeof(*cond)); cond->attr = soap_strdup(soap, "http://egee.cesnet.cz/en/Schema/LB/Attributes:user"); cond->origin = NULL; - cond->__sizerecord = 1; - cond->record = soap_malloc(soap, cond->__sizerecord * sizeof(*(cond->record))); + GLITE_SECURITY_GSOAP_LIST_CREATE(soap, cond, record, struct jptype__indexQueryRecord, 1); // not equal to CertSubj - rec = soap_malloc(soap, sizeof(*rec)); + rec = GLITE_SECURITY_GSOAP_LIST_GET(cond->record, 0); memset(rec, 0, sizeof(*rec)); rec->op = jptype__queryOp__UNEQUAL; rec->value = soap_malloc(soap, sizeof(*(rec->value))); - GSOAP_STRING(rec->value) = soap_strdup(soap, "God"); - GSOAP_BLOB(rec->value) = NULL; - cond->record[0] = rec; - - in.conditions[1] = cond; + memset(rec->value, 0, sizeof(*rec->value)); + GSOAP_SETSTRING(rec->value, soap_strdup(soap, "God")); in.__sizeattributes = 4; @@ -237,11 +221,13 @@ int main(int argc,char *argv[]) soap_call___jpsrv__QueryJobs(soap, server, "",&in,&out)); for (j=0; jjobid); - for (i=0; i__sizeattributes; i++) { + job = GLITE_SECURITY_GSOAP_LIST_GET(out.jobs, j); + printf("jobid = %s\n",job->jobid); + for (i=0; i__sizeattributes; i++) { + attr = GLITE_SECURITY_GSOAP_LIST_GET(job->attributes, i); printf("\t%s = %s\n", - out.jobs[j]->attributes[i]->name, - GSOAP_STRING(out.jobs[j]->attributes[i]->value)); + attr->name, + GSOAP_ISSTRING(attr->value) ? GSOAP_STRING(attr->value) : "binary"); } } } diff --git a/org.glite.jp.index/src/soap_ops.c b/org.glite.jp.index/src/soap_ops.c index c183019..599c5d1 100644 --- a/org.glite.jp.index/src/soap_ops.c +++ b/org.glite.jp.index/src/soap_ops.c @@ -27,7 +27,7 @@ /* Helper functions */ /*------------------*/ -#define dprintf(x) +#define dprintf(FMT, ARGS, ...) #include "glite/jp/ws_fault.c" #define err2fault(CTX, SOAP) glite_jp_server_err2fault((CTX), (SOAP)) @@ -52,7 +52,7 @@ static int updateJob(glite_jpis_context_t ctx, const char *ps, struct jptype__jo if ((ret = glite_jpis_lazyInsertJob(ctx, ps, jobAttrs->jobid, jobAttrs->owner)) != 0) return ret; for (iattrs = 0; iattrs < jobAttrs->__sizeattributes; iattrs++) { - attr = jobAttrs->attributes[iattrs]; + attr = GLITE_SECURITY_GSOAP_LIST_GET(jobAttrs->attributes, iattrs); glite_jpis_SoapToAttrVal(&av, attr); if ((ret = glite_jpis_insertAttrVal(ctx, jobAttrs->jobid, &av)) != 0) return ret; } @@ -101,7 +101,7 @@ SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__UpdateJobs( // insert all attributes for (ijobs = 0; ijobs < jpelem__UpdateJobs->__sizejobAttributes; ijobs++) { - if (updateJob(ctx, (const char *) ps, jpelem__UpdateJobs->jobAttributes[ijobs]) != 0) goto fail; + if (updateJob(ctx, (const char *) ps, GLITE_SECURITY_GSOAP_LIST_GET(jpelem__UpdateJobs->jobAttributes, ijobs)) != 0) goto fail; } free(ps); @@ -143,7 +143,7 @@ static int checkIndexedConditions(glite_jpis_context_t ctx, struct _jpelem__Quer for (k=0; k < in->__sizeconditions; k++) { for (j=0; j < i; j++) { - if (!strcmp(in->conditions[k]->attr, indexed_attrs[j])) { + if (!strcmp(GLITE_SECURITY_GSOAP_LIST_GET(in->conditions, k)->attr, indexed_attrs[j])) { ret = 0; goto end; } @@ -210,18 +210,21 @@ static int get_jobids(struct soap *soap, glite_jpis_context_t ctx, struct _jpele qwhere = strdup(""); for (i=0; i < in->__sizeconditions; i++) { + struct jptype__indexQuery *condition; + + condition = GLITE_SECURITY_GSOAP_LIST_GET(in->conditions, i); /* XXX: deal with jobIds diferently (they are not in attr_X table, but in jobs) if (strcmp(in->conditions[i]->attr,GLITE_JP_ATTR_JOBID)) { trio_asprintf(&qa,"%s (", (i ? "AND" : "") ); - for (j=0; j < in->conditions[i]->__sizerecord; j++) { - if (get_op(in->conditions[i]->record[j]->op, &qop)) goto err; + for (j=0; j < condition->__sizerecord; j++) { + if (get_op(condition->record[j]->op, &qop)) goto err; - attr.name = in->conditions[i]->attr; - attr.value = in->conditions[i]->record[j]->value->string; + attr.name = condition->attr; + attr.value = condition->record[j]->value->string; attr.binary = 0; glite_jpis_SoapToAttrOrig(soap, - in->conditions[i]->origin, &(attr.origin)); + condition->origin, &(attr.origin)); trio_asprintf(&qb,"%s%sjobs.dg_jobid %s \"%|Ss\"", qa, (j ? " OR " : ""), attr_md5, qop, glite_jp_attrval_to_db_index(ctx->jpctx, &attr, 255)); @@ -232,20 +235,23 @@ static int get_jobids(struct soap *soap, glite_jpis_context_t ctx, struct _jpele else */ { - attr_md5 = str2md5(in->conditions[i]->attr); + attr_md5 = str2md5(condition->attr); trio_asprintf(&qa,"%s jobs.jobid = attr_%|Ss.jobid AND (", (i ? "AND" : ""), attr_md5); - for (j=0; j < in->conditions[i]->__sizerecord; j++) { - if (get_op(in->conditions[i]->record[j]->op, &qop)) goto err; + for (j=0; j < condition->__sizerecord; j++) { + struct jptype__indexQueryRecord *record; + + record = GLITE_SECURITY_GSOAP_LIST_GET(condition->record, j); + if (get_op(record->op, &qop)) goto err; add_attr_table(attr_md5, &attr_tables); - if (GSOAP_STRING(in->conditions[i]->record[j]->value)) { - attr.name = in->conditions[i]->attr; - attr.value = GSOAP_STRING(in->conditions[i]->record[j]->value); + if (GSOAP_ISSTRING(record->value)) { + attr.name = condition->attr; + attr.value = GSOAP_STRING(record->value); attr.binary = 0; glite_jpis_SoapToAttrOrig(soap, - in->conditions[i]->origin, &(attr.origin)); + condition->origin, &(attr.origin)); trio_asprintf(&qb,"%s%sattr_%|Ss.value %s \"%|Ss\"", qa, (j ? " OR " : ""), attr_md5, qop, glite_jp_attrval_to_db_index(ctx->jpctx, &attr, 255)); @@ -253,12 +259,12 @@ static int get_jobids(struct soap *soap, glite_jpis_context_t ctx, struct _jpele free(qa); qa = qb; qb = NULL; } else { - attr.name = in->conditions[i]->attr; - attr.value = GSOAP_BLOB(in->conditions[i]->record[j]->value)->__ptr; + attr.name = condition->attr; + attr.value = GSOAP_BLOB(record->value)->__ptr; attr.binary = 1; - attr.size = GSOAP_BLOB(in->conditions[i]->record[j]->value)->__size; + attr.size = GSOAP_BLOB(record->value)->__size; glite_jpis_SoapToAttrOrig(soap, - in->conditions[i]->origin, &(attr.origin)); + condition->origin, &(attr.origin)); trio_asprintf(&qb,"%s %s attr_%|Ss.value %s \"%|Ss\"", qa, (j ? "OR" : ""), attr_md5, qop, glite_jp_attrval_to_db_index(ctx->jpctx, &attr, 255)); @@ -345,18 +351,17 @@ static void freeAttval_t(glite_jp_attrval_t jav) /* get all values of a given attribute for a job with a given jobid */ /* all values are soap_malloc-ated, exept of av (due to absence of */ /* soap_realloc) */ -/* Needs to be reallocated with soap_malloc in calling function! */ +/* Needs to be copied to list using soap_malloc in calling function! */ -static int get_attr(struct soap *soap, glite_jpis_context_t ctx, char *jobid, char *attr_name, struct jptype__jobRecord *out) +static int get_attr(struct soap *soap, glite_jpis_context_t ctx, char *jobid, char *attr_name, int *size, struct jptype__attrValue **out) { glite_jp_attrval_t jav; - struct jptype__attrValue **av = NULL;; + struct jptype__attrValue *av; //enum jptype__attrOrig *origin; char *query, *fv, *jobid_md5, *attr_md5; int i, ret; glite_jp_db_stmt_t stmt; - memset(&jav,0,sizeof(jav)); jobid_md5 = str2md5(jobid); attr_md5 = str2md5(attr_name); @@ -371,43 +376,43 @@ static int get_attr(struct soap *soap, glite_jpis_context_t ctx, char *jobid, ch goto err; free(query); - i = 0; + av = *out; + i = *size; while ( (ret = glite_jp_db_fetchrow(stmt, &fv)) > 0 ) { av = realloc(av, (i+1) * sizeof(*av)); - av[i] = soap_malloc(soap, sizeof(**av)); - memset(av[i], 0, sizeof(**av)); + memset(&av[i], 0, sizeof(av[i])); memset(&jav,0,sizeof(jav)); if (glite_jp_attrval_from_db(ctx->jpctx, fv, &jav)) goto err; - av[i]->name = soap_strdup(soap, attr_name); - av[i]->value = soap_malloc(soap, sizeof(*(av[i]->value))); - memset(av[i]->value, 0, sizeof(*(av[i]->value))); + av[i].name = soap_strdup(soap, attr_name); + av[i].value = soap_malloc(soap, sizeof(*(av[i].value))); + memset(av[i].value, 0, sizeof(*(av[i].value))); if (jav.binary) { - GSOAP_BLOB(av[i]->value) = soap_malloc(soap, sizeof(*(GSOAP_BLOB(av[i]->value)))); - memset(GSOAP_BLOB(av[i]->value), 0, sizeof(*(GSOAP_BLOB(av[i]->value)))); - GSOAP_BLOB(av[i]->value)->__ptr = soap_malloc(soap, jav.size); - memcpy(GSOAP_BLOB(av[i]->value)->__ptr, jav.value, jav.size); - GSOAP_BLOB(av[i]->value)->__size = jav.size; + GSOAP_SETBLOB(av[i].value, soap_malloc(soap, sizeof(*(GSOAP_BLOB(av[i].value))))); + memset(GSOAP_BLOB(av[i].value), 0, sizeof(*(GSOAP_BLOB(av[i].value)))); + GSOAP_BLOB(av[i].value)->__ptr = soap_malloc(soap, jav.size); + memcpy(GSOAP_BLOB(av[i].value)->__ptr, jav.value, jav.size); + GSOAP_BLOB(av[i].value)->__size = jav.size; // XXX: id, type, option - how to handle? } else { - GSOAP_STRING(av[i]->value) = soap_strdup(soap, jav.value); + GSOAP_SETSTRING(av[i].value, soap_strdup(soap, jav.value)); } // XXX: load timestamp and origin from DB // need to add columns to DB -// av[i]->timestamp = jav.timestamp; +// av[i].timestamp = jav.timestamp; // glite_jpis_AttrOrigToSoap(soap, jav.origin, &origin); -// av[i]->origin = *origin; free(origin); -// av[i]->originDetail = soap_strdup(soap, jav.origin_detail); +// av[i].origin = origin; //XXX: NULL(=ANY) origin? +// av[i].originDetail = soap_strdup(soap, jav.origin_detail); i++; freeAttval_t(jav); } if (ret < 0) goto err; - glite_jp_db_freestmt(&stmt); - (*out).__sizeattributes = i; - (*out).attributes = av; + glite_jp_db_freestmt(&stmt); + *size = i; + *out = av; return 0; @@ -461,35 +466,28 @@ err: } /* fills structure jobRecord for a given jobid*/ -static int get_attrs(struct soap *soap, glite_jpis_context_t ctx, char *jobid, struct _jpelem__QueryJobs *in, struct jptype__jobRecord **out) +static int get_attrs(struct soap *soap, glite_jpis_context_t ctx, char *jobid, struct _jpelem__QueryJobs *in, struct jptype__jobRecord *out) { - struct jptype__jobRecord jr; - struct jptype__attrValue **av = NULL; - int j, size; +// struct jptype__jobRecord jr; + struct jptype__attrValue *av = NULL; + int j, size = 0; assert(out); - *out = soap_malloc(soap, sizeof(**out)); - memset(*out, 0, sizeof(**out)); + memset(out, 0, sizeof(*out)); /* jobid */ - (*out)->jobid = soap_strdup(soap, jobid); + out->jobid = soap_strdup(soap, jobid); /* sizeattributes & attributes */ size = 0; - for (j=0; j < in->__sizeattributes; j++) { - if (get_attr(soap, ctx, jobid, in->attributes[j], &jr) ) goto err; - if (jr.__sizeattributes > 0) { - av = realloc(av, (size + jr.__sizeattributes) * sizeof(*av)); - memcpy(&av[size], jr.attributes, jr.__sizeattributes * sizeof(*(jr.attributes))); - size += jr.__sizeattributes; - free(jr.attributes); - } - } - if ( get_owner(ctx, jobid, &((*out)->owner)) ) goto err; - (*out)->__sizeattributes = size; - (*out)->attributes = soap_malloc( soap, size *sizeof(*((*out)->attributes)) ); - memcpy((*out)->attributes, av, size * sizeof(*((*out)->attributes)) ); + for (j=0; j < in->__sizeattributes; j++) + if (get_attr(soap, ctx, jobid, in->attributes[j], &size, &av) ) goto err; + if ( get_owner(ctx, jobid, &(out->owner)) ) goto err; + + GLITE_SECURITY_GSOAP_LIST_CREATE(soap, out, attributes, struct jptype__attrValue, size); + for (j = 0; j < size; j++) + memcpy(GLITE_SECURITY_GSOAP_LIST_GET(out->attributes, j), &av[j], sizeof(av[0])); free(av); return 0; @@ -504,7 +502,8 @@ SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__QueryJobs( struct _jpelem__QueryJobsResponse *out) { CONTEXT_FROM_SOAP(soap, ctx); - struct jptype__jobRecord **jr = NULL; + struct jptype__jobRecord *jr; + char **jobids = NULL, **ps_list = NULL; int i, size; @@ -526,25 +525,22 @@ SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__QueryJobs( /* get all requested attributes for matching jobids */ for (i=0; (jobids && jobids[i]); i++); size = i; - jr = soap_malloc(soap, size * sizeof(*jr)); + GLITE_SECURITY_GSOAP_LIST_CREATE(soap, out, jobs, struct jptype__jobRecord, size); for (i=0; (jobids && jobids[i]); i++) { - if ( get_attrs(soap, ctx, jobids[i], in, &(jr[i])) ) { - return SOAP_ERR; - } + jr = GLITE_SECURITY_GSOAP_LIST_GET(out->jobs, i); + if ( get_attrs(soap, ctx, jobids[i], in, jr) ) return SOAP_ERR; + // XXX: in prototype we return only first value of PS URL // in future database should contain one more table with URLs - jr[i]->__sizeprimaryStorage = 1; - jr[i]->primaryStorage = soap_malloc(soap, sizeof(*(jr[i]->primaryStorage))); - jr[i]->primaryStorage[0] = soap_strdup(soap, ps_list[i]); + jr->__sizeprimaryStorage = 1; + jr->primaryStorage = soap_malloc(soap, sizeof(*(jr->primaryStorage))); + jr->primaryStorage[0] = soap_strdup(soap, ps_list[i]); free(ps_list[i]); free(jobids[i]); } free(jobids); free(ps_list); - (*out).__sizejobs = size; - (*out).jobs = jr; - return SOAP_OK; } diff --git a/org.glite.jp.index/src/soap_ps_calls.c b/org.glite.jp.index/src/soap_ps_calls.c index 0fe3d47..e54defb 100644 --- a/org.glite.jp.index/src/soap_ps_calls.c +++ b/org.glite.jp.index/src/soap_ps_calls.c @@ -2,13 +2,14 @@ #include #include +#include "soap_version.h" #include "glite/jp/types.h" #include "glite/jp/context.h" #include "glite/security/glite_gsplugin.h" +#include "glite/security/glite_gscompat.h" #include "jpps_H.h" #include "jpps_.nsmap" -#include "soap_version.h" #include "conf.h" #include "db_ops.h" @@ -22,6 +23,11 @@ /* Helper functions */ /*------------------*/ +#define dprintf(FMT, ARGS...) +#include "glite/jp/ws_fault.c" +#define check_fault(SOAP, ERR) glite_jp_clientCheckFault((SOAP), (ERR), NULL, 0) + +#if 0 static struct jptype__genericFault *jp2s_error(struct soap *soap, const glite_jp_error_t *err) @@ -106,7 +112,7 @@ static int check_fault(struct soap *soap,int err) { } return 0; } - +#endif /*----------------------*/ /* PS WSDL client calls */ @@ -158,12 +164,11 @@ lprintf("MyFeedIndex for %s called\n", dest); if ((dest_index = find_dest_index(conf, dest)) < 0) goto err; for (i=0; conf->feeds[dest_index]->query[i]; i++); - in.__sizeconditions = i; - in.conditions = soap_malloc(soap, in.__sizeconditions * sizeof(*in.conditions)); + GLITE_SECURITY_GSOAP_LIST_CREATE(soap, &in, conditions, struct jptype__primaryQuery, i); for (i=0; conf->feeds[dest_index]->query[i]; i++) { if (glite_jpis_QueryCondToSoap(soap, conf->feeds[dest_index]->query[i], - &(in.conditions[i])) != SOAP_OK) { + GLITE_SECURITY_GSOAP_LIST_GET(in.conditions, i)) != SOAP_OK) { err.code = EINVAL; err.desc = "error during conds conversion"; asprintf(&src, "%s/%s():%d", __FILE__, __FUNCTION__, __LINE__); diff --git a/org.glite.jp.index/src/ws_is_typeref.c b/org.glite.jp.index/src/ws_is_typeref.c index a9d91f1..bf22534 100644 --- a/org.glite.jp.index/src/ws_is_typeref.c +++ b/org.glite.jp.index/src/ws_is_typeref.c @@ -8,6 +8,7 @@ #include "jpis_H.h" #include "ws_typemap.h" #include "ws_is_typeref.h" + #include "glite/jp/ws_fault.c" @@ -54,14 +55,14 @@ static int SoapToQueryRecordVal( { assert(in); - if (GSOAP_STRING(in)) { + if (GSOAP_ISSTRING(in)) { *binary = 0; *size = 0; *value = strdup(GSOAP_STRING(in)); return 0; } - else if (GSOAP_BLOB(in)) { + else if (GSOAP_ISBLOB(in)) { *binary = 1; *size = GSOAP_BLOB(in)->__size; memcpy(*value, GSOAP_BLOB(in)->__ptr, GSOAP_BLOB(in)->__size); @@ -82,25 +83,26 @@ static int SoapToQueryCond( { glite_jp_query_rec_t *qr; int i; - + struct jptype__indexQueryRecord *record; assert(in); assert(out); qr = calloc(in->__sizerecord, sizeof(*qr)); for (i=0; i < in->__sizerecord; i++) { + record = GLITE_SECURITY_GSOAP_LIST_GET(in->record, i); qr[i].attr = strdup(in->attr); - glite_jpis_SoapToQueryOp(in->record[i]->op, &(qr[i].op)); + glite_jpis_SoapToQueryOp(record->op, &(qr[i].op)); switch (qr[i].op) { case GLITE_JP_QUERYOP_EXISTS: break; case GLITE_JP_QUERYOP_WITHIN: - SoapToQueryRecordVal(soap, in->record[i]->value2, &(qr[i].binary), + SoapToQueryRecordVal(soap, record->value2, &(qr[i].binary), &(qr[i].size2), &(qr[i].value2)); // fall through default: - if ( SoapToQueryRecordVal(soap, in->record[i]->value, &(qr[i].binary), + if ( SoapToQueryRecordVal(soap, record->value, &(qr[i].binary), &(qr[i].size), &(qr[i].value)) ) { *out = NULL; return 1; diff --git a/org.glite.jp.index/src/ws_ps_typeref.c b/org.glite.jp.index/src/ws_ps_typeref.c index 9131ca5..5e065d0 100644 --- a/org.glite.jp.index/src/ws_ps_typeref.c +++ b/org.glite.jp.index/src/ws_ps_typeref.c @@ -82,12 +82,11 @@ static int QueryRecordValToSoap( int glite_jpis_QueryCondToSoap( struct soap *soap, glite_jp_query_rec_t *in, - struct jptype__primaryQuery **out) + struct jptype__primaryQuery *out) { struct jptype__primaryQuery *qr; assert(in); assert(out); - if ( !(qr = soap_malloc(soap, sizeof(*qr))) ) return SOAP_FAULT; memset(qr, 0, sizeof(*qr)); if ( !(qr->attr = soap_strdup(soap, in->attr)) ) return SOAP_FAULT; @@ -104,7 +103,7 @@ int glite_jpis_QueryCondToSoap( break; } - *out = qr; + *out = *qr; return SOAP_OK; } diff --git a/org.glite.jp.index/src/ws_ps_typeref.h b/org.glite.jp.index/src/ws_ps_typeref.h index d4143a8..7c38192 100644 --- a/org.glite.jp.index/src/ws_ps_typeref.h +++ b/org.glite.jp.index/src/ws_ps_typeref.h @@ -1,7 +1,7 @@ #ifndef GLITE_JPIS_TYPEREF_H #define GLITE_JPIS_TYPEREF_H -int glite_jpis_QueryCondToSoap(struct soap *soap, glite_jp_query_rec_t *in, struct jptype__primaryQuery **out); +int glite_jpis_QueryCondToSoap(struct soap *soap, glite_jp_query_rec_t *in, struct jptype__primaryQuery *out); void glite_jpis_AttrOrigToSoap(struct soap *soap, const glite_jp_attr_orig_t in, enum jptype__attrOrig **out);