📄 ospauthrsp.c
字号:
else { return 0; }}#endif /* OSPC_DEBUG */OSPTTNAUDIT *OSPPAuthRspGetTNAudit( OSPTAUTHRSP *ospvAuthRsp){ if(ospvAuthRsp != OSPC_OSNULL) { return ospvAuthRsp->ospmAuthRspTNAudit; } else { return OSPC_OSNULL; }}/**//*-----------------------------------------------------------------------* * OSPPAuthRspNew() - creates a new (empty) authorisation response *-----------------------------------------------------------------------*/OSPTAUTHRSP * /* returns pointer or NULL */ OSPPAuthRspNew(){ OSPTAUTHRSP *ospvAuthRsp; OSPM_MALLOC(ospvAuthRsp, OSPTAUTHRSP,sizeof(OSPTAUTHRSP)); if (ospvAuthRsp != OSPC_OSNULL) { OSPM_MEMSET(ospvAuthRsp, 0, sizeof(OSPTAUTHRSP)); ospvAuthRsp->ospmAuthRspTimestamp = OSPC_TIMEMIN; ospvAuthRsp->ospmAuthRspStatus = OSPC_OSNULL; ospvAuthRsp->ospmAuthRspTrxId = 0; ospvAuthRsp->ospmAuthRspCSAudit = (OSPTCSAUDIT *)OSPC_OSNULL; OSPPListNew(&(ospvAuthRsp->ospmAuthRspDest)); } return(ospvAuthRsp);}/*-----------------------------------------------------------------------* * OSPPAuthRspDelete() - deletes an authorisation response structure *-----------------------------------------------------------------------*/void OSPPAuthRspDelete(OSPTAUTHRSP **ospvAuthRsp){ OSPTDEST *dest = OSPC_OSNULL; if (*ospvAuthRsp != OSPC_OSNULL) { /* first remove the status */ if ((*ospvAuthRsp)->ospmAuthRspStatus != OSPC_OSNULL) { OSPPStatusDelete(&((*ospvAuthRsp)->ospmAuthRspStatus)); } /* remove tnaudit */ if ((*ospvAuthRsp)->ospmAuthRspTNAudit != OSPC_OSNULL) { OSPPTNAuditDelete(&((*ospvAuthRsp)->ospmAuthRspTNAudit)); } /* remove csaudit */ if ((*ospvAuthRsp)->ospmAuthRspCSAudit != OSPC_OSNULL) { OSPPCSAuditDelete(&((*ospvAuthRsp)->ospmAuthRspCSAudit)); } /* now remove any attached dests -- this means following the chain */ while (!OSPPListEmpty(&((*ospvAuthRsp)->ospmAuthRspDest))) { dest = (OSPTDEST *)OSPPListRemove(&((*ospvAuthRsp)->ospmAuthRspDest)); if (dest != OSPC_OSNULL) { OSPPDestDelete(&dest); dest = OSPC_OSNULL; } } /* now delete the authrsp itself */ OSPM_FREE(*ospvAuthRsp); *ospvAuthRsp = OSPC_OSNULL; }}/**//*-----------------------------------------------------------------------* * OSPPAuthRspAddDest() - add a destination to authrsp. If ospvDest is NULL, * adds a new, empty destination. * Returns: pointer to added dest for manipulation *-----------------------------------------------------------------------*/OSPTDEST * /* returns ptr to new destination */ OSPPAuthRspAddDest( OSPTAUTHRSP *ospvAuthRsp, OSPTDEST *ospvDest ){ OSPTDEST *ospvAddedDest = OSPC_OSNULL; if (ospvAuthRsp != OSPC_OSNULL) { /* if this is called with a null destination, create a new * empty destination and add it to the list. */ if (ospvDest == OSPC_OSNULL) { ospvAddedDest = OSPPDestNew(); } else { ospvAddedDest = ospvDest; } if (ospvAddedDest != OSPC_OSNULL) { /* OSPM_MEMCPY(ospvAddedDest, ospvDest, sizeof(OSPTDEST)); ospvAddedDest->ospmDestCallId = OSPPCallIdNew( OSPPCallIdGetSize(ospvDest->ospmDestCallId), OSPPCallIdGetValue(ospvDest->ospmDestCallId)); */ OSPPListAppend(&(ospvAuthRsp->ospmAuthRspDest), ospvAddedDest); } } return(ospvAddedDest);}/**//*-----------------------------------------------------------------------* * OSPPAuthRspFromElement() - get authorisation response from an XML element *-----------------------------------------------------------------------*/unsigned /* returns error code */OSPPAuthRspFromElement( OSPTXMLELEM *ospvElem, /* input is XML element */ OSPTAUTHRSP **ospvAuthRsp /* where to put authorisation response pointer */){ unsigned ospvErrCode = OSPC_ERR_NO_ERROR; OSPTXMLELEM *elem = OSPC_OSNULL; OSPTAUTHRSP *authrsp = OSPC_OSNULL; OSPTDEST *dest = OSPC_OSNULL; OSPTTIME t = 0L; OSPTTRXID transid = 0L; int len = 0; unsigned long delaylimit = 0L; unsigned long delaypref = 0L; if (ospvElem == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_XML_NO_ELEMENT; } if (ospvErrCode == OSPC_ERR_NO_ERROR) { /* create the authorisation response object */ authrsp = OSPPAuthRspNew(); if (authrsp == OSPC_OSNULL) { ospvErrCode = OSPC_ERR_DATA_NO_AUTHRSP; } /* * The Authorisation Rsp element should consist of several * child elements. We'll run through what's there and pick out * the information we need. */ 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; /* ** ospeElemAuthRzp -- OSP Stds spell Authorization not Authorisation */ case ospeElemAuthRzp: case ospeElemAuthRsp: break; case ospeElemTimestamp: ospvErrCode = OSPPMsgTimeFromElement(elem, &t); if (ospvErrCode == OSPC_ERR_NO_ERROR) { OSPPAuthRspSetTimestamp(authrsp,t); } break; case ospeElemStatus: if (authrsp->ospmAuthRspStatus != OSPC_OSNULL) { OSPPStatusDelete(&(authrsp->ospmAuthRspStatus)); } ospvErrCode = OSPPStatusFromElement(elem, &(authrsp->ospmAuthRspStatus)); break; case ospeElemTransId: len = sizeof(OSPTTRXID); ospvErrCode = OSPPMsgTXFromElement(elem, &transid); OSPPAuthRspSetTrxId(authrsp, transid); break; case ospeElemTNDelayLimit: ospvErrCode = OSPPMsgNumFromElement(elem, &delaylimit); OSPPAuthRspSetTNDelayLimit(authrsp, (unsigned)delaylimit); break; case ospeElemTNAudit: ospvErrCode = OSPPTNAuditFromElement(elem, &(authrsp->ospmAuthRspTNAudit)); break; case ospeElemCSAuditTrigger: ospvErrCode = OSPPCSAuditFromElement(elem, &(authrsp->ospmAuthRspCSAudit)); break; case ospeElemTNDelayPref: ospvErrCode = OSPPMsgNumFromElement(elem, &delaypref); OSPPAuthRspSetTNDelayPref(authrsp, (unsigned)delaypref); break; case ospeElemDest: ospvErrCode = OSPPDestFromElement(elem, &dest); if (ospvErrCode == OSPC_ERR_NO_ERROR) { if(dest != OSPC_OSNULL) { OSPPAuthRspAddDest(authrsp,dest); OSPPAuthRspIncNumDests(authrsp); dest = OSPC_OSNULL; } } 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) { *ospvAuthRsp = authrsp; } } return(ospvErrCode);}OSPTCSAUDIT *OSPPAuthRspGetCSAudit( OSPTAUTHRSP *ospvAuthRsp){ if(ospvAuthRsp != OSPC_OSNULL) { if(ospvAuthRsp->ospmAuthRspCSAudit != OSPC_OSNULL) { return ospvAuthRsp->ospmAuthRspCSAudit; } } return (OSPTCSAUDIT *)OSPC_OSNULL;}int OSPPAuthRspHasCSAudit( OSPTAUTHRSP *ospvAuthRsp){ return ospvAuthRsp->ospmAuthRspCSAudit != (OSPTCSAUDIT *)OSPC_OSNULL;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -