⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 acdutils.c

📁 TAPI ACD Samples
💻 C
📖 第 1 页 / 共 2 页
字号:
    pListItem->dwKey = LISTKEY;
    pListItem->dwSize = sizeof(LISTITEM);
    pListItem->pAgent = pAgent;

    InsertStruct((PGENERICSTRUCT *)&pGroup->pAgentList,
                 (PGENERICSTRUCT)pListItem);
    
    return TRUE;
}

//////////////////////////////////////////////////////////////////////////
//
// BOOL RemoveFromGroupList(PGROUP pGroup,
//
//  remove an agent from a group's list
//
//////////////////////////////////////////////////////////////////////////
BOOL RemoveFromGroupList(PGROUP pGroup,
                         PAGENT pAgent)
{
    PLISTITEM       pList;

    pList = pGroup->pAgentList;

    while (pList)
    {
        if (pList->pAgent == pAgent)
        {
            break;
        }

        pList = pList->pNext;
    }

    if (!pList)
    {
        return FALSE;
    }
    
    DeleteStruct((PGENERICSTRUCT *)&pGroup->pAgentList,
                 (PGENERICSTRUCT)pList);

    return TRUE;
}


////////////////////////////////////////////////////////////////////////////////
//
//PLISTITEM IsAgentInList(PLISTITEM pList,
//                        PAGENT pAgent)
//
////////////////////////////////////////////////////////////////////////////////
PLISTITEM IsAgentInList(PLISTITEM pList,
                        PAGENT pAgent)
{
    while (pList)
    {
        if (pList->pAgent == pAgent)
        {
            return pList;
        }

        pList = pList->pNext;
    }

    return NULL;
}

////////////////////////////////////////////////////////////////////////////////
//
// PAGENT GetAgentFromName(LPTSTR lpszName)
//
////////////////////////////////////////////////////////////////////////////////
PAGENT GetAgentFromName(LPTSTR lpszName)
{
    PAGENT   pHold;

    pHold = g.pAgents;

    while (pHold)
    {
        if (!lstrcmpi(pHold->lpszName,
                     lpszName))
        {
            return pHold;
        }

        pHold = pHold->pNext;
    }

    return NULL;
}

///////////////////////////////////////////////////////////////////////////////
//
// PAGENT GetAgentFromhLine(HLINE hLine)
//
///////////////////////////////////////////////////////////////////////////////
PAGENT GetAgentFromhLine(HLINE hLine)
{
    PAGENT pAgent;

    pAgent = g.pAgents;

    while (pAgent)
    {
        if (pAgent->hLine == hLine)
        {
            return pAgent;
        }
        
        pAgent = pAgent->pNext;
    }

    return NULL;
}

///////////////////////////////////////////////////////////////////////////////
//
//  DWORD GetDeviceID(DWORD dwPermID)
//
///////////////////////////////////////////////////////////////////////////////
DWORD GetDeviceID(DWORD dwPermID)
{
    DWORD   dwCount;

    for (dwCount = 0; dwCount < g.dwNumDevs; dwCount++)
    {
        if (g.pdwPermIDs[dwCount] == dwPermID)
        {
            return dwCount;
        }
    }

    return (DWORD)-1;
}
    
///////////////////////////////////////////////////////////////////////////////
//
//      **************TAPI WRAPPER FUNCTIONS**************
//
///////////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////////
//
// LineGetAddressCaps()
//
///////////////////////////////////////////////////////////////////////////////
LINEADDRESSCAPS * LineGetAddressCaps (HLINEAPP hLineApp,
                                      DWORD    dwDeviceID,
                                      DWORD    dwAddressID)
{
    LONG              lRetVal;
    LINEADDRESSCAPS * pLineAddressCaps;
    static DWORD      dwMaxNeededSize = sizeof(LINEADDRESSCAPS);

    // Allocate an initial block of memory for the LINEADDRESSCAPS structure,
    // which may or may not be big enough to hold all of the information.
    //
    pLineAddressCaps = ACDAlloc(dwMaxNeededSize);

    for (;;)
    {
        if (pLineAddressCaps == NULL)
        {
            return NULL;
        }
        pLineAddressCaps->dwTotalSize = dwMaxNeededSize;

        // Try (or retry) to get the LINEADDRESSCAPS information
        //
        lRetVal = lineGetAddressCaps(hLineApp,
                                     dwDeviceID,
                                     dwAddressID,
                                     TAPI_CURRENT_VERSION,
                                     0,
                                     pLineAddressCaps);
        if (lRetVal < 0)
        {
            ACDFree((HLOCAL)pLineAddressCaps);
            return NULL;
        }

        // If the currently allocated LINEADDRESSCAPS memory block was big
        // enough, we're all done, else we need to realloc the memory block
        // and try again.
        //
        if (pLineAddressCaps->dwNeededSize <= dwMaxNeededSize)
        {
            return pLineAddressCaps;
        }
        else
        {
            dwMaxNeededSize = pLineAddressCaps->dwNeededSize;
            pLineAddressCaps = ACDReAlloc((HLOCAL)pLineAddressCaps,
                                            dwMaxNeededSize);
        }
    }
}


///////////////////////////////////////////////////////////////////////////////
//
// LineGetCallInfo()
//
///////////////////////////////////////////////////////////////////////////////
LINECALLINFO * LineGetCallInfo (HCALL hCall)
{
    LONG           lRetVal;
    LINECALLINFO * pLineCallInfo;
    static DWORD   dwMaxNeededSize = sizeof(LINECALLINFO);

    // Allocate an initial block of memory for the LINECALLINFO structure,
    // which may or may not be big enough to hold all of the information.
    //
    pLineCallInfo = ACDAlloc(dwMaxNeededSize);

    for (;;)
    {
        if (pLineCallInfo == NULL)
        {
            return NULL;
        }
        pLineCallInfo->dwTotalSize = dwMaxNeededSize;

        // Try (or retry) to get the LINECALLINFO information
        //
        lRetVal = lineGetCallInfo(hCall,
                                  pLineCallInfo);
        if (lRetVal < 0)
        {
            ACDFree((HLOCAL)pLineCallInfo);
            return NULL;
        }

        // If the currently allocated LINECALLINFO memory block was big
        // enough, we're all done, else we need to realloc the memory block
        // and try again.
        //
        if (pLineCallInfo->dwNeededSize <= dwMaxNeededSize)
        {
            return pLineCallInfo;
        }
        else
        {
            dwMaxNeededSize = pLineCallInfo->dwNeededSize;
            pLineCallInfo = ACDReAlloc((HLOCAL)pLineCallInfo,
                                         dwMaxNeededSize);
        }
    }
}


///////////////////////////////////////////////////////////////////////////////
//
// LineGetDevCaps()
//
///////////////////////////////////////////////////////////////////////////////
LINEDEVCAPS * LineGetDevCaps (HLINEAPP hLineApp,
                              DWORD    dwDeviceID)
{
    LONG           lRetVal;
    LINEDEVCAPS  * pLineDevCaps;
    static DWORD   dwMaxNeededSize = sizeof(LINEDEVCAPS);

    pLineDevCaps = ACDAlloc(dwMaxNeededSize);
    for (;;)
    {
        if (pLineDevCaps == NULL)
        {
            return NULL;
        }
        pLineDevCaps->dwTotalSize = dwMaxNeededSize;
        lRetVal = lineGetDevCaps(hLineApp,
                                 dwDeviceID,
                                 TAPI_CURRENT_VERSION,
                                 0,
                                 pLineDevCaps);
        if (lRetVal < 0)
        {
            ACDFree((HLOCAL)pLineDevCaps);
            return NULL;
        }
        if (pLineDevCaps->dwNeededSize <= dwMaxNeededSize)
        {
            return pLineDevCaps;
        }
        else
        {
            dwMaxNeededSize = pLineDevCaps->dwNeededSize;
            pLineDevCaps = ACDReAlloc((HLOCAL)pLineDevCaps,
                                        dwMaxNeededSize);
        }
    }
}

///////////////////////////////////////////////////////////////////////////////
//
// LineGetID()
//
///////////////////////////////////////////////////////////////////////////////
VARSTRING * LineGetID (HLINE  hLine,
                       DWORD  dwAddressID,
                       HCALL  hCall,
                       DWORD  dwSelect,
                       LPCTSTR lpszDeviceClass)
{
    LONG           lRetVal;
    VARSTRING    * pVarString;
    static DWORD   dwMaxNeededSize = sizeof(VARSTRING);

    // Allocate an initial block of memory for the VARSTRING structure,
    // which may or may not be big enough to hold all of the information.
    //
    pVarString = ACDAlloc(dwMaxNeededSize);

    for (;;)
    {
        if (pVarString == NULL)
        {
            return NULL;
        }
        pVarString->dwTotalSize = dwMaxNeededSize;

        // Try (or retry) to get the VARSTRING information
        //
        lRetVal = lineGetID(hLine,
                            dwAddressID,
                            hCall,
                            dwSelect,
                            pVarString,
                            lpszDeviceClass);
        if (lRetVal < 0)
        {
            ACDFree(pVarString);
            return NULL;
        }

        // If the currently allocated VARSTRING memory block was big
        // enough, we're all done, else we need to realloc the memory block
        // and try again.
        //
        if (pVarString->dwNeededSize <= dwMaxNeededSize)
        {
            return pVarString;
        }
        else
        {
            dwMaxNeededSize = pVarString->dwNeededSize;
            pVarString = ACDReAlloc((HLOCAL)pVarString,
                                      dwMaxNeededSize);
        }
    }
}


///////////////////////////////////////////////////////////////////////////////
//
// LineGetCallStatus()
//
///////////////////////////////////////////////////////////////////////////////
LINECALLSTATUS * LineGetCallStatus (HCALL hCall)
{
    LONG                lRetVal;
    LINECALLSTATUS    * pLineCallStatus;
    static DWORD        dwMaxNeededSize = sizeof(LINECALLSTATUS);

    // Allocate an initial block of memory for the LINECALLSTATUS structure,
    // which may or may not be big enough to hold all of the information.
    //
    pLineCallStatus = ACDAlloc(dwMaxNeededSize);

    while (TRUE)
    {
        if (pLineCallStatus == NULL)
        {
            return NULL;
        }
        pLineCallStatus->dwTotalSize = dwMaxNeededSize;

        // Try (or retry) to get the LINECALLSTATUS information
        //
        lRetVal = lineGetCallStatus(hCall,
                                    pLineCallStatus);
        if (lRetVal < 0)
        {
            ACDFree((HLOCAL)pLineCallStatus);
            return NULL;
        }

        // If the currently allocated LINECALLSTATUS memory block was big
        // enough, we're all done, else we need to realloc the memory block
        // and try again.
        //
        if (pLineCallStatus->dwNeededSize <= dwMaxNeededSize)
        {
            return pLineCallStatus;
        }
        else
        {
            dwMaxNeededSize = pLineCallStatus->dwNeededSize;
            pLineCallStatus = ACDReAlloc((HLOCAL)pLineCallStatus,
                                         dwMaxNeededSize);
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -