Exemplo n.º 1
0
/**
 * \return S_OK for success, S_FALSE for failure
 *
 * Registers a client to the DIL. ClientID will have client id
 * which will be used for further client related calls
 */
HRESULT CDIL_CAN_MHS::CAN_RegisterClient(BOOL bRegister, DWORD& ClientID, char* pacClientName)
{
HRESULT hResult = S_FALSE;
INT Index;

if (bRegister)
  {
  if (sg_unClientCnt < MAX_CLIENT_ALLOWED)
    {
    Index = 0;
    if (!bClientExist(pacClientName, Index))
      {
      //Currently store the client information
      if (_tcscmp(pacClientName, CAN_MONITOR_NODE) == 0)
        {
        //First slot is reserved to monitor node
        ClientID = 1;
        _tcscpy(sg_asClientToBufMap[0].m_acClientName, pacClientName);
        sg_asClientToBufMap[0].m_dwClientID = ClientID;
        sg_asClientToBufMap[0].m_unBufCount = 0;
        }
      else
        {
        if (!bClientExist(CAN_MONITOR_NODE, Index))
          Index = sg_unClientCnt + 1;
        else
          Index = sg_unClientCnt;
        ClientID = dwGetAvailableClientSlot();
        _tcscpy(sg_asClientToBufMap[Index].m_acClientName, pacClientName);
        sg_asClientToBufMap[Index].m_dwClientID = ClientID;
        sg_asClientToBufMap[Index].m_unBufCount = 0;
        }
      sg_unClientCnt++;
      hResult = S_OK;
      }
    else
      {
      ClientID = sg_asClientToBufMap[Index].m_dwClientID;
      hResult = ERR_CLIENT_EXISTS;
      }
    }
  else
    hResult = ERR_NO_MORE_CLIENT_ALLOWED;
  }
else
  {
  if (bRemoveClient(ClientID))
    hResult = S_OK;
  else
    hResult = ERR_NO_CLIENT_EXIST;
  }
return(hResult);
}
Exemplo n.º 2
0
/**
 * Register Client
 */
HRESULT CDIL_CAN_STUB::CAN_RegisterClient(BOOL bRegister,DWORD& ClientID, TCHAR* pacClientName)
{
    USES_CONVERSION;    
    HRESULT hResult = S_FALSE;
    if (bRegister)
    {
        if (sg_unClientCnt < MAX_CLIENT_ALLOWED)
        {        
            INT Index = 0;
            if (!bClientExist(pacClientName, Index))
            {   
                _tcscpy(sg_asClientToBufMap[sg_unClientCnt].pacClientName, pacClientName);
                if (PerformAnOperation(REGISTER) == S_OK)
                {
                    ClientID = sg_asClientToBufMap[sg_unClientCnt].dwClientID = sg_ushTempClientID;
                    sg_asClientToBufMap[sg_unClientCnt].hClientHandle = sg_hTmpClientHandle;
                    sg_asClientToBufMap[sg_unClientCnt].hPipeFileHandle = sg_hTmpPipeHandle;
                    sg_asClientToBufMap[sg_unClientCnt].unBufCount = 0;
                    sg_unClientCnt++;
                    hResult = S_OK;
                }
            }
            else
            {
                ClientID = sg_asClientToBufMap[Index].dwClientID;
                hResult = ERR_CLIENT_EXISTS;
            }
        }
        else
        {
            hResult = ERR_NO_MORE_CLIENT_ALLOWED;
        }
    }
    else
    {
        if (bRemoveClient(ClientID))
        {
            hResult = S_OK;
        }
        else
        {
            hResult = ERR_NO_CLIENT_EXIST;
        }
    }
    return hResult;
}
Exemplo n.º 3
0
/**
* \brief         Registers a client to the DIL.
* \param[in]     bRegister, if TRUE signifies 'Register', FALSE indicates 'Unregister'
* \param[out]    ClientID, is Client ID assigned, will be used for further client related calls
* \param[in]     pacClientName, is the client name
* \return        S_OK for success, S_FALSE for failure
* \authors       Arunkumar Karri
* \date          07.10.2011 Created
*/
HRESULT CDIL_ISOLAR_EVE_VCAN::CAN_RegisterClient(BOOL bRegister, DWORD& ClientID, char* pacClientName)
{
    USES_CONVERSION;
    HRESULT hResult = S_FALSE;

    if (bRegister)
    {
        if (sg_unClientCnt < MAX_CLIENT_ALLOWED)
        {
            INT Index = 0;
            if (!bClientExist(pacClientName, Index))
            {
                /* Currently store the client information */
                if (_tcscmp(pacClientName, CAN_MONITOR_NODE) == 0)
                {
                    /* First slot is reserved to monitor node */
                    ClientID = 1;
                    _tcscpy(sg_asClientToBufMap[0].pacClientName, pacClientName);
                    sg_asClientToBufMap[0].dwClientID = ClientID;
                    sg_asClientToBufMap[0].unBufCount = 0;
                }
                else
                {
                    //if (!bClientExist(CAN_MONITOR_NODE, Index))
                    //{
                    //    Index = sg_unClientCnt + 1;
                    //}
                    //else
                    //{
                    //    /*Index = sg_unClientCnt;*/
                    //}
                    Index = sg_unClientCnt;
                    ClientID = dwGetAvailableClientSlot();
                    _tcscpy(sg_asClientToBufMap[Index].pacClientName, pacClientName);

                    sg_asClientToBufMap[Index].dwClientID = ClientID;
                    sg_asClientToBufMap[Index].unBufCount = 0;
                }
                sg_unClientCnt++;
                hResult = S_OK;
            }
            else
            {
                ClientID = sg_asClientToBufMap[Index].dwClientID;
                hResult = ERR_CLIENT_EXISTS;
            }
        }
        else
        {
            hResult = ERR_NO_MORE_CLIENT_ALLOWED;
        }
    }
    else
    {
        if (bRemoveClient(ClientID))
        {
            hResult = S_OK;
        }
        else
        {
            hResult = ERR_NO_CLIENT_EXIST;
        }
    }

    return hResult;
}