ClRcT clMsgQueueInfoGetClientSync_4_0_0(CL_IN ClIdlHandleT handle, CL_IN ClNameT* pQName, CL_OUT SaMsgQueueCreationAttributesT_4_0_0* pQAttrs)
{
    ClRcT rc = CL_OK;
    ClVersionT funcVer = {4, 0, 0};
    ClUint32T funcNo = CL_EO_GET_FULL_FN_NUM(CL_MSG_CLIENT_SERVER_TABLE_ID, 2);
    ClBufferHandleT inMsgHdl = 0;
    ClBufferHandleT outMsgHdl = 0;
    ClIocAddressT address = {{0}};
    ClIdlHandleObjT* pHandleObj = NULL;
    ClUint32T tempFlags = 0;

    rc = clHandleCheckout(gIdlClnt.idlDbHdl,handle,(void **)&pHandleObj);
    if( rc != CL_OK )
    {
        return rc ;
    }
    if (CL_IDL_ADDRESSTYPE_IOC == pHandleObj->address.addressType)
    {
        address = pHandleObj->address.address.iocAddress;
    }
    else if (CL_IDL_ADDRESSTYPE_NAME == pHandleObj->address.addressType)
    {
        rc = clNameToObjectReferenceGet(&(pHandleObj->address.address.nameAddress.name),
                                        pHandleObj->address.address.nameAddress.attrCount,
                                        pHandleObj->address.address.nameAddress.attr,
                                        pHandleObj->address.address.nameAddress.contextCookie,
                                        (ClUint64T*)&address);
        if (CL_OK != rc)
        {
            return rc;
        }
    }
    else
    {
        return CL_IDL_RC(CL_ERR_INVALID_PARAMETER);
    }

    rc = clBufferCreate(&inMsgHdl);
    if (CL_OK != rc)
    {
        return rc;
    }

    rc = clXdrMarshallClNameT(pQName, inMsgHdl, 0);
    if (CL_OK != rc)
    {
        return rc;
    }


    rc = clBufferCreate(&outMsgHdl);
    if (CL_OK != rc)
    {
        return rc;
    }

    tempFlags |= pHandleObj->flags |
                 (CL_RMD_CALL_NON_PERSISTENT | CL_RMD_CALL_NEED_REPLY);
    tempFlags &= ~CL_RMD_CALL_ASYNC;

    rc = clRmdWithMsgVer(address, &funcVer, funcNo, inMsgHdl, outMsgHdl, tempFlags, &(pHandleObj->options), NULL);
    if(CL_OK != rc)
    {
        clBufferDelete(&outMsgHdl);
    return rc;
    }


    rc = clXdrUnmarshallSaMsgQueueCreationAttributesT_4_0_0( outMsgHdl, pQAttrs);
    if (CL_OK != rc)
    {
        return rc;
    }

    clBufferDelete(&outMsgHdl);
    
    rc = clHandleCheckin(gIdlClnt.idlDbHdl,handle);
    return rc;
}
ClRcT clMsgQueueAllocateServer_4_0_0(ClEoDataT eoData, ClBufferHandleT inMsgHdl, ClBufferHandleT outMsgHdl)
{
    ClIdlContextInfoT *pIdlCtxInfo = NULL;
    ClRcT rc = CL_OK;
    SaNameT  pQName;
    SaMsgQueueOpenFlagsT_4_0_0  openFlags;
    SaMsgQueueCreationAttributesT_4_0_0  pCreationAttributes;
    ClHandleT  pQueueHandle;

    memset(&(pQName), 0, sizeof(SaNameT));
    memset(&(openFlags), 0, sizeof(SaMsgQueueOpenFlagsT_4_0_0));
    memset(&(pCreationAttributes), 0, sizeof(SaMsgQueueCreationAttributesT_4_0_0));
    memset(&(pQueueHandle), 0, sizeof(ClHandleT));


    rc = clXdrUnmarshallSaNameT( inMsgHdl,&(pQName));
    if (CL_OK != rc)
    {
        goto LL0;
    }

    rc = clXdrUnmarshallSaMsgQueueOpenFlagsT_4_0_0( inMsgHdl,&(openFlags));
    if (CL_OK != rc)
    {
        goto LL1;
    }

    rc = clXdrUnmarshallSaMsgQueueCreationAttributesT_4_0_0( inMsgHdl,&(pCreationAttributes));
    if (CL_OK != rc)
    {
        goto LL2;
    }

    pIdlCtxInfo = (ClIdlContextInfoT *)clHeapAllocate(sizeof(ClIdlContextInfoT));
    if(pIdlCtxInfo == NULL)
    {
       return CL_IDL_RC(CL_ERR_NO_MEMORY);
    }
    memset(pIdlCtxInfo, 0, sizeof(ClIdlContextInfoT));
    pIdlCtxInfo->idlDeferMsg = outMsgHdl; 
    pIdlCtxInfo->inProgress  = CL_FALSE;
    rc = clIdlSyncPrivateInfoSet(msgIdlidlSyncKey, (void *)pIdlCtxInfo);
    if (CL_OK != rc)
    {
        clHeapFree(pIdlCtxInfo);
        goto L0;
    }
    rc = clMsgQueueAllocate_4_0_0(&(pQName), openFlags, &(pCreationAttributes), &(pQueueHandle));
    if(pIdlCtxInfo->inProgress == CL_FALSE)
    {
      clHeapFree(pIdlCtxInfo);
      pIdlCtxInfo = NULL;
    }
    if (CL_OK != rc)
    {
       goto L0;
    }
    
    rc = clXdrMarshallSaNameT(&(pQName), 0, 1);
    if (CL_OK != rc)
    {
        goto L1;
    }

    rc = clXdrMarshallSaMsgQueueOpenFlagsT_4_0_0(&(openFlags), 0, 1);
    if (CL_OK != rc)
    {
        goto L2;
    }

    rc = clXdrMarshallSaMsgQueueCreationAttributesT_4_0_0(&(pCreationAttributes), 0, 1);
    if (CL_OK != rc)
    {
        goto L3;
    }

    if(pIdlCtxInfo != NULL)
    {
      clHeapFree(pIdlCtxInfo);
      return rc;
    }
    
    rc = clXdrMarshallClHandleT(&(pQueueHandle), outMsgHdl, 1);
    if (CL_OK != rc)
    {
        goto L4;
    }

L4:    return rc;

LL2:  clXdrMarshallSaMsgQueueCreationAttributesT_4_0_0(&(pCreationAttributes), 0, 1);
LL1:  clXdrMarshallSaMsgQueueOpenFlagsT_4_0_0(&(openFlags), 0, 1);
LL0:  clXdrMarshallSaNameT(&(pQName), 0, 1);

    return rc;

L0:  clXdrMarshallSaNameT(&(pQName), 0, 1);
L1:  clXdrMarshallSaMsgQueueOpenFlagsT_4_0_0(&(openFlags), 0, 1);
L2:  clXdrMarshallSaMsgQueueCreationAttributesT_4_0_0(&(pCreationAttributes), 0, 1);

L3:  clXdrMarshallClHandleT(&(pQueueHandle), 0, 1);

    return rc;
}