📄 ospauthreq.c
字号:
* OSPPAuthReqHasDestNumber() - does the authorisation request include a * dest number? *-----------------------------------------------------------------------*/unsigned /* returns non-zero if number exists */OSPPAuthReqHasDestNumber( OSPTAUTHREQ *ospvAuthReq /* authorisation request effected */){ unsigned ospvHasNumber = OSPC_FALSE; if (ospvAuthReq != OSPC_OSNULL) { ospvHasNumber = ((ospvAuthReq)->ospmAuthReqDestNumber[0] != '\0'); } return(ospvHasNumber);}/**//*-----------------------------------------------------------------------* * OSPPAuthReqSetDestNumber() - set the destination number for an * authorisation request *-----------------------------------------------------------------------*/void /* nothing returned */OSPPAuthReqSetDestNumber( OSPTAUTHREQ *ospvAuthReq, /* authorisation request to set */ const unsigned char *ospvNum /* destination number (as string) */){ if (ospvAuthReq != OSPC_OSNULL) { if (ospvNum != OSPC_OSNULL) { OSPM_STRNCPY((char *)(ospvAuthReq)->ospmAuthReqDestNumber, (const char *)(ospvNum), osp_min(OSPM_STRLEN((const char *)ospvNum)+1,OSPC_E164NUMSIZE-1)); } }}/**//*-----------------------------------------------------------------------* * OSPPAuthReqGetDestNumber() - returns the destination number for an * authorisation request *-----------------------------------------------------------------------*/unsigned char * /* returns number as string */OSPPAuthReqGetDestNumber( OSPTAUTHREQ *ospvAuthReq /* authorisation request */){ unsigned char *ospvDestNum = OSPC_OSNULL; if (ospvAuthReq != OSPC_OSNULL) { ospvDestNum = ((ospvAuthReq)->ospmAuthReqDestNumber); } return(ospvDestNum);}/**//*-----------------------------------------------------------------------* * OSPPAuthReqSetMaxDest() - set the maximum destinations for an * authorisation request *-----------------------------------------------------------------------*/void /* nothing returned */OSPPAuthReqSetMaxDest( OSPTAUTHREQ *ospvAuthReq, /* authorisation request to set */ unsigned ospvNum /* maximum destinations */){ if (ospvAuthReq != OSPC_OSNULL) { if (ospvNum != 0) { (ospvAuthReq)->ospmAuthReqMaxDest = ospvNum; } }}/**//*-----------------------------------------------------------------------* * OSPPAuthReqGetMaxDest() - returns the maximum destinations for an * authorisation request *-----------------------------------------------------------------------*/unsigned /* returns maximum destionations */OSPPAuthReqGetMaxDest( OSPTAUTHREQ *ospvAuthReq /* authorisation request */){ unsigned ospvNum = 0; if (ospvAuthReq != OSPC_OSNULL) { ospvNum = ((ospvAuthReq)->ospmAuthReqMaxDest); } return(ospvNum);}/**//*-----------------------------------------------------------------------* * OSPPAuthReqHasTNCustId() - Does request have a TransNexus Customer Id? *-----------------------------------------------------------------------*/unsigned /* returns non-zero if time */OSPPAuthReqHasTNCustId( OSPTAUTHREQ *ospvAuthReq /* authorisation request in question */){ unsigned ospvHasTNCustId = OSPC_FALSE; if (ospvAuthReq != OSPC_OSNULL) { ospvHasTNCustId = ((ospvAuthReq)->ospmAuthReqTNCustId != 0L); } return(ospvHasTNCustId);}/**//*-----------------------------------------------------------------------* * OSPPAuthReqSetTNCustId() - Set TransNexus Customer Id *-----------------------------------------------------------------------*/void /* nothing returned */OSPPAuthReqSetTNCustId( OSPTAUTHREQ *ospvAuthReq, unsigned long ospvTNCustId){ if (ospvAuthReq != OSPC_OSNULL) { (ospvAuthReq)->ospmAuthReqTNCustId = (ospvTNCustId); }}/**//*-----------------------------------------------------------------------* * OSPPAuthReqGetTNCustId() - returns TN Customer Id for an auth request *-----------------------------------------------------------------------*/unsigned long /* returns the time value */ OSPPAuthReqGetTNCustId( OSPTAUTHREQ *ospvAuthReq /* authorisation request */ ){ unsigned long ospvTNCustId = 0L; if (ospvAuthReq != OSPC_OSNULL) { ospvTNCustId = (ospvAuthReq)->ospmAuthReqTNCustId; } return(ospvTNCustId);}/**//*-----------------------------------------------------------------------* * OSPPAuthReqHasTNDeviceId() - Does request have a TransNexus Device Id? *-----------------------------------------------------------------------*/unsigned /* returns non-zero if time */OSPPAuthReqHasTNDeviceId( OSPTAUTHREQ *ospvAuthReq /* authorisation request in question */){ unsigned ospvHasTNDeviceId = OSPC_FALSE; if (ospvAuthReq != OSPC_OSNULL) { ospvHasTNDeviceId = ((ospvAuthReq)->ospmAuthReqTNDeviceId != 0L); } return(ospvHasTNDeviceId);}/**//*-----------------------------------------------------------------------* * OSPPAuthReqSetTNDeviceId() - Set TransNexus Device Id *-----------------------------------------------------------------------*/void /* nothing returned */OSPPAuthReqSetTNDeviceId( OSPTAUTHREQ *ospvAuthReq, unsigned long ospvTNDeviceId){ if (ospvAuthReq != OSPC_OSNULL) { (ospvAuthReq)->ospmAuthReqTNDeviceId = (ospvTNDeviceId); }}/**//*-----------------------------------------------------------------------* * OSPPAuthReqGetTNDeviceId() - returns TN Device Id for an auth request *-----------------------------------------------------------------------*/unsigned long /* returns the time value */ OSPPAuthReqGetTNDeviceId( OSPTAUTHREQ *ospvAuthReq /* authorisation request */ ){ unsigned long ospvTNDeviceId = 0L; if (ospvAuthReq != OSPC_OSNULL) { ospvTNDeviceId = (ospvAuthReq)->ospmAuthReqTNDeviceId; } return(ospvTNDeviceId);}/**//*-----------------------------------------------------------------------* * OSPPAuthReqHasComponentId() - is the component id set ? *-----------------------------------------------------------------------*/unsigned /* returns non-zero if component id is set */OSPPAuthReqHasComponentId( OSPTAUTHREQ *ospvAuthReq){ return (ospvAuthReq->ospmAuthReqComponentId != OSPC_OSNULL);}#endif /* OSPC_DEBUG *//**//*-----------------------------------------------------------------------* * OSPPAuthReqNew() - creates a new (empty) authorisation request *-----------------------------------------------------------------------*/OSPTAUTHREQ * /* returns pointer or NULL */ OSPPAuthReqNew(){ OSPTAUTHREQ *ospvAuthReq = OSPC_OSNULL; OSPM_MALLOC(ospvAuthReq, OSPTAUTHREQ,sizeof(OSPTAUTHREQ)); if (ospvAuthReq != OSPC_OSNULL) { OSPM_MEMSET(ospvAuthReq, 0,sizeof(OSPTAUTHREQ)); ospvAuthReq->ospmAuthReqTimestamp = OSPC_TIMEMIN; } return(ospvAuthReq);}/*-----------------------------------------------------------------------* * OSPPAuthReqDelete() - deletes an authorisation request structure *-----------------------------------------------------------------------*/void OSPPAuthReqDelete(OSPTAUTHREQ **ospvAuthReq){ OSPTCALLID *callid = OSPC_OSNULL; OSPTALTINFO *altinfo = OSPC_OSNULL; if (*ospvAuthReq) { while(!OSPPListEmpty(&((*ospvAuthReq)->ospmAuthReqCallId))) { callid = (OSPTCALLID *)OSPPListRemove(&((*ospvAuthReq)->ospmAuthReqCallId)); if(callid != OSPC_OSNULL) { OSPM_FREE(callid); callid = OSPC_OSNULL; } } OSPPListDelete(&((*ospvAuthReq)->ospmAuthReqCallId)); while(!OSPPListEmpty(&((*ospvAuthReq)->ospmAuthReqSourceAlternate))) { altinfo = (OSPTALTINFO *)OSPPListRemove(&((*ospvAuthReq)->ospmAuthReqSourceAlternate)); if(altinfo != OSPC_OSNULL) { OSPM_FREE(altinfo); altinfo = OSPC_OSNULL; } } OSPPListDelete(&((*ospvAuthReq)->ospmAuthReqSourceAlternate)); while(!OSPPListEmpty(&((*ospvAuthReq)->ospmAuthReqDestinationAlternate))) { altinfo = (OSPTALTINFO *)OSPPListRemove(&((*ospvAuthReq)->ospmAuthReqDestinationAlternate)); if(altinfo != OSPC_OSNULL) { OSPM_FREE(altinfo); altinfo = OSPC_OSNULL; } } if(OSPPAuthReqHasComponentId(*ospvAuthReq)) { OSPM_FREE((*ospvAuthReq)->ospmAuthReqComponentId); } if(OSPPAuthReqHasMessageId(*ospvAuthReq)) { OSPM_FREE((*ospvAuthReq)->ospmAuthReqMessageId); } OSPPListDelete(&((*ospvAuthReq)->ospmAuthReqDestinationAlternate)); OSPM_FREE(*ospvAuthReq); *ospvAuthReq = OSPC_OSNULL; } return;}/**//*-----------------------------------------------------------------------* * OSPPAuthReqToElement() - create an XML element from an authorisation request *-----------------------------------------------------------------------*/int /* returns error code */OSPPAuthReqToElement( OSPTAUTHREQ *ospvAuthReq, /* authorisation request value */ OSPTXMLELEM **ospvElem /* where to put XML element pointer */){ int ospvErrCode = OSPC_ERR_NO_ERROR; OSPTXMLELEM *elem = OSPC_OSNULL, *authreqelem = OSPC_OSNULL; OSPTXMLATTR *attr = OSPC_OSNULL; OSPTCALLID *callid = OSPC_OSNULL; OSPTALTINFO *altinfo = OSPC_OSNULL; char random[OSPC_MAX_RANDOM]; OSPTBOOL isbase64 = OSPC_TRUE; OSPM_MEMSET(random, 0, OSPC_MAX_RANDOM); if (ospvElem == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_XML_NO_ELEMENT; } if (ospvAuthReq == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_DATA_NO_AUTHREQ; } /* create the "Message" element as the parent */ *ospvElem = OSPPXMLElemNew(OSPPMsgGetElemName(ospeElemMessage), "");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -