|
reSIProcate/stack
9694
|
00001 #if defined(HAVE_CONFIG_H) 00002 #include "config.h" 00003 #endif 00004 00005 #include <iostream> 00006 00007 #include "resip/stack/UnknownParameter.hxx" 00008 #include "resip/stack/ExistsParameter.hxx" 00009 #include "resip/stack/HeaderFieldValue.hxx" 00010 #include "resip/stack/MsgHeaderScanner.hxx" 00011 #include "resip/stack/ParserCategory.hxx" 00012 #include "resip/stack/Symbols.hxx" 00013 #include "rutil/ParseBuffer.hxx" 00014 #include "rutil/Logger.hxx" 00015 #include "rutil/WinLeakCheck.hxx" 00016 00017 using namespace std; 00018 using namespace resip; 00019 00020 00021 #define RESIPROCATE_SUBSYSTEM Subsystem::SIP 00022 00023 const HeaderFieldValue HeaderFieldValue::Empty; 00024 00025 HeaderFieldValue::HeaderFieldValue(const char* field, unsigned int fieldLength) 00026 : mField(field), 00027 mFieldLength(fieldLength), 00028 mMine(false) 00029 {} 00030 00031 HeaderFieldValue::HeaderFieldValue(const HeaderFieldValue& hfv) 00032 : mField(0), 00033 mFieldLength(hfv.mFieldLength), 00034 mMine(true) 00035 { 00036 if(mFieldLength) 00037 { 00038 char* newField = new char[mFieldLength]; 00039 memcpy(newField, hfv.mField, mFieldLength); 00040 mField=newField; 00041 } 00042 } 00043 00044 HeaderFieldValue& 00045 HeaderFieldValue::operator=(const HeaderFieldValue& rhs) 00046 { 00047 if(this!=&rhs) 00048 { 00049 mFieldLength=rhs.mFieldLength; 00050 if(mMine) delete [] mField; 00051 mMine=true; 00052 if(mFieldLength) 00053 { 00054 char* newField = new char[mFieldLength]; 00055 memcpy(newField, rhs.mField, mFieldLength); 00056 mField=newField; 00057 } 00058 else 00059 { 00060 mField=0; 00061 } 00062 } 00063 00064 return *this; 00065 } 00066 00067 HeaderFieldValue& 00068 HeaderFieldValue::copyWithPadding(const HeaderFieldValue& rhs) 00069 { 00070 if(this!=&rhs) 00071 { 00072 mFieldLength=rhs.mFieldLength; 00073 if(mMine) delete [] mField; 00074 mMine=true; 00075 if(mFieldLength) 00076 { 00077 char* newField = MsgHeaderScanner::allocateBuffer(mFieldLength); 00078 memcpy(newField, rhs.mField, mFieldLength); 00079 mField=newField; 00080 } 00081 else 00082 { 00083 mField=0; 00084 } 00085 } 00086 00087 return *this; 00088 } 00089 00090 HeaderFieldValue::HeaderFieldValue(const HeaderFieldValue& hfv, CopyPaddingEnum e) 00091 : mField(0), 00092 mFieldLength(hfv.mFieldLength), 00093 mMine(true) 00094 { 00095 char* newField = MsgHeaderScanner::allocateBuffer(mFieldLength); 00096 memcpy(newField, hfv.mField, mFieldLength); 00097 mField=newField; 00098 } 00099 00100 HeaderFieldValue::HeaderFieldValue(const HeaderFieldValue& hfv, NoOwnershipEnum n) 00101 : mField(hfv.mField), 00102 mFieldLength(hfv.mFieldLength), 00103 mMine(false) 00104 { 00105 // ?bwc? assert(!hfv.mMine); ? 00106 } 00107 00108 HeaderFieldValue::~HeaderFieldValue() 00109 { 00110 if (mMine) 00111 { 00112 delete[] mField; 00113 } 00114 } 00115 00116 EncodeStream& 00117 HeaderFieldValue::encode(EncodeStream& str) const 00118 { 00119 str.write(mField, mFieldLength); 00120 return str; 00121 } 00122 00123 EncodeStream& resip::operator<<(EncodeStream& stream, HeaderFieldValue& hfv) 00124 { 00125 hfv.encode(stream); 00126 return stream; 00127 } 00128 00129 /* ==================================================================== 00130 * The Vovida Software License, Version 1.0 00131 * 00132 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00133 * 00134 * Redistribution and use in source and binary forms, with or without 00135 * modification, are permitted provided that the following conditions 00136 * are met: 00137 * 00138 * 1. Redistributions of source code must retain the above copyright 00139 * notice, this list of conditions and the following disclaimer. 00140 * 00141 * 2. Redistributions in binary form must reproduce the above copyright 00142 * notice, this list of conditions and the following disclaimer in 00143 * the documentation and/or other materials provided with the 00144 * distribution. 00145 * 00146 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00147 * and "Vovida Open Communication Application Library (VOCAL)" must 00148 * not be used to endorse or promote products derived from this 00149 * software without prior written permission. For written 00150 * permission, please contact vocal@vovida.org. 00151 * 00152 * 4. Products derived from this software may not be called "VOCAL", nor 00153 * may "VOCAL" appear in their name, without prior written 00154 * permission of Vovida Networks, Inc. 00155 * 00156 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00157 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00158 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00159 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00160 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00161 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00162 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00163 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00164 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00165 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00166 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00167 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00168 * DAMAGE. 00169 * 00170 * ==================================================================== 00171 * 00172 * This software consists of voluntary contributions made by Vovida 00173 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00174 * Inc. For more information on Vovida Networks, Inc., please see 00175 * <http://www.vovida.org/>. 00176 * 00177 */
1.7.5.1