From: Adrian S. <a3s...@us...> - 2005-04-11 23:13:51
|
Update of /cvsroot/sblim/sfcb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1474 Modified Files: Makefile.am cimXmlParser.c cimXmlParser.h cimXmlRequest.c cimXmlRequest.h classProvider.c cmpidt.h constClass.c control.c instance.c interopProvider.c providerDrv.c providerMgr.c providerMgr.h trace.h Added Files: mrwlock.c mrwlock.h Log Message: Added mrwlock.c and mrwlock.h files Added first stage of support for createClass operation Changed all occurrences of principle to principal Added extra message indicatin which sfcb.cfg file in use Updated broker.sh to use sfcbd instead of sfcBroker --- NEW FILE: mrwlock.h --- /* * $Id: mrwlock.h,v 1.1 2005/04/11 23:13:42 a3schuur Exp $ * * (C) Copyright IBM Corp. 2003 * * THIS FILE IS PROVIDED UNDER THE TERMS OF THE COMMON 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 Common Public License from * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html * * Author: Viktor Mihajlovski <mih...@de...m> * Contributors: * * Description: Multiple Reader/Single Writer Lock * This module facilitates scalable multiple reader single writer * processing paradigms. * */ #ifndef MRWLOCK_H #define MRWLOCK_H #ifdef __cplusplus extern "C" { #endif #include <pthread.h> typedef struct _MRWLOCK { pthread_mutex_t mrw_mutex; pthread_cond_t mrw_cond; unsigned mrw_rnum; } MRWLOCK; /* Macro for stativ MRW Lock Definition */ #define MRWLOCK_DEFINE(n) MRWLOCK n={PTHREAD_MUTEX_INITIALIZER, \ PTHREAD_COND_INITIALIZER, \ 0} extern int MRWInit(MRWLOCK *mrwl); extern int MRWTerm(MRWLOCK *mrwl); extern int MReadLock(MRWLOCK *mrwl); extern int MReadUnlock(MRWLOCK *mrwl); extern int MWriteLock(MRWLOCK *mrwl); extern int MWriteUnlock(MRWLOCK *mrwl); #ifdef __cplusplus } #endif #endif Index: control.c =================================================================== RCS file: /cvsroot/sblim/sfcb/control.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- control.c 12 Mar 2005 00:43:00 -0000 1.4 +++ control.c 11 Apr 2005 23:13:41 -0000 1.5 @@ -87,12 +87,14 @@ if (fn) { strcpy(fin,fn); - } else { - strcpy(fin, SFCB_CONFDIR); - - strcat(fin, "/sfcb.cfg"); + } + else { + strcpy(fin, SFCB_CONFDIR); + strcat(fin, "/sfcb.cfg"); } + if (fin[0]=='/') printf("--- Using %s\n",fin); + else printf("--- Using ./%s\n",fin); in = fopen(fin, "r"); if (in == NULL) { fprintf(stderr, "--- %s not found\n", fin); Index: providerMgr.h =================================================================== RCS file: /cvsroot/sblim/sfcb/providerMgr.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- providerMgr.h 12 Mar 2005 00:43:00 -0000 1.2 +++ providerMgr.h 11 Apr 2005 23:13:42 -0000 1.3 @@ -143,7 +143,7 @@ void *provId; unsigned int flags; unsigned long count; // maps to MsgList - MsgSegment principle; + MsgSegment principal; MsgSegment objectPath; MsgSegment properties[1]; }; @@ -157,7 +157,7 @@ void *provId; unsigned int flags; unsigned long count; // maps to MsgList - MsgSegment principle; + MsgSegment principal; MsgSegment objectPath; }; } EnumClassNamesReq; @@ -170,7 +170,7 @@ void *provId; unsigned int flags; unsigned long count; // maps to MsgList - MsgSegment principle; + MsgSegment principal; MsgSegment objectPath; }; } EnumClassesReq; @@ -183,7 +183,7 @@ void *provId; unsigned int flags; unsigned long count; // maps to MsgList - MsgSegment principle; + MsgSegment principal; MsgSegment objectPath; }; } EnumInstanceNamesReq; @@ -196,7 +196,7 @@ void *provId; unsigned int flags; unsigned long count; // maps to MsgList - MsgSegment principle; + MsgSegment principal; MsgSegment objectPath; MsgSegment properties[1]; }; @@ -210,7 +210,7 @@ void *provId; unsigned int flags; unsigned long count; // maps to MsgList - MsgSegment principle; + MsgSegment principal; MsgSegment objectPath; MsgSegment query; MsgSegment queryLang; @@ -225,7 +225,7 @@ void *provId; unsigned int flags; unsigned long count; // maps to MsgList - MsgSegment principle; + MsgSegment principal; MsgSegment objectPath; MsgSegment resultClass; MsgSegment role; @@ -243,7 +243,7 @@ void *provId; unsigned int flags; unsigned long count; // maps to MsgList - MsgSegment principle; + MsgSegment principal; MsgSegment objectPath; MsgSegment resultClass; MsgSegment role; @@ -259,7 +259,7 @@ void *provId; unsigned int flags; unsigned long count; // maps to MsgList - MsgSegment principle; + MsgSegment principal; MsgSegment objectPath; MsgSegment resultClass; MsgSegment role; @@ -276,7 +276,7 @@ void *provId; unsigned int flags; unsigned long count; // maps to MsgList - MsgSegment principle; + MsgSegment principal; MsgSegment objectPath; MsgSegment resultClass; MsgSegment role; @@ -291,12 +291,26 @@ void *provId; unsigned int flags; unsigned long count; // maps to MsgList - MsgSegment principle; + MsgSegment principal; MsgSegment objectPath; MsgSegment properties[1]; }; } GetInstanceReq; +typedef union createClassReq { + BinRequestHdr hdr; + struct { + unsigned short operation; + unsigned short options; + void *provId; + unsigned int flags; + unsigned long count; // maps to MsgList + MsgSegment principal; + MsgSegment path; + MsgSegment cls; + }; +} CreateClassReq; + typedef union createInstanceReq { BinRequestHdr hdr; struct { @@ -305,7 +319,7 @@ void *provId; unsigned int flags; unsigned long count; // maps to MsgList - MsgSegment principle; + MsgSegment principal; MsgSegment path; MsgSegment instance; }; @@ -319,7 +333,7 @@ void *provId; unsigned int flags; unsigned long count; // maps to MsgList - MsgSegment principle; + MsgSegment principal; MsgSegment path; MsgSegment instance; MsgSegment properties[1]; @@ -334,7 +348,7 @@ void *provId; unsigned int flags; unsigned long count; // maps to MsgList - MsgSegment principle; + MsgSegment principal; MsgSegment objectPath; }; } DeleteInstanceReq; @@ -347,7 +361,7 @@ void *provId; unsigned int flags; unsigned long count; // maps to MsgList - MsgSegment principle; + MsgSegment principal; MsgSegment objectPath; MsgSegment method; MsgSegment in; @@ -389,7 +403,7 @@ void *provId; unsigned int flags; unsigned long count; // maps to MsgList - MsgSegment principle; + MsgSegment principal; MsgSegment objectPath; MsgSegment query; MsgSegment language; Index: providerDrv.c =================================================================== RCS file: /cvsroot/sblim/sfcb/providerDrv.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- providerDrv.c 30 Mar 2005 12:30:51 -0000 1.4 +++ providerDrv.c 11 Apr 2005 23:13:42 -0000 1.5 @@ -58,6 +58,7 @@ extern void getSerializedArgs(CMPIArgs * cl, void *area); extern CMPIConstClass *relocateSerializedConstClass(void *area); extern CMPIInstance *relocateSerializedInstance(void *area); +extern CMPIConstClass *relocateSerializedConstClass(void *area); extern void getSerializedInstance(CMPIInstance * ci, void *area); extern CMPIArgs *relocateSerializedArgs(void *area); extern MsgSegment setArgsMsgSegment(CMPIArgs * args); @@ -652,12 +653,11 @@ if (req->flags & FL_includeQualifiers) flgs|=CMPI_FLAG_IncludeQualifiers; if (req->flags & FL_includeClassOrigin) flgs|=CMPI_FLAG_IncludeClassOrigin; ctx->ft->addEntry(ctx,CMPIInvocationFlags,(CMPIValue*)&flgs,CMPI_uint32); - ctx->ft->addEntry(ctx,CMPIPrinciple,(CMPIValue*)&req->principle.data,CMPI_chars); + ctx->ft->addEntry(ctx,CMPIPrincipal,(CMPIValue*)&req->principal.data,CMPI_chars); if (req->count>2) props=makePropertyList(req->count-2,req->properties); _SFCB_TRACE(1, ("--- Calling provider %s",info->providerName)); -// rci = info->instanceMI->ft->getInstance(info->instanceMI, ctx, result, path,props); rci = info->classMI->ft->getClass(info->classMI, ctx, result, path,props); _SFCB_TRACE(1, ("--- Back from provider rc: %d", rci.rc)); @@ -678,6 +678,42 @@ _SFCB_RETURN(resp); } +static BinResponseHdr *createClass(BinRequestHdr * hdr, ProviderInfo * info, + int requestor) +{ + _SFCB_ENTER(TRACE_PROVIDERDRV, "createClass"); + CreateClassReq *req = (CreateClassReq *) hdr; + CMPIObjectPath *path = relocateSerializedObjectPath(req->path.data); + CMPIConstClass *cls = relocateSerializedConstClass(req->cls.data); + CMPIStatus rci = { CMPI_RC_OK, NULL }; + CMPIResult *result = native_new_CMPIResult(0,1,NULL); + CMPIContext *ctx = native_new_CMPIContext(TOOL_MM_ADD,info); + CMPIArray *r; + CMPICount count; + BinResponseHdr *resp; + CMPIFlags flgs=0; + int i; + + ctx->ft->addEntry(ctx,CMPIInvocationFlags,(CMPIValue*)&flgs,CMPI_uint32); + ctx->ft->addEntry(ctx,CMPIPrincipal,(CMPIValue*)&req->principal.data,CMPI_chars); + + printf("--- Calling provider %s\n",info->providerName); + + _SFCB_TRACE(1, ("--- Calling provider %s",info->providerName)); + rci = info->classMI->ft->createClass(info->classMI, ctx, result, path, cls); + _SFCB_TRACE(1, ("--- Back from provider rc: %d", rci.rc)); + + if (rci.rc == CMPI_RC_OK) { + resp = (BinResponseHdr *) calloc(1,sizeof(BinResponseHdr)); + resp->count = 0; + resp->moreChunks=0; + resp->rc = 1; + } + else resp = errorResp(&rci); + + _SFCB_RETURN(resp); +} + static BinResponseHdr *enumClassNames(BinRequestHdr * hdr, ProviderInfo * info, int requestor) { @@ -696,7 +732,7 @@ _SFCB_ENTER(TRACE_PROVIDERDRV, "enumClassNames"); ctx->ft->addEntry(ctx,CMPIInvocationFlags,(CMPIValue*)&flgs,CMPI_uint32); - ctx->ft->addEntry(ctx,CMPIPrinciple,(CMPIValue*)&req->principle.data,CMPI_chars); + ctx->ft->addEntry(ctx,CMPIPrincipal,(CMPIValue*)&req->principal.data,CMPI_chars); _SFCB_TRACE(1, ("--- Calling provider %s",info->providerName)); @@ -738,7 +774,7 @@ CMPIFlags flgs=req->flags; ctx->ft->addEntry(ctx,CMPIInvocationFlags,(CMPIValue*)&flgs,CMPI_uint32); - ctx->ft->addEntry(ctx,CMPIPrinciple,(CMPIValue*)&req->principle.data,CMPI_chars); + ctx->ft->addEntry(ctx,CMPIPrincipal,(CMPIValue*)&req->principal.data,CMPI_chars); _SFCB_TRACE(1, ("--- Calling provider %s",info->providerName)); @@ -774,7 +810,7 @@ CMPIFlags flgs=0; ctx->ft->addEntry(ctx,CMPIInvocationFlags,(CMPIValue*)&flgs,CMPI_uint32); - ctx->ft->addEntry(ctx,CMPIPrinciple,(CMPIValue*)&req->principle.data,CMPI_chars); + ctx->ft->addEntry(ctx,CMPIPrincipal,(CMPIValue*)&req->principal.data,CMPI_chars); if (req->count>5) { int i,s,n; @@ -838,7 +874,7 @@ if (req->flags & FL_includeQualifiers) flgs|=CMPI_FLAG_IncludeQualifiers; if (req->flags & FL_includeClassOrigin) flgs|=CMPI_FLAG_IncludeClassOrigin; ctx->ft->addEntry(ctx,CMPIInvocationFlags,(CMPIValue*)&flgs,CMPI_uint32); - ctx->ft->addEntry(ctx,CMPIPrinciple,(CMPIValue*)&req->principle.data,CMPI_chars); + ctx->ft->addEntry(ctx,CMPIPrincipal,(CMPIValue*)&req->principal.data,CMPI_chars); if (req->count>2) props=makePropertyList(req->count-2,req->properties); @@ -877,7 +913,7 @@ CMPIFlags flgs=0; ctx->ft->addEntry(ctx,CMPIInvocationFlags,(CMPIValue*)&flgs,CMPI_uint32); - ctx->ft->addEntry(ctx,CMPIPrinciple,(CMPIValue*)&req->principle.data,CMPI_chars); + ctx->ft->addEntry(ctx,CMPIPrincipal,(CMPIValue*)&req->principal.data,CMPI_chars); _SFCB_TRACE(1, ("--- Calling provider %s",info->providerName)); rci = info->instanceMI->ft->deleteInstance(info->instanceMI, ctx, result, @@ -912,7 +948,7 @@ int i; ctx->ft->addEntry(ctx,CMPIInvocationFlags,(CMPIValue*)&flgs,CMPI_uint32); - ctx->ft->addEntry(ctx,CMPIPrinciple,(CMPIValue*)&req->principle.data,CMPI_chars); + ctx->ft->addEntry(ctx,CMPIPrincipal,(CMPIValue*)&req->principal.data,CMPI_chars); _SFCB_TRACE(1, ("--- Calling provider %s",info->providerName)); rci = info->instanceMI->ft->createInstance(info->instanceMI, ctx, result, @@ -953,7 +989,7 @@ if (req->flags & FL_includeQualifiers) flgs|=CMPI_FLAG_IncludeQualifiers; ctx->ft->addEntry(ctx,CMPIInvocationFlags,(CMPIValue*)&flgs,CMPI_uint32); - ctx->ft->addEntry(ctx,CMPIPrinciple,(CMPIValue*)&req->principle.data,CMPI_chars); + ctx->ft->addEntry(ctx,CMPIPrincipal,(CMPIValue*)&req->principal.data,CMPI_chars); if (req->count>3) props=makePropertyList(req->count-3,req->properties); @@ -993,7 +1029,7 @@ if (req->flags & FL_includeQualifiers) flgs|=CMPI_FLAG_IncludeQualifiers; if (req->flags & FL_includeClassOrigin) flgs|=CMPI_FLAG_IncludeClassOrigin; ctx->ft->addEntry(ctx,CMPIInvocationFlags,(CMPIValue*)&flgs,CMPI_uint32); - ctx->ft->addEntry(ctx,CMPIPrinciple,(CMPIValue*)&req->principle.data,CMPI_chars); + ctx->ft->addEntry(ctx,CMPIPrincipal,(CMPIValue*)&req->principal.data,CMPI_chars); if (req->count>2) props=makePropertyList(req->count-2,req->properties); @@ -1024,7 +1060,7 @@ CMPIFlags flgs=0; ctx->ft->addEntry(ctx,CMPIInvocationFlags,(CMPIValue*)&flgs,CMPI_uint32); - ctx->ft->addEntry(ctx,CMPIPrinciple,(CMPIValue*)&req->principle.data,CMPI_chars); + ctx->ft->addEntry(ctx,CMPIPrincipal,(CMPIValue*)&req->principal.data,CMPI_chars); _SFCB_TRACE(1, ("--- Calling provider %s",info->providerName)); rci = info->instanceMI->ft->enumInstanceNames(info->instanceMI, ctx, result, @@ -1109,7 +1145,7 @@ int irc; ctx->ft->addEntry(ctx,CMPIInvocationFlags,(CMPIValue*)&flgs,CMPI_uint32); - ctx->ft->addEntry(ctx,CMPIPrinciple,(CMPIValue*)&req->principle.data,CMPI_chars); + ctx->ft->addEntry(ctx,CMPIPrincipal,(CMPIValue*)&req->principal.data,CMPI_chars); _SFCB_TRACE(1, ("--- Calling provider %s",info->providerName)); rci = info->instanceMI->ft->execQuery(info->instanceMI, ctx, result, path, @@ -1182,7 +1218,7 @@ if (req->flags & FL_includeQualifiers) flgs|=CMPI_FLAG_IncludeQualifiers; if (req->flags & FL_includeClassOrigin) flgs|=CMPI_FLAG_IncludeClassOrigin; ctx->ft->addEntry(ctx,CMPIInvocationFlags,(CMPIValue*)&flgs,CMPI_uint32); - ctx->ft->addEntry(ctx,CMPIPrinciple,(CMPIValue*)&req->principle.data,CMPI_chars); + ctx->ft->addEntry(ctx,CMPIPrincipal,(CMPIValue*)&req->principal.data,CMPI_chars); if (req->count>6) props=makePropertyList(req->count-6,req->properties); @@ -1221,7 +1257,7 @@ if (req->flags & FL_includeQualifiers) flgs|=CMPI_FLAG_IncludeQualifiers; if (req->flags & FL_includeClassOrigin) flgs|=CMPI_FLAG_IncludeClassOrigin; ctx->ft->addEntry(ctx,CMPIInvocationFlags,(CMPIValue*)&flgs,CMPI_uint32); - ctx->ft->addEntry(ctx,CMPIPrinciple,(CMPIValue*)&req->principle.data,CMPI_chars); + ctx->ft->addEntry(ctx,CMPIPrincipal,(CMPIValue*)&req->principal.data,CMPI_chars); if (req->count>4) props=makePropertyList(req->count-4,req->properties); @@ -1255,7 +1291,7 @@ CMPIFlags flgs=0; ctx->ft->addEntry(ctx,CMPIInvocationFlags,(CMPIValue*)&flgs,CMPI_uint32); - ctx->ft->addEntry(ctx,CMPIPrinciple,(CMPIValue*)&req->principle.data,CMPI_chars); + ctx->ft->addEntry(ctx,CMPIPrincipal,(CMPIValue*)&req->principal.data,CMPI_chars); _SFCB_TRACE(1, ("--- Calling provider %s",info->providerName)); rci = info->associationMI->ft->associatorNames(info->associationMI, ctx, @@ -1288,7 +1324,7 @@ CMPIFlags flgs=0; ctx->ft->addEntry(ctx,CMPIInvocationFlags,(CMPIValue*)&flgs,CMPI_uint32); - ctx->ft->addEntry(ctx,CMPIPrinciple,(CMPIValue*)&req->principle.data,CMPI_chars); + ctx->ft->addEntry(ctx,CMPIPrincipal,(CMPIValue*)&req->principal.data,CMPI_chars); _SFCB_TRACE(1, ("--- Calling provider %s",info->providerName)); rci = info->associationMI->ft->referenceNames(info->associationMI, ctx, @@ -1328,7 +1364,7 @@ char *type; ctx->ft->addEntry(ctx,CMPIInvocationFlags,(CMPIValue*)&flgs,CMPI_uint32); - ctx->ft->addEntry(ctx,CMPIPrinciple,(CMPIValue*)&req->principle.data,CMPI_chars); + ctx->ft->addEntry(ctx,CMPIPrincipal,(CMPIValue*)&req->principal.data,CMPI_chars); _SFCB_TRACE(1,("--- pid: %d activFilters %p %s",currentProc,activFilters,processName)); for (se = activFilters; se; se = se->next) { @@ -1360,7 +1396,7 @@ _SFCB_TRACE(1, ("--- Calling authorizeFilter %s",info->providerName)); rci = info->indicationMI->ft->authorizeFilter(info->indicationMI, ctx, result, (CMPISelectExp*)se, type, path, - PROVCHARS(req->principle.data)); + PROVCHARS(req->principal.data)); _SFCB_TRACE(1, ("--- Back from provider rc: %d", rci.rc)); if (rci.rc==CMPI_RC_OK) { @@ -1415,7 +1451,7 @@ CMPIFlags flgs=0; ctx->ft->addEntry(ctx,CMPIInvocationFlags,(CMPIValue*)&flgs,CMPI_uint32); - ctx->ft->addEntry(ctx,CMPIPrinciple,(CMPIValue*)&req->principle.data,CMPI_chars); + ctx->ft->addEntry(ctx,CMPIPrincipal,(CMPIValue*)&req->principal.data,CMPI_chars); resp = (BinResponseHdr *) calloc(1,sizeof(BinResponseHdr)); resp->rc=1; @@ -1499,7 +1535,7 @@ info->initialized=1; ctx->ft->addEntry(ctx,CMPIInvocationFlags,(CMPIValue*)&flgs,CMPI_uint32); - ctx->ft->addEntry(ctx,CMPIPrinciple,(CMPIValue*)"$$",CMPI_chars); + ctx->ft->addEntry(ctx,CMPIPrincipal,(CMPIValue*)"$$",CMPI_chars); if (info->type & INSTANCE_PROVIDER) { rc |= (getInstanceMI(info, &mi, ctx) != 1); @@ -1601,7 +1637,7 @@ {getInstance}, //OPS_GetInstance 2 {opNotSupported}, //OPS_DeleteClass 3 {deleteInstance}, //OPS_DeleteInstance 4 - {opNotSupported}, //OPS_CreateClass 5 + {createClass}, //OPS_CreateClass 5 {createInstance}, //OPS_CreateInstance 6 {opNotSupported}, //OPS_ModifyClass 7 {modifyInstance}, //OPS_ModifyInstance 8 Index: instance.c =================================================================== RCS file: /cvsroot/sblim/sfcb/instance.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- instance.c 12 Mar 2005 00:43:00 -0000 1.2 +++ instance.c 11 Apr 2005 23:13:41 -0000 1.3 @@ -453,7 +453,7 @@ else { j=0; asm("int $3"); - ns = "'NoNameSpace*"; + ns = "*NoNameSpace*"; cn = "*NoClassName*"; tmp1.rc=tmp2.rc=tmp3.rc=CMPI_RC_OK; } --- NEW FILE: mrwlock.c --- /* * $Id: mrwlock.c,v 1.1 2005/04/11 23:13:42 a3schuur Exp $ * * (C) Copyright IBM Corp. 2003 * * THIS FILE IS PROVIDED UNDER THE TERMS OF THE COMMON 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 Common Public License from * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html * * Author: Viktor Mihajlovski <mih...@de...m> * Contributors: * * Description: Multiple Reader/Single Writer Locks */ #include "mrwlock.h" int MReadLock(MRWLOCK *mrwl) { if (mrwl && pthread_mutex_lock(&mrwl->mrw_mutex) == 0) { mrwl->mrw_rnum += 1; return pthread_mutex_unlock(&mrwl->mrw_mutex); } else { return -1; } } int MReadUnlock(MRWLOCK *mrwl) { if (mrwl && pthread_mutex_lock(&mrwl->mrw_mutex) == 0) { mrwl->mrw_rnum -= 1; if (mrwl->mrw_rnum == 0) pthread_cond_broadcast(&mrwl->mrw_cond); return pthread_mutex_unlock(&mrwl->mrw_mutex); } else { return -1; } } int MWriteLock(MRWLOCK *mrwl) { if (mrwl && pthread_mutex_lock(&mrwl->mrw_mutex) == 0) { while (mrwl->mrw_rnum) pthread_cond_wait(&mrwl->mrw_cond,&mrwl->mrw_mutex); return 0; } else { return -1; } } int MWriteUnlock(MRWLOCK *mrwl) { if (mrwl && pthread_mutex_unlock(&mrwl->mrw_mutex) == 0) { return 0; } else { return -1; } } int MRWInit(MRWLOCK *mrwl) { static pthread_mutex_t mi=PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t ci=PTHREAD_COND_INITIALIZER; mrwl->mrw_mutex=mi; mrwl->mrw_cond=ci; mrwl->mrw_rnum=0; return 0; } Index: interopProvider.c =================================================================== RCS file: /cvsroot/sblim/sfcb/interopProvider.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- interopProvider.c 13 Mar 2005 15:41:39 -0000 1.4 +++ interopProvider.c 11 Apr 2005 23:13:41 -0000 1.5 @@ -275,7 +275,7 @@ BinResponseHdr *resp=NULL; BinRequestContext binCtx; OperationHdr req = {OPS_IndicationLookup, 2}; - char *principle=ctx->ft->getEntry(ctx,CMPIPrinciple,NULL).value.string->hdl;; + char *principal=ctx->ft->getEntry(ctx,CMPIPrincipal,NULL).value.string->hdl;; int irc; _SFCB_ENTER(TRACE_INDPROVIDER, "deactivateFilter"); @@ -283,7 +283,7 @@ path = TrackedCMPIObjectPath(ns, cn, &st); - sreq.principle = setCharsMsgSegment(principle); + sreq.principal = setCharsMsgSegment(principal); sreq.objectPath = setObjectPathMsgSegment(path); sreq.query = setCharsMsgSegment(fi->query); sreq.language = setCharsMsgSegment(fi->lang); @@ -337,7 +337,7 @@ extern CMPISelectExp *TempCMPISelectExp(QLStatement *qs); -CMPIStatus activateSubscription(char *principle, const char *cn, const char *type, +CMPIStatus activateSubscription(char *principal, const char *cn, const char *type, Filter *fi, int *rrc) { CMPIObjectPath *path; @@ -353,7 +353,7 @@ if (rrc) *rrc=0; path = TrackedCMPIObjectPath(fi->sns, cn, &rc); - sreq.principle = setCharsMsgSegment(principle); + sreq.principal = setCharsMsgSegment(principal); sreq.objectPath = setObjectPathMsgSegment(path); sreq.query = setCharsMsgSegment(fi->query); sreq.language = setCharsMsgSegment(fi->lang); @@ -401,7 +401,7 @@ _SFCB_RETURN(st); } -CMPIStatus activateLifeCycleSubscription(char *principle, const char *cn, +CMPIStatus activateLifeCycleSubscription(char *principal, const char *cn, Filter *fi, int type) { CMPIStatus st={CMPI_RC_OK,NULL}; @@ -431,7 +431,7 @@ ok=1; _SFCB_TRACE(1,("lhs: %s",(char*)lhs->hdl)); _SFCB_TRACE(1,("rhs: %s\n",(char*)rhs->hdl)); - st=activateSubscription(principle,(char*)rhs->hdl,cn,fi,&irc); + st=activateSubscription(principal,(char*)rhs->hdl,cn,fi,&irc); if (irc==MSG_X_INVALID_CLASS) st.rc=CMPI_RC_ERR_INVALID_CLASS; if (st.rc!=CMPI_RC_OK) break; @@ -457,28 +457,28 @@ int fowardSubscription(CMPIContext * ctx, Filter *fi, CMPIStatus *st) { CMPIStatus rc; - char *principle=NULL; + char *principal=NULL; char **fClasses=fi->qs->ft->getFromClassList(fi->qs); - CMPIData principleP=ctx->ft->getEntry(ctx,CMPIPrinciple,&rc); + CMPIData principalP=ctx->ft->getEntry(ctx,CMPIPrincipal,&rc); int irc; _SFCB_ENTER(TRACE_INDPROVIDER, "fowardSubscription"); if (rc.rc==CMPI_RC_OK) - principle=(char*)principleP.value.string->hdl; + principal=(char*)principalP.value.string->hdl; for ( ; *fClasses; fClasses++) { if (isa(fi->sns,*fClasses,"cim_processindication")) { - *st=activateSubscription(principle, *fClasses, *fClasses, fi, &irc); + *st=activateSubscription(principal, *fClasses, *fClasses, fi, &irc); } else if (isa("root/interop",*fClasses,"CIM_InstCreation")) { - *st=activateLifeCycleSubscription(principle, *fClasses, fi,CREATE_INST); + *st=activateLifeCycleSubscription(principal, *fClasses, fi,CREATE_INST); } else if (isa("root/interop",*fClasses,"CIM_InstDeletion")) { - *st=activateLifeCycleSubscription(principle, *fClasses, fi,DELETE_INST); + *st=activateLifeCycleSubscription(principal, *fClasses, fi,DELETE_INST); } else if (isa("root/interop",*fClasses,"CIM_InstModification")) { - *st=activateLifeCycleSubscription(principle, *fClasses, fi,MODIFY_INST); + *st=activateLifeCycleSubscription(principal, *fClasses, fi,MODIFY_INST); } else { setStatus(st,CMPI_RC_ERR_NOT_SUPPORTED,"Lifecycle indications not supported"); Index: classProvider.c =================================================================== RCS file: /cvsroot/sblim/sfcb/classProvider.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- classProvider.c 30 Mar 2005 12:47:18 -0000 1.6 +++ classProvider.c 11 Apr 2005 23:13:41 -0000 1.7 @@ -43,6 +43,7 @@ #include "cmpimacs.h" #include "cmpimacsx.h" #include "objectImpl.h" +#include "mrwlock.h" #define LOCALCLASSNAME "ClassProvider" @@ -62,6 +63,7 @@ char *fn; UtilHashTable *ht; UtilHashTable *it; + MRWLOCK mrwLock; } ClassBase; struct _Class_Register_FT { @@ -71,11 +73,36 @@ CMPIConstClass *(*getClass) (ClassRegister * br, const char *clsName); int (*putClass) (ClassRegister * br, CMPIConstClass * cls); UtilList *(*getChildren) (ClassRegister * br, const char *className); + void (*rLock)(ClassRegister * cr); + void (*wLock)(ClassRegister * cr); + void (*rUnLock)(ClassRegister * cr); + void (*wUnLock)(ClassRegister * cr); }; extern Class_Register_FT *ClassRegisterFT; -//static ClassRegister *cReg = NULL; + +static CMPIConstClass *getClass(ClassRegister * cr, const char *clsName); +extern ClClass *ClClassNew(const char *cn, const char *pa); +extern int ClClassAddQualifier(ClObjectHdr * hdr, ClSection * qlfs, + const char *id, CMPIData d); +extern int ClClassAddProperty(ClClass * cls, const char *id, CMPIData d); +extern void *ClObjectGetClSection(ClObjectHdr * hdr, ClSection * s); +extern int ClClassAddPropertyQualifier(ClObjectHdr * hdr, ClProperty * p, + const char *id, CMPIData d); +extern ClClass *ClClassRebuildClass(ClClass * cls, void *area); +extern void ClClassFreeClass(ClClass * cls); +extern char *ClClassToString(ClClass * cls); +extern CMPIConstClass initConstClass(ClClass *cl); +extern int ClClassGetQualifierAt(ClClass * cls, int id, CMPIData * data, char **name); +extern int ClClassGetQualifierCount(ClClass * cls); +extern int ClClassGetPropertyCount(ClClass * cls); +extern int ClClassGetPropertyAt(ClClass * cls, int id, CMPIData * data, char **name, + unsigned long *quals); +extern int ClClassGetPropQualifierCount(ClClass * cls, int id); +extern int ClClassGetPropQualifierAt(ClClass * cls, int id, int qid, CMPIData * data, + char **name); + int assocs = 0, topAssocs = 0; typedef struct nameSpaces { @@ -120,11 +147,31 @@ free(cr); } -static ClassRegister *clone(ClassRegister * cr) +static ClassRegister *regClone(ClassRegister * cr) { return NULL; } +void rLock(ClassRegister * cr) { + ClassBase *cb = (ClassBase *) cr->hdl; + MReadLock(&cb->mrwLock); +} + +void wLock(ClassRegister * cr) { + ClassBase *cb = (ClassBase *) cr->hdl; + MWriteLock(&cb->mrwLock); +} + +void rUnLock(ClassRegister * cr) { + ClassBase *cb = (ClassBase *) cr->hdl; + MReadUnlock(&cb->mrwLock); +} + +void wUnLock(ClassRegister * cr) { + ClassBase *cb = (ClassBase *) cr->hdl; + MWriteUnlock(&cb->mrwLock); +} + static UtilList *getChildren(ClassRegister * cr, const char *className) { ClassBase *cb = (ClassBase *) (cr + 1); @@ -154,12 +201,14 @@ UtilHashTable_charKey | UtilHashTable_ignoreKeyCase); cb->it = UtilFactory->newHashTable(61, UtilHashTable_charKey | UtilHashTable_ignoreKeyCase); + MRWInit(&cb->mrwLock); return cr; } cb->fn = strdup(fin); cb->ht = UtilFactory->newHashTable(61, UtilHashTable_charKey | UtilHashTable_ignoreKeyCase); + MRWInit(&cb->mrwLock); while ((s = fread(&hdr, 1, sizeof(hdr), in)) == sizeof(hdr)) { // while ((s = fread(&size, 1, 4, in)) == 4) { @@ -198,14 +247,90 @@ return NULL; } } -// printf("--- %d Association classes\n", assocs); -// printf("--- %d Top level Association classes\n", topAssocs); + printf("--- ClassProvider for %s using %ld bytes\n", fname, total); buildInheritanceTable(cr); + return cr; } +int cpyClass(ClClass *cl, CMPIConstClass *cc) +{ + ClClass *ccl=(ClClass*)cc->hdl; + CMPIData d; + char *name; + int i,m,iq,mq,propId; + unsigned long quals; + ClProperty *prop; + + cl->quals |= ccl->quals; + for (i=0,m=ClClassGetQualifierCount(ccl); i<m; i++) { + ClClassGetQualifierAt(ccl,i,&d,&name); + ClClassAddQualifier(&cl->hdr, &cl->qualifiers, name, d); + } + + for (i=0,m=ClClassGetPropertyCount(ccl); i<m; i++) { + ClClassGetPropertyAt(ccl,i,&d,&name,&quals); + propId=ClClassAddProperty(cl, name, d); + prop=((ClProperty*)ClObjectGetClSection(&cl->hdr,&cl->properties))+propId-1; + + for (iq=0,mq=ClClassGetPropQualifierCount(ccl,propId-1); i<m; i++) { + ClClassGetPropQualifierAt(ccl,iq, propId-1, &d, &name); + ClClassAddPropertyQualifier(&cl->hdr, prop, name, d); + } + } + return 0; +} + +CMPIStatus mergeParents(ClassRegister * cr, ClClass *cl, char *p, CMPIConstClass *cc) +{ + CMPIStatus st = { CMPI_RC_OK, NULL }; + CMPIConstClass *pcc=getClass(cr,p); + + if (p) { + char* np=(char*)cc->ft->getCharSuperClassName(pcc); + st=mergeParents(cr,cl,np,NULL); + } + + if (cc) cpyClass(cl,cc); + else cpyClass(cl,pcc); + + return st; +} + +static int addClass(ClassRegister * cr,CMPIConstClass *ccp, char *cn, char *p) +{ + ClassBase *cb = (ClassBase *) (cr + 1); + UtilHashTable *it=cb->it; + UtilList *ul; + char *pn=p; + ClClass *mc; + CMPIConstClass *cc=ccp; + + if (p) { + mc=ClClassNew(cn,p); + mergeParents(cr,mc,pn,cc); + } + + cb->ht->ft->put(cb->ht, cn, cc); + if (cc->ft->isAssociation(cc)) assocs++; + if (p == NULL) topAssocs++; + + + + else { + ul = it->ft->get(it, p); + if (ul == NULL) { + ul = UtilFactory->newList(); + it->ft->put(it, p, ul); + } + ul->ft->prepend(ul, cn); + } + + return 0; +} + static UtilHashTable *gatherNameSpaces(char *dn, UtilHashTable *ns) { DIR *dir; @@ -300,10 +425,14 @@ static Class_Register_FT ift = { 1, release, - clone, + regClone, getClass, putClass, - getChildren + getChildren, + rLock, + wLock, + rUnLock, + wUnLock }; Class_Register_FT *ClassRegisterFT = &ift; @@ -385,7 +514,9 @@ cni=ref->ft->getClassName(ref,NULL); if (cni) cn=(char*)cni->hdl; cb = (ClassBase *) cReg->hdl; - + + cReg->ft->rLock(cReg); + if (cn && strcasecmp(cn,"$ClassProvider$")==0) cn=NULL; if (cn==NULL) { @@ -416,6 +547,8 @@ loopOnChildNames(cReg, cn, rslt); } + cReg->ft->rUnLock(cReg); + _SFCB_RETURN(st); } @@ -456,6 +589,8 @@ _SFCB_RETURN(st); } + cReg->ft->rLock(cReg); + flgs=ctx->ft->getEntry(ctx,CMPIInvocationFlags,NULL).value.uint32; cni=ref->ft->getClassName(ref,NULL); if (cni) { @@ -486,6 +621,8 @@ loopOnChildren(cReg, cn, rslt); } + cReg->ft->rUnLock(cReg); + _SFCB_RETURN(st); } @@ -510,21 +647,57 @@ return st; } + cReg->ft->rLock(cReg); + cl = getClass(cReg, (char *) cn->hdl); if (cl) CMReturnInstance(rslt, (CMPIInstance *) cl); else { st.rc = CMPI_RC_ERR_NOT_FOUND; } + + cReg->ft->rUnLock(cReg); + _SFCB_RETURN(st); } CMPIStatus ClassProviderCreateClass(CMPIClassMI * mi, CMPIContext * ctx, CMPIResult * rslt, - CMPIObjectPath * cop, CMPIConstClass * ci) + CMPIObjectPath * ref, CMPIConstClass * cc) { - CMPIStatus st = { CMPI_RC_ERR_NOT_SUPPORTED, NULL }; - return st; + ClassRegister *cReg; + CMPIConstClass * cl; + int rc; + + CMPIStatus st = { CMPI_RC_OK, NULL }; + + _SFCB_ENTER(TRACE_PROVIDERS, "ClassProviderCreateClass"); + + cReg=getNsReg(ref, &rc); + if (cReg==NULL) { + CMPIStatus st = { CMPI_RC_ERR_INVALID_NAMESPACE, NULL }; + _SFCB_RETURN(st); + } + + char *pn = (char*)cc->ft->getCharSuperClassName(cc); + char *cn = (char*)cc->ft->getCharClassName(cc); + + cl = getClass(cReg,cn); + if (cl) { + st.rc = CMPI_RC_ERR_ALREADY_EXISTS; + _SFCB_RETURN(st); + } + if (pn && (cl=getClass(cReg,cn))==NULL) { + st.rc = CMPI_RC_ERR_INVALID_SUPERCLASS; + _SFCB_RETURN(st); + } + + cReg->ft->wLock(cReg); + addClass(cReg,cc,cn,pn); + + cReg->ft->wUnLock(cReg); + + _SFCB_RETURN(st); } CMPIStatus ClassProviderSetClass(CMPIClassMI * mi, @@ -627,8 +800,6 @@ _SFCB_ENTER(TRACE_PROVIDERS, "ClassProviderInvokeMethod"); - CMPIString *nsi=CMGetNameSpace(ref,NULL); - cReg=getNsReg(ref, &rc); if (cReg==NULL) { CMPIStatus st = { CMPI_RC_ERR_INVALID_NAMESPACE, NULL }; @@ -638,6 +809,9 @@ if (strcasecmp(methodName, "getchildren") == 0) { CMPIData cn = CMGetArg(in, "class", NULL); _SFCB_TRACE(1,("--- getchildren %s",(char*)cn.value.string->hdl)); + + cReg->ft->rLock(cReg); + if (cn.type == CMPI_string && cn.value.string && cn.value.string->hdl) { char *child; int l=0, i=0; @@ -652,12 +826,18 @@ } else { } + + cReg->ft->rUnLock(cReg); + } else if (strcasecmp(methodName, "getallchildren") == 0) { int ignprov=0; CMPIStatus st; CMPIData cn = CMGetArg(in, "class", &st); + + cReg->ft->rLock(cReg); + if (st.rc!=CMPI_RC_OK) { cn = CMGetArg(in, "classignoreprov", NULL); ignprov=1; @@ -676,6 +856,8 @@ } else { } + + cReg->ft->rUnLock(cReg); } else if (strcasecmp(methodName, "getassocs") == 0) { @@ -687,13 +869,17 @@ CMPIConstClass *cc; int n; - for (n = 0, i = ct->ft->getFirst(ct, (void **) &cn, (void **) &cc); i; + cReg->ft->rUnLock(cReg); + + for (n = 0, i = ct->ft->getFirst(ct, (void **) &cn, (void **) &cc); i; i = ct->ft->getNext(ct, i, (void **) &cn, (void **) &cc)) { if (cc->ft->getCharSuperClassName(cc) == NULL) { CMSetArrayElementAt(ar, n++, cn, CMPI_chars); } } CMAddArg(out, "assocs", &ar, CMPI_stringA); + + cReg->ft->rUnLock(cReg); } else if (strcasecmp(methodName, "ischild") == 0) { @@ -702,6 +888,8 @@ char *chldn=(char*)CMGetArg(in, "child", NULL).value.string->hdl; char *child; + cReg->ft->rLock(cReg); + st.rc = CMPI_RC_ERR_FAILED; if (ul) for (child=(char*)ul->ft->getFirst(ul); child; child=(char*)ul->ft->getNext(ul)) { @@ -710,6 +898,8 @@ break; } } + + cReg->ft->rUnLock(cReg); } else if (strcasecmp(methodName, "_startup") == 0) { Index: cimXmlRequest.h =================================================================== RCS file: /cvsroot/sblim/sfcb/cimXmlRequest.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- cimXmlRequest.h 9 Mar 2005 12:25:10 -0000 1.1.1.1 +++ cimXmlRequest.h 11 Apr 2005 23:13:41 -0000 1.2 @@ -49,7 +49,7 @@ typedef struct cimXmlRequestContext { char *cimXmlDoc; - char *principle; + char *principal; char *host; unsigned long cimXmlDocLength; struct commHndl *commHndl; Index: providerMgr.c =================================================================== RCS file: /cvsroot/sblim/sfcb/providerMgr.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- providerMgr.c 30 Mar 2005 12:30:51 -0000 1.3 +++ providerMgr.c 11 Apr 2005 23:13:42 -0000 1.4 @@ -996,7 +996,7 @@ _SFCB_ENTER(TRACE_PROVIDERMGR, "getConstClass"); path = TrackedCMPIObjectPath(ns, cn, &rc); - sreq.principle = setCharsMsgSegment("$$"); + sreq.principal = setCharsMsgSegment("$$"); sreq.objectPath = setObjectPathMsgSegment(path); req.nameSpace = setCharsMsgSegment((char *) ns); @@ -1048,7 +1048,7 @@ path = NewCMPIObjectPath(ns, cn, st); sreq.objectPath = setObjectPathMsgSegment(path); - sreq.principle = setCharsMsgSegment("$$"); + sreq.principal = setCharsMsgSegment("$$"); req.nameSpace = setCharsMsgSegment((char *) ns); req.className = setCharsMsgSegment((char *) cn); @@ -1101,7 +1101,7 @@ sreq.out = setArgsMsgSegment(NULL); sreq.objectPath = setObjectPathMsgSegment(path); sreq.method = setCharsMsgSegment(method); - sreq.principle = setCharsMsgSegment("$$"); + sreq.principal = setCharsMsgSegment("$$"); binCtx->oHdr = &req; binCtx->bHdr = &sreq.hdr; Index: cimXmlParser.h =================================================================== RCS file: /cvsroot/sblim/sfcb/cimXmlParser.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- cimXmlParser.h 30 Mar 2005 12:30:51 -0000 1.2 +++ cimXmlParser.h 11 Apr 2005 23:13:41 -0000 1.3 @@ -241,6 +241,7 @@ XtokValueArray list; } XtokPropertyList; + typedef struct xtokParamValue { struct xtokParamValue *next; char *name; @@ -257,6 +258,56 @@ } XtokParamValues; +typedef struct xtokParam { + struct xtokParam *next; + XtokQualifiers qualifiers; + XtokQualifier qualifier; + int qPart; + int pType; + char *name; + char *refClass; + char *arraySize; + CMPIType type; +} XtokParam; + +typedef struct xtokParams { + XtokParam *last, *first; // must be free'd +} XtokParams; + + +typedef struct xtokMethod { + struct xtokMethod *next; + XtokParams params; + char *name; + char *classOrigin; + int propagated; + CMPIType type; +} XtokMethod; + +typedef struct xtokMethodPart { + XtokParam param; + int qPart; + XtokQualifier qualifier; +} XtokMethodPart; + +typedef struct xtokMethodPartList { + XtokQualifiers qualifiers; + XtokParams params; +} XtokMethodPartList; + +typedef struct xtokMethods { + XtokMethod *last, *first; // must be free'd +} XtokMethods; + + +typedef struct xtokClass { + char *className; + char *superClass; + XtokProperties properties; + XtokQualifiers qualifiers; + XtokMethods methods; +} XtokClass; + /* * methodCall @@ -384,6 +435,22 @@ /* + * createClass +*/ + +typedef struct xtokCreateClassParm { + XtokClass cls; +} XtokCreateClassParm; + +typedef struct xtokCreateClass { + OperationHdr op; + XtokClass cls; + char *className; + char *superClass; +} XtokCreateClass; + + +/* * createInstance */ @@ -622,6 +689,7 @@ RequestHdr reqHdr; XtokProperties properties; XtokQualifiers qualifiers; + XtokMethods methods; XtokParamValues paramValues; jmp_buf env; } ParserControl; Index: Makefile.am =================================================================== RCS file: /cvsroot/sblim/sfcb/Makefile.am,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- Makefile.am 1 Apr 2005 15:19:28 -0000 1.8 +++ Makefile.am 11 Apr 2005 23:13:34 -0000 1.9 @@ -84,7 +84,8 @@ queryLexer.l \ queryOperation.c \ queryStatement.c \ - cimXmlGen.c + cimXmlGen.c \ + mrwlock.c libsfcBrokerCore_la_CFLAGS = @SFCB_CMPI_OS@ @SFCB_CMPI_PLATFORM@ @@ -150,7 +151,8 @@ hashtable.h utilft.h \ cmpidt.h cmpift.h cmpiftx.h cmpimacs.h cmpimacsx.h cmpios.h fileRepository.h \ selectexp.h queryOperation.h authorizationUtil.h authorizationEnum.c \ - sfcVersion.h + sfcVersion.h mrwlock.h + EXTRA_DIST=sfcb.cfg.pre.in sfcb.spec sfcbrepos.sh.in sfcbstage.sh.in \ sfcb.init-redhat sfcb.init-suse sfcb.init-none regressionTests doc Index: trace.h =================================================================== RCS file: /cvsroot/sblim/sfcb/trace.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- trace.h 9 Mar 2005 12:25:14 -0000 1.1.1.1 +++ trace.h 11 Apr 2005 23:13:42 -0000 1.2 @@ -111,6 +111,7 @@ #define TRACE_SOCKETS 4096 #define TRACE_MEMORYMGR 8192 #define TRACE_MSGQUEUE 16384 +#define TRACE_XMLPARSING 32768 typedef void sigHandler(int); Index: cmpidt.h =================================================================== RCS file: /cvsroot/sblim/sfcb/cmpidt.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- cmpidt.h 9 Mar 2005 12:25:10 -0000 1.1.1.1 +++ cmpidt.h 11 Apr 2005 23:13:41 -0000 1.2 @@ -370,7 +370,7 @@ #define CMPI_FLAG_IncludeClassOrigin 8 #define CMPIInvocationFlags "CMPIInvocationFlags" - #define CMPIPrinciple "CMPIPrinciple" + #define CMPIPrincipal "CMPIPrincipal" typedef enum _CMPIrc { CMPI_RC_OK =0, Index: cimXmlParser.c =================================================================== RCS file: /cvsroot/sblim/sfcb/cimXmlParser.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- cimXmlParser.c 9 Mar 2005 12:25:09 -0000 1.1.1.1 +++ cimXmlParser.c 11 Apr 2005 23:13:41 -0000 1.2 @@ -27,6 +27,7 @@ #include "cimXmlParser.h" #include "cimXmlOps.h" #include "cimXmlRequest.h" +#include "trace.h" static int attrsOk(XmlBuffer * xb, const XmlElement * e, XmlAttr * r, @@ -469,6 +470,9 @@ if (strcasecmp(attr[0].attr, "execQuery") == 0) return XTOK_EXECQUERY; + if (strcasecmp(attr[0].attr, "createClass") == 0) + return XTOK_CREATECLASS; + if (strcasecmp(attr[0].attr, "deleteClass") == 0) return unsupported(parm); if (strcasecmp(attr[0].attr, "getProperty") == 0) @@ -609,6 +613,7 @@ {"propertylist", XTOK_IP_PROPERTYLIST}, {"querylanguage", XTOK_IP_QUERYLANG}, {"query", XTOK_IP_QUERY}, + {"newclass", XTOK_IP_CLASS}, }; static int procIParamValue(YYSTYPE * lvalp, ParserControl * parm) @@ -705,6 +710,26 @@ return 0; } +static int procClass(YYSTYPE * lvalp, ParserControl * parm) +{ + static XmlElement elm[] = { + {"NAME"}, + {"SUPERCLASS"}, + {NULL} + }; + XmlAttr attr[2]; + + memset(attr, 0, sizeof(attr)); + if (tagEquals(parm->xmb, "CLASS")) { + if (attrsOk(parm->xmb, elm, attr, "CLASS", ZTOK_CLASS)) { + lvalp->xtokClass.className = attr[0].attr; + lvalp->xtokClass.superClass = attr[1].attr; + return XTOK_CLASS; + } + } + return 0; +} + static int procKeyValue(YYSTYPE * lvalp, ParserControl * parm) { static XmlElement elm[] = { @@ -966,7 +991,6 @@ {NULL} }; XmlAttr attr[4]; - int i, m; memset(attr, 0, sizeof(attr)); if (tagEquals(parm->xmb, "PROPERTY.REFERENCE")) { @@ -985,6 +1009,151 @@ return 0; } +static int procMethod(YYSTYPE * lvalp, ParserControl * parm) +{ + static XmlElement elm[] = { {"NAME"}, + {"TYPE"}, + {"CLASSORIGIN"}, + {"PROPAGATED"}, + {NULL} + }; + XmlAttr attr[4]; + int i, m; + + memset(attr, 0, sizeof(attr)); + if (tagEquals(parm->xmb, "METHOD")) { + attr[1].attr = NULL; + if (attrsOk(parm->xmb, elm, attr, "METHOD", ZTOK_METHODDEF)) { + memset(&lvalp->xtokMethod, 0, sizeof(XtokMethod)); + lvalp->xtokMethod.name = attr[0].attr; + lvalp->xtokMethod.type = (CMPIType) - 1; + if (attr[1].attr) + for (i = 0, m = sizeof(types) / sizeof(Types); i < m; i++) { + if (strcasecmp(attr[1].attr, types[i].str) == 0) { + lvalp->xtokMethod.type = types[i].type; + break; + } + } + lvalp->xtokMethod.classOrigin = attr[2].attr; + if (attr[3].attr) + lvalp->xtokMethod.propagated = !strcasecmp(attr[3].attr, "true"); + return XTOK_METHODDEF; + } + } + return 0; +} + +static int procParam(YYSTYPE * lvalp, ParserControl * parm) +{ + static XmlElement elm[] = + { {"NAME"}, + {"TYPE"}, + {NULL} + }; + XmlAttr attr[2]; + int i,m; + + memset(attr, 0, sizeof(attr)); + if (tagEquals(parm->xmb, "PARAMETER")) { + attr[1].attr = NULL; + if (attrsOk(parm->xmb, elm, attr, "PARAMETER", ZTOK_PARAM)) { + memset(&lvalp->xtokParam, 0, sizeof(XtokParam)); + lvalp->xtokParam.pType = ZTOK_PARAM; + lvalp->xtokParam.name = attr[0].attr; + lvalp->xtokParam.type = (CMPIType) - 1; + if (attr[1].attr) + for (i = 0, m = sizeof(types) / sizeof(Types); i < m; i++) { + if (strcasecmp(attr[1].attr, types[i].str) == 0) { + lvalp->xtokParam.type = types[i].type; + break; + } + } + return XTOK_PARAM; + } + } + return 0; +} + +static int procParamArray(YYSTYPE * lvalp, ParserControl * parm) +{ + static XmlElement elm[] = + { {"NAME"}, + {"TYPE"}, + {"ARRAYSIZE"}, + {NULL} + }; + XmlAttr attr[3]; + int i,m; + + memset(attr, 0, sizeof(attr)); + if (tagEquals(parm->xmb, "PARAMETER.ARRAY")) { + attr[1].attr = NULL; + if (attrsOk(parm->xmb, elm, attr, "PARAMETER.ARRAY", ZTOK_PARAM)) { + memset(&lvalp->xtokParam, 0, sizeof(XtokParam)); + lvalp->xtokParam.pType = ZTOK_PARAMARRAY; + lvalp->xtokParam.name = attr[0].attr; + lvalp->xtokParam.type = (CMPIType) - 1; + if (attr[1].attr) + for (i = 0, m = sizeof(types) / sizeof(Types); i < m; i++) { + if (strcasecmp(attr[1].attr, types[i].str) == 0) { + lvalp->xtokParam.type = types[i].type; + break; + } + } + lvalp->xtokParam.arraySize = attr[2].attr; + return XTOK_PARAM; + } + } + return 0; +} + +static int procParamRef(YYSTYPE * lvalp, ParserControl * parm) +{ + static XmlElement elm[] = + { {"NAME"}, + {"REFERENCECLASS"}, + {NULL} + }; + XmlAttr attr[2]; + + memset(attr, 0, sizeof(attr)); + if (tagEquals(parm->xmb, "PARAMETER.REFERENCE")) { + attr[1].attr = NULL; + if (attrsOk(parm->xmb, elm, attr, "PARAMETER.REFERENCE", ZTOK_PARAM)) { + memset(&lvalp->xtokParam, 0, sizeof(XtokParam)); + lvalp->xtokParam.pType = ZTOK_PARAMREF; + lvalp->xtokParam.name = attr[0].attr; + lvalp->xtokParam.refClass = attr[1].attr; + return XTOK_PARAM; + } + } + return 0; +} + +static int procParamRefArray(YYSTYPE * lvalp, ParserControl * parm) +{ + static XmlElement elm[] = + { {"NAME"}, + {"REFERENCECLASS"}, + {"ARRAYSIZE"}, + {NULL} + }; + XmlAttr attr[3]; + + memset(attr, 0, sizeof(attr)); + if (tagEquals(parm->xmb, "PARAMETER.REFARRAY")) { + attr[1].attr = NULL; + if (attrsOk(parm->xmb, elm, attr, "PARAMETER.REFARRAY", ZTOK_PARAM)) { + memset(&lvalp->xtokParam, 0, sizeof(XtokParam)); + lvalp->xtokParam.pType = ZTOK_PARAMREFARRAY; + lvalp->xtokParam.name = attr[0].attr; + lvalp->xtokParam.refClass = attr[1].attr; + lvalp->xtokParam.arraySize = attr[2].attr; + return XTOK_PARAM; + } + } + return 0; +} static Tags tags[] = { @@ -1015,29 +1184,38 @@ {"PROPERTY.ARRAY", procPropertyArray, ZTOK_PROPERTYARRAY}, {"PROPERTY", procProperty, ZTOK_PROPERTY}, {"QUALIFIER", procQualifier, ZTOK_QUALIFIER}, + {"PARAMETER.ARRAY", procParamArray, ZTOK_PARAMARRAY}, + {"PARAMETER.REFERENCE", procParamRef, ZTOK_PARAMREF}, + {"PARAMETER.REFARRAY", procParamRefArray, ZTOK_PARAMREFARRAY}, + {"PARAMETER", procParam, ZTOK_PARAM}, + {"METHOD", procMethod, ZTOK_METHODDEF}, + {"CLASS", procClass, ZTOK_CLASS}, {"?xml", procXml, ZTOK_XML}, }; int yylex(YYSTYPE * lvalp, ParserControl * parm) { - int i, m; + int i, m, rc; char *next; + _SFCB_ENTER(TRACE_XMLPARSING, "yylex"); + for (;;) { next = nextTag(parm->xmb); - if (next == NULL) - return 0; - //printf(">> %.32s\n",next); + if (next == NULL) { + _SFCB_RETURN(0); + } + _SFCB_TRACE(1, ("--- token: %.32s\n",next)); if (parm->xmb->eTagFound) { parm->xmb->eTagFound = 0; - return parm->xmb->etag; + _SFCB_RETURN(parm->xmb->etag); } if (*next == '/') { for (i = 0, m = sizeof(tags); i < m; i++) { if (nextEquals(next + 1, tags[i].tag) == 1) { skipTag(parm->xmb); - return tags[i].etag; + _SFCB_RETURN(tags[i].etag); } } } @@ -1050,13 +1228,14 @@ for (i = 0, m = sizeof(tags); i < m; i++) { if (nextEquals(next, tags[i].tag) == 1) { //printf("+++ %d\n",i); - return tags[i].process(lvalp, parm); + rc=tags[i].process(lvalp, parm); + _SFCB_RETURN(rc); } } } break; } - return 0; + _SFCB_RETURN(0); } int yyerror(char *s) Index: constClass.c =================================================================== RCS file: /cvsroot/sblim/sfcb/constClass.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- constClass.c 21 Mar 2005 14:22:38 -0000 1.2 +++ constClass.c 11 Apr 2005 23:13:41 -0000 1.3 @@ -330,4 +330,12 @@ if (rc.rc==0) count++; } return count; +} + +CMPIConstClass initConstClass(ClClass *cl) +{ + CMPIConstClass c; + c.hdl=cl; + c.ft=&ift; + return c; } \ No newline at end of file Index: cimXmlRequest.c =================================================================== RCS file: /cvsroot/sblim/sfcb/cimXmlRequest.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- cimXmlRequest.c 11 Apr 2005 22:50:27 -0000 1.4 +++ cimXmlRequest.c 11 Apr 2005 23:13:41 -0000 1.5 @@ -75,6 +75,7 @@ extern MsgSegment setInstanceMsgSegment(CMPIInstance * ci); extern MsgSegment setCharsMsgSegment(char *str); extern MsgSegment setArgsMsgSegment(CMPIArgs * args); +extern MsgSegment setConstClassMsgSegment(CMPIConstClass * cl); extern void closeProviderContext(BinRequestContext * ctx); extern CMPIStatus arraySetElementNotTrackedAt(CMPIArray * array, CMPICount index, CMPIValue * val, CMPIType type); @@ -526,7 +527,7 @@ path = NewCMPIObjectPath(req->op.nameSpace.data, req->op.className.data, NULL); sreq->objectPath = setObjectPathMsgSegment(path); - sreq->principle = setCharsMsgSegment(ctx->principle); + sreq->principal = setCharsMsgSegment(ctx->principal); for (i=0; i<req->properties; i++) sreq->properties[i]=setCharsMsgSegment(req->propertyList[i]); @@ -563,6 +564,104 @@ _SFCB_RETURN(ctxErrResponse(hdr, &binCtx,0)); } +extern int ClClassAddQualifier(ClObjectHdr * hdr, ClSection * qlfs, + const char *id, CMPIData d); +extern int ClClassAddProperty(ClClass * cls, const char *id, CMPIData d); +extern void *ClObjectGetClSection(ClObjectHdr * hdr, ClSection * s); +extern int ClClassAddPropertyQualifier(ClObjectHdr * hdr, ClProperty * p, + const char *id, CMPIData d); +extern ClClass *ClClassNew(const char *cn, const char *pa); +extern ClClass *ClClassRebuildClass(ClClass * cls, void *area); +extern void ClClassFreeClass(ClClass * cls); +extern char *ClClassToString(ClClass * cls); +extern CMPIConstClass initConstClass(ClClass *cl); + +static RespSegments createClass(CimXmlRequestContext * ctx, RequestHdr * hdr) +{ + _SFCB_ENTER(TRACE_CIMXMLPROC, "createClass"); + CMPIObjectPath *path; + CMPIConstClass cls; + ClClass *cl; + int irc; + BinRequestContext binCtx; + BinResponseHdr *resp; + CreateClassReq sreq = BINREQ(OPS_CreateClass, 3); + + XtokProperty *p = NULL; + XtokProperties *ps = NULL; + XtokQualifiers *qs = NULL; + XtokQualifier *q = NULL; + XtokClass *c; + CMPIData d; + + printf("--- createClass request\n"); + + memset(&binCtx,0,sizeof(BinRequestContext)); + XtokCreateClass *req = (XtokCreateClass *) hdr->cimRequest; + + path = NewCMPIObjectPath(req->op.nameSpace.data, req->op.className.data, NULL); + + cl = ClClassNew(req->op.className.data, req->superClass ? req->superClass : NULL); + cls=initConstClass(cl); + c=&req->cls; + + qs=&c->qualifiers; + for (q=qs->first; q; q=q->next) { + d.state=CMPI_goodValue; + d.value=str2CMPIValue(q->type,q->value,NULL); + d.type=q->type; + ClClassAddQualifier(&cl->hdr, &cl->qualifiers, q->name, d); + } + + ps=&c->properties; + for (p=ps->first; p; p=p->next) { + ClProperty *prop; + int propId; + d.state=CMPI_goodValue; + d.value=str2CMPIValue(p->valueType,p->value,NULL); + d.type=p->valueType; + propId=ClClassAddProperty(cl, p->name, d); + + qs=&p->qualifiers; + prop=((ClProperty*)ClObjectGetClSection(&cl->hdr,&cl->properties))+propId-1; + for (q=qs->first; q; q=q->next) { + d.state=CMPI_goodValue; + d.value=str2CMPIValue(q->type,q->value,NULL); + d.type=q->type; + ClClassAddPropertyQualifier(&cl->hdr, prop, q->name, d); + } + } + + sreq.principal = setCharsMsgSegment(ctx->principal); + sreq.path = setObjectPathMsgSegment(path); + sreq.cls = setConstClassMsgSegment(&cls); + + binCtx.oHdr = (OperationHdr *) req; + binCtx.bHdr = &sreq.hdr; + binCtx.rHdr = hdr; + binCtx.bHdrSize = sizeof(sreq); + binCtx.chunkedMode=binCtx.xmlAs=binCtx.noResp=0; + binCtx.pAs=NULL; + + _SFCB_TRACE(1, ("--- Getting Provider context")); + irc = getProviderContext(&binCtx, (OperationHdr *) req); + printf("--- Getting Provider context %d\n",irc); + + _SFCB_TRACE(1, ("--- Provider context gotten")); + if (irc == MSG_X_PROVIDER) { + resp = invokeProvider(&binCtx); + closeProviderContext(&binCtx); + resp->rc--; + if (resp->rc == CMPI_RC_OK) { + _SFCB_RETURN(iMethodResponse(hdr, NULL)); + } + _SFCB_RETURN(iMethodErrResponse(hdr, getErrSegment(resp->rc, + (char*)resp->object[0].data))); + } + closeProviderContext(&binCtx); + _SFCB_RETURN(ctxErrResponse(hdr, &binCtx,0)); +} + static RespSegments enumClassNames(CimXmlRequestContext * ctx, RequestHdr * hdr) { @@ -579,7 +678,7 @@ path = NewCMPIObjectPath(req->op.nameSpace.data, req->op.className.data, NULL); sreq.objectPath = setObjectPathMsgSegment(path); - sreq.principle = setCharsMsgSegment(ctx->principle); + sreq.principal = setCharsMsgSegment(ctx->principal); sreq.flags = req->flags; binCtx.oHdr = (OperationHdr *) req; @@ -630,7 +729,7 @@ path = NewCMPIObjectPath(req->op.nameSpace.data, req->op.className.data, NULL); sreq.objectPath = setObjectPathMsgSegment(path); - sreq.principle = setCharsMsgSegment(ctx->principle); + sreq.principal = setCharsMsgSegment(ctx->principal); sreq.flags = req->flags; binCtx.oHdr = (OperationHdr *) req; @@ -708,7 +807,7 @@ CMAddKey(path, req->instanceName.bindings.keyBindings[i].name, valp, type); } sreq->objectPath = setObjectPathMsgSegment(path); - sreq->principle = setCharsMsgSegment(ctx->principle); + sreq->principal = setCharsMsgSegment(ctx->principal); for (i=0; i<req->properties; i++) sreq->properties[i]=setCharsMsgSegment(req->propertyList[i]); @@ -770,7 +869,7 @@ type); } sreq.objectPath = setObjectPathMsgSegment(path); - sreq.principle = setCharsMsgSegment(ctx->principle); + sreq.principal = setCharsMsgSegment(ctx->principal); binCtx.oHdr = (OperationHdr *) req; binCtx.bHdr = &sreq.hdr; @@ -822,7 +921,7 @@ } sreq.instance = setInstanceMsgSegment(inst); - sreq.principle = setCharsMsgSegment(ctx->principle); + sreq.principal = setCharsMsgSegment(ctx->principal); path = inst->ft->getObjectPath(inst,NULL); sreq.path = setObjectPathMsgSegment(path); @@ -900,7 +999,7 @@ } sreq->instance = setInstanceMsgSegment(inst); sreq->path = setObjectPathMsgSegment(path); - sreq->principle = setCharsMsgSegment(ctx->principle); + sreq->principal = setCharsMsgSegment(ctx->principal); binCtx.oHdr = (OperationHdr *) req; binCtx.bHdr = &sreq->hdr; @@ -945,7 +1044,7 @@ path = NewCMPIObjectPath(req->op.nameSpace.data, req->op.className.data, NULL); sreq.objectPath = setObjectPathMsgSegment(path); - sreq.principle = setCharsMsgSegment(ctx->principle); + sreq.principal = setCharsMsgSegment(ctx->principal); binCtx.oHdr = (OperationHdr *) req; binCtx.bHdr = &sreq.hdr; @@ -997,7 +1096,7 @@ sreq->count=req->properties+2; path = NewCMPIObjectPath(req->op.nameSpace.data, req->op.className.data, NULL); - sreq->principle = setCharsMsgSegment(ctx->principle); + sreq->principal = setCharsMsgSegment(ctx->principal); sreq->objectPath = setObjectPathMsgSegment(path); for (i=0; i<req->properties; i++) { @@ -1077,7 +1176,7 @@ path = NewCMPIObjectPath(req->op.nameSpace.data, *fCls, NULL); sreq.objectPath = setObjectPathMsgSegment(path); - sreq.principle = setCharsMsgSegment(ctx->principle); + sreq.principal = setCharsMsgSegment(ctx->principal); sreq.query = setCharsMsgSegment((char*)req->op.query.data); sreq.queryLang = setCharsMsgSegment((char*)req->op.queryLang.data); @@ -1163,7 +1262,7 @@ sreq.role = req->op.role; sreq.assocClass = req->op.assocClass; sreq.resultRole = req->op.resultRole; - sreq.principle = setCharsMsgSegment(ctx->principle); + sreq.principal = setCharsMsgSegment(ctx->principal); req->op.className = req->op.assocClass; @@ -1239,7 +1338,7 @@ sreq->assocClass = req->op.assocClass; sreq->resultRole = req->op.resultRole; sreq->flags = req->flags; - sreq->principle = setCharsMsgSegment(ctx->principle); + sreq->principal = setCharsMsgSegment(ctx->principal); for (i=0; i<req->properties; i++) sreq->properties[i]=setCharsMsgSegment(req->propertyList[i]); @@ -1325,7 +1424,7 @@ sreq.resultClass = req->op.resultClass; sreq.role = req->op.role; - sreq.principle = setCharsMsgSegment(ctx->principle); + sreq.principal = setCharsMsgSegment(ctx->principal); req->op.className = req->op.resultClass; @@ -1400,7 +1499,7 @@ sreq->resultClass = req->op.resultClass; sreq->role = req->op.role; sreq->flags = req->flags; - sreq->principle = setCharsMsgSegment(ctx->principle); + sreq->principal = setCharsMsgSegment(ctx->principal); for (i=0; i<req->properties; i++) sreq->properties[i]=setCharsMsgSegment(req->propertyList[i]); @@ -1481,7 +1580,7 @@ CMAddKey(path, req->instanceName.bindings.keyBindings[i].name, valp, type); } sreq.objectPath = setObjectPathMsgSegment(path); - sreq.principle = setCharsMsgSegment(ctx->principle); + sreq.principal = setCharsMsgSegment(ctx->principal); for (p = req->paramValues.first; p; p = p->next) { CMPIValue val = str2CMPIValue(p->type, p->value.value, &p->valueRef); @@ -1539,7 +1638,7 @@ {getInstance}, //OPS_GetInstance 2 {notSupported}, //OPS_DeleteClass 3 {deleteInstance}, //OPS_DeleteInstance 4 - {notSupported}, //OPS_CreateClass 5 + {createClass}, //OPS_CreateClass 5 {createInstance}, //OPS_CreateInstance 6 {notSupported}, //OPS_ModifyClass 7 {modifyInstance}, ... [truncated message content] |