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

📄 osptokeninfo.c

📁 mgcp协议源代码。支持多种编码:g711
💻 C
📖 第 1 页 / 共 2 页
字号:
}/**//*-----------------------------------------------------------------------* * OSPPTokenInfoGetValidUntil() - returns valid until time *-----------------------------------------------------------------------*/OSPTTIME                                   /* returns time */    OSPPTokenInfoGetValidUntil(    OSPTTOKENINFO *ospvTokenInfo                     /* token in question */    ){    OSPTTIME ospvValidUntil = 0;    if(ospvTokenInfo != OSPC_OSNULL)    {        ospvValidUntil = (ospvTokenInfo)->ospmTokenInfoValidUntil;    }    return(ospvValidUntil);}/**//*-----------------------------------------------------------------------* * OSPPTokenInfoSetTrxId() - set the transaction id *-----------------------------------------------------------------------*/void                                /* nothing returned */OSPPTokenInfoSetTrxId(    OSPTTOKENINFO *ospvTokenInfo,     /* token info to set */    OSPTTRXID ospvTrxId    /* transaction id to set to */){    if (ospvTokenInfo != OSPC_OSNULL)     {        if (ospvTrxId  != (OSPTTRXID)OSPC_OSNULL)         {            ospvTokenInfo->ospmTokenInfoTrxId = ospvTrxId;        }    }    return;}/**//*-----------------------------------------------------------------------* * OSPPTokenInfoGetTrxId() - returns the trans id for a token info *-----------------------------------------------------------------------*/OSPTTRXID    OSPPTokenInfoGetTrxId(    OSPTTOKENINFO *ospvTokenInfo                     /* token info */    ){    OSPTTRXID ospvTrxId = 0;    if (ospvTokenInfo != OSPC_OSNULL)     {        ospvTrxId = ospvTokenInfo->ospmTokenInfoTrxId;    }    return ospvTrxId;}/**//*-----------------------------------------------------------------------* * OSPPTokenInfoSetDuration() - set the duration *-----------------------------------------------------------------------*/void                                /* nothing returned */OSPPTokenInfoSetDuration(    OSPTTOKENINFO *ospvTokenInfo,     /* token info to set */    int ospvDuration /* duration to set to */){    if (ospvTokenInfo != OSPC_OSNULL)    {        if (ospvDuration  >= 0)        {            ospvTokenInfo->ospmTokenInfoDuration = ospvDuration;        }    }    return;}/**//*-----------------------------------------------------------------------* * OSPPTokenInfoGetDuration() - returns the duration for a token info *-----------------------------------------------------------------------*/intOSPPTokenInfoGetDuration(    OSPTTOKENINFO *ospvTokenInfo                     /* token info */){    int ospvDuration = 0;    if (ospvTokenInfo != OSPC_OSNULL)    {        ospvDuration = ospvTokenInfo->ospmTokenInfoDuration;    }    return ospvDuration;}#endif /* OSPC_DEBUG *//**//*-----------------------------------------------------------------------* * OSPPTokenInfoNew() - creates a new (empty) token info object *-----------------------------------------------------------------------*/OSPTTOKENINFO *                                 /* returns pointer or NULL */    OSPPTokenInfoNew(){    OSPTTOKENINFO *ospvTokenInfo;    OSPM_MALLOC(ospvTokenInfo, OSPTTOKENINFO, sizeof(OSPTTOKENINFO));    if (ospvTokenInfo != OSPC_OSNULL)    {        ospvTokenInfo->ospmTokenInfoSourceNumber[0] = '\0';        ospvTokenInfo->ospmTokenInfoDestNumber[0] = '\0';        ospvTokenInfo->ospmTokenInfoCallId = (OSPTCALLID *)OSPC_OSNULL;        ospvTokenInfo->ospmTokenInfoValidAfter = OSPC_TIMEMIN;        ospvTokenInfo->ospmTokenInfoValidUntil = OSPC_TIMEMAX;        ospvTokenInfo->ospmTokenInfoTrxId = (OSPTTRXID)OSPC_OSNULL;        ospvTokenInfo->ospmTokenInfoDuration = -1;    }    return ospvTokenInfo;}/**//*-----------------------------------------------------------------------* * OSPPTokenInfoDelete() - deletes a token info object *-----------------------------------------------------------------------*/voidOSPPTokenInfoDelete(OSPTTOKENINFO **ospvTokenInfo){    if (*ospvTokenInfo)    {        if (OSPPTokenInfoHasCallId(*ospvTokenInfo))            OSPPCallIdDelete(&((*ospvTokenInfo)->ospmTokenInfoCallId));        OSPM_FREE(*ospvTokenInfo);        *ospvTokenInfo = OSPC_OSNULL;    }    return;}/**//*-----------------------------------------------------------------------* * OSPPTokenInfoFromElement() - get token info from an XML element *-----------------------------------------------------------------------*/unsigned                          /* returns error code */OSPPTokenInfoFromElement(    OSPTXMLELEM  *ospvElem,       /* input is XML element */    OSPTTOKENINFO **ospvTokenInfo   /* where to put token info pointer */){    unsigned      ospvErrCode = OSPC_ERR_NO_ERROR;    OSPTXMLELEM  *elem = OSPC_OSNULL;    OSPTTOKENINFO *tokeninfo = OSPC_OSNULL;    OSPTCALLID   *callId;    OSPTTIME      t;    OSPTTRXID     trxid;    unsigned      duration;    if (ospvElem == OSPC_OSNULL)    {        ospvErrCode = OSPC_ERR_XML_NO_ELEMENT;    }    if (ospvTokenInfo == OSPC_OSNULL)    {        ospvErrCode = OSPC_ERR_DATA_NO_TOKEN;    }    if (ospvErrCode == OSPC_ERR_NO_ERROR)    {        /* create the token info object */        tokeninfo = OSPPTokenInfoNew();        if (tokeninfo == OSPC_OSNULL)        {            ospvErrCode = OSPC_ERR_DATA_NO_TOKENINFO;        }    }    /*     * The Token Info element should consist of several child     * elements. We'll run through what's there and pick out     * the information we need.     */    if (ospvErrCode == OSPC_ERR_NO_ERROR)    {        for ( elem = (OSPTXMLELEM *)OSPPXMLElemFirstChild(ospvElem);            (elem != (OSPTXMLELEM *)OSPC_OSNULL) && (ospvErrCode == OSPC_ERR_NO_ERROR);            elem = (OSPTXMLELEM *)OSPPXMLElemNextChild(ospvElem, elem) )        {            switch (OSPPMsgGetElemPart(OSPPXMLElemGetName(elem)))            {                case ospeElemMessage:                break;                case ospeElemTokenInfo:                break;                case ospeElemSrcInfo:                OSPPTokenInfoSetSourceNumber(tokeninfo, (const unsigned char *)OSPPXMLElemGetValue(elem));                break;                case ospeElemDestInfo:                OSPPTokenInfoSetDestNumber(tokeninfo, (const unsigned char *)OSPPXMLElemGetValue(elem));                break;                case ospeElemCallId:                ospvErrCode = OSPPCallIdFromElement(elem, &callId);                if (ospvErrCode == OSPC_ERR_NO_ERROR)                {                    OSPPTokenInfoSetCallId(tokeninfo, callId);                    OSPPCallIdDelete(&callId);                }                break;                case ospeElemTransId:                ospvErrCode = OSPPMsgTXFromElement(elem, &trxid);                OSPPTokenInfoSetTrxId(tokeninfo, trxid);                break;                case ospeElemValidAfter:                ospvErrCode = OSPPMsgTimeFromElement(elem, &t);                if (ospvErrCode == OSPC_ERR_NO_ERROR)                {                    OSPPTokenInfoSetValidAfter(tokeninfo,t);                }                break;                case ospeElemValidUntil:                ospvErrCode = OSPPMsgTimeFromElement(elem, &t);                if (ospvErrCode == OSPC_ERR_NO_ERROR)                {                    OSPPTokenInfoSetValidUntil(tokeninfo,t);                }                break;                case ospeElemUsageDetail:                OSPPUsageFromElement(elem, &duration);                OSPPTokenInfoSetDuration(tokeninfo, (int)duration);                break;                default:                /*                 * This is an element we don't understand. If it's                 * critical, then we have to report an error.                 * Otherwise we can ignore it.                 */                if (OSPPMsgElemIsCritical(elem))                {                    ospvErrCode = OSPC_ERR_XML_BAD_ELEMENT;                }                break;            }        }    }    if (ospvErrCode == OSPC_ERR_NO_ERROR)    {        *ospvTokenInfo = tokeninfo;    }    return ospvErrCode;}

⌨️ 快捷键说明

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