Coverage Report

Created: 2025-06-13 06:12

/src/resiprocate/resip/stack/StatusLine.cxx
Line
Count
Source (jump to first uncovered line)
1
#if defined(HAVE_CONFIG_H)
2
#include "config.h"
3
#endif
4
5
#include "resip/stack/StatusLine.hxx"
6
#include "rutil/Data.hxx"
7
#include "rutil/DnsUtil.hxx"
8
#include "rutil/Logger.hxx"
9
#include "rutil/ParseBuffer.hxx"
10
//#include "rutil/WinLeakCheck.hxx"  // not compatible with placement new used below
11
12
using namespace resip;
13
using namespace std;
14
15
#define RESIPROCATE_SUBSYSTEM Subsystem::SIP
16
17
//====================
18
// StatusLine:
19
//====================
20
StatusLine::StatusLine() 
21
0
   : StartLine(), 
22
0
     mResponseCode(-1),
23
0
     mSipVersion(Data::Share,Symbols::DefaultSipVersion), 
24
0
     mReason()
25
0
{}
26
27
StatusLine::StatusLine(const HeaderFieldValue& hfv)
28
0
   : StartLine(hfv), 
29
0
     mResponseCode(-1), 
30
0
     mSipVersion(Data::Share,Symbols::DefaultSipVersion), 
31
0
     mReason() 
32
0
{}
33
34
StatusLine::StatusLine(const char* buf, int length) :
35
5
   StartLine(buf, length),
36
5
   mResponseCode(-1), 
37
5
   mSipVersion(Data::Share,Symbols::DefaultSipVersion), 
38
5
   mReason() 
39
5
{}
40
41
StatusLine::StatusLine(const StatusLine& rhs)
42
0
   : StartLine(rhs),
43
0
     mResponseCode(rhs.mResponseCode),
44
0
     mSipVersion(rhs.mSipVersion),
45
0
     mReason(rhs.mReason)
46
0
{}
47
     
48
StatusLine&
49
StatusLine::operator=(const StatusLine& rhs)
50
0
{
51
0
   if (this != &rhs)
52
0
   {
53
0
      StartLine::operator=(rhs);
54
0
      mResponseCode = rhs.mResponseCode;
55
0
      mSipVersion = rhs.mSipVersion;
56
0
      mReason = rhs.mReason;
57
0
   }
58
0
   return *this;
59
0
}
60
61
StartLine *
62
StatusLine::clone() const
63
0
{
64
0
   return new StatusLine(*this);
65
0
}
66
67
StartLine *
68
StatusLine::clone(void* location) const
69
0
{
70
0
   return new (location) StatusLine(*this);
71
0
}
72
73
int&
74
StatusLine::responseCode()
75
0
{
76
0
   checkParsed();
77
0
   return mResponseCode;
78
0
}
79
80
int 
81
StatusLine::responseCode() const
82
0
{
83
0
   checkParsed();
84
0
   return mResponseCode;
85
0
}
86
87
int& 
88
StatusLine::statusCode()
89
0
{
90
0
   checkParsed();
91
0
   return mResponseCode;
92
0
}
93
94
int 
95
StatusLine::statusCode() const
96
0
{
97
0
   checkParsed();
98
0
   return mResponseCode;
99
0
}
100
101
const Data& 
102
StatusLine::getSipVersion() const
103
0
{
104
0
   checkParsed();
105
0
   return mSipVersion;
106
0
}
107
108
Data& 
109
StatusLine::reason()
110
0
{
111
0
   checkParsed();
112
0
   return mReason;
113
0
}
114
115
const Data& 
116
StatusLine::reason() const
117
0
{
118
0
   checkParsed();
119
0
   return mReason;
120
0
}
121
122
void
123
StatusLine::parse(ParseBuffer& pb)
124
0
{
125
0
   const char* start = pb.skipWhitespace();
126
0
   pb.skipNonWhitespace();
127
0
   pb.data(mSipVersion, start);
128
129
0
   start = pb.skipWhitespace();
130
0
   mResponseCode = pb.integer();
131
0
   start = pb.skipWhitespace();
132
0
   pb.skipToEnd();
133
0
   pb.data(mReason, start);
134
0
}
135
136
EncodeStream&
137
StatusLine::encodeParsed(EncodeStream& str) const
138
0
{
139
0
   str << mSipVersion << Symbols::SPACE 
140
0
       << mResponseCode << Symbols::SPACE
141
0
       << mReason;
142
0
   return str;
143
0
}
144
145
const Data& 
146
StatusLine::errorContext() const
147
0
{
148
0
   static const Data statLine("Status Line");
149
0
   return statLine;
150
0
}
151
152
/* ====================================================================
153
 * The Vovida Software License, Version 1.0 
154
 * 
155
 * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
156
 * 
157
 * Redistribution and use in source and binary forms, with or without
158
 * modification, are permitted provided that the following conditions
159
 * are met:
160
 * 
161
 * 1. Redistributions of source code must retain the above copyright
162
 *    notice, this list of conditions and the following disclaimer.
163
 * 
164
 * 2. Redistributions in binary form must reproduce the above copyright
165
 *    notice, this list of conditions and the following disclaimer in
166
 *    the documentation and/or other materials provided with the
167
 *    distribution.
168
 * 
169
 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
170
 *    and "Vovida Open Communication Application Library (VOCAL)" must
171
 *    not be used to endorse or promote products derived from this
172
 *    software without prior written permission. For written
173
 *    permission, please contact vocal@vovida.org.
174
 *
175
 * 4. Products derived from this software may not be called "VOCAL", nor
176
 *    may "VOCAL" appear in their name, without prior written
177
 *    permission of Vovida Networks, Inc.
178
 * 
179
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
180
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
181
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
182
 * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
183
 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
184
 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
185
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
186
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
187
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
188
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
189
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
190
 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
191
 * DAMAGE.
192
 * 
193
 * ====================================================================
194
 * 
195
 * This software consists of voluntary contributions made by Vovida
196
 * Networks, Inc. and many individuals on behalf of Vovida Networks,
197
 * Inc.  For more information on Vovida Networks, Inc., please see
198
 * <http://www.vovida.org/>.
199
 *
200
 */