int Frame::Response(Frame*& resp)const // 旧代码.以后要废弃!!!! { int retcode = 0; APDU *apdu = NULL, *apdu2 = NULL; std::vector<APDU*> apdus; apdu = APDU::BuildAPDUFromFrame(*this); if ( NULL == apdu ) { retcode = -11; goto _out; } retcode = apdu->Response(apdu2, apdus); if ( 0 != retcode || NULL == apdu2 ) { retcode = -12; goto _out; } resp = Frame::BuildFrameFromAPDU(*apdu2); _out: delete apdu2; delete apdu; for ( int i = 0; i < apdus.size(); i++ ) { delete apdus[i]; } return retcode; }
// Response的新版本. int Frame::Response(std::vector<Frame*>& resps)const { int retcode = 0; APDU *apdu = NULL, *apdu2 = NULL; std::vector<APDU*> apdus; Frame* frame = NULL; resps.clear(); apdu = APDU::BuildAPDUFromFrame(*this); if ( NULL == apdu ) { retcode = -11; goto _out; } retcode = apdu->Response(apdu2, apdus); if ( 0 != retcode && NULL == apdu2 && apdus.empty() ) { retcode = -12; goto _out; } if ( NULL != apdu2 ) { frame = Frame::BuildFrameFromAPDU(*apdu2); if ( NULL != frame ) { resps.push_back(frame); } } for ( int i = 0; i < apdus.size(); i++ ) { frame = Frame::BuildFrameFromAPDU(*apdus[i]); if ( NULL != frame ) { resps.push_back(frame); } } _out: delete apdu2; delete apdu; for ( int i = 0; i < apdus.size(); i++ ) { delete apdus[i]; } return retcode; }