From 803cd374d15d4663a2beda4d3b7b33d5ca7f7ae1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Milo=C5=A1=20Mula=C4=8D?= Date: Mon, 3 Oct 2005 15:35:10 +0000 Subject: [PATCH] indexQuery soap -> C conversion functions - not used (=not tested) yet --- org.glite.jp.index/src/ws_is_typeref.c | 108 +++++++++++++++++++++++++++++++++ org.glite.jp.index/src/ws_is_typeref.h | 6 ++ 2 files changed, 114 insertions(+) create mode 100644 org.glite.jp.index/src/ws_is_typeref.c create mode 100644 org.glite.jp.index/src/ws_is_typeref.h diff --git a/org.glite.jp.index/src/ws_is_typeref.c b/org.glite.jp.index/src/ws_is_typeref.c new file mode 100644 index 0000000..da4ed16 --- /dev/null +++ b/org.glite.jp.index/src/ws_is_typeref.c @@ -0,0 +1,108 @@ +#include +#include +#include +#include + +#include + +#include "jpis_H.h" +#include "ws_typemap.h" +#include "ws_typeref.h" + + +static void SoapToQueryOp(const enum jptype__queryOp in, glite_jp_queryop_t *out) +{ + switch ( in ) + { + case EQUAL: *out = GLITE_JP_QUERYOP_EQUAL; break; + case UNEQUAL: *out = GLITE_JP_QUERYOP_UNEQUAL; break; + case LESS: *out = GLITE_JP_QUERYOP_LESS; break; + case GREATER: *out = GLITE_JP_QUERYOP_GREATER; break; + case WITHIN: *out = GLITE_JP_QUERYOP_WITHIN; break; + case EXISTS: *out = GLITE_JP_QUERYOP_EXISTS; break; + default: assert(0); break; + } +} + +static void SoapToAttrOrig(struct soap *soap, const enum jptype__attrOrig *in, glite_jp_attr_orig_t *out) +{ + + switch ( in ) + { + case NULL: *out = GLITE_JP_ATTR_ORIG_ANY; break; + case SYSTEM: *out = GLITE_JP_ATTR_ORIG_SYSTEM; break; + case USER: *out = GLITE_JP_ATTR_ORIG_USER; break; + case FILE_: *out = GLITE_JP_ATTR_ORIG_FILE; break; + default: assert(0); break; + } +} + +static int SoapToQueryRecordVal( + struct soap *soap, + struct jptype__stringOrBlob *in, + int *binary, + size_t *size, + char **value) +{ + + assert(in); + if (value->string) { + *binary = 0; + *size = 0; + *value = strdup(value->string); + + return 0; + } + else if (value->blob) { + *binary = 1; + *size = value->blob->__size; + memcpy(*value, value->blob->__ptr, value->blob->__size); + // XXX how to handle id, type, option? + + return 0; + } + else + // malformed value + return 1; +} + + +/** + * Translate JP query condition from soap to C query_rec + * + * \param IN Soap structure + * \param OUT in glite_jp_query_rec_t query record + */ +int glite_jpis_SoapToQueryCond( + struct soap *soap, + struct jptype__indexQuery *in, + glite_jp_query_rec_t **out) +{ + glite_jp_query_rec_t *qr; + int i; + + + assert(in); assert(out); + qr = calloc(in->__sizerecord, sizeof(*qr)); + + for (i=0; i < __sizerecord; i++) { + qr[i].attr = strdup(in->attr); + SoapToQueryOpTo(in->record[i]->op, &(qr[i].op)); + + switch (qr[i].op) { + case GLITE_JP_QUERYOP_EXISTS: + break; + + case GLITE_JP_QUERYOP_WITHIN: + SoapToQueryRecordVal(in->record[i]->value2, *(qr[i].binary), + *(qr[i].size2), *(qr[i].value2)); + // fall through + default: + SoapToQueryRecordVal(in->record[i]->value, *(qr[i].binary), + *(qr[i].size), *(qr[i].value)); + break; + } + + SoapToAttrOrig(soap, in->origin, &(qr[i].origin) ); + } +} diff --git a/org.glite.jp.index/src/ws_is_typeref.h b/org.glite.jp.index/src/ws_is_typeref.h new file mode 100644 index 0000000..9f2d22f --- /dev/null +++ b/org.glite.jp.index/src/ws_is_typeref.h @@ -0,0 +1,6 @@ +#ifndef GLITE_JPIS_IS_TYPEREF_H +#define GLITE_JPIS_IS_TYPEREF_H + +int glite_jpis_SoapToQueryCond(struct soap *soap, struct jptype__indexQuery *in, glite_jp_query_rec_t **out); + +#endif -- 1.8.2.3