📄 sipaccept.cxx
字号:
/* ==================================================================== * The Vovida Software License, Version 1.0 * * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The names "VOCAL", "Vovida Open Communication Application Library", * and "Vovida Open Communication Application Library (VOCAL)" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact vocal@vovida.org. * * 4. Products derived from this software may not be called "VOCAL", nor * may "VOCAL" appear in their name, without prior written * permission of Vovida Networks, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * * ==================================================================== * * This software consists of voluntary contributions made by Vovida * Networks, Inc. and many individuals on behalf of Vovida Networks, * Inc. For more information on Vovida Networks, Inc., please see * <http://www.vovida.org/>. * */static const char* const SipAccept_cxx_Version = "$Id: SipAccept.cxx,v 1.35 2002/03/19 21:39:54 jason Exp $";#include "global.h"#include "symbols.hxx"#include "SipAccept.hxx"#include "Data.hxx"#include "SipParserMode.hxx"using namespace Vocal;stringSipAcceptParserException::getName( void ) const{ return "SipAcceptParserException";}SipAccept::SipAccept() : allmedia(false), flagmedia(false){}SipAccept::SipAccept(const Data& newaccept) : allmedia(false), flagmedia(false){ try { decode(newaccept); } catch (SipAcceptParserException&) { if (SipParserMode::sipParserMode()) { throw SipAcceptParserException( "failed to decode the Priority string", __FILE__, __LINE__, DECODE_ACCEPT_FAILED); } }}void SipAccept::decode(const Data& acceptdata){ Data data = acceptdata; try { scanAccept(data); } catch (SipAcceptParserException&) { if (SipParserMode::sipParserMode()) { throw SipAcceptParserException( "failed to decode the Priority string", __FILE__, __LINE__, DECODE_ACCEPT_FAILED); } }}voidSipAccept::scanAccept(const Data &tmpdata){ Data accdata; Data aptdata = tmpdata; int ret = aptdata.match("/", &accdata, true); if (ret == FOUND) { if (accdata == ASTERISK) { Data acptdata = aptdata; Data tkdata; int retr = acptdata.match(";", &tkdata, true); if (retr == FOUND) { if (tkdata == ASTERISK) { allmedia = true; parseMediaParm(acptdata); } else { if (SipParserMode::sipParserMode()) { throw SipAcceptParserException( "failed to decode the Priority string", __FILE__, __LINE__, DECODE_ACCEPT_FAILED); } //exception } } else if (retr == NOT_FOUND) { // Since it's optional if (acptdata == ASTERISK) { allmedia = true; } else { if (SipParserMode::sipParserMode()) { throw SipAcceptParserException( "failed to decode the Accept string", __FILE__, __LINE__, DECODE_ACCEPT_FAILED); } //exceptions because "*/*" is not satisfied } } else if (retr == FIRST) { if (SipParserMode::sipParserMode()) { throw SipAcceptParserException( "failed to decode the Accept string", __FILE__, __LINE__, DECODE_ACCEPT_FAILED); } } } else { setMediaType(accdata); Data fdata = aptdata; Data kdata ; int re = fdata.match(";", &kdata, true); if (re == FOUND) { if (kdata == ASTERISK) { flagmedia = true; parseMediaParm(fdata); } else { setMediaSubtype(kdata); string testdata = fdata.convertString(); int test1 = testdata.find("q"); if (test1 == 0) { parseAcceptParm(fdata); } else { parseMediaParm(fdata); } } } else if (re == NOT_FOUND) { // Since it's optional if (kdata == ASTERISK) { flagmedia = true; } else { setMediaSubtype(fdata); } } else if (re == FIRST) { if (SipParserMode::sipParserMode()) { throw SipAcceptParserException( "failed to decode the Accept string", __FILE__, __LINE__, DECODE_ACCEPT_FAILED); } //excpetion } } } else if (ret == NOT_FOUND) { if (SipParserMode::sipParserMode()) { throw SipAcceptParserException( "failed to decode the Accept string", __FILE__, __LINE__, DECODE_ACCEPT_FAILED); } // } else if (ret == FIRST) { if (SipParserMode::sipParserMode()) { throw SipAcceptParserException( "failed to decode the Accept string", __FILE__, __LINE__, DECODE_ACCEPT_FAILED); } // //exceptions }}voidSipAccept::parseMediaParm(const Data& tmpdata){ Data apctdata = tmpdata; Data findata; string testdata = tmpdata.convertString(); int test1 = testdata.find("q"); if (test1 == 0) { parseAcceptParm(apctdata); } else { while (apctdata.length()) { string testdata = apctdata.convertString(); int test2 = testdata.find("q"); if (test2 == 0) { parseAcceptParm(apctdata); break; } int ret = apctdata.match(SEMICOLON, &findata, true); if (ret == FOUND) { parseMediaParms(findata, apctdata); } else if (ret == FIRST) { if (SipParserMode::sipParserMode()) { throw SipAcceptParserException( "failed to decode the Accept string", __FILE__, __LINE__, DECODE_ACCEPT_FAILED); } } else if (ret == NOT_FOUND) { Data pvalue; Data pdata = apctdata; int check = pdata.match("=", &pvalue , true); if ( check == NOT_FOUND) { //Exceptions } else if (check == FIRST) { if (SipParserMode::sipParserMode()) { throw SipAcceptParserException( "failed to decode the Accept string", __FILE__, __LINE__, DECODE_ACCEPT_FAILED); } } else if (check == FOUND) //value has the correct if (pdata.length()) { try { parseMediaExtension(pvalue, pdata); } catch (SipAcceptParserException&) { if (SipParserMode::sipParserMode()) { throw SipAcceptParserException( "failed to decode the Accept string", __FILE__, __LINE__, DECODE_ACCEPT_FAILED); } } } break; } } }}voidSipAccept::parseMediaParms(const Data& data, const Data& value){ Data pvalue = value; Data pdata = data; string testdata = data.convertString(); int test1 = testdata.find("q"); if (test1 == 0) { parseAcceptParm(pdata); } // Check for the Parms With Constant "=" sign int check = pdata.match("=", &pvalue , true); if ( check == NOT_FOUND) { //Exceptions } else if (check == FIRST) { if (SipParserMode::sipParserMode()) { throw SipAcceptParserException( "failed to decode the Accept string",
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -