|
From: Dave H. <hel...@us...> - 2013-02-07 23:28:04
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "SFCC - Small Footprint CIM Client".
The branch, master has been updated
via 1f82c33791fe33739a57cfcd511845918ac415bc (commit)
from 2e796d9319081edd29e8553107b932e133e6a9fc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 1f82c33791fe33739a57cfcd511845918ac415bc
Author: Dave Heller <hel...@us...>
Date: Thu Feb 7 18:04:53 2013 -0500
[ 3529678 ] getClass does not expose method information
-----------------------------------------------------------------------
Summary of changes:
diff --git a/Makefile.am b/Makefile.am
index dbb4977..e6ab239 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -89,7 +89,9 @@ libcimcClientXML_la_SOURCES = \
backend/cimxml/instance.c \
backend/cimxml/indicationlistener.c \
backend/cimxml/constClass.c \
+ backend/cimxml/method.c \
backend/cimxml/objectpath.c \
+ backend/cimxml/parameter.c \
backend/cimxml/property.c \
backend/cimxml/qualifier.c \
backend/cimxml/string.c \
diff --git a/NEWS b/NEWS
index 3736862..e833da5 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,9 @@ Small Footprint CIM Client Library NEWS
Changes in 2.2.6
================
+New Features:
+- 3529678 getClass does not expose method information
+
Bugs:
Changes in 2.2.5
diff --git a/TEST/show.c b/TEST/show.c
index 0621133..6deb23d 100755
--- a/TEST/show.c
+++ b/TEST/show.c
@@ -199,12 +199,37 @@ void showInstance( CMPIInstance *instance )
if (objectpath) CMRelease(objectpath);
}
+char *type2Chars(CMPIType type)
+{
+ if (type == CMPI_boolean) return "boolean";
+ if (type == CMPI_dateTime) return "datetime";
+ if (type == CMPI_uint8) return "uint8";
+ if (type == CMPI_uint16) return "uint16";
+ if (type == CMPI_uint32) return "uint32";
+ if (type == CMPI_uint64) return "uint64";
+ if (type == CMPI_sint8) return "sint8";
+ if (type == CMPI_sint16) return "sint16";
+ if (type == CMPI_sint32) return "sint32";
+ if (type == CMPI_sint64) return "sint64";
+ if (type == CMPI_real32) return "real32";
+ if (type == CMPI_real64) return "real64";
+ if (type & (CMPI_INTEGER | CMPI_REAL)) return "numeric";
+ if (type & (CMPI_chars | CMPI_string)) return "string";
+ // TODO: handle remaining types
+#define SBUFLEN 32
+ char str[SBUFLEN];
+ snprintf(str, SBUFLEN, "unknown [CMPIType=%d]", (unsigned short) type);
+ return strdup(str);
+}
void showClass( CMPIConstClass * class )
{
CMPIString * classname = class->ft->getClassName(class, NULL);
int numproperties = class->ft->getPropertyCount(class, NULL);
- int i;
+ int numqualifiers = class->ft->getQualifierCount(class, NULL);
+ int nummethods = class->ft->getMethodCount(class, NULL);
+ int numparameters;
+ int i, j;
char *cv;
if (classname && classname->hdl)
@@ -239,6 +264,88 @@ void showClass( CMPIConstClass * class )
}
}
+ if (numqualifiers)
+ {
+ printf("qualifiers:\n");
+ for (i=0; i<numqualifiers; i++)
+ {
+ CMPIString * qualifiername;
+ CMPIData data = class->ft->getQualifierAt(class, i, &qualifiername, NULL);
+
+ if (data.state==0)
+ {
+ cv = value2Chars(data.type, &data.value);
+ printf("\t%s=\"%.60s%s\n", (char *) qualifiername->hdl, cv,
+ (strlen(cv) > 60) ? "...\"" : "\"");
+ if(cv) free(cv);
+ }
+ else
+ printf("\t%s=NIL\n", (char *)qualifiername->hdl);
+
+ if (qualifiername) CMRelease(qualifiername);
+ }
+ }
+
+ if (nummethods)
+ {
+ printf("methods:\n");
+ for (i=0; i<nummethods; i++)
+ {
+ CMPIString * methodname;
+ CMPIData data = class->ft->getMethodAt(class, i, &methodname, NULL);
+
+ printf("\tMethod=%s (%s)\n", (char *)methodname->hdl, type2Chars(data.type));
+
+ numparameters = class->ft->getMethodParameterCount(class, (char *)methodname->hdl, NULL);
+
+ if (numparameters)
+ {
+ printf("\tmethod parameters:\n");
+ for (j=0; j<numparameters; j++)
+ {
+ CMPIString * parametername;
+ CMPIData data = class->ft->getMethodParameterAt(class, (char *)methodname->hdl, j, ¶metername, NULL);
+
+ printf("\t\t%s (%s)\n", (char *)parametername->hdl, type2Chars(data.type));
+
+ if (parametername) CMRelease(parametername);
+ }
+ }
+
+ numqualifiers = class->ft->getMethodQualifierCount(class, (char *)methodname->hdl, NULL);
+
+ if (numqualifiers)
+ {
+ printf("\tmethod qualifiers:\n");
+ for (j=0; j<numqualifiers; j++)
+ {
+ CMPIString * qualifiername;
+ CMPIData data = class->ft->getMethodQualifierAt(class, (char *)methodname->hdl, j, &qualifiername, NULL);
+
+ if (data.state==0)
+ {
+ if (data.type & CMPI_ARRAY) {
+ // TODO: properly print array values here
+ printf("\t\t%s=ARRAY\n", (char *)qualifiername->hdl);
+ }
+ else {
+ cv = value2Chars(data.type, &data.value);
+ printf("\t\t%s=\"%.60s%s\n", (char *) qualifiername->hdl, cv,
+ (strlen(cv) > 60) ? "...\"" : "\"");
+ if(cv) free(cv);
+ }
+ }
+ else
+ printf("\t\t%s=NIL\n", (char *)qualifiername->hdl);
+
+ if (qualifiername) CMRelease(qualifiername);
+ }
+ }
+
+ if (methodname) CMRelease(methodname);
+ }
+ }
+
if (classname) CMRelease(classname);
}
diff --git a/backend/cimxml/constClass.c b/backend/cimxml/constClass.c
index c149fdf..9cd04ad 100644
--- a/backend/cimxml/constClass.c
+++ b/backend/cimxml/constClass.c
@@ -36,14 +36,6 @@
/****************************************************************************/
-extern CMPIConstClass * native_new_CMPIConstClass ( char *cn,
- CMPIStatus * rc );
-extern int addClassProperty( CMPIConstClass * ccls, char * name,
- CMPIValue * value, CMPIType type,
- CMPIValueState state);
-
-/****************************************************************************/
-
static CMPIStatus __ccft_release ( CMPIConstClass * ccls )
{
@@ -54,6 +46,7 @@ static CMPIStatus __ccft_release ( CMPIConstClass * ccls )
free ( cc->classname );
propertyFT.release ( cc->props );
qualifierFT.release ( cc->qualifiers );
+ methodFT.release ( cc->methods );
free ( cc );
CMReturn ( CMPI_RC_OK );
@@ -73,6 +66,7 @@ static CMPIConstClass * __ccft_clone ( CMPIConstClass * ccls, CMPIStatus * rc )
new->classname = strdup ( cc->classname );
new->qualifiers= qualifierFT.clone ( cc->qualifiers, rc );
new->props = propertyFT.clone ( cc->props, rc );
+ new->methods = methodFT.clone ( cc->methods, rc );
return (CMPIConstClass *) new;
}
@@ -183,7 +177,112 @@ static unsigned int __ccft_getPropertyQualifierCount ( CMPIConstClass * ccls,
return 0;
}
+static CMPIData __ccft_getMethod ( CMPIConstClass * ccls,
+ const char * name,
+ CMPIStatus * rc )
+{
+ struct native_constClass * c = (struct native_constClass *) ccls;
+
+ return methodFT.getDataMethod ( c->methods, name, rc );
+}
+
+static CMPIData __ccft_getMethodAt ( CMPIConstClass * ccls,
+ unsigned int index,
+ CMPIString ** name,
+ CMPIStatus * rc )
+{
+ struct native_constClass * c = (struct native_constClass *) ccls;
+
+ return methodFT.getDataMethodAt ( c->methods, index, name, rc );
+}
+
+static unsigned int __ccft_getMethodCount ( CMPIConstClass * ccls,
+ CMPIStatus * rc )
+{
+ struct native_constClass * c = (struct native_constClass *) ccls;
+
+ return methodFT.getMethodCount ( c->methods, rc );
+}
+
+static CMPIData __ccft_getMethodQualifier ( CMPIConstClass * ccls,
+ const char * mname, const char *qname,
+ CMPIStatus * rc )
+{
+ struct native_constClass * c = (struct native_constClass *) ccls;
+ struct native_method *m=methodFT.getMethod ( c->methods, mname );
+
+ if (m) return qualifierFT.getDataQualifier ( m->qualifiers, qname, rc );
+ CMSetStatus ( rc, CMPI_RC_ERR_METHOD_NOT_FOUND );
+ CMPIData ret = { 0, CMPI_nullValue, {0} };
+ return ret;
+}
+
+static CMPIData __ccft_getMethodQualifierAt ( CMPIConstClass * ccls,
+ const char * mname,
+ unsigned int index,
+ CMPIString ** name,
+ CMPIStatus * rc )
+{
+ struct native_constClass * c = (struct native_constClass *) ccls;
+ struct native_method *m=methodFT.getMethod ( c->methods, mname );
+ if (m) return qualifierFT.getDataQualifierAt ( m->qualifiers, index, name, rc );
+ CMSetStatus ( rc, CMPI_RC_ERR_METHOD_NOT_FOUND );
+ CMPIData ret= { 0, CMPI_nullValue, {0} };
+ return ret;
+}
+
+static unsigned int __ccft_getMethodQualifierCount ( CMPIConstClass * ccls,
+ const char * mname,
+ CMPIStatus * rc )
+{
+ struct native_constClass * c = (struct native_constClass *) ccls;
+ struct native_method *m=methodFT.getMethod ( c->methods, mname );
+
+ if (m) return qualifierFT.getQualifierCount ( m->qualifiers, rc );
+ CMSetStatus ( rc, CMPI_RC_ERR_METHOD_NOT_FOUND );
+ return 0;
+}
+
+static CMPIData __ccft_getMethodParameter ( CMPIConstClass * ccls,
+ const char * mname, const char *pname,
+ CMPIStatus * rc )
+{
+ struct native_constClass * c = (struct native_constClass *) ccls;
+ struct native_method *m=methodFT.getMethod ( c->methods, mname );
+
+ if (m) return parameterFT.getDataParameter ( m->parameters, pname, rc );
+ CMSetStatus ( rc, CMPI_RC_ERR_METHOD_NOT_FOUND );
+ CMPIData ret = { 0, CMPI_nullValue, {0} };
+ return ret;
+}
+
+static CMPIData __ccft_getMethodParameterAt ( CMPIConstClass * ccls,
+ const char * mname,
+ unsigned int index,
+ CMPIString ** name,
+ CMPIStatus * rc )
+{
+ struct native_constClass * c = (struct native_constClass *) ccls;
+ struct native_method *m=methodFT.getMethod ( c->methods, mname );
+
+ if (m) return parameterFT.getDataParameterAt ( m->parameters, index, name, rc );
+ CMSetStatus ( rc, CMPI_RC_ERR_METHOD_NOT_FOUND );
+ CMPIData ret= { 0, CMPI_nullValue, {0} };
+ return ret;
+}
+
+static unsigned int __ccft_getMethodParameterCount ( CMPIConstClass * ccls,
+ const char * mname,
+ CMPIStatus * rc )
+{
+ struct native_constClass * c = (struct native_constClass *) ccls;
+ struct native_method *m=methodFT.getMethod ( c->methods, mname );
+
+ if (m) return parameterFT.getParameterCount ( m->parameters, rc );
+ CMSetStatus ( rc, CMPI_RC_ERR_METHOD_NOT_FOUND );
+ return 0;
+}
@@ -197,12 +296,21 @@ CMPIConstClass * native_new_CMPIConstClass ( char *cn, CMPIStatus * rc )
__ccft_getProperty,
__ccft_getPropertyAt,
__ccft_getPropertyCount,
- __ccft_getQualifier,
- __ccft_getQualifierAt,
- __ccft_getQualifierCount,
- __ccft_getPropertyQualifier,
- __ccft_getPropertyQualifierAt,
- __ccft_getPropertyQualifierCount
+ __ccft_getQualifier,
+ __ccft_getQualifierAt,
+ __ccft_getQualifierCount,
+ __ccft_getPropertyQualifier,
+ __ccft_getPropertyQualifierAt,
+ __ccft_getPropertyQualifierCount,
+ __ccft_getMethod,
+ __ccft_getMethodAt,
+ __ccft_getMethodCount,
+ __ccft_getMethodParameter,
+ __ccft_getMethodParameterAt,
+ __ccft_getMethodParameterCount,
+ __ccft_getMethodQualifier,
+ __ccft_getMethodQualifierAt,
+ __ccft_getMethodQualifierCount
};
static CMPIConstClass cc = {
"CMPIConstClass",
@@ -286,8 +394,71 @@ int addClassPropertyQualifier( CMPIConstClass* cc, char * pname, char *qname,
return ( CMPI_RC_OK );
}
return CMPI_RC_ERR_NO_SUCH_PROPERTY;
-}
-
+}
+
+int addClassMethod( CMPIConstClass * cc,
+ char * name,
+ CMPIValue * value,
+ CMPIType type,
+ CMPIValueState state)
+{
+ struct native_constClass * c = (struct native_constClass *) cc;
+
+ if ( methodFT.setMethod ( c->methods,
+ name,
+ type,
+ value ) ) {
+ methodFT.addMethod ( &c->methods,
+ name,
+ type,
+ state,
+ value );
+ }
+ return ( CMPI_RC_OK );
+}
+
+int addClassMethodQualifier( CMPIConstClass* cc, char * mname, char *qname,
+ CMPIValue * value,
+ CMPIType type)
+{
+ struct native_constClass * c = (struct native_constClass *) cc;
+ struct native_method *m=methodFT.getMethod ( c->methods, mname );
+
+ if (m) {
+ if ( qualifierFT.setQualifier ( m->qualifiers,
+ qname,
+ type,
+ value ) ) {
+ qualifierFT.addQualifier ( &m->qualifiers,
+ qname,
+ type,
+ 0,
+ value );
+ }
+ return ( CMPI_RC_OK );
+ }
+ return CMPI_RC_ERR_METHOD_NOT_FOUND;
+}
+
+int addClassMethodParameter( CMPIConstClass* cc, char * mname, char *pname,
+ CMPIType type)
+{
+ struct native_constClass * c = (struct native_constClass *) cc;
+ struct native_method *m=methodFT.getMethod ( c->methods, mname );
+
+ if (m) {
+ if ( parameterFT.setParameter ( m->parameters,
+ pname,
+ type ) ) {
+ parameterFT.addParameter ( &m->parameters,
+ pname,
+ type );
+ }
+ return ( CMPI_RC_OK );
+ }
+ return CMPI_RC_ERR_METHOD_NOT_FOUND;
+}
+
/****************************************************************************/
/*** Local Variables: ***/
diff --git a/backend/cimxml/grammar.c b/backend/cimxml/grammar.c
index d109421..9e543c9 100644
--- a/backend/cimxml/grammar.c
+++ b/backend/cimxml/grammar.c
@@ -431,6 +431,7 @@ static void iReturnValueContent(ParserControl *parm, parseUnion *stateUnion)
cls = native_new_CMPIConstClass(lvalp.xtokClass.className,NULL);
setClassQualifiers(cls, &lvalp.xtokClass.qualifiers);
setClassProperties(cls, &lvalp.xtokClass.properties);
+ setClassMethods(cls, &lvalp.xtokClass.methods);
simpleArrayAdd(parm->respHdr.rvArray,(CMPIValue*)&cls,CMPI_class);
ct = localLex(&lvalp, parm);
}
@@ -701,6 +702,7 @@ static void method(ParserControl *parm, parseUnion *stateUnion)
do {
dontLex = 1;
methodData(parm, (parseUnion*)&lvalp.xtokMethodData);
+ addParam(parm,&stateUnion->xtokMethod.params,&lvalp.xtokParam);
ct = localLex(&lvalp, parm);
}
while(ct == XTOK_PARAM || ct == XTOK_PARAMREF || ct == XTOK_PARAMARRAY || ct == XTOK_PARAMREFARRAY);
diff --git a/backend/cimxml/method.c b/backend/cimxml/method.c
new file mode 100644
index 0000000..3a3199c
--- /dev/null
+++ b/backend/cimxml/method.c
@@ -0,0 +1,254 @@
+/*!
+ \file method.c
+ \brief Native method implementation.
+
+ This module implements a native method, which is not public to any
+ provider programmer. It is used to implement various other data types
+ natively, such as instances, object-paths and args.
+
+ It provides means to maintain linked lists of named methods including
+ functionality to add, remove, clone and release them.
+
+ (C) Copyright IBM Corp. 2013
+
+ THIS FILE IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE
+ ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE
+ CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT.
+
+ You can obtain a current copy of the Eclipse Public License from
+ http://www.opensource.org/licenses/eclipse-1.0.php
+
+ \author Frank Scheffler
+ $Revision: 1.3 $
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "cmcidt.h"
+#include "cmcift.h"
+#include "cmcimacs.h"
+#include "native.h"
+
+#ifdef DMALLOC
+#include "dmalloc.h"
+#endif
+
+//! Storage container for commonly needed data within native CMPI data types.
+/*!
+ This structure is used to build linked lists of data containers as needed
+ for various native data types.
+*/
+// struct native_method {} // defined in frontend/sfcc/native.h
+
+/****************************************************************************/
+
+static CMPIData __convert2CMPIData(struct native_method * meth,
+ CMPIString ** methname) {
+
+ CMPIData result = { 0, CMPI_nullValue, { 0 } };
+
+ if (meth != NULL) {
+ result.type = meth->type;
+ result.state = meth->state;
+ result.value = meth->value;
+
+ if (methname) {
+ *methname = native_new_CMPIString(meth->name, NULL);
+ }
+ }
+ return result;
+}
+
+
+/**
+ * returns non-zero if already existent
+ */
+static int __addMethod(struct native_method ** meth, const char * name,
+ CMPIType type, CMPIValueState state,
+ CMPIValue * value) {
+
+ CMPIStatus rc;
+
+ if (*meth == NULL) {
+ struct native_method * tmp = *meth = (struct native_method *) calloc(1,
+ sizeof(struct native_method));
+
+ tmp->name = strdup(name);
+ tmp->type = type;
+ tmp->state = state;
+
+ if (type != CMPI_null && state != CMPI_nullValue) {
+ if (type == CMPI_chars) {
+ tmp->type = CMPI_string;
+ tmp->value.string = native_new_CMPIString((char *) value, &rc);
+ } else
+ tmp->value = native_clone_CMPIValue(type, value, &rc);
+ } else {
+ tmp->state = CMPI_nullValue;
+ tmp->value.uint64 = 0;
+ }
+ return 0;
+ }
+ return (strcasecmp((*meth)->name, name) == 0
+ || __addMethod(&((*meth)->next), name, type, state, value));
+}
+
+
+/**
+ * returns -1 if non-existent
+ */
+static int __setMethod(struct native_method * meth, const char * name,
+ CMPIType type, CMPIValue * value) {
+
+ CMPIStatus rc;
+
+ if (meth == NULL)
+ return -1;
+
+ if (strcasecmp(meth->name, name) == 0) {
+
+ if (!(meth->state & CMPI_nullValue))
+ native_release_CMPIValue(meth->type, &meth->value);
+
+ meth->type = type;
+ if (type == CMPI_chars) {
+ meth->type = CMPI_string;
+ meth->value.string = native_new_CMPIString((char *) value, &rc);
+ } else {
+ if (type != CMPI_null)
+ meth->value = native_clone_CMPIValue(type, value, &rc);
+ else
+ meth->state = CMPI_nullValue;
+ }
+ return 0;
+ }
+ return __setMethod(meth->next, name, type, value);
+}
+
+
+static struct native_method * __getMethod(struct native_method * meth,
+ const char * name) {
+
+ if (!meth || !name) {
+ return NULL;
+ }
+
+ return
+ (strcasecmp(meth->name, name) == 0) ? meth : __getMethod(meth->next, name);
+}
+
+
+static CMPIData __getDataMethod(struct native_method * meth, const char * name,
+ CMPIStatus * rc) {
+
+ struct native_method * m = __getMethod(meth, name);
+
+ CMSetStatus( rc, ( m ) ? CMPI_RC_OK : CMPI_RC_ERR_FAILED);
+
+ return __convert2CMPIData(m, NULL);
+}
+
+
+static struct native_method * __getMethodAt(struct native_method * meth,
+ unsigned int pos) {
+
+ if (!meth)
+ return NULL;
+
+ return (pos == 0) ? meth : __getMethodAt(meth->next, --pos);
+}
+
+
+static CMPIData __getDataMethodAt(struct native_method * meth, unsigned int pos,
+ CMPIString ** methname, CMPIStatus * rc) {
+
+ struct native_method * m = __getMethodAt(meth, pos);
+
+ CMSetStatus( rc, ( m ) ? CMPI_RC_OK : CMPI_RC_ERR_METHOD_NOT_FOUND);
+
+ return __convert2CMPIData(m, methname);
+}
+
+
+static CMPICount __getMethodCount(struct native_method * meth, CMPIStatus * rc) {
+ CMPICount c = 0;
+
+ CMSetStatus(rc, CMPI_RC_OK);
+
+ while (meth != NULL) {
+ c++;
+ meth = meth->next;
+ }
+ return c;
+}
+
+
+static void __release(struct native_method * meth) {
+
+ struct native_method *next;
+
+ for (; meth; meth = next) {
+ free(meth->name);
+ if(meth->state != CMPI_nullValue)
+ native_release_CMPIValue (meth->type, &meth->value);
+ parameterFT.release(meth->parameters);
+ qualifierFT.release(meth->qualifiers);
+ next = meth->next;
+ free(meth);
+ }
+}
+
+
+static struct native_method * __clone(struct native_method * meth,
+ CMPIStatus * rc) {
+
+ struct native_method * result;
+ CMPIStatus tmp;
+
+ if (meth == NULL) {
+ CMSetStatus( rc, CMPI_RC_OK);
+ return NULL;
+ }
+
+ result = (struct native_method *) calloc(1, sizeof(struct native_method));
+
+ result->name = strdup(meth->name);
+ result->type = meth->type;
+ result->state = meth->state;
+ result->value = native_clone_CMPIValue(meth->type, &meth->value, &tmp);
+
+ if (tmp.rc != CMPI_RC_OK)
+ result->state = CMPI_nullValue;
+
+ result->parameters = parameterFT.clone ( meth->parameters, rc );
+ result->qualifiers = qualifierFT.clone ( meth->qualifiers, rc );
+
+ result->next = __clone(meth->next, rc);
+ return result;
+}
+
+
+/**
+ * Global function table to access native_method helper functions.
+ */
+struct native_methodFT const methodFT = {
+ NATIVE_FT_VERSION,
+ __release,
+ __clone,
+ __getMethod,
+ __addMethod,
+ __setMethod,
+ __getDataMethod,
+ __getDataMethodAt,
+ __getMethodCount
+};
+
+
+
+/****************************************************************************/
+
+/*** Local Variables: ***/
+/*** mode: C ***/
+/*** c-basic-offset: 8 ***/
+/*** End: ***/
diff --git a/backend/cimxml/parameter.c b/backend/cimxml/parameter.c
new file mode 100644
index 0000000..6fb49f6
--- /dev/null
+++ b/backend/cimxml/parameter.c
@@ -0,0 +1,229 @@
+/*!
+ \file parameter.c
+ \brief Native parameter implementation.
+
+ This module implements a native parameter, which is not public to any
+ provider programmer. It is used to implement various other data types
+ natively, such as instances, object-paths and args.
+
+ It provides means to maintain linked lists of named parameters including
+ functionality to add, remove, clone and release them.
+
+ (C) Copyright IBM Corp. 2013
+
+ THIS FILE IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE
+ ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE
+ CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT.
+
+ You can obtain a current copy of the Eclipse Public License from
+ http://www.opensource.org/licenses/eclipse-1.0.php
+
+ \author Frank Scheffler
+ $Revision: 1.3 $
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "cmcidt.h"
+#include "cmcift.h"
+#include "cmcimacs.h"
+#include "native.h"
+
+#ifdef DMALLOC
+#include "dmalloc.h"
+#endif
+
+//! Storage container for commonly needed data within native CMPI data types.
+/*!
+ This structure is used to build linked lists of data containers as needed
+ for various native data types.
+*/
+// struct native_parameter {} // defined in frontend/sfcc/native.h
+
+/****************************************************************************/
+
+static CMPIData __convert2CMPIData(struct native_parameter * param,
+ CMPIString ** paramname) {
+
+ CMPIData result = { 0, CMPI_nullValue, { 0 } };
+
+ if (param != NULL) {
+ result.type = param->type;
+ result.state = param->state;
+ result.value = param->value;
+
+ if (paramname) {
+ *paramname = native_new_CMPIString(param->name, NULL);
+ }
+ }
+ return result;
+}
+
+
+/**
+ * returns non-zero if already existent
+ */
+static int __addParameter(struct native_parameter ** param, const char * name,
+ CMPIType type) {
+
+ CMPIStatus rc;
+
+ if (*param == NULL) {
+ struct native_parameter * tmp = *param = (struct native_parameter *) calloc(1,
+ sizeof(struct native_parameter));
+
+ tmp->name = strdup(name);
+ tmp->type = type;
+
+ return 0;
+ }
+ return (strcasecmp((*param)->name, name) == 0
+ || __addParameter(&((*param)->next), name, type));
+}
+
+
+/**
+ * returns -1 if non-existent
+ */
+static int __setParameter(struct native_parameter * param, const char * name,
+ CMPIType type) {
+
+ CMPIStatus rc;
+
+ if (param == NULL)
+ return -1;
+
+ if (strcasecmp(param->name, name) == 0) {
+
+ if (!(param->state & CMPI_nullValue))
+ native_release_CMPIValue(param->type, ¶m->value);
+
+ param->type = type;
+
+ return 0;
+ }
+ return __setParameter(param->next, name, type);
+}
+
+
+static struct native_parameter * __getParameter(struct native_parameter * param,
+ const char * name) {
+
+ if (!param || !name) {
+ return NULL;
+ }
+
+ return
+ (strcasecmp(param->name, name) == 0) ? param : __getParameter(param->next, name);
+}
+
+
+static CMPIData __getDataParameter(struct native_parameter * param, const char * name,
+ CMPIStatus * rc) {
+
+ struct native_parameter * p = __getParameter(param, name);
+
+ CMSetStatus( rc, ( p ) ? CMPI_RC_OK : CMPI_RC_ERR_FAILED);
+
+ return __convert2CMPIData(p, NULL);
+}
+
+
+static struct native_parameter * __getParameterAt(struct native_parameter * param,
+ unsigned int pos) {
+
+ if (!param)
+ return NULL;
+
+ return (pos == 0) ? param : __getParameterAt(param->next, --pos);
+}
+
+
+static CMPIData __getDataParameterAt(struct native_parameter * param, unsigned int pos,
+ CMPIString ** paramname, CMPIStatus * rc) {
+
+ struct native_parameter * p = __getParameterAt(param, pos);
+
+ CMSetStatus( rc, ( p ) ? CMPI_RC_OK : CMPI_RC_ERR_NOT_FOUND);
+
+ return __convert2CMPIData(p, paramname);
+}
+
+
+static CMPICount __getParameterCount(struct native_parameter * param, CMPIStatus * rc) {
+ CMPICount c = 0;
+
+ CMSetStatus(rc, CMPI_RC_OK);
+
+ while (param != NULL) {
+ c++;
+ param = param->next;
+ }
+ return c;
+}
+
+
+static void __release(struct native_parameter * param) {
+
+ struct native_parameter *next;
+
+ for (; param; param = next) {
+ free(param->name);
+ if(param->state != CMPI_nullValue)
+ native_release_CMPIValue(param->type, ¶m->value);
+ next = param->next;
+ free(param);
+ }
+}
+
+
+static struct native_parameter * __clone(struct native_parameter * param,
+ CMPIStatus * rc) {
+
+ struct native_parameter * result;
+ CMPIStatus tmp;
+
+ if (param == NULL) {
+ CMSetStatus( rc, CMPI_RC_OK);
+ return NULL;
+ }
+
+ result = (struct native_parameter *) calloc(1, sizeof(struct native_parameter));
+
+ result->name = strdup(param->name);
+ result->type = param->type;
+ result->state = param->state;
+ result->value = native_clone_CMPIValue(param->type, ¶m->value, &tmp);
+
+ if (tmp.rc != CMPI_RC_OK)
+ result->state = CMPI_nullValue;
+
+ result->next = __clone(param->next, rc);
+ return result;
+}
+
+
+/**
+ * Global function table to access native_parameter helper functions.
+ */
+struct native_parameterFT const parameterFT = {
+ NATIVE_FT_VERSION,
+ __release,
+ __clone,
+ __getParameter, // added this... need it, or just use the getDataParameterX funcs...?
+ __addParameter,
+ __setParameter,
+ __getDataParameter,
+ __getDataParameterAt,
+ __getParameterCount
+};
+
+
+
+/****************************************************************************/
+
+/*** Local Variables: ***/
+/*** mode: C ***/
+/*** c-basic-offset: 8 ***/
+/*** End: ***/
diff --git a/backend/cimxml/parserUtil.c b/backend/cimxml/parserUtil.c
index cee43b0..7d1e314 100644
--- a/backend/cimxml/parserUtil.c
+++ b/backend/cimxml/parserUtil.c
@@ -1,7 +1,7 @@
/*
* $id$
*
- * © Copyright IBM Corp. 2007
+ * © Copyright IBM Corp. 2013
*
* THIS FILE IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE
* ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE
@@ -44,6 +44,15 @@ extern int addClassPropertyQualifier( CMPIConstClass* cc, char * pname,
extern int addClassQualifier( CMPIConstClass* cc, char * name,
CMPIValue * value,
CMPIType type);
+extern int addClassMethod( CMPIConstClass* cc, char * mname,
+ CMPIValue * value, CMPIType type,
+ CMPIValueState state);
+extern int addClassMethodQualifier( CMPIConstClass* cc, char * mname,
+ char *qname, CMPIValue * value,
+ CMPIType type);
+extern int addClassMethodParameter( CMPIConstClass* cc, char * mname,
+ char *pname,
+ CMPIType type);
extern char *XmlToAsciiStr(char *XmlStr);
#if DEBUG
@@ -221,6 +230,64 @@ void setInstQualifiers(CMPIInstance *ci, XtokQualifiers *qs)
}
}
+void setClassMethods(CMPIConstClass *cls, XtokMethods *ms)
+{
+ XtokMethod *nm = NULL,*m = ms ? ms->first : NULL;
+ CMPIValue val;
+ CMPIArray *arr = NULL;
+ XtokQualifier *nq,*q;
+ XtokQualifiers *qs;
+ XtokParam *np,*p;
+ XtokParams *ps;
+ int rc, n;
+
+ val.uint64=0l;
+ while (m) {
+ addClassMethod(cls, m->name, &val, m->type, CMPI_nullValue);
+
+ qs=&m->qualifiers;
+ q=qs ? qs->first : NULL;
+ n=0;
+ while (q) {
+ if (q->type & CMPI_ARRAY) {
+ CMPIType type=q->type&~CMPI_ARRAY;
+ arr = newCMPIArray(0, type, NULL);
+ int i;
+ if (q->data.array.max) {
+ for (i = 0; i < q->data.array.next; ++i) {
+ val = str2CMPIValue(type, q->data.array.values[i], NULL);
+ CMSetArrayElementAt(arr, i, &val, type);
+ native_release_CMPIValue(type,&val);
+ }
+ }
+ val.array = arr;
+ rc = addClassMethodQualifier(cls, m->name, q->name, &val, q->type);
+ native_release_CMPIValue(q->type,(CMPIValue*)&arr);
+ }
+ else {
+ val = str2CMPIValue(q->type, q->data.value.data.value, NULL);
+ rc= addClassMethodQualifier(cls, m->name, q->name, &val, q->type);
+ native_release_CMPIValue(q->type,&val);
+ }
+ ...
[truncated message content] |