From 3a3f815459075701e16b192c9dbe187c95863e6b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Milo=C5=A1=20Mula=C4=8D?= Date: Wed, 29 Jun 2005 12:56:46 +0000 Subject: [PATCH] improvements of QueryRec <-> soap conversion functions (ws_joblog seems to work - modulo not present event <-> soap conversion functions, so return nothing now) --- org.glite.lb.server/examples/ws_joblog.c | 41 ++++++++++++++++++++++++++------ org.glite.lb.server/src/ws_query.c | 6 ++--- org.glite.lb.server/src/ws_typeref.c.T | 14 +++++------ 3 files changed, 44 insertions(+), 17 deletions(-) diff --git a/org.glite.lb.server/examples/ws_joblog.c b/org.glite.lb.server/examples/ws_joblog.c index 2440a11..9a7b0de 100644 --- a/org.glite.lb.server/examples/ws_joblog.c +++ b/org.glite.lb.server/examples/ws_joblog.c @@ -41,8 +41,10 @@ int main(int argc,char** argv) struct soap *mydlo = soap_new(); struct _lbe__QueryEventsResponse out; struct _lbe__QueryEvents in; + edg_wll_QueryRec **jconds = NULL, + **econds = NULL; edg_wll_QueryRec j[2], e[1]; - int opt, err; + int opt, err, i; edg_wlc_JobId job; char *server = "http://localhost:9003/", *jobid = NULL, @@ -92,22 +94,47 @@ int main(int argc,char** argv) j[0].op = EDG_WLL_QUERY_OP_EQUAL; j[0].value.j = job; - edg_wll_QueryCondsExtToSoap(mydlo, (const edg_wll_QueryRec **)j, - &in.__sizejobConditions, &in.jobConditions); - edg_wll_QueryCondsExtToSoap(mydlo, (const edg_wll_QueryRec **)e, - &in.__sizeeventConditions, &in.eventConditions); + + jconds = (edg_wll_QueryRec **) calloc(2, sizeof(edg_wll_QueryRec *)); + for ( i = 0; i < 2; i++ ) + { + jconds[i] = (edg_wll_QueryRec *) calloc(2, sizeof(edg_wll_QueryRec)); + jconds[i][0] = j[i]; + } + + econds = (edg_wll_QueryRec **) calloc(1, sizeof(edg_wll_QueryRec *)); + for ( i = 0; i < 1; i++ ) + { + econds[i] = (edg_wll_QueryRec *) calloc(1, sizeof(edg_wll_QueryRec)); + econds[i][0] = e[i]; + } + + + if (edg_wll_QueryCondsExtToSoap(mydlo, (const edg_wll_QueryRec **)jconds, + &in.__sizejobConditions, &in.jobConditions) != SOAP_OK) { + printf("Error converting QueryConds to Soap!\n"); + return(1); + } + + //edg_wll_QueryCondsExtToSoap(mydlo, (const edg_wll_QueryRec **)econds, + // &in.__sizeeventConditions, &in.eventConditions); + + //in.jobConditions = NULL; + //in.__sizejobConditions = 0; + in.eventConditions = NULL; + in.__sizeeventConditions = 0; switch (err = soap_call___lb__QueryEvents(mydlo, server, "",&in,&out)) { case SOAP_OK: { - edg_wll_Event *events; + edg_wll_Event *events = NULL; int i; edg_wll_SoapToEvents(mydlo,out,&events); - for ( i = 0; events[i].type != EDG_WLL_EVENT_UNDEF; i++ ) + for ( i = 0; events && events[i].type != EDG_WLL_EVENT_UNDEF; i++ ) { char *e = edg_wll_UnparseEvent(ctx,events+i); fputs(e,stdout); diff --git a/org.glite.lb.server/src/ws_query.c b/org.glite.lb.server/src/ws_query.c index 4a8b4e0..32df2a1 100644 --- a/org.glite.lb.server/src/ws_query.c +++ b/org.glite.lb.server/src/ws_query.c @@ -144,12 +144,12 @@ SOAP_FMAC5 int SOAP_FMAC6 __lb__QueryEvents( edg_wll_Context ctx = (edg_wll_Context) glite_gsplugin_get_udata(soap); edg_wll_QueryRec **job_conditions; edg_wll_QueryRec **event_conditions; - edg_wll_Event *events; + edg_wll_Event *events = NULL; int ret = SOAP_OK; edg_wll_ResetError(ctx); - if ( edg_wll_SoapToQueryCondsExt(*in->jobConditions, in->__sizejobConditions, + if ( edg_wll_SoapToQueryCondsExt(in->jobConditions, in->__sizejobConditions, &job_conditions) ) { edg_wll_SetError(ctx, ENOMEM, "Couldn't create internal structures"); @@ -158,7 +158,7 @@ SOAP_FMAC5 int SOAP_FMAC6 __lb__QueryEvents( goto cleanup; } - if ( edg_wll_SoapToQueryCondsExt(*in->eventConditions, in->__sizeeventConditions, + if ( edg_wll_SoapToQueryCondsExt(in->eventConditions, in->__sizeeventConditions, &event_conditions) ) { edg_wll_SetError(ctx, ENOMEM, "Couldn't create internal structures"); diff --git a/org.glite.lb.server/src/ws_typeref.c.T b/org.glite.lb.server/src/ws_typeref.c.T index 1998647..853e3e8 100644 --- a/org.glite.lb.server/src/ws_typeref.c.T +++ b/org.glite.lb.server/src/ws_typeref.c.T @@ -496,13 +496,13 @@ int edg_wll_QueryCondsToSoap( if ( !qc->statName ) return SOAP_FAULT; edg_wll_JobStatCodeToSoap(in->attr_id.state, qc->statName); } - else { + else if ( in->attr == EDG_WLL_QUERY_ATTR_USERTAG) { qc->tagName = soap_strdup(soap, in->attr_id.tag); if ( !qc->tagName ) return SOAP_FAULT; } - i = 0; - while ( in[i].attr ) qc->__sizerecord++; + qc->__sizerecord = 0; + while ( in[qc->__sizerecord++].attr ); if ( !qc->__sizerecord ) goto ret; @@ -532,7 +532,7 @@ int edg_wll_SoapToQueryCondsExt(const struct lbt__queryConditions **in, int __si edg_wll_QueryRec **qr; - assert(in); assert(out); + assert(out); if ( !(qr = calloc(__sizecondition, sizeof(*qr))) ) return -1; for ( i = 0; i < __sizecondition; i++ ) if ( edg_wll_SoapToQueryConds(in[i], qr+i) ) goto err; @@ -573,8 +573,8 @@ int edg_wll_QueryCondsExtToSoap( assert(in); assert(out); - i = 0; - while ( in[i] ) size++; + size = 0; + while ( in[size] ) size++; if ( !size ) goto ret; @@ -583,7 +583,7 @@ int edg_wll_QueryCondsExtToSoap( if ( !qc ) return SOAP_FAULT; for ( i = 0; in[i]; i++ ) - if ( edg_wll_QueryCondsToSoap(soap, in[i], qc[i]) ) + if ( edg_wll_QueryCondsToSoap(soap, in[i], &qc[i]) ) return SOAP_FAULT; ret: -- 1.8.2.3