コード例 #1
0
ANSC_STATUS
Bmc2EnvcoAddCommandProperty
    (
        ANSC_HANDLE                 hThisObject,
        ANSC_HANDLE                 hCommandProperty,
        ANSC_HANDLE                 hCommandInsertBefore
    )
{
    ANSC_STATUS                     returnStatus         = ANSC_STATUS_SUCCESS;
    PBMC2_ENV_CONTROLLER_OBJECT     pMyObject            = (PBMC2_ENV_CONTROLLER_OBJECT  )hThisObject;
    PBMC2_ENV_CONTROLLER_PROPERTY   pProperty            = (PBMC2_ENV_CONTROLLER_PROPERTY)&pMyObject->Property;
    PBMC2_COMMAND_PROPERTY          pBmc2CommandProperty = (PBMC2_COMMAND_PROPERTY       )hCommandProperty;
    PBMC2_COMMAND_PROPERTY          pBmc2CommandPropRef  = (PBMC2_COMMAND_PROPERTY       )hCommandInsertBefore;
    ULONG                           ulHashIndex          = AnscHashString(pBmc2CommandProperty->CommandName, AnscSizeOfString(pBmc2CommandProperty->CommandName), BMC2_ENVCO_COMPO_TABLE_SIZE);

    AnscAcquireLock   (&pMyObject->CompoTableLock);
    if ( !pBmc2CommandPropRef )
    {
        AnscQueuePushEntry(&pMyObject->CompoTable[ulHashIndex], &pBmc2CommandProperty->Linkage);
    }
    else
    {
        /* This makes sure that the command property with more specific domain pattern name appears before those
         * with less specific name. So when the command is issued, framework always tries to match domain
         * with longer domain name, therefore there will be no mismatch.
         */
        AnscQueuePushEntryBefore(&pMyObject->CompoTable[ulHashIndex], &pBmc2CommandProperty->Linkage, &pBmc2CommandPropRef->Linkage);
    }
    AnscReleaseLock   (&pMyObject->CompoTableLock);

    return  ANSC_STATUS_SUCCESS;
}
コード例 #2
0
ANSC_STATUS
HttpFcoAddFormElement
    (
        ANSC_HANDLE                 hThisObject,
        ANSC_HANDLE                 hFeo
    )
{
    ANSC_STATUS                     returnStatus  = ANSC_STATUS_SUCCESS;
    PHTTP_FORM_CONTENT_OBJECT       pMyObject     = (PHTTP_FORM_CONTENT_OBJECT)hThisObject;
    PHTTP_HFP_INTERFACE             pHfpIf        = (PHTTP_HFP_INTERFACE      )pMyObject->hHfpIf;
    PHTTP_FORM_ELEMENT              pFormElement  = (PHTTP_FORM_ELEMENT       )hFeo;
    ULONG                           ulHashIndex   = 0;

    ulHashIndex =
        AnscHashString
            (
                pFormElement->Name,
                AnscSizeOfString(pFormElement->Name),
                HTTP_FCO_FEO_TABLE_SIZE
            );

    pFormElement->FormIndex = pMyObject->FormIndex++;
    pFormElement->HashIndex = ulHashIndex;

    AnscAcquireLock   (&pMyObject->FeoTableLock);
    AnscQueuePushEntry(&pMyObject->FeoTable[ulHashIndex], &pFormElement->Linkage);
    AnscReleaseLock   (&pMyObject->FeoTableLock);

    return  ANSC_STATUS_SUCCESS;
}
コード例 #3
0
ファイル: ccsp_cr_profile.c プロジェクト: davekimble/CcspCr
/**********************************************************************

    prototype:

        BOOL
        CcspCrLoadRemoteCRInfo
            (
                ANSC_HANDLE                                 hCcspCr,
                ANSC_HANDLE                                 hXmlHandle
            );

    description:

        This function is called to load single remote cr information

    argument:   ANSC_HANDLE                                 hCcspCr
                the handle of CCSP CR component;

                ANSC_HANDLE                                 hXmlHandle
                the XML handle of remote CR in profile;

    return:     Succeeded or not;

**********************************************************************/
BOOL
CcspCrLoadRemoteCRInfo
    (
        ANSC_HANDLE                                 hCcspCr,
        ANSC_HANDLE                                 hXmlHandle
    )
{
    PCCSP_CR_MANAGER_OBJECT         pMyObject         = (PCCSP_CR_MANAGER_OBJECT)hCcspCr;
    PANSC_XML_DOM_NODE_OBJECT       pObjectNode       = (PANSC_XML_DOM_NODE_OBJECT)hXmlHandle;
    PANSC_XML_DOM_NODE_OBJECT       pChildNode        = (PANSC_XML_DOM_NODE_OBJECT)NULL;
    PCCSP_REMOTE_CRINFO             pCRInfo           = (PCCSP_REMOTE_CRINFO)NULL;
    char                            buffer1[512]       = { 0 };
    char                            buffer2[512]       = { 0 };
    ULONG                           uLength           = 512;

    /* get the prefix */
    pChildNode = (PANSC_XML_DOM_NODE_OBJECT)
        pObjectNode->GetChildByName(pObjectNode, CCSP_CR_XML_NODE_cr_prefix);
     
    if( pChildNode == NULL || pChildNode->GetDataString(pChildNode, NULL, buffer1, &uLength) != ANSC_STATUS_SUCCESS || uLength == 0)
    {
        AnscTraceWarning(("Empty or invalid 'prefix' name.\n"));
        
        return FALSE;
    }

    uLength = 512;
    /* get the id */
    pChildNode = (PANSC_XML_DOM_NODE_OBJECT)
        pObjectNode->GetChildByName(pObjectNode, CCSP_CR_XML_NODE_cr_id);
     
    if( pChildNode == NULL || pChildNode->GetDataString(pChildNode, NULL, buffer2, &uLength) != ANSC_STATUS_SUCCESS || uLength == 0)
    {
        AnscTraceWarning(("Empty or invalid 'id' name.\n"));
        
        return FALSE;
    }

    /* create a remote CR info */
    pCRInfo = (PCCSP_REMOTE_CRINFO)CcspCrAllocateMemory(sizeof(CCSP_REMOTE_CRINFO));

    if( pCRInfo != NULL)
    {
        pCRInfo->pPrefix        = CcspCrCloneString(buffer1);
        pCRInfo->pID            = CcspCrCloneString(buffer2);

        AnscQueuePushEntry(&pMyObject->RemoteCRQueue, &pCRInfo->Linkage);
    }

    return TRUE;
}
コード例 #4
0
ファイル: ccsp_cr_profile.c プロジェクト: davekimble/CcspCr
/**********************************************************************

    prototype:

        BOOL
        CcspCrLoadComponentProfile
            (
                ANSC_HANDLE                                 hCcspCr,
                ANSC_HANDLE                                 hXmlHandle
            );

    description:

        This function is called to load single component profile.

    argument:   ANSC_HANDLE                                 hCcspCr
                the handle of CCSP CR component;

                ANSC_HANDLE                                 hXmlHandle
                the handle of component XML handle in profile;

    return:     Succeeded or not;

**********************************************************************/
BOOL
CcspCrLoadComponentProfile
    (
        ANSC_HANDLE                                 hCcspCr,
        ANSC_HANDLE                                 hXmlHandle
    )
{
    PCCSP_CR_MANAGER_OBJECT         pMyObject         = (PCCSP_CR_MANAGER_OBJECT)hCcspCr;
    PANSC_XML_DOM_NODE_OBJECT       pObjectNode       = (PANSC_XML_DOM_NODE_OBJECT)hXmlHandle;
    PANSC_XML_DOM_NODE_OBJECT       pChildNode        = (PANSC_XML_DOM_NODE_OBJECT)NULL;
    PCCSP_COMPONENT_INFO            pCompInfo         = (PCCSP_COMPONENT_INFO)NULL;
    char                            buffer[512]       = { 0 };
    ULONG                           uLength           = 512;
    ULONG                           uVersion          = 0;

    /* get the name */
    pChildNode = (PANSC_XML_DOM_NODE_OBJECT)
        pObjectNode->GetChildByName(pObjectNode, CCSP_CR_XML_NODE_component_name);
     
    if( pChildNode == NULL || pChildNode->GetDataString(pChildNode, NULL, buffer, &uLength) != ANSC_STATUS_SUCCESS || uLength == 0)
    {
        AnscTraceWarning(("Failed to load component name.\n"));
        
        return FALSE;
    }

    /* get the version */
    pChildNode = (PANSC_XML_DOM_NODE_OBJECT)
        pObjectNode->GetChildByName(pObjectNode, CCSP_CR_XML_NODE_component_version);

    if( pChildNode == NULL || pChildNode->GetDataUlong(pChildNode, NULL, &uVersion) != ANSC_STATUS_SUCCESS)
    {
        AnscTraceWarning(("Failed to load component version.\n"));
        
        return FALSE;
    }

    /* create a Component Info and add it */
    pCompInfo = (PCCSP_COMPONENT_INFO)CcspCrAllocateMemory(sizeof(CCSP_COMPONENT_INFO));

    if( pCompInfo != NULL)
    {
        pCompInfo->pComponentName = CcspCrCloneString(buffer);
        pCompInfo->uVersion       = uVersion;
        pCompInfo->uStatus        = CCSP_Component_NotRegistered;

        AnscQueuePushEntry(&pMyObject->CompInfoQueue, &pCompInfo->Linkage);
    }

    return TRUE;
}
コード例 #5
0
ANSC_STATUS
AnscLpccoAddPartyAddr
    (
        ANSC_HANDLE                 hThisObject,
        ANSC_HANDLE                 party_addr
    )
{
    ANSC_STATUS                     returnStatus = ANSC_STATUS_SUCCESS;
    PANSC_LPC_CONNECTOR_OBJECT      pMyObject    = (PANSC_LPC_CONNECTOR_OBJECT)hThisObject;
    PANSC_LPC_PARTY_ADDR            pPartyAddr   = (PANSC_LPC_PARTY_ADDR      )party_addr;
    char*                           pPartyName   = (char*                     )pPartyAddr->PartyName;
    ULONG                           ulHashIndex  = AnscHashString(pPartyName, AnscSizeOfString(pPartyName), ANSC_LPCCO_PARTY_TABLE_SIZE);

    if ( pMyObject->GetPartyAddr
            (
                (ANSC_HANDLE)pMyObject,
                pPartyName
            ) != (ANSC_HANDLE)NULL )
    {
        AnscTrace
            (
                "[AnscLpccoAddPartyAddr] collison found, failed to add party <%s> from %d.%d.%d.%d (%d)\n",
                pPartyAddr->PartyName,
                pPartyAddr->PartyAddr.Dot[0],
                pPartyAddr->PartyAddr.Dot[1],
                pPartyAddr->PartyAddr.Dot[2],
                pPartyAddr->PartyAddr.Dot[3],
                pPartyAddr->PartyPort
            );

        return  ANSC_STATUS_COLLISION;
    }

    AnscAcquireLock   (&pMyObject->PartyTableLock);
    AnscQueuePushEntry(&pMyObject->PartyTable[ulHashIndex], &pPartyAddr->Linkage);
    AnscReleaseLock   (&pMyObject->PartyTableLock);

    AnscTrace
        (
            "[AnscLpccoAddPartyAddr] party <%s> from %d.%d.%d.%d (%d) has been added.\n",
            pPartyAddr->PartyName,
            pPartyAddr->PartyAddr.Dot[0],
            pPartyAddr->PartyAddr.Dot[1],
            pPartyAddr->PartyAddr.Dot[2],
            pPartyAddr->PartyAddr.Dot[3],
            pPartyAddr->PartyPort
        );

    return  ANSC_STATUS_SUCCESS;
}
コード例 #6
0
ANSC_STATUS
DslhObjroAddVarRecord
    (
        ANSC_HANDLE                 hThisObject,
        ANSC_HANDLE                 hVarRecord
    )
{
    PDSLH_OBJ_RECORD_OBJECT         pMyObject       = (PDSLH_OBJ_RECORD_OBJECT)hThisObject;
    PDSLH_OBJ_ENTITY_OBJECT         pObjEntity      = (PDSLH_OBJ_ENTITY_OBJECT)pMyObject->hDslhObjEntity;
    PDSLH_VAR_RECORD_OBJECT         pChildVarRecord = (PDSLH_VAR_RECORD_OBJECT)hVarRecord;

    AnscQueuePushEntry(&pMyObject->VarroTable, &pChildVarRecord->Linkage);

    return  ANSC_STATUS_SUCCESS;
}
コード例 #7
0
ANSC_STATUS
AnscLpccoAddPendingCall
    (
        ANSC_HANDLE                 hThisObject,
        ANSC_HANDLE                 hPendingCall
    )
{
    ANSC_STATUS                     returnStatus = ANSC_STATUS_SUCCESS;
    PANSC_LPC_CONNECTOR_OBJECT      pMyObject    = (PANSC_LPC_CONNECTOR_OBJECT)hThisObject;
    PANSC_LPCCO_PENDING_CALL        pPendingCall = (PANSC_LPCCO_PENDING_CALL  )hPendingCall;

    AnscAcquireLock   (&pMyObject->PcallQueueLock);
    AnscQueuePushEntry(&pMyObject->PcallQueue, &pPendingCall->Linkage);
    AnscReleaseLock   (&pMyObject->PcallQueueLock);

    return  ANSC_STATUS_SUCCESS;
}
コード例 #8
0
ANSC_STATUS
Bmc2EnvcoAddComTerminal
    (
        ANSC_HANDLE                 hThisObject,
        ANSC_HANDLE                 hComTerminal
    )
{
    ANSC_STATUS                     returnStatus     = ANSC_STATUS_SUCCESS;
    PBMC2_ENV_CONTROLLER_OBJECT     pMyObject        = (PBMC2_ENV_CONTROLLER_OBJECT  )hThisObject;
    PBMC2_ENV_CONTROLLER_PROPERTY   pProperty        = (PBMC2_ENV_CONTROLLER_PROPERTY)&pMyObject->Property;
    PBMC2_COM_TERMINAL_OBJECT       pBmc2ComTerminal = (PBMC2_COM_TERMINAL_OBJECT    )hComTerminal;

    AnscAcquireLock   (&pMyObject->ComtoQueueLock);
    AnscQueuePushEntry(&pMyObject->ComtoQueue, &pBmc2ComTerminal->Linkage);
    AnscReleaseLock   (&pMyObject->ComtoQueueLock);

    return  ANSC_STATUS_SUCCESS;
}
コード例 #9
0
ANSC_STATUS
DslhObjroAddObjRecord
    (
        ANSC_HANDLE                 hThisObject,
        ANSC_HANDLE                 hObjRecord
    )
{
    ANSC_STATUS                     returnStatus    = ANSC_STATUS_SUCCESS;
    PDSLH_OBJ_RECORD_OBJECT         pMyObject       = (PDSLH_OBJ_RECORD_OBJECT)hThisObject;
    PDSLH_OBJ_ENTITY_OBJECT         pObjEntity      = (PDSLH_OBJ_ENTITY_OBJECT)pMyObject->hDslhObjEntity;
    PDSLH_OBJ_RECORD_OBJECT         pChildObjRecord = (PDSLH_OBJ_RECORD_OBJECT)hObjRecord;
    char                            next_ins_name[16];

    AnscQueuePushEntry(&pMyObject->ObjroQueue, &pChildObjRecord->Linkage);

    if ( pObjEntity->ObjDescr && (pObjEntity->ObjDescr->Type == DSLH_CWMP_OBJECT_TYPE_table) )
    {
        pMyObject->NextInstanceNumber = (ULONG)_ansc_atoi(pChildObjRecord->LastName);

        do
        {
            pMyObject->NextInstanceNumber++;

            if ( pMyObject->NextInstanceNumber == 0 )
            {
                pMyObject->NextInstanceNumber = 1;
            }

            AnscZeroMemory(next_ins_name, 16);
            _ansc_itoa(pMyObject->NextInstanceNumber, next_ins_name, 10);

            pChildObjRecord =
                (PDSLH_OBJ_RECORD_OBJECT)pMyObject->GetObjRecord
                    (
                        (ANSC_HANDLE)pMyObject,
                        next_ins_name
                    );
        }
        while ( pChildObjRecord );
    }

    return  ANSC_STATUS_SUCCESS;
}
コード例 #10
0
ANSC_STATUS
TlsSmoAddSession
(
    ANSC_HANDLE                 hThisObject,
    ANSC_HANDLE                 hSession
)
{
    PTLS_SESSION_MANAGER_OBJECT     pMyObject     = (PTLS_SESSION_MANAGER_OBJECT  )hThisObject;
    PTLS_SESSION_ENTRY_OBJECT       pSessionEntry = (PTLS_SESSION_ENTRY_OBJECT    )hSession;
    ULONG                           ulHashIndex   = AnscHashUlong(pSessionEntry->SessionState.PeerID, TLS_SMO_SEO_TABLE_SIZE);

    pSessionEntry->Timestamp        = AnscGetTickInSeconds();

    AnscAcquireLock   (&pMyObject->SeoTableLock);
    AnscQueuePushEntry(&pMyObject->SeoTable[ulHashIndex], &pSessionEntry->Linkage);
    AnscReleaseLock   (&pMyObject->SeoTableLock);

    return  ANSC_STATUS_SUCCESS;
}
コード例 #11
0
ANSC_STATUS
HttpBmoAddHeaderField
    (
        ANSC_HANDLE                 hThisObject,
        ANSC_HANDLE                 hHfo
    )
{
    ANSC_STATUS                     returnStatus = ANSC_STATUS_SUCCESS;
    PHTTP_BASIC_MESSAGE_OBJECT      pMyObject    = (PHTTP_BASIC_MESSAGE_OBJECT)hThisObject;
    PHTTP_HFP_INTERFACE             pHfpIf       = (PHTTP_HFP_INTERFACE       )pMyObject->hHfpIf;
    PHTTP_HEADER_FIELD              pHttpHfo     = (PHTTP_HEADER_FIELD        )hHfo;
    ULONG                           ulHashIndex  = AnscHashUlong(pHttpHfo->HeaderId, HTTP_BMO_HFO_TABLE_SIZE);

    pHttpHfo->HashIndex = ulHashIndex;

    AnscAcquireLock   (&pMyObject->HfoTableLock);
    AnscQueuePushEntry(&pMyObject->HfoTable[ulHashIndex], &pHttpHfo->Linkage);
    AnscReleaseLock   (&pMyObject->HfoTableLock);

    return  ANSC_STATUS_SUCCESS;
}
コード例 #12
0
ANSC_HANDLE
AnscXmlDomNodeAddChild
    (
        ANSC_HANDLE                 hThisObject,
        ANSC_HANDLE                 hChildNode
    )
{
    ANSC_STATUS                     returnStatus  = ANSC_STATUS_SUCCESS;
    PANSC_XML_DOM_NODE_OBJECT       pXmlNode      = (PANSC_XML_DOM_NODE_OBJECT)hThisObject;
    PANSC_XML_DOM_NODE_OBJECT       pChildNode    = (PANSC_XML_DOM_NODE_OBJECT)hChildNode;

    AnscAcquireXmlLock(&pXmlNode->ChildNodeQueueLock);
    AnscQueuePushEntry(&pXmlNode->ChildNodeQueue, &pChildNode->Linkage);
    AnscReleaseXmlLock(&pXmlNode->ChildNodeQueueLock);

    AnscXmlDomNodeSetParentNode((ANSC_HANDLE)pChildNode, (ANSC_HANDLE)pXmlNode);

    AnscXmlDomNodeSetLevel((ANSC_HANDLE)pChildNode, AnscXmlDomNodeGetLevel((ANSC_HANDLE)pXmlNode) + 1);

    return  (ANSC_HANDLE)pChildNode;
}
コード例 #13
0
ANSC_STATUS
BwrmEcoRamForcePageCache
    (
        ANSC_HANDLE                 hThisObject,
        char*                       page_path,
        BOOL                        bCachedForced
    )
{
    ANSC_STATUS                     returnStatus     = ANSC_STATUS_SUCCESS;
    PBWRM_ENV_CONTROLLER_OBJECT     pMyObject        = (PBWRM_ENV_CONTROLLER_OBJECT  )hThisObject;
    PBWRM_ENV_CONTROLLER_PROPERTY   pProperty        = (PBWRM_ENV_CONTROLLER_PROPERTY)&pMyObject->Property;
    PSINGLE_LINK_ENTRY              pSLinkEntry      = (PSINGLE_LINK_ENTRY         )NULL;
    PBWRM_ENV_CACHE_FORCED_PAGE     pCacheForcedPage = (PBWRM_ENV_CACHE_FORCED_PAGE)NULL;
    BOOL                            bFound           = FALSE;
    ULONG                           ulLen            = AnscSizeOfString(page_path);

    AnscAcquireLock(&pMyObject->AccessLock);

    pSLinkEntry = AnscQueueGetFirstEntry(&pMyObject->ForcedCachedPages);

    while ( pSLinkEntry )
    {
        pCacheForcedPage = ACCESS_BWRM_ENV_CACHE_FORCED_PAGE(pSLinkEntry);
        pSLinkEntry      = AnscQueueGetNextEntry(pSLinkEntry);

        if ( ulLen == AnscSizeOfString(pCacheForcedPage->PagePath) &&
             AnscEqualString2(pCacheForcedPage->PagePath, page_path, ulLen, FALSE) )
        {
            bFound = TRUE;
            break;
        }
    }

    if ( bFound && !bCachedForced )
    {
        /* remove it from the list */
        AnscQueuePopEntryByLink(&pMyObject->ForcedCachedPages, &pCacheForcedPage->Linkage);
    }
    else if ( bCachedForced && !bFound )
    {
        pCacheForcedPage = (PBWRM_ENV_CACHE_FORCED_PAGE)AnscAllocateMemory(sizeof(BWRM_ENV_CACHE_FORCED_PAGE));

        if ( pCacheForcedPage )
        {
            pCacheForcedPage->PagePath = AnscCloneString(page_path);

            if ( pCacheForcedPage->PagePath )
            {
                AnscQueuePushEntry(&pMyObject->ForcedCachedPages, &pCacheForcedPage->Linkage);
            }
            else
            {
                BwrmEnvRemoveCacheForcedPage(pCacheForcedPage);
            }
        }
    }

    AnscReleaseLock(&pMyObject->AccessLock);

    return  returnStatus;
}
コード例 #14
0
ファイル: ccsp_cr_profile.c プロジェクト: davekimble/CcspCr
/**********************************************************************

    prototype:

        BOOL
        CcspCrLoadDeviceProfile
            (
                ANSC_HANDLE                                 hCcspCr
            );

    description:

        This function is called to load device profile for CR.

    argument:   ANSC_HANDLE                                 hCcspCr
                the handle of CCSP CR component;

    return:     Succeeded or not;

**********************************************************************/
BOOL
CcspCrLoadDeviceProfile
    (
        ANSC_HANDLE                                 hCcspCr
    )
{
    PCCSP_CR_MANAGER_OBJECT         pMyObject          = (PCCSP_CR_MANAGER_OBJECT)hCcspCr;
    PCCSP_NAMESPACE_MGR_OBJECT      pNSMgr             = (PCCSP_NAMESPACE_MGR_OBJECT)pMyObject->hCcspNamespaceMgr;
    ANSC_HANDLE                     pFileHandle        = NULL;
    char*                           pXMLContent        = NULL;
    char*                           pBackContent       = NULL;
    ULONG                           uXMLLength         = 0;
    PANSC_XML_DOM_NODE_OBJECT       pXmlNode           = (PANSC_XML_DOM_NODE_OBJECT)NULL;
    PANSC_XML_DOM_NODE_OBJECT       pListNode          = (PANSC_XML_DOM_NODE_OBJECT)NULL;
    PANSC_XML_DOM_NODE_OBJECT       pChildNode         = (PANSC_XML_DOM_NODE_OBJECT)NULL;
    BOOL                            bStatus            = TRUE;
    ULONG                           uFileLength        = 0;
    ULONG                           uBufferSize        = 0;
    char                            buffer[512]        = { 0 };
    ULONG                           uLength            = 511;
    PCCSP_COMPONENT_INFO            pCompInfo          = (PCCSP_COMPONENT_INFO)NULL;

    /* load from the file */
    pFileHandle =
        AnscOpenFile
        (
            CCSP_CR_DEVICE_PROFILE_XML_FILE,
            ANSC_FILE_O_BINARY | ANSC_FILE_O_RDONLY,
            ANSC_FILE_S_IREAD
        );

    if( pFileHandle == NULL)
    {
        AnscTrace("Failed to load the file : '%s'\n", CCSP_CR_DEVICE_PROFILE_XML_FILE);

        return FALSE;
    }

    uFileLength = AnscGetFileSize( pFileHandle);

    pXMLContent = (char*)AnscAllocateMemory( uFileLength + 8);

    if( pXMLContent == NULL)
    {
        return FALSE;
    }

    uBufferSize = uFileLength + 8;

    if( AnscReadFile( pFileHandle, pXMLContent, &uBufferSize) != ANSC_STATUS_SUCCESS)
    {
        AnscFreeMemory(pXMLContent);

        return FALSE;
    }

    if( pFileHandle != NULL)
    {
        AnscCloseFile(pFileHandle);
    }

    /* parse the XML content */
    pBackContent = pXMLContent;

    pXmlNode = (PANSC_XML_DOM_NODE_OBJECT)
        AnscXmlDomParseString((ANSC_HANDLE)NULL, (PCHAR*)&pXMLContent, uBufferSize);

    AnscFreeMemory(pBackContent);

    if( pXmlNode == NULL)
    {
        AnscTraceWarning(("Failed to parse the CR profile file.\n"));

        return FALSE;
    }

    /* load CR name */
    pChildNode  = (PANSC_XML_DOM_NODE_OBJECT)
		AnscXmlDomNodeGetChildByName(pXmlNode, CCSP_CR_XML_NODE_crName); 

    if( pChildNode != NULL && pChildNode->GetDataString(pChildNode, NULL, buffer, &uLength) == ANSC_STATUS_SUCCESS && uLength > 0)
    {
        pMyObject->pCRName = AnscCloneString(buffer);
    }
    else
    {
        pMyObject->pCRName = AnscCloneString(CCSP_CR_NAME);
    }

    AnscTraceWarning(("CR Name: %s\n", pMyObject->pCRName));

#if 0
    /* load prefix name */
    /* Prefix will be set from command line instead */
    uLength            = 511;
    AnscZeroMemory(buffer, 512);

    pChildNode  = (PANSC_XML_DOM_NODE_OBJECT)
		AnscXmlDomNodeGetChildByName(pXmlNode, CCSP_CR_XML_NODE_prefix); 

    if( pChildNode != NULL && pChildNode->GetDataString(pChildNode, NULL, buffer, &uLength) == ANSC_STATUS_SUCCESS && uLength > 0)
    {
        pMyObject->pPrefix = AnscCloneString(buffer);

        pNSMgr->SubsysPrefix = AnscCloneString(buffer);

        AnscTraceWarning(("CR Prefix: %s\n", pMyObject->pPrefix));
    }
#endif

    /* get remote cr array */
    pListNode = (PANSC_XML_DOM_NODE_OBJECT)
		AnscXmlDomNodeGetChildByName(pXmlNode, CCSP_CR_XML_NODE_remote);

    if( pListNode != NULL)
    {
        pChildNode = (PANSC_XML_DOM_NODE_OBJECT)
		    AnscXmlDomNodeGetHeadChild(pListNode);

        while(pChildNode != NULL)
        {
            /* load remote cr information */
            if(!CcspCrLoadRemoteCRInfo(hCcspCr, (ANSC_HANDLE)pChildNode))
            {
                AnscTraceWarning(("Failed to load remote cr infor.\n"));
            }

            pChildNode = (PANSC_XML_DOM_NODE_OBJECT)
		        AnscXmlDomNodeGetNextChild(pListNode, pChildNode);
        }
    }


    /* get the component array node */
    pListNode = (PANSC_XML_DOM_NODE_OBJECT)
		AnscXmlDomNodeGetChildByName(pXmlNode, CCSP_CR_XML_NODE_components);

    if( pListNode != NULL)
    {
        pChildNode = (PANSC_XML_DOM_NODE_OBJECT)
		    AnscXmlDomNodeGetHeadChild(pListNode);

        while(pChildNode != NULL)
        {
            /* load component information */
            if(!CcspCrLoadComponentProfile(hCcspCr, (ANSC_HANDLE)pChildNode))
            {
                AnscTraceWarning(("Failed to load component profile.\n"));
            }

            pChildNode = (PANSC_XML_DOM_NODE_OBJECT)
		        AnscXmlDomNodeGetNextChild(pListNode, pChildNode);
        }
    }

    if( pXmlNode != NULL)
    {
        pXmlNode->Remove(pXmlNode);
    }


    /* create a Component Info for CR itself */
    pCompInfo = (PCCSP_COMPONENT_INFO)CcspCrAllocateMemory(sizeof(CCSP_COMPONENT_INFO));

    if( pCompInfo != NULL)
    {
        pCompInfo->pComponentName = CcspCrCloneString(CCSP_CR_NAME);
        pCompInfo->uVersion       = CCSP_CR_VERSION;
        pCompInfo->uStatus        = CCSP_Component_NotRegistered;

        AnscQueuePushEntry(&pMyObject->CompInfoQueue, &pCompInfo->Linkage);
    }

    return bStatus;
}
コード例 #15
0
ANSC_HANDLE
AnscXmlDomNodeCopy
    (
        ANSC_HANDLE                 hNode
    )
{
    CHAR                            pNodeName[128]  = { 0 };
    ULONG                           uNodeLength     = 128;

    PANSC_XML_DOM_NODE_OBJECT       pOld            = (PANSC_XML_DOM_NODE_OBJECT)hNode;
    PANSC_XML_DOM_NODE_OBJECT       pCopy           = NULL;

    PANSC_XML_ATTRIBUTE             pFirst          = NULL;
    PANSC_XML_ATTRIBUTE             pNewAttribute   = NULL;

    PANSC_XML_DOM_NODE_OBJECT       pFirstNode      = NULL;
    ANSC_HANDLE                     hCopy, hChild;

    if( hNode == NULL)
    {
        return (ANSC_HANDLE)NULL;
    }

    /* create a new node with the node name */
    pCopy = (PANSC_XML_DOM_NODE_OBJECT)AnscXmlDomNodeCreate(pOld->hOwnerContext);
    if( pCopy == NULL)
    {
        return (ANSC_HANDLE)NULL;
    }

    hCopy = (ANSC_HANDLE)pCopy;

    AnscXmlDomNodeSetName(hCopy, AnscXmlDomNodeGetName(hNode));

    /* copy all the attributes */
    pFirst = (PANSC_XML_ATTRIBUTE)AnscXmlDomNodeGetFirstAttr(hNode);
    while ( pFirst != NULL)
    {
        /*
         * generate a new tree Attribute
         */
        pNewAttribute = (PANSC_XML_ATTRIBUTE)AnscAllocateMemory(sizeof(ANSC_XML_ATTRIBUTE));

        if ( !pNewAttribute )
        {
        	AnscXmlDomNodeRemove( hCopy );
            ANSC_XML_TRACE("Failed to allocate attribute structure for in ALXMLCopyHandle\n");

            return (ANSC_HANDLE)NULL;
        }

        AnscZeroMemory(pNewAttribute, sizeof(ANSC_XML_ATTRIBUTE));
        pNewAttribute->hParentNode   = (ANSC_HANDLE)pCopy;
        pNewAttribute->hXMLContext   = pCopy->hXMLContext;
        pNewAttribute->DataSize      = pFirst->DataSize;
        pNewAttribute->StringData    = AnscAllocateMemory( pFirst->DataSize + 1);

        if( pNewAttribute->StringData != NULL)
        {
            AnscZeroMemory(pNewAttribute->StringData,pFirst->DataSize + 1);

            /* copy the attribute name and value */
            AnscCopyString(pNewAttribute->Name, pFirst->Name);

            if( pFirst->StringData != NULL)
            {
                AnscCopyMemory(pNewAttribute->StringData, pFirst->StringData, pNewAttribute->DataSize);
            }

            /* add the attribute to the list */
            AnscAcquireXmlLock(&pCopy->AttributesListLock);
            AnscQueuePushEntry(&pCopy->AttributesList, &pNewAttribute->Linkage);
            AnscReleaseXmlLock(&pCopy->AttributesListLock);
        }
        else
        {
            AnscFreeMemory(pNewAttribute);
        }

        /* goto next attribute */
        pFirst = (PANSC_XML_ATTRIBUTE)AnscXmlDomNodeGetNextAttr(hNode, (ANSC_HANDLE)pFirst);
    }

     /* copy the text value */
    if( pOld->DataSize > 0 && pOld->StringData != NULL)
    {
        pCopy->DataSize   = pOld->DataSize;
        pCopy->StringData = AnscAllocateMemory( pOld->DataSize + 1);

        if( pCopy->StringData != NULL)
        {
            AnscZeroMemory(pCopy->StringData, pOld->DataSize + 1);
            AnscCopyMemory(pCopy->StringData, pOld->StringData, pOld->DataSize);
        }
        else
        {
            pCopy->DataSize = 0;
        }
    }

    /* create and copy all the child node */
    pFirstNode  = AnscXmlDomNodeGetHeadChild(hNode);

    while( pFirstNode )
    {
        hChild  = AnscXmlDomNodeCopy((ANSC_HANDLE)pFirstNode);
        if (hChild)
        	AnscXmlDomNodeAddChild(hCopy, hChild);

        /* goto the next node */
        pFirstNode = AnscXmlDomNodeGetNextChild(hNode, (ANSC_HANDLE)pFirstNode);
    }

    return hCopy;
}