-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathMonitorString.cpp
More file actions
256 lines (226 loc) · 5.62 KB
/
MonitorString.cpp
File metadata and controls
256 lines (226 loc) · 5.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
/*
* Copyright (C) 2012 Yee Young Han <websearch@naver.com> (http://blog.naver.com/websearch)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "SipPlatformDefine.h"
#include "SipUdp.h"
#include "MonitorString.h"
#include "TimeString.h"
#include "MemoryDebug.h"
CMonitorString::CMonitorString()
{
}
CMonitorString::~CMonitorString()
{
}
/**
* @ingroup SipStack
* @brief 컬럼 문자열을 저장한다.
* @param pszValue 문자열
*/
void CMonitorString::AddCol( const char * pszValue )
{
m_strBuf.append( pszValue );
m_strBuf.append( MR_COL_SEP );
}
/**
* @ingroup SipStack
* @brief 컬럼 문자열을 저장한다.
* @param strValue 문자열
*/
void CMonitorString::AddCol( const std::string & strValue )
{
m_strBuf.append( strValue );
m_strBuf.append( MR_COL_SEP );
}
/**
* @ingroup SipStack
* @brief 컬럼 문자열에 IP 주소와 포트 번호를 저장한다.
* @param strIp IP 주소
* @param iPort 포트 번호
*/
void CMonitorString::AddCol( const std::string & strIp, int iPort )
{
m_strBuf.append( strIp );
m_strBuf.append( ":" );
AddCol( iPort );
}
/**
* @ingroup SipStack
* @brief 컬럼 문자열에 IP 주소와 포트 번호를 저장한다.
* @param iIp IP 주소
* @param iPort 포트 번호
*/
void CMonitorString::AddCol( uint32_t iIp, uint16_t iPort )
{
char szTemp[25];
snprintf( szTemp, sizeof(szTemp), "%d.%d.%d.%d:%d", (iIp)&0xFF, (iIp>>8)&0xFF, (iIp>>16)&0xFF, (iIp>>24)&0xFF, ntohs(iPort) );
AddCol( szTemp );
}
/**
* @ingroup SipStack
* @brief 컬럼 문자열에 숫자를 저장한다.
* @param iValue 숫자
*/
void CMonitorString::AddCol( int iValue )
{
char szValue[21];
snprintf( szValue, sizeof(szValue), "%d", iValue );
AddCol( szValue );
}
/**
* @ingroup SipStack
* @brief 컬럼 문자열에 숫자를 저장한다.
* @param iValue 숫자
*/
void CMonitorString::AddCol( uint32_t iValue )
{
char szValue[21];
snprintf( szValue, sizeof(szValue), "%u", iValue );
AddCol( szValue );
}
/**
* @ingroup SipStack
* @brief 컬럼 문자열에 시간 문자열을 저장한다.
* @param iTime 시간
*/
void CMonitorString::AddCol( time_t iTime )
{
char szTime[21];
GetDateTimeString( iTime, szTime, sizeof(szTime) );
AddCol( szTime );
}
/**
* @ingroup SipStack
* @brief 컬럼 문자열에 true/false 를 저장한다.
* @param bValue true/false
*/
void CMonitorString::AddCol( bool bValue )
{
AddCol( bValue ? "true" : "false" );
}
/**
* @ingroup SipStack
* @brief 줄의 마지막 문자열을 저장한다.
* @param pszValue 문자열
*/
void CMonitorString::AddRow( const char * pszValue )
{
m_strBuf.append( pszValue );
m_strBuf.append( MR_ROW_SEP );
}
/**
* @ingroup SipStack
* @brief 줄의 마지막 문자열을 저장한다.
* @param strValue 문자열
*/
void CMonitorString::AddRow( const std::string & strValue )
{
m_strBuf.append( strValue );
m_strBuf.append( MR_ROW_SEP );
}
/**
* @ingroup SipStack
* @brief 줄의 마지막 문자열에 IP 주소와 포트 번호를 저장한다.
* @param strIp IP 주소
* @param iPort 포트 번호
*/
void CMonitorString::AddRow( const std::string & strIp, int iPort )
{
m_strBuf.append( strIp );
m_strBuf.append( ":" );
AddRow( iPort );
}
/**
* @ingroup SipStack
* @brief 줄의 마지막 문자열에 IP 주소와 포트 번호를 저장한다.
* @param iIp IP 주소
* @param iPort 포트 번호
*/
void CMonitorString::AddRow( uint32_t iIp, uint16_t iPort )
{
char szTemp[25];
snprintf( szTemp, sizeof(szTemp), "%d.%d.%d.%d:%d", (iIp)&0xFF, (iIp>>8)&0xFF, (iIp>>16)&0xFF, (iIp>>24)&0xFF, ntohs(iPort) );
AddRow( szTemp );
}
/**
* @ingroup SipStack
* @brief 줄의 마지막 문자열에 숫자를 저장한다.
* @param iValue 숫자
*/
void CMonitorString::AddRow( int iValue )
{
char szValue[21];
snprintf( szValue, sizeof(szValue), "%d", iValue );
AddRow( szValue );
}
/**
* @ingroup SipStack
* @brief 줄의 마지막 문자열에 숫자를 저장한다.
* @param iValue 숫자
*/
void CMonitorString::AddRow( uint32_t iValue )
{
char szValue[21];
snprintf( szValue, sizeof(szValue), "%u", iValue );
AddRow( szValue );
}
/**
* @ingroup SipStack
* @brief 줄의 마지막 문자열에 시간 문자열을 저장한다.
* @param iTime 시간
*/
void CMonitorString::AddRow( time_t iTime )
{
char szTime[21];
GetDateTimeString( iTime, szTime, sizeof(szTime) );
AddRow( szTime );
}
/**
* @ingroup SipStack
* @brief 줄의 마지막 문자열에 true/false 를 저장한다.
* @param bValue true/false
*/
void CMonitorString::AddRow( bool bValue )
{
AddRow( bValue ? "true" : "false" );
}
/**
* @ingroup SipStack
* @brief 저장된 문자열을 초기화시킨다.
*/
void CMonitorString::Clear( )
{
m_strBuf.clear();
}
/**
* @ingroup SipStack
* @brief 저장된 문자열을 리턴한다.
* @returns 저장된 문자열을 리턴한다.
*/
const char * CMonitorString::GetString()
{
return m_strBuf.c_str();
}
/**
* @ingroup SipStack
* @brief 저장된 문자열의 길이를 리턴한다.
* @returns 저장된 문자열의 길이를 리턴한다.
*/
int CMonitorString::GetLength()
{
return (int)m_strBuf.length();
}