merge from RC31 branch + bugfixes
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Wed, 28 Mar 2007 14:15:49 +0000 (14:15 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Wed, 28 Mar 2007 14:15:49 +0000 (14:15 +0000)
org.glite.jp.index/Makefile
org.glite.jp.index/examples/jpis-client.c
org.glite.jp.index/examples/jpis-test.c
org.glite.jp.index/examples/query-tests/run-test.sh
org.glite.jp.index/project/version.properties
org.glite.jp.index/src/conf.c
org.glite.jp.index/src/soap_ops.c
org.glite.jp.index/src/soap_ps_calls.c
org.glite.jp.index/src/ws_is_typeref.c
org.glite.jp.index/src/ws_ps_typeref.c
org.glite.jp.index/src/ws_ps_typeref.h

index 34dd4ac..00ed923 100644 (file)
@@ -61,7 +61,7 @@ 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\
+       ${is_prefix}ServerLib.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 ws_is_typeref.c
@@ -83,7 +83,7 @@ TRIOLIB:=-lglite_jp_trio
 
 default all: compile doc
 
-compile: ${daemon} ${examples} copy_tests
+compile: ${daemon} ${examples}
 
 ${daemon}: ${OBJS}
        ${LINK} -o $@ -export-dynamic ${OBJS} ${BONESLIB} ${TRIOLIB} ${COMMONLIB} ${GSOAPLIB} ${GLOBUS_LIBS} ${SRVCOMMONLIB}
@@ -97,11 +97,6 @@ jpis-db-internal: ${EXA_DB_OBJS}
 glite-jpis-client: ${EXA_CLIENT_OBJS}
        ${LINK} -o $@ $+ ${GSOAPLIB}
 
-copy_tests: ${test} ${test_files}
-
-${test} ${test_files}:
-       for i in $@; do cp ${top_srcdir}/examples/query-tests/$$i  ${top_srcdir}/build; done
-
 JobProvenanceIS.xh: JobProvenanceIS.wsdl JobProvenanceTypes.wsdl typemap.dat
        cp  ${stagedir}/interface/JobProvenanceTypes.wsdl .
        ${gsoap_bin_prefix}/wsdl2h -t ${top_srcdir}/src/typemap.dat -c -o $@ $<
@@ -119,18 +114,18 @@ JobProvenancePS.xh: %.xh: %.wsdl JobProvenanceTypes.wsdl typemap.dat
 
 ${is_prefix}ClientLib.c ${is_prefix}Client.c \
 ${is_prefix}Server.c ${is_prefix}ServerLib.c  \
-${is_prefix}C.c ${is_prefix}H.h ${is_prefix}_Stub.h: JobProvenanceIS.xh
+${is_prefix}C.c ${is_prefix}H.h ${is_prefix}Stub.h: JobProvenanceIS.xh
        ${gsoap_bin_prefix}/soapcpp2 -n -w -c -p ${is_prefix} $<
 
 # JobProvenanceISClient.xh should be used, 
 # for now (gsoap-2.7.0) used direct JobProvenanceIS.xh
 ${is_client_prefix}ClientLib.c ${is_client_prefix}Client.c \
 ${is_client_prefix}Server.c ${is_client_prefix}ServerLib.c  \
-${is_client_prefix}C.c ${is_client_prefix}H.h ${is_client_prefix}_Stub.h: JobProvenanceIS.xh
+${is_client_prefix}C.c ${is_client_prefix}H.h ${is_client_prefix}Stub.h: JobProvenanceIS.xh
        ${gsoap_bin_prefix}/soapcpp2 -n -w -c -p ${is_client_prefix} $<
 
 ${ps_prefix}Client.c ${ps_prefix}ClientLib.c  \
-${ps_prefix}C.c ${ps_prefix}H.h ${ps_prefix}_Stub.h: JobProvenancePS.xh
+${ps_prefix}C.c ${ps_prefix}H.h ${ps_prefix}Stub.h: JobProvenancePS.xh
        ${gsoap_bin_prefix}/soapcpp2 -n -w -c -p ${ps_prefix} $<
 
 
@@ -177,8 +172,10 @@ install:
        ${INSTALL} -m 644 ${top_srcdir}/doc/README ${HTMLS} ${PREFIX}/share/doc/${package}-${version}
        ${INSTALL} -m 644 ${MANS1} ${PREFIX}/share/man/man1
        ${INSTALL} -m 644 ${MANS8} ${PREFIX}/share/man/man8
-       ${INSTALL} -m 755 ${test} ${PREFIX}/examples/query-tests
-       ${INSTALL} -m 644 ${test_files} ${PREFIX}/examples/query-tests
+       ${INSTALL} -m 755 ../examples/query-tests/${test} ${PREFIX}/examples/query-tests
+       for i in ${test_files}; do \
+               ${INSTALL} -m 644 ../examples/query-tests/$$i ${PREFIX}/examples/query-tests; \
+       done
        ${INSTALL} -m 644 ${top_srcdir}/interface/JobProvenanceISClient.xsd ${PREFIX}/interface
 
 clean:
index f35c670..e285006 100644 (file)
@@ -5,12 +5,16 @@
 #include <getopt.h>
 #include <stdlib.h>
 
+#include "soap_version.h"
+
 #include <stdsoap2.h>
 #include <glite/security/glite_gsplugin.h>
+#include <glite/security/glite_gscompat.h>
 
-#include "soap_version.h"
 #include "jpis_client_.nsmap"
 #include "common.h"
+#define dprintf(FMT, ARGS...) fprintf(stderr, FMT, ##ARGS);
+#include <glite/jp/ws_fault.c>
 
 
 /* 'jpisclient' as future namespace */
@@ -74,15 +78,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));
 }
 
 
@@ -94,20 +92,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;
@@ -128,54 +118,43 @@ 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 = soap_malloc(soap, sizeof(*(cond->origin)));
        *(cond->origin) = jptype__attrOrig__SYSTEM;
-       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;
@@ -213,7 +192,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;
 }
@@ -223,21 +202,23 @@ 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);
-               if (in->conditions[i]->origin) {
+               cond = GLITE_SECURITY_GSOAP_LIST_GET(in->conditions, i);
+               fprintf(out, "\t%s\n", cond->attr);
+               if (cond->origin) {
                        for (k = 0; k <= NUMBER_ORIG; k++)
-                               if (origins[k].orig == *(in->conditions[i]->origin)) break;
+                               if (origins[k].orig == *(cond->origin)) break;
                        fprintf(out, "\t\torigin == %s\n", origins[k].name);
                } else {
                        fprintf(out, "\t\torigin IS ANY\n");
                }
-               for (j = 0; j < in->conditions[i]->__sizerecord; j++) {
-                       rec = in->conditions[i]->record[j];
+               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\tvalue %s", operations[k].name);
@@ -322,6 +303,7 @@ 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;
 
@@ -330,9 +312,10 @@ static void queryresult_print(FILE *out, const struct  _jpelem__QueryJobsRespons
 #endif
        fprintf(out, "Result %d jobs:\n", in->__sizejobs);
        for (j=0; j<in->__sizejobs; j++) {
-               fprintf(out, "\tjobid = %s, owner = %s\n", in->jobs[j]->jobid, in->jobs[j]->owner);
-               for (i=0; i<in->jobs[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<job->__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);
@@ -377,52 +360,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[]) {
index 54395d6..7e4651a 100644 (file)
 #define soap_call___jpsrv__UpdateJobs soap_call___ns1__UpdateJobs
 #define soap_call___jpsrv__QueryJobs soap_call___ns1__QueryJobs
 #endif
+#define dprintf(FMT, ARGS...) fprintf(stderr, FMT, ##ARGS);
+#define check_fault(SOAP, ERR) glite_jp_clientCheckFault((SOAP), (ERR), NULL, 0)
+#include "glite/jp/ws_fault.c"
 
 
 /* insert simulating FeedIndex call */
 #define INSERT "insert into feeds value ('93', '12345', '8', '0' , 'http://localhost:8901', '2005-10-14 10:48:27', 'COND2');" 
 #define DELETE "delete from feeds where feedid = '12345';" 
 
-static int check_fault(struct soap *soap,int err);
-
-
        
 int main(int argc,char *argv[])
 {
@@ -78,17 +78,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 = false_;
-               in.__sizejobAttributes = 2;
-               in.jobAttributes = soap_malloc(soap, 
-                       in.__sizejobAttributes * sizeof(*(in.jobAttributes)));
+               in.feedDone = GLITE_SECURITY_GSOAP_FALSE;
+               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");
                        {
@@ -105,58 +104,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)));
-                       rec->attributes[0]->value->string = soap_strdup(soap, "CertSubj");
-                       rec->attributes[0]->value->blob = 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)));
-                       rec->attributes[1]->value->string = soap_strdup(soap, "Done");
-                       rec->attributes[1]->value->blob = 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)));
-                       rec->attributes[0]->value->string = soap_strdup(soap, "CertSubj");
-                       rec->attributes[0]->value->blob = 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)));
-                       rec->attributes[1]->value->string = soap_strdup(soap, "Ready");
-                       rec->attributes[1]->value->blob = 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));
@@ -169,61 +163,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)));
-               rec->value->string = soap_strdup(soap, "Done");
-               rec->value->blob = 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)));
-               rec->value->string = soap_strdup(soap, "Ready");
-               rec->value->blob = 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)));
-               rec->value->string = soap_strdup(soap, "God");
-               rec->value->blob = 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;
@@ -241,11 +225,13 @@ int main(int argc,char *argv[])
                        soap_call___jpsrv__QueryJobs(soap, server, "",&in,&out));
 
                for (j=0; j<out.__sizejobs; j++) {
-                       printf("jobid = %s\n",out.jobs[j]->jobid);
-                       for (i=0; i<out.jobs[j]->__sizeattributes; i++) {
+                       job = GLITE_SECURITY_GSOAP_LIST_GET(out.jobs, j);
+                       printf("jobid = %s\n",job->jobid);
+                       for (i=0; i<job->__sizeattributes; i++) {
+                               attr = GLITE_SECURITY_GSOAP_LIST_GET(job->attributes, i);
                                printf("\t%s = %s\n",
-                                       out.jobs[j]->attributes[i]->name,
-                                       out.jobs[j]->attributes[i]->value->string);
+                                       attr->name,
+                                       GSOAP_ISSTRING(attr->value) ? GSOAP_STRING(attr->value) : "binary");
                        }
                }
        } 
@@ -254,49 +240,5 @@ int main(int argc,char *argv[])
 }
 
 
-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: puts("OK");
-                             break;
-               case SOAP_FAULT:
-               case SOAP_SVR_FAULT:
-                       if (soap->version == 2) {
-                               detail = soap->fault->SOAP_ENV__Detail;
-                               reason = soap->fault->SOAP_ENV__Reason;
-                       }
-                       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;
-}
-
-
-
 /* XXX: we don't use it */
 SOAP_NMAC struct Namespace namespaces[] = { {NULL,NULL} };
index 0e8ce22..e386211 100755 (executable)
@@ -174,7 +174,7 @@ run_test_feed() {
        # run the example
        numok=`X509_USER_KEY=${X509_USER_KEY} X509_USER_CERT=${X509_USER_CERT}\
                $GLITE_LOCATION/examples/glite-jpis-test -p $GLITE_JPIS_TEST_PORT \
-               -m $GLITE_JPIS_TEST_DB -x $GLITE_JPIS_TEST_CONFIG | grep -c OK`
+               -m $GLITE_JPIS_TEST_DB -x $GLITE_JPIS_TEST_CONFIG 2>&1 | grep -c OK`
        if [ "$numok" -eq "2" ]; then
                echo OK.
        else
index 4b685bc..0617a79 100644 (file)
@@ -9,7 +9,6 @@
 #include <getopt.h>
 #include <unistd.h>
 
-
 #include <glite/jp/types.h>
 #include <glite/jp/context.h>
 #include "conf.h"
@@ -200,6 +199,7 @@ static int read_conf(glite_jp_is_conf *conf, char *conf_file)
                }
        }
        if (out.__sizefeeds) {
+#warning FIXME: list
                conf->feeds = calloc(out.__sizefeeds + 1, sizeof(*conf->feeds));
                for (i=0; i < out.__sizefeeds; i++) {
                        conf->feeds[i] = calloc(1, sizeof(*conf->feeds[i]));
@@ -254,6 +254,7 @@ static int dump_conf(void) {
         out.plugins[0] = strdup("plugin1");
         out.plugins[1] = strdup("plugin2");
 
+#warning: FIXME: lists
        out.__sizefeeds = 1;
         out.feeds = calloc(1, sizeof(*out.feeds));
        out.feeds[0] = calloc(1, sizeof(*out.feeds[0]));
index 2c29a25..9b4772b 100644 (file)
@@ -12,6 +12,7 @@
 #include "jpis_H.h"
 #include "jpis_.nsmap"
 #include "soap_version.h"
+#include "glite/security/glite_gscompat.h"
 #include "db_ops.h"
 // XXX: avoid 2 wsdl collisions - work only because ws_ps_typeref.h 
 // uses common types from jpis_H.h (awful)
                                // XXX: 2 is only for debugging, replace with e.g. 100
 #define        JOBIDS_STRIDE   2       // how often realloc matched jobids result
 
-#if GSOAP_VERSION >= 20706
-#define false_ xsd__boolean__false_
-#endif
-
 /*------------------*/
 /* Helper functions */
 /*------------------*/
 
-
-static struct jptype__genericFault *jp2s_error(struct soap *soap,
-               const glite_jp_error_t *err)
-{
-       struct jptype__genericFault *ret = NULL;
-       if (err) {
-               ret = soap_malloc(soap,sizeof *ret);
-               memset(ret,0,sizeof *ret);
-               ret->code = err->code;
-               ret->source = soap_strdup(soap,err->source);
-               ret->text = soap_strdup(soap,strerror(err->code));
-               ret->description = soap_strdup(soap,err->desc);
-               ret->reason = jp2s_error(soap,err->reason);
-       }
-       return ret;
-}
-
-static void err2fault(const glite_jp_context_t ctx,struct soap *soap)
-{
-       struct SOAP_ENV__Detail *detail = soap_malloc(soap,sizeof *detail);
-       struct _genericFault *f = soap_malloc(soap,sizeof *f);
-
-
-       f->jpelem__genericFault = jp2s_error(soap,ctx->error);
-
-       detail->__type = SOAP_TYPE__genericFault;
-#if GSOAP_VERSION >= 20700
-       detail->fault = f;
-#else
-       detail->value = f;
-#endif
-       detail->__any = NULL;
-
-       soap_receiver_fault(soap,"Oh, shit!",NULL);
-       if (soap->version == 2) soap->fault->SOAP_ENV__Detail = detail;
-       else soap->fault->detail = detail;
-}
-
-
+#define dprintf(FMT, ARGS, ...)
+#include "glite/jp/ws_fault.c"
+#define err2fault(CTX, SOAP) glite_jp_server_err2fault((CTX), (SOAP))
 
 
 
@@ -88,11 +49,11 @@ static int updateJob(glite_jpis_context_t ctx, const char *ps, struct jptype__jo
 
        lprintf("jobid='%s', attrs=%d\n", jobAttrs->jobid, jobAttrs->__sizeattributes);
 
-       if (jobAttrs->remove) assert(*(jobAttrs->remove) == false_);
+       if (jobAttrs->remove) assert(*(jobAttrs->remove) == GLITE_SECURITY_GSOAP_FALSE);
 
        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;
        }
@@ -141,7 +102,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);
 
@@ -183,7 +144,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++) {
-                       char *attr = in->conditions[k]->attr;
+                       char *attr = GLITE_SECURITY_GSOAP_LIST_GET(in->conditions, k)->attr;
                        if (!strcmp(attr, GLITE_JP_ATTR_JOBID) || !strcmp(attr, indexed_attrs[j])) {
                                ret = 0;
                                goto end;
@@ -252,18 +213,22 @@ 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);
+
                        /* attr name */
-                       if (strcmp(in->conditions[i]->attr, GLITE_JP_ATTR_JOBID) == 0) {
+                       if (strcmp(condition->attr, GLITE_JP_ATTR_JOBID) == 0) {
                                /* no subset from attr_ table, used jobs table instead */
                                attr_md5 = NULL;
                                qa = strdup("(");
                        } else {
-                               attr_md5 = str2md5(in->conditions[i]->attr);
+                               attr_md5 = str2md5(condition->attr);
 
                                /* origin */
-                               if (in->conditions[i]->origin) {
-                                       glite_jpis_SoapToAttrOrig(soap, in->conditions[i]->origin, &orig);
+                               if (condition->origin) {
+                                       glite_jpis_SoapToAttrOrig(soap, condition->origin, &orig);
                                        trio_asprintf(&qb, "attr_%|Ss.origin = %d AND ", attr_md5, orig);
                                } else
                                        trio_asprintf(&qb, "");
@@ -276,24 +241,27 @@ static int get_jobids(struct soap *soap, glite_jpis_context_t ctx, struct _jpele
                        }
 
                        /* inside part of the condition: record list (ORs) */
-                       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;
                                if (attr_md5) add_attr_table(attr_md5, &attr_tables);
 
-                               attr.name = in->conditions[i]->attr;
-                               if (in->conditions[i]->record[j]->value->string) {
-                                       attr.value = in->conditions[i]->record[j]->value->string;
+                               attr.name = condition->attr;
+                               if (GSOAP_ISSTRING(record->value)) {
+                                       attr.value = GSOAP_STRING(record->value);
                                        attr.binary = 0;
                                } else {
-                                       attr.value = in->conditions[i]->record[j]->value->blob->__ptr;
-                                       attr.size = in->conditions[i]->record[j]->value->blob->__size;
+                                       attr.value = GSOAP_BLOB(record->value)->__ptr;
+                                       attr.size = GSOAP_BLOB(record->value)->__size;
                                        attr.binary = 1;
                                }
                                glite_jpis_SoapToAttrOrig(soap,
-                                       in->conditions[i]->origin, &(attr.origin));
-                               if (strcmp(in->conditions[i]->attr, GLITE_JP_ATTR_JOBID) == 0) {
-                                       trio_asprintf(&qb,"%s%sjobs.dg_jobid %s \"%|Ss\"",
-                                               qa, (j ? " OR " : ""), qop, attr.value);
+                                       condition->origin, &(attr.origin));
+                               if (strcmp(condition->attr, GLITE_JP_ATTR_JOBID) == 0) {
+                                       trio_asprintf(&qb,"%s%sjobs.dg_jobid %s \"%|Ss\"",
+                                               qa, (j ? " OR " : ""), qop, attr.value);
                                } else {
                                        trio_asprintf(&qb,"%s%sattr_%|Ss.value %s \"%|Ss\"",
                                                qa, (j ? " OR " : ""), attr_md5, qop,
@@ -381,18 +349,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);
@@ -407,41 +374,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) {
-                       av[i]->value->blob = soap_malloc(soap, sizeof(*(av[i]->value->blob)));
-                       memset(av[i]->value->blob, 0, sizeof(*(av[i]->value->blob)));
-                       av[i]->value->blob->__ptr = soap_malloc(soap, jav.size);
-                       memcpy(av[i]->value->blob->__ptr, jav.value, jav.size);
-                       av[i]->value->blob->__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 {
-                       av[i]->value->string = soap_strdup(soap, jav.value);
+                       GSOAP_SETSTRING(av[i].value, jav.value ? soap_strdup(soap, jav.value) : NULL);
                }
-               av[i]->timestamp = jav.timestamp;
+               av[i].timestamp = jav.timestamp;
                glite_jpis_AttrOrigToSoap(soap, jav.origin, &origin);
-               av[i]->origin = *origin; soap_dealloc(soap, origin);
-               av[i]->originDetail = soap_strdup(soap, jav.origin_detail);             
+               // atribute has always origin
+               assert(origin != GLITE_JP_ATTR_ORIG_ANY);
+               av[i].origin = *origin; soap_dealloc(soap, origin);
+               if (jav.origin_detail) 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;
 
@@ -495,35 +464,27 @@ 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__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;
@@ -538,7 +499,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;
 
@@ -560,25 +522,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;
 }
 
index 41ae0be..e54defb 100644 (file)
@@ -2,13 +2,14 @@
 #include <fcntl.h>
 #include <assert.h>
 
+#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"
 /* 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 */
@@ -135,7 +141,7 @@ int MyFeedIndex(glite_jpis_context_t ctx, glite_jp_is_conf *conf, long int uniqu
        struct soap                             *soap = soap_new();
        glite_gsplugin_Context                  plugin_ctx;
        glite_jp_error_t err;
-       char *src, hname[512];
+       char *src;
 
 lprintf("MyFeedIndex for %s called\n", dest);
        glite_gsplugin_init_context(&plugin_ctx);
@@ -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__);
index 94aaad2..414b033 100644 (file)
@@ -9,6 +9,8 @@
 #include "ws_typemap.h"
 #include "ws_is_typeref.h"
 
+#include "glite/jp/ws_fault.c"
+
 
 void glite_jpis_SoapToQueryOp(const enum jptype__queryOp in, glite_jp_queryop_t *out)
 {
@@ -53,17 +55,17 @@ static int SoapToQueryRecordVal(
 {
        
         assert(in);
-       if (in->string) {
+       if (GSOAP_ISSTRING(in)) {
                *binary = 0;
                *size = 0;
-               *value = strdup(in->string);
+               *value = strdup(GSOAP_STRING(in));
 
                return 0;
        }
-       else if (in->blob) {
+       else if (GSOAP_ISBLOB(in)) {
                *binary = 1;
-               *size = in->blob->__size;
-               memcpy(*value, in->blob->__ptr, in->blob->__size);
+               *size = GSOAP_BLOB(in)->__size;
+               memcpy(*value, GSOAP_BLOB(in)->__ptr, GSOAP_BLOB(in)->__size);
                // XXX how to handle id, type, option?
 
                return 0;
@@ -81,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 + 1, 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;
index 3fea887..9574f05 100644 (file)
@@ -8,6 +8,7 @@
 #include "jpps_H.h"
 #include "ws_typemap.h"
 #include "ws_ps_typeref.h"
+#include "glite/jp/ws_fault.c"
 
 
 static void QueryOpToSoap(const glite_jp_queryop_t in, enum jptype__queryOp *out)
@@ -55,16 +56,16 @@ static int QueryRecordValToSoap(
        memset(val, 0, sizeof(*val) );
 
         if (binary) {
-               val->string = NULL;
-               if ( !(val->blob = soap_malloc(soap, sizeof(*val->blob))) ) return SOAP_FAULT;
-               val->blob->__size = size;
-               if ( !(val->blob->__ptr = soap_malloc(soap, val->blob->__size)) ) return SOAP_FAULT;
-               memcpy(val->blob->__ptr, in, val->blob->__size);
+               GSOAP_STRING(val) = NULL;
+               if ( !(GSOAP_BLOB(val) = soap_malloc(soap, sizeof(*GSOAP_BLOB(val)))) ) return SOAP_FAULT;
+               GSOAP_BLOB(val)->__size = size;
+               if ( !(GSOAP_BLOB(val)->__ptr = soap_malloc(soap, GSOAP_BLOB(val)->__size)) ) return SOAP_FAULT;
+               memcpy(GSOAP_BLOB(val)->__ptr, in, GSOAP_BLOB(val)->__size);
                // XXX how to handle id, type, option?
        }
        else {
-               val->blob = NULL;
-               if ( !(val->string = soap_strdup(soap, in)) )  return SOAP_FAULT;
+               GSOAP_BLOB(val) = NULL;
+               if ( !(GSOAP_STRING(val) = soap_strdup(soap, in)) )  return SOAP_FAULT;
        }
 
        *out = val;
@@ -81,12 +82,12 @@ 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;
+       qr = out;
        memset(qr, 0, sizeof(*qr));
 
        if ( !(qr->attr = soap_strdup(soap, in->attr)) ) return SOAP_FAULT;
@@ -103,7 +104,7 @@ int glite_jpis_QueryCondToSoap(
                break;
        }
 
-       *out = qr;
+       *out = *qr;
                
        return SOAP_OK;
 }
@@ -122,14 +123,14 @@ static void SoapToAttrOrig(glite_jp_attr_orig_t *out, const enum jptype__attrOri
 void glite_jpis_SoapToAttrVal(glite_jp_attrval_t *av, const struct jptype__attrValue *attr) {
        memset(av, 0, sizeof(*av));
        av->name = attr->name;
-       av->binary = attr->value->blob ? 1 : 0;
-       assert(av->binary || attr->value->string);
+       av->binary = GSOAP_BLOB(attr->value) ? 1 : 0;
+       assert(av->binary || GSOAP_STRING(attr->value));
        if (av->binary) {
-               av->value = attr->value->blob->__ptr;
-               av->size =attr->value->blob->__size ;
+               av->value = GSOAP_BLOB(attr->value)->__ptr;
+               av->size = GSOAP_BLOB(attr->value)->__size ;
        } else {
                av->size = -1;
-               av->value = attr->value->string;
+               av->value = GSOAP_STRING(attr->value);
        }
        SoapToAttrOrig(&av->origin, attr->origin);
        av->origin_detail = attr->originDetail;
index d4143a8..7c38192 100644 (file)
@@ -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);