From: Dave H. <hel...@us...> - 2013-02-20 15:48:32
|
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 "sfcb - Small Footprint CIM Broker". The branch, master has been updated via 72f7aae5e0a1a5935f1015bbb14dca46df0e6637 (commit) from 06f04db7d5038d81bc73c67ffa0e9e603410bb0e (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 72f7aae5e0a1a5935f1015bbb14dca46df0e6637 Author: Dave Heller <hel...@us...> Date: Wed Feb 20 10:44:22 2013 -0500 [#2463] getClass does not expose method information for localconnect ----------------------------------------------------------------------- Summary of changes: NEWS | 1 + constClass.c | 231 ++++++++++++++++++++++++++++++++++++++++++++++++ constClass.h | 26 ++++++ test/localtests/show.c | 122 +++++++++++++++++++++++++- 4 files changed, 379 insertions(+), 1 deletions(-) diff --git a/NEWS b/NEWS index c2ae03f..3782ea7 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,7 @@ New features: - 3599160 Add sfcbproc utility - 3601943 ObjectImpl unit test - 2766931 Property filters for interop and interopserver providers +- 2463 getClass does not expose method information for localconnect Bugs fixed: - 3599526 segfault during ecn with classProviderSf diff --git a/constClass.c b/constClass.c index d195bfc..a483255 100644 --- a/constClass.c +++ b/constClass.c @@ -259,6 +259,72 @@ getQualifierCount(CMPIConstClass * cc, CMPIStatus *rc) } CMPIData +internalGetMethQualAt(CMPIConstClass * cc, CMPICount m, CMPICount i, + CMPIString **name, CMPIStatus *rc) +{ + ClClass *cls = (ClClass *) cc->hdl; + char *n; + CMPIData rv = { 0, CMPI_notFound, {0} }; + + ClMethod *mthd = (ClMethod *) ClObjectGetClSection(&cls->hdr, &cls->methods); + if (m > cls->methods.used) + return rv; + mthd = mthd + m; + + if (ClClassGetMethQualifierAt(cls, mthd, i, &rv, name ? &n : NULL)) { + if (rc) + CMSetStatus(rc, CMPI_RC_ERR_NOT_FOUND); + if (name) + *name = sfcb_native_new_CMPIString(NULL, NULL, 0); + return rv; + } + if (rv.type == CMPI_chars) { + rv.value.string = sfcb_native_new_CMPIString(ClObjectGetClString + (&cls->hdr, + (ClString *) & rv.value. + chars), NULL, 0); + rv.type = CMPI_string; + } + if (name) { + *name = sfcb_native_new_CMPIString(n, NULL, 0); + } + if (rc) + CMSetStatus(rc, CMPI_RC_OK); + + return rv; +} + +CMPIData +internalGetMethParamAt(CMPIConstClass * cc, CMPICount m, CMPICount i, + CMPIString **name, CMPIStatus *rc) +{ + ClClass *cls = (ClClass *) cc->hdl; + char *n; + CMPIData rv = { 0, CMPI_notFound, {0} }; + CMPIParameter p; + + ClMethod *mthd = (ClMethod *) ClObjectGetClSection(&cls->hdr, &cls->methods); + if (m > cls->methods.used) + return rv; + mthd = mthd + m; + + if (ClClassGetMethParameterAt(cls, mthd, i, &p, name ? &n : NULL)) { + if (rc) + CMSetStatus(rc, CMPI_RC_ERR_NOT_FOUND); + if (name) + *name = sfcb_native_new_CMPIString(NULL, NULL, 0); + return rv; + } + rv.type = p.type; + if (name) { + *name = sfcb_native_new_CMPIString(n, NULL, 0); + } + if (rc) + CMSetStatus(rc, CMPI_RC_OK); + return rv; +} + +CMPIData internalGetPropQualAt(CMPIConstClass * cc, CMPICount p, CMPICount i, CMPIString **name, CMPIStatus *rc) { @@ -444,6 +510,162 @@ getKeyList(CMPIConstClass * cc) return kar; } +static CMPIData +getMethod(CMPIConstClass * cc, const char *name, CMPIStatus *rc) +{ + ClClass *cls = (ClClass *) cc->hdl; + CMPIData rv_notfound = { 0, CMPI_notFound, {0} }; + CMPIData rv; + char *mname; + CMPICount cnt = ClClassGetMethodCount(cls), + i; + unsigned long quals; + + for (i = 0; i < cnt; i++) { + if (ClClassGetMethodAt(cls, i, &rv.type, &mname, &quals)) { + if (rc) + CMSetStatus(rc, CMPI_RC_ERR_NOT_FOUND); + return rv_notfound; + } + if (strcasecmp(name, mname) == 0) { + if (rc) + CMSetStatus(rc, CMPI_RC_OK); + return rv; + }; + } + if (rc) + CMSetStatus(rc, CMPI_RC_ERR_NOT_FOUND); + return rv_notfound; +} + +static CMPIData +getMethodAt(CMPIConstClass * cc, CMPICount i, CMPIString **name, + CMPIStatus *rc) +{ + ClClass *cls = (ClClass *) cc->hdl; + char *n; + CMPIData rv = { 0, CMPI_notFound, {0} }; + unsigned long quals; + if (ClClassGetMethodAt(cls, i, &rv.type, &n, &quals)) { + if (rc) + CMSetStatus(rc, CMPI_RC_ERR_NOT_FOUND); + return rv; + } + if (name) { + *name = sfcb_native_new_CMPIString(n, NULL, 0); + } + if (rc) + CMSetStatus(rc, CMPI_RC_OK); + return rv; +} + +static CMPICount +getMethodCount(CMPIConstClass * cc, CMPIStatus *rc) +{ + ClClass *cls = (ClClass *) cc->hdl; + if (rc) + CMSetStatus(rc, CMPI_RC_OK); + return (CMPICount) ClClassGetMethodCount(cls); +} + +static CMPIData +getMethodQualifier(CMPIConstClass * cc, const char *meth, const char *cmq, + CMPIStatus *rc) +{ + ClClass *cls = (ClClass *) cc->hdl; + ClSection *mths = &cls->methods; + CMPIData rv_notFound = { 0, CMPI_notFound, {0} }; + CMPIData rv; + CMPICount m = ClClassLocateMethod(&cls->hdr, mths, meth); + CMPICount num = ClClassGetMethQualifierCount(cls, m - 1); + CMPICount i; + CMPIString *name; + + for (i = 0; i < num; i++) { + rv = internalGetMethQualAt(cc, m - 1, i, &name, rc); + + if (strcasecmp(cmq, (char*)name->hdl) == 0) { + if (rc) + CMSetStatus(rc, CMPI_RC_OK); + return rv; + } + } + if (rc) + CMSetStatus(rc, CMPI_RC_ERR_NOT_FOUND); + return rv_notFound; +} + +static CMPIData +getMethodQualifierAt(CMPIConstClass * cc, const char *meth, CMPICount i, + CMPIString **name, CMPIStatus *rc) +{ + ClClass *cls = (ClClass *) cc->hdl; + ClSection *mths = &cls->methods; + CMPICount m = ClClassLocateMethod(&cls->hdr, mths, meth); + return internalGetMethQualAt(cc, m - 1, i, name, rc); +} + +static CMPICount +getMethodQualifierCount(CMPIConstClass * cc, const char *meth, + CMPIStatus *rc) +{ + ClClass *cls = (ClClass *) cc->hdl; + ClSection *mths = &cls->methods; + CMPICount m = ClClassLocateMethod(&cls->hdr, mths, meth); + if (rc) + CMSetStatus(rc, CMPI_RC_OK); + return ClClassGetMethQualifierCount(cls, m - 1); +} + +static CMPIData +getMethodParameter(CMPIConstClass * cc, const char *meth, const char *cmq, + CMPIStatus *rc) +{ + ClClass *cls = (ClClass *) cc->hdl; + ClSection *mths = &cls->methods; + CMPIData rv_notFound = { 0, CMPI_notFound, {0} }; + CMPIData rv; + CMPICount m = ClClassLocateMethod(&cls->hdr, mths, meth); + CMPICount num = ClClassGetMethParameterCount(cls, m - 1); + CMPICount i; + CMPIString *name; + + for (i = 0; i < num; i++) { + rv = internalGetMethParamAt(cc, m - 1, i, &name, rc); + + if (strcasecmp(cmq, (char*)name->hdl) == 0) { + if (rc) + CMSetStatus(rc, CMPI_RC_OK); + return rv; + } + } + if (rc) + CMSetStatus(rc, CMPI_RC_ERR_NOT_FOUND); + return rv_notFound; +} + +static CMPIData +getMethodParameterAt(CMPIConstClass * cc, const char *meth, CMPICount i, + CMPIString **name, CMPIStatus *rc) +{ + ClClass *cls = (ClClass *) cc->hdl; + ClSection *mths = &cls->methods; + CMPICount m = ClClassLocateMethod(&cls->hdr, mths, meth); + return internalGetMethParamAt(cc, m - 1, i, name, rc); +} + +static CMPICount +getMethodParameterCount(CMPIConstClass * cc, const char *meth, + CMPIStatus *rc) +{ + ClClass *cls = (ClClass *) cc->hdl; + ClSection *mths = &cls->methods; + CMPICount m = ClClassLocateMethod(&cls->hdr, mths, meth); + if (rc) + CMSetStatus(rc, CMPI_RC_OK); + return ClClassGetMethParameterCount(cls, m - 1); +} + struct _CMPIConstClass_FT ift = { 1, release, @@ -458,6 +680,15 @@ struct _CMPIConstClass_FT ift = { getPropQualifier, getPropQualifierAt, getPropQualifierCount, + getMethod, + getMethodAt, + getMethodCount, + getMethodParameter, + getMethodParameterAt, + getMethodParameterCount, + getMethodQualifier, + getMethodQualifierAt, + getMethodQualifierCount, getSuperClassName, getKeyList, toString, diff --git a/constClass.h b/constClass.h index 3924fa9..a8933ab 100644 --- a/constClass.h +++ b/constClass.h @@ -77,6 +77,32 @@ struct _CMPIConstClass_FT { const char *prop, CMPIStatus *rc); + CMPIData (*getMethod) (CMPIConstClass * cc, const char *name, + CMPIStatus* rc); + CMPIData (*getMethodAt) (CMPIConstClass * cc, CMPICount i, + CMPIString** name, CMPIStatus* rc); + CMPICount (*getMethodCount) (CMPIConstClass * cc, CMPIStatus* rc); + + CMPIData (*getMethodParameter) (CMPIConstClass * cc, const char *mname, + const char *pname, CMPIStatus* rc); + CMPIData (*getMethodParameterAt) (CMPIConstClass * cc, + const char *mname, + unsigned int index, + CMPIString** name, CMPIStatus* rc); + CMPICount (*getMethodParameterCount) (CMPIConstClass * cc, + const char *mname, + CMPIStatus* rc); + + CMPIData (*getMethodQualifier) (CMPIConstClass * cc, const char *mname, + const char *qname, CMPIStatus* rc); + CMPIData (*getMethodQualifierAt) (CMPIConstClass * cc, + const char *mname, + unsigned int index, + CMPIString** name, CMPIStatus* rc); + CMPICount (*getMethodQualifierCount) (CMPIConstClass * cc, + const char *mname, + CMPIStatus* rc); + /* * local functions for sfcb */ diff --git a/test/localtests/show.c b/test/localtests/show.c index 6c51a64..04acb14 100644 --- a/test/localtests/show.c +++ b/test/localtests/show.c @@ -1,6 +1,7 @@ #include "CimClientLib/cmci.h" #include "CimClientLib/native.h" #include <unistd.h> +#include <stdlib.h> #include <string.h> #include "show.h" @@ -177,12 +178,41 @@ showInstance(CMPIInstance *instance) 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_ARRAY | CMPI_chars)) return "ARRAY of chars"; + if (type == (CMPI_ARRAY | CMPI_string)) return "ARRAY of strings"; + if (type & (CMPI_INTEGER | CMPI_REAL)) return "numeric"; + if (type & CMPI_chars) return "chars"; + if (type & 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) { @@ -218,6 +248,96 @@ 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 (%s)\n", (char *) qualifiername->hdl, + type2Chars(data.type)); + } + else { + cv = value2Chars(data.type, &data.value); + printf("\t\t%s (%s)=\"%.60s%s\n", (char *) qualifiername->hdl, + type2Chars(data.type), 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); } hooks/post-receive -- sfcb - Small Footprint CIM Broker |