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

📄 ospmsgque.c

📁 mgcp协议源代码。支持多种编码:g711
💻 C
字号:
/**########################################################################*########################################################################*########################################################################*                                                               *   COPYRIGHT (c) 1998, 1999 by TransNexus, LLC                          *                                                                    *   This software contains proprietary and confidential information  *   of TransNexus, LLC. Except as may be set forth in the license    *   agreement under which this software is supplied, use, disclosure, *   or reproduction is prohibited without the prior, express, written*   consent of TransNexus, LLC.                                      *                                     *******#########################################################################*#########################################################################*#########################################################################*//* * ospmsgque.cpp - MsgQueue object funcions. */#include "osp.h"#include "ospmsgque.h"#include "ospmsginfo.h"#include "osplist.h"staticintosppMsgQueueInitSync(    OSPTMSGQUEUE *ospvMsgQueue){    int errorcode = OSPC_ERR_NO_ERROR,        tmperror  = OSPC_ERR_NO_ERROR;    OSPM_MUTEX_INIT(ospvMsgQueue->Mutex, OSPC_OSNULL, errorcode);    if (errorcode == OSPC_ERR_NO_ERROR)    {        OSPM_CONDVAR_INIT(ospvMsgQueue->CondVar, OSPC_OSNULL, errorcode);        if (errorcode != OSPC_ERR_NO_ERROR)        {            OSPM_MUTEX_DESTROY(ospvMsgQueue->Mutex, tmperror);        }    }            return errorcode;}intOSPPMsgQueueNew(    OSPTMSGQUEUE **ospvMsgQueue){    int errorcode = OSPC_ERR_NO_ERROR;    OSPM_MALLOC(*ospvMsgQueue, OSPTMSGQUEUE, sizeof(OSPTMSGQUEUE));    if (*ospvMsgQueue != (OSPTMSGQUEUE *)OSPC_OSNULL)     {        OSPM_MEMSET(*ospvMsgQueue, 0, sizeof(OSPTMSGQUEUE));        /*         * initialize the mutex and conditional variable         * for the message queue         */        errorcode = osppMsgQueueInitSync(*ospvMsgQueue);        /*         * initialize the list used to hold message info         * structures (items)         */        OSPPListNew((OSPTLIST *)&((*ospvMsgQueue)->MsgInfoList));        if (errorcode != OSPC_ERR_NO_ERROR)            OSPM_FREE(*ospvMsgQueue);    }    if (errorcode != OSPC_ERR_NO_ERROR)    {        errorcode = OSPC_ERR_MSGQ_NO_MEMORY;        OSPM_DBGERRORLOG(errorcode, "ospvMsgQueue malloc failed");    }    return errorcode;}voidOSPPMsgQueueDelete(    OSPTMSGQUEUE **ospvMsgQueue){    if (*ospvMsgQueue != (OSPTMSGQUEUE *)OSPC_OSNULL)    {        OSPM_FREE(*ospvMsgQueue);        *ospvMsgQueue = (OSPTMSGQUEUE *)OSPC_OSNULL;    }    return;}voidOSPPMsgQueueIncrementNumberOfTransactions(    OSPTMSGQUEUE *ospvMsgQueue){    if (ospvMsgQueue != OSPC_OSNULL)    {        ospvMsgQueue->NumberOfTransactions++;    }    return;}voidOSPPMsgQueueDecrementNumberOfTransactions(    OSPTMSGQUEUE *ospvMsgQueue){    if (ospvMsgQueue != OSPC_OSNULL)    {        ospvMsgQueue->NumberOfTransactions--;    }    return;}intOSPPMsgQueueAddTransaction(    OSPTMSGQUEUE *ospvMsgQueue,    OSPTMSGINFO  *ospvMsgInfo){    int errorcode = OSPC_ERR_NO_ERROR;    if (ospvMsgQueue == OSPC_OSNULL)    {        errorcode = OSPC_ERR_UTIL_INVALID_ARG;    }    if (ospvMsgInfo == OSPC_OSNULL)    {        errorcode = OSPC_ERR_UTIL_INVALID_ARG;    }    /*     * acquire message queue mutex     */    if (errorcode == OSPC_ERR_NO_ERROR)    {        OSPM_MUTEX_LOCK(ospvMsgQueue->Mutex, errorcode);    }    if (errorcode == OSPC_ERR_NO_ERROR)    {        /*         * add the item to the message queue list         */        OSPPListAppend((OSPTLIST *)&(ospvMsgQueue->MsgInfoList),             (void *)ospvMsgInfo);        /*         * increment number of transactions in the queue         */        OSPPMsgQueueIncrementNumberOfTransactions(ospvMsgQueue);        /*         * signal the communication manager that a new         * transaction is now in the queue         */        OSPM_CONDVAR_SIGNAL(ospvMsgQueue->CondVar, errorcode);        assert(errorcode == OSPC_ERR_NO_ERROR);        /* release msg queue mutex lock */        OSPM_MUTEX_UNLOCK(ospvMsgQueue->Mutex, errorcode);        assert(errorcode == OSPC_ERR_NO_ERROR);        /*         * wait for transaction response from the         * the communication manager         */        errorcode = OSPPMsgInfoWaitForMsg(ospvMsgInfo);    }    return errorcode;}

⌨️ 快捷键说明

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