~ubuntu-branches/ubuntu/saucy/resiprocate/saucy-proposed

« back to all changes in this revision

Viewing changes to resip/stack/StatusLine.cxx

  • Committer: Package Import Robot
  • Author(s): Daniel Pocock
  • Date: 2012-05-17 19:29:59 UTC
  • Revision ID: package-import@ubuntu.com-20120517192959-vv00m77isztdy64q
Tags: upstream-1.8.2
ImportĀ upstreamĀ versionĀ 1.8.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
   : StartLine(), 
 
22
     mResponseCode(-1),
 
23
     mSipVersion(Data::Share,Symbols::DefaultSipVersion), 
 
24
     mReason()
 
25
{}
 
26
 
 
27
StatusLine::StatusLine(const HeaderFieldValue& hfv)
 
28
   : StartLine(hfv), 
 
29
     mResponseCode(-1), 
 
30
     mSipVersion(Data::Share,Symbols::DefaultSipVersion), 
 
31
     mReason() 
 
32
{}
 
33
 
 
34
StatusLine::StatusLine(const char* buf, int length) :
 
35
   StartLine(buf, length),
 
36
   mResponseCode(-1), 
 
37
   mSipVersion(Data::Share,Symbols::DefaultSipVersion), 
 
38
   mReason() 
 
39
{}
 
40
 
 
41
StatusLine::StatusLine(const StatusLine& rhs)
 
42
   : StartLine(rhs),
 
43
     mResponseCode(rhs.mResponseCode),
 
44
     mSipVersion(rhs.mSipVersion),
 
45
     mReason(rhs.mReason)
 
46
{}
 
47
     
 
48
StatusLine&
 
49
StatusLine::operator=(const StatusLine& rhs)
 
50
{
 
51
   if (this != &rhs)
 
52
   {
 
53
      StartLine::operator=(rhs);
 
54
      mResponseCode = rhs.mResponseCode;
 
55
      mSipVersion = rhs.mSipVersion;
 
56
      mReason = rhs.mReason;
 
57
   }
 
58
   return *this;
 
59
}
 
60
 
 
61
StartLine *
 
62
StatusLine::clone() const
 
63
{
 
64
   return new StatusLine(*this);
 
65
}
 
66
 
 
67
StartLine *
 
68
StatusLine::clone(void* location) const
 
69
{
 
70
   return new (location) StatusLine(*this);
 
71
}
 
72
 
 
73
int&
 
74
StatusLine::responseCode()
 
75
{
 
76
   checkParsed();
 
77
   return mResponseCode;
 
78
}
 
79
 
 
80
int 
 
81
StatusLine::responseCode() const
 
82
{
 
83
   checkParsed();
 
84
   return mResponseCode;
 
85
}
 
86
 
 
87
int& 
 
88
StatusLine::statusCode()
 
89
{
 
90
   checkParsed();
 
91
   return mResponseCode;
 
92
}
 
93
 
 
94
int 
 
95
StatusLine::statusCode() const
 
96
{
 
97
   checkParsed();
 
98
   return mResponseCode;
 
99
}
 
100
 
 
101
const Data& 
 
102
StatusLine::getSipVersion() const
 
103
{
 
104
   checkParsed();
 
105
   return mSipVersion;
 
106
}
 
107
 
 
108
Data& 
 
109
StatusLine::reason()
 
110
{
 
111
   checkParsed();
 
112
   return mReason;
 
113
}
 
114
 
 
115
const Data& 
 
116
StatusLine::reason() const
 
117
{
 
118
   checkParsed();
 
119
   return mReason;
 
120
}
 
121
 
 
122
void
 
123
StatusLine::parse(ParseBuffer& pb)
 
124
{
 
125
   const char* start = pb.skipWhitespace();
 
126
   pb.skipNonWhitespace();
 
127
   pb.data(mSipVersion, start);
 
128
 
 
129
   start = pb.skipWhitespace();
 
130
   mResponseCode = pb.integer();
 
131
   start = pb.skipWhitespace();
 
132
   pb.skipToEnd();
 
133
   pb.data(mReason, start);
 
134
}
 
135
 
 
136
EncodeStream&
 
137
StatusLine::encodeParsed(EncodeStream& str) const
 
138
{
 
139
   str << mSipVersion << Symbols::SPACE 
 
140
       << mResponseCode << Symbols::SPACE
 
141
       << mReason;
 
142
   return str;
 
143
}
 
144
 
 
145
const Data& 
 
146
StatusLine::errorContext() const
 
147
{
 
148
   static const Data statLine("Status Line");
 
149
   return statLine;
 
150
}
 
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
 */