From f98a6cb8002895d4625c03bc39eee1ec5cbc817d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Wed, 28 Feb 2007 15:00:34 +0000 Subject: [PATCH] Gsoap compatiblity, 1. part: error handling and choice type. So compatible with 2.7.6b for now. --- org.glite.jp.primary/examples/dag-deps.c | 58 +++++---------------------- org.glite.jp.primary/examples/jpps-test.c | 66 ++++++------------------------- org.glite.jp.primary/src/is_client.c | 7 +++- org.glite.jp.primary/src/soap_ops.c | 60 ++++++---------------------- org.glite.jp.primary/src/soap_util.c | 24 +++++------ 5 files changed, 53 insertions(+), 162 deletions(-) diff --git a/org.glite.jp.primary/examples/dag-deps.c b/org.glite.jp.primary/examples/dag-deps.c index c68c13b..f4acdc0 100644 --- a/org.glite.jp.primary/examples/dag-deps.c +++ b/org.glite.jp.primary/examples/dag-deps.c @@ -9,15 +9,15 @@ #include -#include "glite/security/glite_gsplugin.h" #include "glite/jp/known_attr.h" #include "jpps_H.h" #include "jpps_.nsmap" #include "jptype_map.h" +#include "glite/security/glite_gsplugin.h" +#include "glite/security/glite_gscompat.h" -#include "soap_version.h" #if GSOAP_VERSION <= 20602 #define soap_call___jpsrv__RegisterJob soap_call___ns1__RegisterJob #define soap_call___jpsrv__StartUpload soap_call___ns1__StartUpload @@ -28,6 +28,10 @@ #define soap_call___jpsrv__GetJob soap_call___ns1__GetJob #endif +#define dprintf(FMT, ARGS...) fprintf(stderr, (FMT), ##ARGS) +#include "glite/jp/ws_fault.c" +#define check_fault(SOAP, ERR) glite_jp_clientCheckFault((SOAP), (ERR), NULL, 0) + static void usage(const char *me) { @@ -35,48 +39,6 @@ static void usage(const char *me) exit (EX_USAGE); } - -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; -} static const char *orig2str(enum jptype__attrOrig orig) { @@ -131,7 +93,7 @@ int main(int argc,char *argv[]) if ((ret = check_fault(soap,soap_call___jpsrv__GetJobAttributes(soap,server,"",&in,&out)))) return 1; - ad = cclassad_create(out.attrValues[0]->value->string); + ad = cclassad_create(GSOAP_STRING(out.attrValues[0]->value)); if (!ad) { fputs("Can't parse JDL\n",stderr); return 1; @@ -196,14 +158,14 @@ int main(int argc,char *argv[]) in.tag = &tagval; tagval.name = GLITE_JP_ATTR_WF_SUCCESSOR; tagval.value = &val; - val.string = js; - val.blob = NULL; + GSOAP_STRING(&val) = js; + GSOAP_BLOB(&val) = NULL; printf("Register successor ...\n"); ret = check_fault(soap,soap_call___jpsrv__RecordTag(soap, server, "",&in, &empty)); in.jobid = js; tagval.name = GLITE_JP_ATTR_WF_ANCESTOR; - val.string = ja; + GSOAP_STRING(&val) = ja; printf("Register ancestor ...\n"); ret = check_fault(soap,soap_call___jpsrv__RecordTag(soap, server, "",&in, &empty)); diff --git a/org.glite.jp.primary/examples/jpps-test.c b/org.glite.jp.primary/examples/jpps-test.c index 0710c78..8468aac 100644 --- a/org.glite.jp.primary/examples/jpps-test.c +++ b/org.glite.jp.primary/examples/jpps-test.c @@ -3,14 +3,13 @@ #include #include -#include "glite/security/glite_gsplugin.h" - #include "jpps_H.h" #include "jpps_.nsmap" #include "jptype_map.h" +#include "glite/security/glite_gsplugin.h" +#include "glite/security/glite_gscompat.h" -#include "soap_version.h" #if GSOAP_VERSION <= 20602 #define soap_call___jpsrv__RegisterJob soap_call___ns1__RegisterJob #define soap_call___jpsrv__StartUpload soap_call___ns1__StartUpload @@ -21,6 +20,9 @@ #define soap_call___jpsrv__GetJob soap_call___ns1__GetJob #endif +#define dprintf(x) printf x +#include "glite/jp/ws_fault.c" +#define check_fault(SOAP, ERR) glite_jp_clientCheckFault((SOAP), (ERR), NULL, 0) static void usage(const char *me) { @@ -39,48 +41,6 @@ static void usage(const char *me) exit (EX_USAGE); } -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; -} - /* FIXME: new wsdl */ #if 0 static struct jptype__Attribute sample_attr[] = { @@ -182,8 +142,8 @@ int main(int argc,char *argv[]) in.tag = &tagval; tagval.name = argv[3]; tagval.value = &val; - val.string = argv[4]; - val.blob = NULL; + GSOAP_STRING(&val) = argv[4]; + GSOAP_BLOB(&val)= NULL; if (!(ret = check_fault(soap, soap_call___jpsrv__RecordTag(soap, server, "",&in, &empty)))) { @@ -196,10 +156,10 @@ int main(int argc,char *argv[]) "http://egee.cesnet.cz/en/Schema/JP/System:owner" }; - struct jptype__stringOrBlob vals[] = { - { "/O=CESNET/O=Masaryk University/CN=Ales Krenek", NULL }, - { "Done", NULL } - }; + struct jptype__stringOrBlob vals[2]; + memset(vals, 0, sizeof vals); + GSOAP_STRING(vals) = "/O=CESNET/O=Masaryk University/CN=Ales Krenek"; + GSOAP_STRING(vals + 1) = "Done"; struct jptype__primaryQuery q[] = { { @@ -281,8 +241,8 @@ int main(int argc,char *argv[]) puts("Attribute values:"); for (i=0; ivalue->string ? - out.attrValues[i]->value->string : + GSOAP_STRING(out.attrValues[i]->value) ? + GSOAP_STRING(out.attrValues[i]->value) : "binary", orig2str(out.attrValues[i]->origin), ctime(&out.attrValues[i]->timestamp)); diff --git a/org.glite.jp.primary/src/is_client.c b/org.glite.jp.primary/src/is_client.c index ff77ca4..9cf17bf 100644 --- a/org.glite.jp.primary/src/is_client.c +++ b/org.glite.jp.primary/src/is_client.c @@ -8,7 +8,9 @@ #define SOAP_FMAC1 static #include "glite/jp/types.h" +#include "soap_version.h" #include "glite/security/glite_gsplugin.h" +#include "glite/security/glite_gscompat.h" #include "feed.h" #include "is_client.h" @@ -20,6 +22,7 @@ #include "jpis_.nsmap" +#include "glite/jp/ws_fault.c" #include "soap_util.c" #include "soap_env_ctx.h" @@ -94,7 +97,7 @@ int glite_jpps_single_feed( struct _jpelem__UpdateJobsResponse out; struct jptype__jobRecord jr, *jrp = &jr; int i; - enum xsd__boolean false = false_; + enum xsd__boolean false = GLITE_SECURITY_GSOAP_FALSE; glite_jp_error_t err; glite_jp_clear_error(ctx); @@ -166,7 +169,7 @@ int glite_jpps_multi_feed( struct _jpelem__UpdateJobs in; struct _jpelem__UpdateJobsResponse out; struct jptype__jobRecord *jr; - enum xsd__boolean false = false_; + enum xsd__boolean false = GLITE_SECURITY_GSOAP_FALSE; glite_jp_error_t err; printf("multi_feed: %s\n",destination); diff --git a/org.glite.jp.primary/src/soap_ops.c b/org.glite.jp.primary/src/soap_ops.c index e2bceaa..0c6a3f2 100644 --- a/org.glite.jp.primary/src/soap_ops.c +++ b/org.glite.jp.primary/src/soap_ops.c @@ -13,6 +13,7 @@ #include "attrs.h" #include "jptype_map.h" +#include "glite/security/glite_gscompat.h" #include "file_plugin.h" #include "builtin_plugins.h" @@ -24,48 +25,13 @@ #include "jpps_.nsmap" -#include "soap_util.c" - #include "soap_env_ctx.h" #include "soap_env_ctx.c" -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) -{ - char *et; - 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; +#include "glite/jp/ws_fault.c" +#include "soap_util.c" - soap_receiver_fault(soap,"Oh, shit!",NULL); - if (soap->version == 2) soap->fault->SOAP_ENV__Detail = detail; - else soap->fault->detail = detail; -} +#define err2fault(CTX, SOAP) glite_jp_server_err2fault((CTX), (SOAP)); #define CONTEXT_FROM_SOAP(soap,ctx) glite_jp_context_t ctx = (glite_jp_context_t) ((soap)->user) @@ -211,13 +177,13 @@ SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__RecordTag( } attr[0].name = in->tag->name; - if (in->tag->value->string) { - attr[0].value = in->tag->value->string; + if (GSOAP_STRING(in->tag->value)) { + attr[0].value = GSOAP_STRING(in->tag->value); attr[0].binary = 0; } else { - attr[0].value = in->tag->value->blob->__ptr; - attr[0].size = in->tag->value->blob->__size; + attr[0].value = GSOAP_BLOB(in->tag->value)->__ptr; + attr[0].size = GSOAP_BLOB(in->tag->value)->__size; attr[0].binary = 1; } attr[0].origin = GLITE_JP_ATTR_ORIG_USER; @@ -270,16 +236,16 @@ err: static void s2jp_qval(const struct jptype__stringOrBlob *in, char **value, int *binary, size_t *size) { - if (in->string) { - *value = in->string; + if (GSOAP_STRING(in)) { + *value = GSOAP_STRING(in); *binary = 0; *size = 0; } else { - assert(in->blob); /* XXX: should report error instead */ - *value = in->blob->__ptr; + assert(GSOAP_BLOB(in)); /* XXX: should report error instead */ + *value = GSOAP_BLOB(in)->__ptr; *binary = 1; - *size = in->blob->__size; + *size = GSOAP_BLOB(in)->__size; } } diff --git a/org.glite.jp.primary/src/soap_util.c b/org.glite.jp.primary/src/soap_util.c index eebbd1a..4f5e108 100644 --- a/org.glite.jp.primary/src/soap_util.c +++ b/org.glite.jp.primary/src/soap_util.c @@ -28,17 +28,17 @@ static int jp2s_attrValues( if (freeit) free(in[i].name); a->value = soap_malloc(soap,sizeof *a->value); if (in[i].binary) { - a->value->blob = soap_malloc(soap,sizeof *a->value->blob); - memset(a->value->blob,0,sizeof *a->value->blob); - a->value->blob->__ptr = soap_malloc(soap,in[i].size); - a->value->blob->__size = in[i].size; - memcpy(a->value->blob->__ptr,in[i].value,in[i].size); + GSOAP_BLOB(a->value) = soap_malloc(soap,sizeof *GSOAP_BLOB(a->value)); + memset(GSOAP_BLOB(a->value),0,sizeof *GSOAP_BLOB(a->value)); + GSOAP_BLOB(a->value)->__ptr = soap_malloc(soap,in[i].size); + GSOAP_BLOB(a->value)->__size = in[i].size; + memcpy(GSOAP_BLOB(a->value)->__ptr,in[i].value,in[i].size); - a->value->string = NULL; + GSOAP_STRING(a->value) = NULL; } else { - a->value->string = soap_strdup(soap,in[i].value); - a->value->blob = NULL; + GSOAP_STRING(a->value) = soap_strdup(soap,in[i].value); + GSOAP_BLOB(a->value) = NULL; } if (freeit) free(in[i].value); a->origin = jp2s_origin(in[i].origin); @@ -61,10 +61,10 @@ static void attrValues_free( for (i=0; iname); - if (a[i]->value->string) soap_dealloc(soap,a[i]->value->string); - if (a[i]->value->blob) { - soap_dealloc(soap,a[i]->value->blob->__ptr); - soap_dealloc(soap,a[i]->value->blob); + if (GSOAP_STRING(a[i]->value)) soap_dealloc(soap,GSOAP_STRING(a[i]->value)); + if (GSOAP_BLOB(a[i]->value)) { + soap_dealloc(soap,GSOAP_BLOB(a[i]->value)->__ptr); + soap_dealloc(soap,GSOAP_BLOB(a[i]->value)); } soap_dealloc(soap,a[i]->value); if (a[i]->originDetail) soap_dealloc(soap,a[i]->originDetail); -- 1.8.2.3