aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llcommon
diff options
context:
space:
mode:
authorJacek Antonelli2008-09-06 18:24:57 -0500
committerJacek Antonelli2008-09-06 18:25:07 -0500
commit798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch)
tree1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/llcommon
parentSecond Life viewer sources 1.20.15 (diff)
downloadmeta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz
Second Life viewer sources 1.21.0-RC
Diffstat (limited to 'linden/indra/llcommon')
-rw-r--r--linden/indra/llcommon/CMakeLists.txt188
-rw-r--r--linden/indra/llcommon/files.lst49
-rw-r--r--linden/indra/llcommon/indra_constants.h14
-rw-r--r--linden/indra/llcommon/linden_common.h5
-rw-r--r--linden/indra/llcommon/llapp.cpp2
-rw-r--r--linden/indra/llcommon/llapr.cpp24
-rw-r--r--linden/indra/llcommon/llapr.h34
-rw-r--r--linden/indra/llcommon/llares.cpp805
-rw-r--r--linden/indra/llcommon/llares.h572
-rw-r--r--linden/indra/llcommon/llassettype.cpp20
-rw-r--r--linden/indra/llcommon/llassettype.h6
-rw-r--r--linden/indra/llcommon/llbase64.cpp2
-rw-r--r--linden/indra/llcommon/llchat.h6
-rw-r--r--linden/indra/llcommon/llcommon.vcproj608
-rw-r--r--linden/indra/llcommon/llcommon_vc8.vcproj847
-rw-r--r--linden/indra/llcommon/llcommon_vc9.vcproj828
-rw-r--r--linden/indra/llcommon/llcrc.cpp224
-rw-r--r--linden/indra/llcommon/llcrc.h73
-rw-r--r--linden/indra/llcommon/lldarray.h1
-rw-r--r--linden/indra/llcommon/lldate.cpp2
-rw-r--r--linden/indra/llcommon/llerror.cpp44
-rw-r--r--linden/indra/llcommon/llevent.cpp2
-rw-r--r--linden/indra/llcommon/llfile.cpp88
-rw-r--r--linden/indra/llcommon/llfile.h81
-rw-r--r--linden/indra/llcommon/llfixedbuffer.cpp2
-rw-r--r--linden/indra/llcommon/llfixedbuffer.h2
-rw-r--r--linden/indra/llcommon/llframetimer.cpp1
-rw-r--r--linden/indra/llcommon/llframetimer.h8
-rw-r--r--linden/indra/llcommon/llhash.h4
-rw-r--r--linden/indra/llcommon/llheartbeat.cpp7
-rw-r--r--linden/indra/llcommon/llindraconfigfile.cpp2
-rw-r--r--linden/indra/llcommon/llkeythrottle.h110
-rw-r--r--linden/indra/llcommon/llliveappconfig.cpp2
-rw-r--r--linden/indra/llcommon/lllivefile.cpp2
-rw-r--r--linden/indra/llcommon/lllslconstants.h6
-rw-r--r--linden/indra/llcommon/llmd5.cpp531
-rw-r--r--linden/indra/llcommon/llmd5.h133
-rw-r--r--linden/indra/llcommon/llmemory.cpp1
-rw-r--r--linden/indra/llcommon/llmemtype.h1
-rw-r--r--linden/indra/llcommon/llpreprocessor.h7
-rw-r--r--linden/indra/llcommon/llprocessor.cpp4
-rw-r--r--linden/indra/llcommon/llprocessor.h2
-rw-r--r--linden/indra/llcommon/llptrskiplist.h1
-rw-r--r--linden/indra/llcommon/llrand.cpp176
-rw-r--r--linden/indra/llcommon/llrand.h132
-rw-r--r--linden/indra/llcommon/llsd.cpp28
-rw-r--r--linden/indra/llcommon/llsd.h4
-rw-r--r--linden/indra/llcommon/llsdserialize.cpp30
-rw-r--r--linden/indra/llcommon/llsdserialize.h41
-rw-r--r--linden/indra/llcommon/llsdserialize_xml.cpp137
-rw-r--r--linden/indra/llcommon/llsdutil.cpp132
-rw-r--r--linden/indra/llcommon/llsdutil.h17
-rw-r--r--linden/indra/llcommon/llsecondlifeurls.cpp72
-rw-r--r--linden/indra/llcommon/llsecondlifeurls.h32
-rw-r--r--linden/indra/llcommon/llstat.cpp5
-rw-r--r--linden/indra/llcommon/llstat.h8
-rw-r--r--linden/indra/llcommon/llstatenums.h3
-rw-r--r--linden/indra/llcommon/llstl.h2
-rw-r--r--linden/indra/llcommon/llstring.cpp292
-rw-r--r--linden/indra/llcommon/llstring.h391
-rw-r--r--linden/indra/llcommon/llsys.cpp56
-rw-r--r--linden/indra/llcommon/llsys.h4
-rw-r--r--linden/indra/llcommon/llthread.cpp2
-rw-r--r--linden/indra/llcommon/llthread.h2
-rw-r--r--linden/indra/llcommon/lltimer.cpp25
-rw-r--r--linden/indra/llcommon/lltimer.h37
-rw-r--r--linden/indra/llcommon/lluri.cpp2
-rw-r--r--linden/indra/llcommon/lluuid.cpp923
-rw-r--r--linden/indra/llcommon/lluuid.h331
-rw-r--r--linden/indra/llcommon/llversionserver.h6
-rw-r--r--linden/indra/llcommon/llversionviewer.h4
-rw-r--r--linden/indra/llcommon/metapropertyt.h13
-rw-r--r--linden/indra/llcommon/roles_constants.h10
-rw-r--r--linden/indra/llcommon/stdtypes.h2
-rw-r--r--linden/indra/llcommon/u64.cpp36
-rw-r--r--linden/indra/llcommon/u64.h9
76 files changed, 3641 insertions, 4674 deletions
diff --git a/linden/indra/llcommon/CMakeLists.txt b/linden/indra/llcommon/CMakeLists.txt
new file mode 100644
index 0000000..72d267d
--- /dev/null
+++ b/linden/indra/llcommon/CMakeLists.txt
@@ -0,0 +1,188 @@
1# -*- cmake -*-
2
3project(llcommon)
4
5include(00-Common)
6include(LLCommon)
7
8include_directories(
9 ${EXPAT_INCLUDE_DIRS}
10 ${LLCOMMON_INCLUDE_DIRS}
11 ${ZLIB_INCLUDE_DIRS}
12 )
13
14set(llcommon_SOURCE_FILES
15 llapp.cpp
16 llapr.cpp
17 llassettype.cpp
18 llbase32.cpp
19 llbase64.cpp
20 llcommon.cpp
21 llcrc.cpp
22 llcriticaldamp.cpp
23 lldate.cpp
24 llerror.cpp
25 llerrorthread.cpp
26 llevent.cpp
27 llfasttimer.cpp
28 llfile.cpp
29 llfindlocale.cpp
30 llfixedbuffer.cpp
31 llformat.cpp
32 llframetimer.cpp
33 llheartbeat.cpp
34 llindraconfigfile.cpp
35 llliveappconfig.cpp
36 lllivefile.cpp
37 lllog.cpp
38 llmd5.cpp
39 llmemory.cpp
40 llmemorystream.cpp
41 llmetrics.cpp
42 llmortician.cpp
43 llprocessor.cpp
44 llqueuedthread.cpp
45 llrand.cpp
46 llrun.cpp
47 llsd.cpp
48 llsdserialize.cpp
49 llsdserialize_xml.cpp
50 llsdutil.cpp
51 llsecondlifeurls.cpp
52 llstat.cpp
53 llstreamtools.cpp
54 llstring.cpp
55 llstringtable.cpp
56 llsys.cpp
57 llthread.cpp
58 lltimer.cpp
59 lluri.cpp
60 lluuid.cpp
61 llworkerthread.cpp
62 metaclass.cpp
63 metaproperty.cpp
64 reflective.cpp
65 timing.cpp
66 u64.cpp
67 )
68
69set(llcommon_HEADER_FILES
70 CMakeLists.txt
71
72 bitpack.h
73 ctype_workaround.h
74 doublelinkedlist.h
75 imageids.h
76 indra_constants.h
77 linden_common.h
78 linked_lists.h
79 llagentconstants.h
80 llapp.h
81 llapr.h
82 llassettype.h
83 llassoclist.h
84 llavatarconstants.h
85 llbase32.h
86 llbase64.h
87 llboost.h
88 llchat.h
89 llclickaction.h
90 llcommon.h
91 llcrc.h
92 llcriticaldamp.h
93 lldarray.h
94 lldarrayptr.h
95 lldate.h
96 lldefs.h
97 lldepthstack.h
98 lldlinked.h
99 lldqueueptr.h
100 llendianswizzle.h
101 llenum.h
102 llerror.h
103 llerrorcontrol.h
104 llerrorlegacy.h
105 llerrorthread.h
106 llevent.h
107 lleventemitter.h
108 llextendedstatus.h
109 llfasttimer.h
110 llfile.h
111 llfindlocale.h
112 llfixedbuffer.h
113 llformat.h
114 llframetimer.h
115 llhash.h
116 llheartbeat.h
117 llindexedqueue.h
118 llindraconfigfile.h
119 llkeythrottle.h
120 lllinkedqueue.h
121 llliveappconfig.h
122 lllivefile.h
123 lllocalidhashmap.h
124 lllog.h
125 lllslconstants.h
126 llmap.h
127 llmd5.h
128 llmemory.h
129 llmemorystream.h
130 llmemtype.h
131 llmetrics.h
132 llmortician.h
133 llnametable.h
134 llpreprocessor.h
135 llpriqueuemap.h
136 llprocessor.h
137 llptrskiplist.h
138 llptrskipmap.h
139 llqueuedthread.h
140 llrand.h
141 llrun.h
142 llsd.h
143 llsdserialize.h
144 llsdserialize_xml.h
145 llsdutil.h
146 llsecondlifeurls.h
147 llsimplehash.h
148 llskiplist.h
149 llskipmap.h
150 llstack.h
151 llstat.h
152 llstatenums.h
153 llstl.h
154 llstreamtools.h
155 llstrider.h
156 llstring.h
157 llstringtable.h
158 llsys.h
159 llthread.h
160 lltimer.h
161 lluri.h
162 lluuid.h
163 lluuidhashmap.h
164 llversionserver.h
165 llversionviewer.h
166 llworkerthread.h
167 metaclass.h
168 metaclasst.h
169 metaproperty.h
170 metapropertyt.h
171 processor.h
172 reflective.h
173 reflectivet.h
174 roles_constants.h
175 stdenums.h
176 stdtypes.h
177 string_table.h
178 timer.h
179 timing.h
180 u64.h
181 )
182
183set_source_files_properties(${llcommon_HEADER_FILES}
184 PROPERTIES HEADER_FILE_ONLY TRUE)
185
186list(APPEND llcommon_SOURCE_FILES ${llcommon_HEADER_FILES})
187
188add_library (llcommon ${llcommon_SOURCE_FILES})
diff --git a/linden/indra/llcommon/files.lst b/linden/indra/llcommon/files.lst
deleted file mode 100644
index d698773..0000000
--- a/linden/indra/llcommon/files.lst
+++ /dev/null
@@ -1,49 +0,0 @@
1llcommon/llapp.cpp
2llcommon/llapr.cpp
3llcommon/llares.cpp
4llcommon/llassettype.cpp
5llcommon/llbase32.cpp
6llcommon/llbase64.cpp
7llcommon/llcommon.cpp
8llcommon/llcriticaldamp.cpp
9llcommon/lldate.cpp
10llcommon/llerror.cpp
11llcommon/llerrorthread.cpp
12llcommon/llevent.cpp
13llcommon/llfasttimer.cpp
14llcommon/llfile.cpp
15llcommon/llfindlocale.cpp
16llcommon/llfixedbuffer.cpp
17llcommon/llformat.cpp
18llcommon/llframetimer.cpp
19llcommon/llheartbeat.cpp
20llcommon/llindraconfigfile.cpp
21llcommon/lllog.cpp
22llcommon/llliveappconfig.cpp
23llcommon/lllivefile.cpp
24llcommon/llmemory.cpp
25llcommon/llmemorystream.cpp
26llcommon/llmetrics.cpp
27llcommon/llmortician.cpp
28llcommon/llprocessor.cpp
29llcommon/llqueuedthread.cpp
30llcommon/llrun.cpp
31llcommon/llsd.cpp
32llcommon/llsdserialize.cpp
33llcommon/llsdserialize_xml.cpp
34llcommon/llsdutil.cpp
35llcommon/llsecondlifeurls.cpp
36llcommon/llstat.cpp
37llcommon/llstreamtools.cpp
38llcommon/llstring.cpp
39llcommon/llstringtable.cpp
40llcommon/llsys.cpp
41llcommon/llthread.cpp
42llcommon/lltimer.cpp
43llcommon/lluri.cpp
44llcommon/llworkerthread.cpp
45llcommon/metaclass.cpp
46llcommon/metaproperty.cpp
47llcommon/reflective.cpp
48llcommon/timing.cpp
49llcommon/u64.cpp
diff --git a/linden/indra/llcommon/indra_constants.h b/linden/indra/llcommon/indra_constants.h
index 77f3d8c..1c48a5c 100644
--- a/linden/indra/llcommon/indra_constants.h
+++ b/linden/indra/llcommon/indra_constants.h
@@ -38,7 +38,11 @@
38// At 45 Hz collisions seem stable and objects seem 38// At 45 Hz collisions seem stable and objects seem
39// to settle down at a reasonable rate. 39// to settle down at a reasonable rate.
40// JC 3/18/2003 40// JC 3/18/2003
41const F32 PHYSICS_TIMESTEP = 1.f / 45.f; 41
42// const F32 PHYSICS_TIMESTEP = 1.f / 45.f;
43// This must be a #define due to anal retentive restrictions on const expressions
44// CG 2008-06-05
45#define PHYSICS_TIMESTEP (1.f / 45.f)
42 46
43const F32 COLLISION_TOLERANCE = 0.1f; 47const F32 COLLISION_TOLERANCE = 0.1f;
44const F32 HALF_COLLISION_TOLERANCE = COLLISION_TOLERANCE * 0.5f; 48const F32 HALF_COLLISION_TOLERANCE = COLLISION_TOLERANCE * 0.5f;
@@ -50,9 +54,9 @@ const U32 DAYS_PER_LINDEN_YEAR = 11;
50const U32 SEC_PER_LINDEN_DAY = HOURS_PER_LINDEN_DAY * 60 * 60; 54const U32 SEC_PER_LINDEN_DAY = HOURS_PER_LINDEN_DAY * 60 * 60;
51const U32 SEC_PER_LINDEN_YEAR = DAYS_PER_LINDEN_YEAR * SEC_PER_LINDEN_DAY; 55const U32 SEC_PER_LINDEN_YEAR = DAYS_PER_LINDEN_YEAR * SEC_PER_LINDEN_DAY;
52 56
53const F32 REGION_WIDTH_METERS = 256.f; 57static const F32 REGION_WIDTH_METERS = 256.f;
54const S32 REGION_WIDTH_UNITS = 256; 58static const S32 REGION_WIDTH_UNITS = 256;
55const U32 REGION_WIDTH_U32 = 256; 59static const U32 REGION_WIDTH_U32 = 256;
56 60
57const F32 REGION_HEIGHT_METERS = 4096.f; 61const F32 REGION_HEIGHT_METERS = 4096.f;
58 62
@@ -74,7 +78,7 @@ enum LAND_STAT_REPORT_TYPE
74const U32 STAT_FILTER_MASK = 0x1FFFFFFF; 78const U32 STAT_FILTER_MASK = 0x1FFFFFFF;
75 79
76// Default maximum number of tasks/prims per region. 80// Default maximum number of tasks/prims per region.
77const U32 MAX_TASKS_PER_REGION = 15000; 81const U32 DEFAULT_MAX_REGION_WIDE_PRIM_COUNT = 15000;
78 82
79const F32 MIN_AGENT_DEPTH = 0.30f; 83const F32 MIN_AGENT_DEPTH = 0.30f;
80const F32 DEFAULT_AGENT_DEPTH = 0.45f; 84const F32 DEFAULT_AGENT_DEPTH = 0.45f;
diff --git a/linden/indra/llcommon/linden_common.h b/linden/indra/llcommon/linden_common.h
index 547cceb..7d3c82d 100644
--- a/linden/indra/llcommon/linden_common.h
+++ b/linden/indra/llcommon/linden_common.h
@@ -45,9 +45,10 @@
45#include <iostream> 45#include <iostream>
46#include <fstream> 46#include <fstream>
47 47
48// Work around stupid Microsoft STL warning 48// Work Microsoft compiler warnings
49#ifdef LL_WINDOWS 49#ifdef LL_WINDOWS
50#pragma warning (disable : 4702) // warning C4702: unreachable code 50#pragma warning (disable : 4702) // unreachable code
51#pragma warning (disable : 4244) // conversion from time_t to S32
51#endif // LL_WINDOWS 52#endif // LL_WINDOWS
52 53
53#include <algorithm> 54#include <algorithm>
diff --git a/linden/indra/llcommon/llapp.cpp b/linden/indra/llcommon/llapp.cpp
index ebace4e..3ca3782 100644
--- a/linden/indra/llcommon/llapp.cpp
+++ b/linden/indra/llcommon/llapp.cpp
@@ -224,6 +224,7 @@ LLSD LLApp::getOptionData(OptionPriority level)
224void LLApp::stepFrame() 224void LLApp::stepFrame()
225{ 225{
226 LLFrameTimer::updateFrameTime(); 226 LLFrameTimer::updateFrameTime();
227 LLFrameTimer::updateFrameCount();
227 LLEventTimer::updateClass(); 228 LLEventTimer::updateClass();
228 mRunner.run(); 229 mRunner.run();
229} 230}
@@ -492,6 +493,7 @@ void LLApp::setDefaultChildCallback(LLAppChildCallback callback)
492 493
493pid_t LLApp::fork() 494pid_t LLApp::fork()
494{ 495{
496 fflush(NULL); // flush all buffers before the child inherits them
495 pid_t pid = ::fork(); 497 pid_t pid = ::fork();
496 if( pid < 0 ) 498 if( pid < 0 )
497 { 499 {
diff --git a/linden/indra/llcommon/llapr.cpp b/linden/indra/llcommon/llapr.cpp
index 78bf876..73e715a 100644
--- a/linden/indra/llcommon/llapr.cpp
+++ b/linden/indra/llcommon/llapr.cpp
@@ -129,7 +129,7 @@ void ll_apr_assert_status(apr_status_t status)
129} 129}
130 130
131// File I/O 131// File I/O
132apr_file_t* ll_apr_file_open(const LLString& filename, apr_int32_t flags, S32* sizep, apr_pool_t* pool) 132apr_file_t* ll_apr_file_open(const std::string& filename, apr_int32_t flags, S32* sizep, apr_pool_t* pool)
133{ 133{
134 apr_file_t* apr_file; 134 apr_file_t* apr_file;
135 apr_status_t s; 135 apr_status_t s;
@@ -160,15 +160,15 @@ apr_file_t* ll_apr_file_open(const LLString& filename, apr_int32_t flags, S32* s
160 160
161 return apr_file; 161 return apr_file;
162} 162}
163apr_file_t* ll_apr_file_open(const LLString& filename, apr_int32_t flags, S32* sizep) 163apr_file_t* ll_apr_file_open(const std::string& filename, apr_int32_t flags, S32* sizep)
164{ 164{
165 return ll_apr_file_open(filename, flags, sizep, NULL); 165 return ll_apr_file_open(filename, flags, sizep, NULL);
166} 166}
167apr_file_t* ll_apr_file_open(const LLString& filename, apr_int32_t flags, apr_pool_t* pool) 167apr_file_t* ll_apr_file_open(const std::string& filename, apr_int32_t flags, apr_pool_t* pool)
168{ 168{
169 return ll_apr_file_open(filename, flags, NULL, pool); 169 return ll_apr_file_open(filename, flags, NULL, pool);
170} 170}
171apr_file_t* ll_apr_file_open(const LLString& filename, apr_int32_t flags) 171apr_file_t* ll_apr_file_open(const std::string& filename, apr_int32_t flags)
172{ 172{
173 return ll_apr_file_open(filename, flags, NULL, NULL); 173 return ll_apr_file_open(filename, flags, NULL, NULL);
174} 174}
@@ -188,7 +188,7 @@ S32 ll_apr_file_read(apr_file_t* apr_file, void *buf, S32 nbytes)
188 } 188 }
189} 189}
190 190
191S32 ll_apr_file_read_ex(const LLString& filename, apr_pool_t* pool, void *buf, S32 offset, S32 nbytes) 191S32 ll_apr_file_read_ex(const std::string& filename, apr_pool_t* pool, void *buf, S32 offset, S32 nbytes)
192{ 192{
193 if (pool == NULL) pool = gAPRPoolp; 193 if (pool == NULL) pool = gAPRPoolp;
194 apr_file_t* filep = ll_apr_file_open(filename, APR_READ|APR_BINARY, pool); 194 apr_file_t* filep = ll_apr_file_open(filename, APR_READ|APR_BINARY, pool);
@@ -230,7 +230,7 @@ S32 ll_apr_file_write(apr_file_t* apr_file, const void *buf, S32 nbytes)
230 } 230 }
231} 231}
232 232
233S32 ll_apr_file_write_ex(const LLString& filename, apr_pool_t* pool, void *buf, S32 offset, S32 nbytes) 233S32 ll_apr_file_write_ex(const std::string& filename, apr_pool_t* pool, void *buf, S32 offset, S32 nbytes)
234{ 234{
235 if (pool == NULL) pool = gAPRPoolp; 235 if (pool == NULL) pool = gAPRPoolp;
236 apr_int32_t flags = APR_CREATE|APR_WRITE|APR_BINARY; 236 apr_int32_t flags = APR_CREATE|APR_WRITE|APR_BINARY;
@@ -287,7 +287,7 @@ S32 ll_apr_file_seek(apr_file_t* apr_file, apr_seek_where_t where, S32 offset)
287 } 287 }
288} 288}
289 289
290bool ll_apr_file_remove(const LLString& filename, apr_pool_t* pool) 290bool ll_apr_file_remove(const std::string& filename, apr_pool_t* pool)
291{ 291{
292 apr_status_t s; 292 apr_status_t s;
293 if (pool == NULL) pool = gAPRPoolp; 293 if (pool == NULL) pool = gAPRPoolp;
@@ -301,7 +301,7 @@ bool ll_apr_file_remove(const LLString& filename, apr_pool_t* pool)
301 return true; 301 return true;
302} 302}
303 303
304bool ll_apr_file_rename(const LLString& filename, const LLString& newname, apr_pool_t* pool) 304bool ll_apr_file_rename(const std::string& filename, const std::string& newname, apr_pool_t* pool)
305{ 305{
306 apr_status_t s; 306 apr_status_t s;
307 if (pool == NULL) pool = gAPRPoolp; 307 if (pool == NULL) pool = gAPRPoolp;
@@ -315,7 +315,7 @@ bool ll_apr_file_rename(const LLString& filename, const LLString& newname, apr_p
315 return true; 315 return true;
316} 316}
317 317
318bool ll_apr_file_exists(const LLString& filename, apr_pool_t* pool) 318bool ll_apr_file_exists(const std::string& filename, apr_pool_t* pool)
319{ 319{
320 apr_file_t* apr_file; 320 apr_file_t* apr_file;
321 apr_status_t s; 321 apr_status_t s;
@@ -332,7 +332,7 @@ bool ll_apr_file_exists(const LLString& filename, apr_pool_t* pool)
332 } 332 }
333} 333}
334 334
335S32 ll_apr_file_size(const LLString& filename, apr_pool_t* pool) 335S32 ll_apr_file_size(const std::string& filename, apr_pool_t* pool)
336{ 336{
337 apr_file_t* apr_file; 337 apr_file_t* apr_file;
338 apr_finfo_t info; 338 apr_finfo_t info;
@@ -358,7 +358,7 @@ S32 ll_apr_file_size(const LLString& filename, apr_pool_t* pool)
358 } 358 }
359} 359}
360 360
361bool ll_apr_dir_make(const LLString& dirname, apr_pool_t* pool) 361bool ll_apr_dir_make(const std::string& dirname, apr_pool_t* pool)
362{ 362{
363 apr_status_t s; 363 apr_status_t s;
364 if (pool == NULL) pool = gAPRPoolp; 364 if (pool == NULL) pool = gAPRPoolp;
@@ -372,7 +372,7 @@ bool ll_apr_dir_make(const LLString& dirname, apr_pool_t* pool)
372 return true; 372 return true;
373} 373}
374 374
375bool ll_apr_dir_remove(const LLString& dirname, apr_pool_t* pool) 375bool ll_apr_dir_remove(const std::string& dirname, apr_pool_t* pool)
376{ 376{
377 apr_status_t s; 377 apr_status_t s;
378 if (pool == NULL) pool = gAPRPoolp; 378 if (pool == NULL) pool = gAPRPoolp;
diff --git a/linden/indra/llcommon/llapr.h b/linden/indra/llcommon/llapr.h
index 695b93e..323dcb2 100644
--- a/linden/indra/llcommon/llapr.h
+++ b/linden/indra/llcommon/llapr.h
@@ -40,11 +40,11 @@
40 40
41#include <boost/noncopyable.hpp> 41#include <boost/noncopyable.hpp>
42 42
43#include "apr-1/apr_thread_proc.h" 43#include "apr_thread_proc.h"
44#include "apr-1/apr_thread_mutex.h" 44#include "apr_thread_mutex.h"
45#include "apr-1/apr_getopt.h" 45#include "apr_getopt.h"
46#include "apr-1/apr_signal.h" 46#include "apr_signal.h"
47#include "apr-1/apr_atomic.h" 47#include "apr_atomic.h"
48#include "llstring.h" 48#include "llstring.h"
49 49
50extern apr_thread_mutex_t* gLogMutexp; 50extern apr_thread_mutex_t* gLogMutexp;
@@ -130,24 +130,24 @@ typedef LLAtomic32<S32> LLAtomicS32;
130#define LL_APR_WB (APR_CREATE|APR_TRUNCATE|APR_WRITE|APR_BINARY) // "wb" 130#define LL_APR_WB (APR_CREATE|APR_TRUNCATE|APR_WRITE|APR_BINARY) // "wb"
131#define LL_APR_RPB (APR_READ|APR_WRITE|APR_BINARY) // "r+b" 131#define LL_APR_RPB (APR_READ|APR_WRITE|APR_BINARY) // "r+b"
132#define LL_APR_WPB (APR_CREATE|APR_TRUNCATE|APR_READ|APR_WRITE|APR_BINARY) // "w+b" 132#define LL_APR_WPB (APR_CREATE|APR_TRUNCATE|APR_READ|APR_WRITE|APR_BINARY) // "w+b"
133apr_file_t* ll_apr_file_open(const LLString& filename, apr_int32_t flags, S32* sizep, apr_pool_t* pool); 133apr_file_t* ll_apr_file_open(const std::string& filename, apr_int32_t flags, S32* sizep, apr_pool_t* pool);
134apr_file_t* ll_apr_file_open(const LLString& filename, apr_int32_t flags, S32* sizep); 134apr_file_t* ll_apr_file_open(const std::string& filename, apr_int32_t flags, S32* sizep);
135apr_file_t* ll_apr_file_open(const LLString& filename, apr_int32_t flags, apr_pool_t* pool); 135apr_file_t* ll_apr_file_open(const std::string& filename, apr_int32_t flags, apr_pool_t* pool);
136apr_file_t* ll_apr_file_open(const LLString& filename, apr_int32_t flags); 136apr_file_t* ll_apr_file_open(const std::string& filename, apr_int32_t flags);
137// Returns actual offset, -1 if seek fails 137// Returns actual offset, -1 if seek fails
138S32 ll_apr_file_seek(apr_file_t* apr_file, apr_seek_where_t where, S32 offset); 138S32 ll_apr_file_seek(apr_file_t* apr_file, apr_seek_where_t where, S32 offset);
139// Returns bytes read/written, 0 if read/write fails: 139// Returns bytes read/written, 0 if read/write fails:
140S32 ll_apr_file_read(apr_file_t* apr_file, void* buf, S32 nbytes); 140S32 ll_apr_file_read(apr_file_t* apr_file, void* buf, S32 nbytes);
141S32 ll_apr_file_read_ex(const LLString& filename, apr_pool_t* pool, void *buf, S32 offset, S32 nbytes); 141S32 ll_apr_file_read_ex(const std::string& filename, apr_pool_t* pool, void *buf, S32 offset, S32 nbytes);
142S32 ll_apr_file_write(apr_file_t* apr_file, const void* buf, S32 nbytes); 142S32 ll_apr_file_write(apr_file_t* apr_file, const void* buf, S32 nbytes);
143S32 ll_apr_file_write_ex(const LLString& filename, apr_pool_t* pool, void *buf, S32 offset, S32 nbytes); 143S32 ll_apr_file_write_ex(const std::string& filename, apr_pool_t* pool, void *buf, S32 offset, S32 nbytes);
144// returns false if failure: 144// returns false if failure:
145bool ll_apr_file_remove(const LLString& filename, apr_pool_t* pool = NULL); 145bool ll_apr_file_remove(const std::string& filename, apr_pool_t* pool = NULL);
146bool ll_apr_file_rename(const LLString& filename, const LLString& newname, apr_pool_t* pool = NULL); 146bool ll_apr_file_rename(const std::string& filename, const std::string& newname, apr_pool_t* pool = NULL);
147bool ll_apr_file_exists(const LLString& filename, apr_pool_t* pool = NULL); 147bool ll_apr_file_exists(const std::string& filename, apr_pool_t* pool = NULL);
148S32 ll_apr_file_size(const LLString& filename, apr_pool_t* pool = NULL); 148S32 ll_apr_file_size(const std::string& filename, apr_pool_t* pool = NULL);
149bool ll_apr_dir_make(const LLString& dirname, apr_pool_t* pool = NULL); 149bool ll_apr_dir_make(const std::string& dirname, apr_pool_t* pool = NULL);
150bool ll_apr_dir_remove(const LLString& dirname, apr_pool_t* pool = NULL); 150bool ll_apr_dir_remove(const std::string& dirname, apr_pool_t* pool = NULL);
151 151
152/** 152/**
153 * @brief Function which approprately logs error or remains quiet on 153 * @brief Function which approprately logs error or remains quiet on
diff --git a/linden/indra/llcommon/llares.cpp b/linden/indra/llcommon/llares.cpp
deleted file mode 100644
index 4d054e4..0000000
--- a/linden/indra/llcommon/llares.cpp
+++ /dev/null
@@ -1,805 +0,0 @@
1/**
2 * @file llares.cpp
3 * @author Bryan O'Sullivan
4 * @date 2007-08-15
5 * @brief Wrapper for asynchronous DNS lookups.
6 *
7 * $LicenseInfo:firstyear=2007&license=viewergpl$
8 *
9 * Copyright (c) 2007-2008, Linden Research, Inc.
10 *
11 * Second Life Viewer Source Code
12 * The source code in this file ("Source Code") is provided by Linden Lab
13 * to you under the terms of the GNU General Public License, version 2.0
14 * ("GPL"), unless you have obtained a separate licensing agreement
15 * ("Other License"), formally executed by you and Linden Lab. Terms of
16 * the GPL can be found in doc/GPL-license.txt in this distribution, or
17 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
18 *
19 * There are special exceptions to the terms and conditions of the GPL as
20 * it is applied to this Source Code. View the full text of the exception
21 * in the file doc/FLOSS-exception.txt in this software distribution, or
22 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
23 *
24 * By copying, modifying or distributing this software, you acknowledge
25 * that you have read and understood your obligations described above,
26 * and agree to abide by those obligations.
27 *
28 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
29 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
30 * COMPLETENESS OR PERFORMANCE.
31 * $/LicenseInfo$
32 */
33
34#ifdef LL_STANDALONE
35# include <ares_dns.h>
36#else
37# include <ares/ares_dns.h>
38#endif
39
40#include "apr-1/apr_portable.h"
41#include "apr-1/apr_network_io.h"
42#include "apr-1/apr_poll.h"
43
44#include "linden_common.h"
45#include "llapr.h"
46#include "llares.h"
47
48#if defined(LL_WINDOWS)
49# define ns_c_in 1
50# define NS_HFIXEDSZ 12 /* #/bytes of fixed data in header */
51# define NS_QFIXEDSZ 4 /* #/bytes of fixed data in query */
52# define NS_RRFIXEDSZ 10 /* #/bytes of fixed data in r record */
53#else
54# include <arpa/nameser.h>
55#endif
56
57LLAres::HostResponder::~HostResponder()
58{
59}
60
61void LLAres::HostResponder::hostResult(const hostent *ent)
62{
63 llinfos << "LLAres::HostResponder::hostResult not implemented" << llendl;
64}
65
66void LLAres::HostResponder::hostError(int code)
67{
68 llinfos << "LLAres::HostResponder::hostError " << code << ": "
69 << LLAres::strerror(code) << llendl;
70}
71
72LLAres::NameInfoResponder::~NameInfoResponder()
73{
74}
75
76void LLAres::NameInfoResponder::nameInfoResult(const char *node,
77 const char *service)
78{
79 llinfos << "LLAres::NameInfoResponder::nameInfoResult not implemented"
80 << llendl;
81}
82
83void LLAres::NameInfoResponder::nameInfoError(int code)
84{
85 llinfos << "LLAres::NameInfoResponder::nameInfoError " << code << ": "
86 << LLAres::strerror(code) << llendl;
87}
88
89LLAres::QueryResponder::~QueryResponder()
90{
91}
92
93void LLAres::QueryResponder::queryResult(const char *buf, size_t len)
94{
95 llinfos << "LLAres::QueryResponder::queryResult not implemented"
96 << llendl;
97}
98
99void LLAres::QueryResponder::queryError(int code)
100{
101 llinfos << "LLAres::QueryResponder::queryError " << code << ": "
102 << LLAres::strerror(code) << llendl;
103}
104
105LLAres::LLAres()
106 : chan_(NULL)
107{
108 ares_init(&chan_);
109}
110
111LLAres::~LLAres()
112{
113 if (chan_)
114 ares_destroy(chan_);
115}
116
117void LLAres::cancel()
118{
119 if (chan_)
120 ares_cancel(chan_);
121}
122
123static void host_callback(void *arg, int status, struct hostent *ent)
124{
125 LLPointer<LLAres::HostResponder> *resp =
126 (LLPointer<LLAres::HostResponder> *) arg;
127
128 if (status == ARES_SUCCESS)
129 {
130 (*resp)->hostResult(ent);
131 } else {
132 (*resp)->hostError(status);
133 }
134
135 delete resp;
136}
137
138void LLAres::getHostByName(const char *name, HostResponder *resp,
139 int family)
140{
141 if (!chan_)
142 {
143 resp->hostError(ARES_EBADRESP);
144 return;
145 }
146 ares_gethostbyname(chan_, name, family, host_callback,
147 new LLPointer<LLAres::HostResponder>(resp));
148}
149
150void LLAres::getSrvRecords(const std::string &name, SrvResponder *resp)
151{
152 search(name, RES_SRV, resp);
153}
154
155void LLAres::rewriteURI(const std::string &uri, UriRewriteResponder *resp)
156{
157 LL_DEBUGS2("AppInit","Rewrite") << "Rewriting " << uri << LL_ENDL;
158
159 resp->mUri = LLURI(uri);
160 search("_" + resp->mUri.scheme() + "._tcp." + resp->mUri.hostName(),
161 RES_SRV, resp);
162}
163
164LLQueryResponder::LLQueryResponder()
165 : LLAres::QueryResponder(),
166 mResult(ARES_ENODATA),
167 mType(RES_INVALID)
168{
169}
170
171int LLQueryResponder::parseRR(const char *buf, size_t len, const char *&pos,
172 LLPointer<LLDnsRecord> &r)
173{
174 std::string rrname;
175 size_t enclen;
176 int ret;
177
178 // RR name.
179
180 ret = LLAres::expandName(pos, buf, len, rrname, enclen);
181 if (ret != ARES_SUCCESS)
182 {
183 return ret;
184 }
185
186 pos += enclen;
187
188 if (pos + NS_RRFIXEDSZ > buf + len)
189 {
190 return ARES_EBADRESP;
191 }
192
193 int rrtype = DNS_RR_TYPE(pos);
194 int rrclass = DNS_RR_CLASS(pos);
195 int rrttl = DNS_RR_TTL(pos);
196 int rrlen = DNS_RR_LEN(pos);
197
198 if (rrclass != ns_c_in)
199 {
200 return ARES_EBADRESP;
201 }
202
203 pos += NS_RRFIXEDSZ;
204
205 if (pos + rrlen > buf + len)
206 {
207 return ARES_EBADRESP;
208 }
209
210 switch (rrtype)
211 {
212 case RES_A:
213 r = new LLARecord(rrname, rrttl);
214 break;
215 case RES_NS:
216 r = new LLNsRecord(rrname, rrttl);
217 break;
218 case RES_CNAME:
219 r = new LLCnameRecord(rrname, rrttl);
220 break;
221 case RES_PTR:
222 r = new LLPtrRecord(rrname, rrttl);
223 break;
224 case RES_AAAA:
225 r = new LLAaaaRecord(rrname, rrttl);
226 break;
227 case RES_SRV:
228 r = new LLSrvRecord(rrname, rrttl);
229 break;
230 default:
231 llinfos << "LLQueryResponder::parseRR got unknown RR type " << rrtype
232 << llendl;
233 return ARES_EBADRESP;
234 }
235
236 ret = r->parse(buf, len, pos, rrlen);
237
238 if (ret == ARES_SUCCESS)
239 {
240 pos += rrlen;
241 } else {
242 r = NULL;
243 }
244
245 return ret;
246}
247
248int LLQueryResponder::parseSection(const char *buf, size_t len,
249 size_t count, const char *&pos,
250 dns_rrs_t &rrs)
251{
252 int ret = ARES_SUCCESS;
253
254 for (size_t i = 0; i < count; i++)
255 {
256 LLPointer<LLDnsRecord> r;
257 ret = parseRR(buf, len, pos, r);
258 if (ret != ARES_SUCCESS)
259 {
260 break;
261 }
262 rrs.push_back(r);
263 }
264
265 return ret;
266}
267
268void LLQueryResponder::queryResult(const char *buf, size_t len)
269{
270 const char *pos = buf;
271 int qdcount = DNS_HEADER_QDCOUNT(pos);
272 int ancount = DNS_HEADER_ANCOUNT(pos);
273 int nscount = DNS_HEADER_NSCOUNT(pos);
274 int arcount = DNS_HEADER_ARCOUNT(pos);
275 int ret;
276
277 if (qdcount == 0 || ancount + nscount + arcount == 0)
278 {
279 ret = ARES_ENODATA;
280 goto bail;
281 }
282
283 pos += NS_HFIXEDSZ;
284
285 for (int i = 0; i < qdcount; i++)
286 {
287 std::string ignore;
288 size_t enclen;
289
290 ret = LLAres::expandName(pos, buf, len, i == 0 ? mQuery : ignore,
291 enclen);
292 if (ret != ARES_SUCCESS)
293 {
294 goto bail;
295 }
296
297 pos += enclen;
298
299 if (i == 0)
300 {
301 int t = DNS_QUESTION_TYPE(pos);
302 switch (t)
303 {
304 case RES_A:
305 case RES_NS:
306 case RES_CNAME:
307 case RES_PTR:
308 case RES_AAAA:
309 case RES_SRV:
310 mType = (LLResType) t;
311 break;
312 default:
313 llinfos << "Cannot grok query type " << t << llendl;
314 ret = ARES_EBADQUERY;
315 goto bail;
316 }
317 }
318
319 pos += NS_QFIXEDSZ;
320 if (pos > buf + len)
321 {
322 ret = ARES_EBADRESP;
323 goto bail;
324 }
325 }
326
327 ret = parseSection(buf, len, ancount, pos, mAnswers);
328 if (ret != ARES_SUCCESS)
329 {
330 goto bail;
331 }
332
333 ret = parseSection(buf, len, nscount, pos, mAuthorities);
334 if (ret != ARES_SUCCESS)
335 {
336 goto bail;
337 }
338
339 ret = parseSection(buf, len, arcount, pos, mAdditional);
340
341bail:
342 mResult = ret;
343 if (mResult == ARES_SUCCESS)
344 {
345 queryResult();
346 } else {
347 queryError(mResult);
348 }
349}
350
351void LLQueryResponder::queryResult()
352{
353 llinfos << "LLQueryResponder::queryResult not implemented" << llendl;
354}
355
356void LLAres::SrvResponder::queryResult()
357{
358 if (mType == RES_SRV)
359 {
360 srvResult(mAnswers);
361 } else {
362 srvError(ARES_EBADRESP);
363 }
364}
365
366void LLAres::SrvResponder::queryError(int code)
367{
368 srvError(code);
369}
370
371void LLAres::SrvResponder::srvResult(const dns_rrs_t &ents)
372{
373 llinfos << "LLAres::SrvResponder::srvResult not implemented" << llendl;
374
375 for (size_t i = 0; i < ents.size(); i++)
376 {
377 const LLSrvRecord *s = (const LLSrvRecord *) ents[i].get();
378
379 llinfos << "[" << i << "] " << s->host() << ":" << s->port()
380 << " priority " << s->priority()
381 << " weight " << s->weight()
382 << llendl;
383 }
384}
385
386void LLAres::SrvResponder::srvError(int code)
387{
388 llinfos << "LLAres::SrvResponder::srvError " << code << ": "
389 << LLAres::strerror(code) << llendl;
390}
391
392static void nameinfo_callback(void *arg, int status, char *node, char *service)
393{
394 LLPointer<LLAres::NameInfoResponder> *resp =
395 (LLPointer<LLAres::NameInfoResponder> *) arg;
396
397 if (status == ARES_SUCCESS)
398 {
399 (*resp)->nameInfoResult(node, service);
400 } else {
401 (*resp)->nameInfoError(status);
402 }
403
404 delete resp;
405}
406
407void LLAres::getNameInfo(const struct sockaddr &sa, socklen_t salen, int flags,
408 NameInfoResponder *resp)
409{
410 if (!chan_)
411 {
412 resp->nameInfoError(ARES_EBADRESP);
413 return;
414 }
415 ares_getnameinfo(chan_, &sa, salen, flags, nameinfo_callback,
416 new LLPointer<NameInfoResponder>(resp));
417}
418
419static void search_callback(void *arg, int status, unsigned char *abuf,
420 int alen)
421{
422 LLPointer<LLAres::QueryResponder> *resp =
423 (LLPointer<LLAres::QueryResponder> *) arg;
424
425 if (status == ARES_SUCCESS)
426 {
427 (*resp)->queryResult((const char *) abuf, alen);
428 } else {
429 (*resp)->queryError(status);
430 }
431
432 delete resp;
433}
434
435void LLAres::search(const std::string &query, LLResType type,
436 QueryResponder *resp)
437{
438 if (!chan_)
439 {
440 resp->queryError(ARES_EBADRESP);
441 return;
442 }
443 ares_search(chan_, query.c_str(), ns_c_in, type, search_callback,
444 new LLPointer<QueryResponder>(resp));
445}
446
447bool LLAres::process(U64 timeout)
448{
449 if (!gAPRPoolp)
450 {
451 ll_init_apr();
452 }
453
454 int socks[ARES_GETSOCK_MAXNUM];
455 apr_pollfd_t aprFds[ARES_GETSOCK_MAXNUM];
456 apr_int32_t nsds = 0;
457 apr_status_t status;
458 apr_pool_t *pool;
459 int nactive = 0;
460 int bitmask;
461
462 if (!chan_)
463 {
464 goto bail;
465 }
466
467 bitmask = ares_getsock(chan_, socks, ARES_GETSOCK_MAXNUM);
468
469 if (bitmask == 0)
470 {
471 goto bail;
472 }
473
474 status = apr_pool_create(&pool, gAPRPoolp);
475 ll_apr_assert_status(status);
476
477 for (int i = 0; i < ARES_GETSOCK_MAXNUM; i++)
478 {
479 if (ARES_GETSOCK_READABLE(bitmask, i))
480 {
481 aprFds[nactive].reqevents = APR_POLLIN | APR_POLLERR;
482 }
483 else if (ARES_GETSOCK_WRITABLE(bitmask, i))
484 {
485 aprFds[nactive].reqevents = APR_POLLOUT | APR_POLLERR;
486 } else {
487 continue;
488 }
489
490 apr_socket_t *aprSock = NULL;
491
492 status = apr_os_sock_put(&aprSock, (apr_os_sock_t *) &socks[i], pool);
493 if (status != APR_SUCCESS)
494 {
495 ll_apr_warn_status(status);
496 goto bail_pool;
497 }
498
499 aprFds[nactive].desc.s = aprSock;
500 aprFds[nactive].desc_type = APR_POLL_SOCKET;
501 aprFds[nactive].p = pool;
502 aprFds[nactive].rtnevents = 0;
503 aprFds[nactive].client_data = &socks[i];
504
505 nactive++;
506 }
507
508 if (nactive > 0)
509 {
510 status = apr_poll(aprFds, nactive, &nsds, timeout);
511
512 if (status != APR_SUCCESS && status != APR_TIMEUP)
513 {
514 ll_apr_warn_status(status);
515 }
516
517 for (int i = 0; i < nactive; i++)
518 {
519 int evts = aprFds[i].rtnevents;
520 int ifd = (evts & (APR_POLLIN | APR_POLLERR))
521 ? *((int *) aprFds[i].client_data) : ARES_SOCKET_BAD;
522 int ofd = (evts & (APR_POLLOUT | APR_POLLERR))
523 ? *((int *) aprFds[i].client_data) : ARES_SOCKET_BAD;
524
525 ares_process_fd(chan_, ifd, ofd);
526 }
527 }
528
529bail_pool:
530 apr_pool_destroy(pool);
531
532bail:
533 return nsds > 0;
534}
535
536bool LLAres::processAll()
537{
538 if (!chan_)
539 {
540 return false;
541 }
542
543 bool anyProcessed = false, ret;
544
545 do {
546 timeval tv;
547
548 ret = ares_timeout(chan_, NULL, &tv) != NULL;
549
550 if (ret)
551 {
552 ret = process(tv.tv_sec * 1000000LL + tv.tv_usec);
553 anyProcessed |= ret;
554 }
555 } while (ret);
556
557 return anyProcessed;
558}
559
560int LLAres::expandName(const char *encoded, const char *abuf, size_t alen,
561 std::string &s, size_t &enclen)
562{
563 char *t;
564 int ret;
565 long e;
566
567 ret = ares_expand_name((const unsigned char *) encoded,
568 (const unsigned char *) abuf, alen, &t, &e);
569 if (ret == ARES_SUCCESS)
570 {
571 s.assign(t);
572 enclen = e;
573 ares_free_string(t);
574 }
575 return ret;
576}
577
578const char *LLAres::strerror(int code)
579{
580 return ares_strerror(code);
581}
582
583LLAres *gAres;
584
585LLAres *ll_init_ares()
586{
587 if (gAres == NULL)
588 {
589 gAres = new LLAres();
590 }
591 return gAres;
592}
593
594LLDnsRecord::LLDnsRecord(LLResType type, const std::string &name,
595 unsigned ttl)
596 : LLRefCount(),
597 mType(type),
598 mName(name),
599 mTTL(ttl)
600{
601}
602
603LLHostRecord::LLHostRecord(LLResType type, const std::string &name,
604 unsigned ttl)
605 : LLDnsRecord(type, name, ttl)
606{
607}
608
609int LLHostRecord::parse(const char *buf, size_t len, const char *pos,
610 size_t rrlen)
611{
612 int ret;
613
614 ret = LLAres::expandName(pos, buf, len, mHost);
615 if (ret != ARES_SUCCESS)
616 {
617 goto bail;
618 }
619
620 ret = ARES_SUCCESS;
621
622bail:
623 return ret;
624}
625
626LLCnameRecord::LLCnameRecord(const std::string &name, unsigned ttl)
627 : LLHostRecord(RES_CNAME, name, ttl)
628{
629}
630
631LLPtrRecord::LLPtrRecord(const std::string &name, unsigned ttl)
632 : LLHostRecord(RES_PTR, name, ttl)
633{
634}
635
636LLAddrRecord::LLAddrRecord(LLResType type, const std::string &name,
637 unsigned ttl)
638 : LLDnsRecord(type, name, ttl)
639{
640}
641
642LLARecord::LLARecord(const std::string &name, unsigned ttl)
643 : LLAddrRecord(RES_A, name, ttl)
644{
645}
646
647int LLARecord::parse(const char *buf, size_t len, const char *pos,
648 size_t rrlen)
649{
650 int ret;
651
652 if (rrlen != sizeof(mSA.sin.sin_addr.s_addr))
653 {
654 ret = ARES_EBADRESP;
655 goto bail;
656 }
657
658 memset(&mSA, 0, sizeof(mSA));
659 memcpy(&mSA.sin.sin_addr.s_addr, pos, rrlen);
660 mSA.sin.sin_family = AF_INET6;
661 mSize = sizeof(mSA.sin);
662
663 ret = ARES_SUCCESS;
664
665bail:
666 return ret;
667}
668
669LLAaaaRecord::LLAaaaRecord(const std::string &name, unsigned ttl)
670 : LLAddrRecord(RES_AAAA, name, ttl)
671{
672}
673
674int LLAaaaRecord::parse(const char *buf, size_t len, const char *pos,
675 size_t rrlen)
676{
677 int ret;
678
679 if (rrlen != sizeof(mSA.sin6.sin6_addr))
680 {
681 ret = ARES_EBADRESP;
682 goto bail;
683 }
684
685 memset(&mSA, 0, sizeof(mSA));
686 memcpy(&mSA.sin6.sin6_addr.s6_addr, pos, rrlen);
687 mSA.sin6.sin6_family = AF_INET6;
688 mSize = sizeof(mSA.sin6);
689
690 ret = ARES_SUCCESS;
691
692bail:
693 return ret;
694}
695
696LLSrvRecord::LLSrvRecord(const std::string &name, unsigned ttl)
697 : LLHostRecord(RES_SRV, name, ttl)
698{
699}
700
701int LLSrvRecord::parse(const char *buf, size_t len, const char *pos,
702 size_t rrlen)
703{
704 int ret;
705
706 if (rrlen < 6)
707 {
708 ret = ARES_EBADRESP;
709 goto bail;
710 }
711
712 memcpy(&mPriority, pos, 2);
713 memcpy(&mWeight, pos + 2, 2);
714 memcpy(&mPort, pos + 4, 2);
715
716 mPriority = ntohs(mPriority);
717 mWeight = ntohs(mWeight);
718 mPort = ntohs(mPort);
719
720 ret = LLHostRecord::parse(buf, len, pos + 6, rrlen - 6);
721
722bail:
723 return ret;
724}
725
726LLNsRecord::LLNsRecord(const std::string &name, unsigned ttl)
727 : LLHostRecord(RES_NS, name, ttl)
728{
729}
730
731void LLAres::UriRewriteResponder::queryError(int code)
732{
733 std::vector<std::string> uris;
734 uris.push_back(mUri.asString());
735 rewriteResult(uris);
736}
737
738void LLAres::UriRewriteResponder::queryResult()
739{
740 std::vector<std::string> uris;
741
742 if (mType != RES_SRV)
743 {
744 goto bail;
745 }
746
747 for (size_t i = 0; i < mAnswers.size(); i++)
748 {
749 const LLSrvRecord *r = (const LLSrvRecord *) mAnswers[i].get();
750
751 if (r->type() == RES_SRV)
752 {
753 // Check the domain in the response to ensure that it's
754 // the same as the domain in the request, so that bad guys
755 // can't forge responses that point to their own login
756 // servers with their own certificates.
757
758 // Hard-coding the domain to check here is a bit of a
759 // hack. Hoist it to an outer caller if anyone ever needs
760 // this functionality on other domains.
761
762 static const std::string domain(".lindenlab.com");
763 const std::string &host = r->host();
764
765 std::string::size_type s = host.find(domain) + domain.length();
766
767 if (s != host.length() && s != host.length() - 1)
768 {
769 continue;
770 }
771
772 LLURI uri(mUri.scheme(),
773 mUri.userName(),
774 mUri.password(),
775 r->host(),
776 mUri.defaultPort() ? r->port() : mUri.hostPort(),
777 mUri.escapedPath(),
778 mUri.escapedQuery());
779 uris.push_back(uri.asString());
780 }
781 }
782
783 if (!uris.empty())
784 {
785 goto done;
786 }
787
788bail:
789 uris.push_back(mUri.asString());
790
791done:
792 rewriteResult(uris);
793}
794
795void LLAres::UriRewriteResponder::rewriteResult(
796 const std::vector<std::string> &uris)
797{
798 llinfos << "LLAres::UriRewriteResponder::rewriteResult not implemented"
799 << llendl;
800
801 for (size_t i = 0; i < uris.size(); i++)
802 {
803 llinfos << "[" << i << "] " << uris[i] << llendl;
804 }
805}
diff --git a/linden/indra/llcommon/llares.h b/linden/indra/llcommon/llares.h
deleted file mode 100644
index 07957f1..0000000
--- a/linden/indra/llcommon/llares.h
+++ /dev/null
@@ -1,572 +0,0 @@
1/**
2 * @file llares.h
3 * @author Bryan O'Sullivan
4 * @date 2007-08-15
5 * @brief Wrapper for asynchronous DNS lookups.
6 *
7 * $LicenseInfo:firstyear=2007&license=viewergpl$
8 *
9 * Copyright (c) 2007-2008, Linden Research, Inc.
10 *
11 * Second Life Viewer Source Code
12 * The source code in this file ("Source Code") is provided by Linden Lab
13 * to you under the terms of the GNU General Public License, version 2.0
14 * ("GPL"), unless you have obtained a separate licensing agreement
15 * ("Other License"), formally executed by you and Linden Lab. Terms of
16 * the GPL can be found in doc/GPL-license.txt in this distribution, or
17 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
18 *
19 * There are special exceptions to the terms and conditions of the GPL as
20 * it is applied to this Source Code. View the full text of the exception
21 * in the file doc/FLOSS-exception.txt in this software distribution, or
22 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
23 *
24 * By copying, modifying or distributing this software, you acknowledge
25 * that you have read and understood your obligations described above,
26 * and agree to abide by those obligations.
27 *
28 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
29 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
30 * COMPLETENESS OR PERFORMANCE.
31 * $/LicenseInfo$
32 */
33
34#ifndef LL_LLARES_H
35#define LL_LLARES_H
36
37#ifdef LL_WINDOWS
38# include <ws2tcpip.h>
39#endif
40
41#ifdef LL_STANDALONE
42# include <ares.h>
43#else
44# include <ares/ares.h>
45#endif
46
47#include "llmemory.h"
48#include "lluri.h"
49
50class LLQueryResponder;
51
52/**
53 * @brief Supported DNS RR types.
54 */
55enum LLResType
56{
57 RES_INVALID = 0, /**< Cookie. */
58 RES_A = 1, /**< "A" record. IPv4 address. */
59 RES_NS = 2, /**< "NS" record. Authoritative server. */
60 RES_CNAME = 5, /**< "CNAME" record. Canonical name. */
61 RES_PTR = 12, /**< "PTR" record. Domain name pointer. */
62 RES_AAAA = 28, /**< "AAAA" record. IPv6 Address. */
63 RES_SRV = 33, /**< "SRV" record. Server Selection. */
64 RES_MAX = 65536 /**< Sentinel; RR types are 16 bits wide. */
65};
66
67/**
68 * @class LLDnsRecord
69 * @brief Base class for all DNS RR types.
70 */
71class LLDnsRecord : public LLRefCount
72{
73protected:
74 friend class LLQueryResponder;
75
76 LLResType mType;
77 std::string mName;
78 unsigned mTTL;
79
80 virtual int parse(const char *buf, size_t len, const char *pos,
81 size_t rrlen) = 0;
82
83 LLDnsRecord(LLResType type, const std::string &name, unsigned ttl);
84
85public:
86 /**
87 * @brief Record name.
88 */
89 const std::string &name() const { return mName; }
90
91 /**
92 * @brief Time-to-live value, in seconds.
93 */
94 unsigned ttl() const { return mTTL; }
95
96 /**
97 * @brief RR type.
98 */
99 LLResType type() const { return mType; }
100};
101
102/**
103 * @class LLAddrRecord
104 * @brief Base class for address-related RRs.
105 */
106class LLAddrRecord : public LLDnsRecord
107{
108protected:
109 friend class LLQueryResponder;
110
111 LLAddrRecord(LLResType type, const std::string &name, unsigned ttl);
112
113 union
114 {
115 sockaddr sa;
116 sockaddr_in sin;
117 sockaddr_in6 sin6;
118 } mSA;
119
120 socklen_t mSize;
121
122public:
123 /**
124 * @brief Generic socket address.
125 */
126 const sockaddr &addr() const { return mSA.sa; }
127
128 /**
129 * @brief Size of the socket structure.
130 */
131 socklen_t size() const { return mSize; }
132};
133
134/**
135 * @class LLARecord
136 * @brief A RR, for IPv4 addresses.
137 */
138class LLARecord : public LLAddrRecord
139{
140protected:
141 friend class LLQueryResponder;
142
143 LLARecord(const std::string &name, unsigned ttl);
144
145 int parse(const char *buf, size_t len, const char *pos, size_t rrlen);
146
147public:
148 /**
149 * @brief Socket address.
150 */
151 const sockaddr_in &addr_in() const { return mSA.sin; }
152};
153
154/**
155 * @class LLAaaaRecord
156 * @brief AAAA RR, for IPv6 addresses.
157 */
158class LLAaaaRecord : public LLAddrRecord
159{
160protected:
161 friend class LLQueryResponder;
162
163 LLAaaaRecord(const std::string &name, unsigned ttl);
164
165 int parse(const char *buf, size_t len, const char *pos, size_t rrlen);
166
167public:
168 /**
169 * @brief Socket address.
170 */
171 const sockaddr_in6 &addr_in6() const { return mSA.sin6; }
172};
173
174/**
175 * @class LLHostRecord
176 * @brief Base class for host-related RRs.
177 */
178class LLHostRecord : public LLDnsRecord
179{
180protected:
181 LLHostRecord(LLResType type, const std::string &name, unsigned ttl);
182
183 int parse(const char *buf, size_t len, const char *pos, size_t rrlen);
184
185 std::string mHost;
186
187public:
188 /**
189 * @brief Host name.
190 */
191 const std::string &host() const { return mHost; }
192};
193
194/**
195 * @class LLCnameRecord
196 * @brief CNAME RR.
197 */
198class LLCnameRecord : public LLHostRecord
199{
200protected:
201 friend class LLQueryResponder;
202
203 LLCnameRecord(const std::string &name, unsigned ttl);
204};
205
206/**
207 * @class LLPtrRecord
208 * @brief PTR RR.
209 */
210class LLPtrRecord : public LLHostRecord
211{
212protected:
213 friend class LLQueryResponder;
214
215 LLPtrRecord(const std::string &name, unsigned ttl);
216};
217
218/**
219 * @class LLSrvRecord
220 * @brief SRV RR.
221 */
222class LLSrvRecord : public LLHostRecord
223{
224protected:
225 U16 mPriority;
226 U16 mWeight;
227 U16 mPort;
228
229 int parse(const char *buf, size_t len, const char *pos, size_t rrlen);
230
231public:
232 LLSrvRecord(const std::string &name, unsigned ttl);
233
234 /**
235 * @brief Service priority.
236 */
237 U16 priority() const { return mPriority; }
238
239 /**
240 * @brief Service weight.
241 */
242 U16 weight() const { return mWeight; }
243
244 /**
245 * @brief Port number of service.
246 */
247 U16 port() const { return mPort; }
248
249 /**
250 * @brief Functor for sorting SRV records by priority.
251 */
252 struct ComparePriorityLowest
253 {
254 bool operator()(const LLSrvRecord& lhs, const LLSrvRecord& rhs)
255 {
256 return lhs.mPriority < rhs.mPriority;
257 }
258 };
259};
260
261/**
262 * @class LLNsRecord
263 * @brief NS RR.
264 */
265class LLNsRecord : public LLHostRecord
266{
267public:
268 LLNsRecord(const std::string &name, unsigned ttl);
269};
270
271class LLQueryResponder;
272
273/**
274 * @class LLAres
275 * @brief Asynchronous address resolver.
276 */
277class LLAres
278{
279public:
280 /**
281 * @class HostResponder
282 * @brief Base class for responding to hostname lookups.
283 * @see LLAres::getHostByName
284 */
285 class HostResponder : public LLRefCount
286 {
287 public:
288 virtual ~HostResponder();
289
290 virtual void hostResult(const hostent *ent);
291 virtual void hostError(int code);
292 };
293
294 /**
295 * @class NameInfoResponder
296 * @brief Base class for responding to address lookups.
297 * @see LLAres::getNameInfo
298 */
299 class NameInfoResponder : public LLRefCount
300 {
301 public:
302 virtual ~NameInfoResponder();
303
304 virtual void nameInfoResult(const char *node, const char *service);
305 virtual void nameInfoError(int code);
306 };
307
308 /**
309 * @class QueryResponder
310 * @brief Base class for responding to custom searches.
311 * @see LLAres::search
312 */
313 class QueryResponder : public LLRefCount
314 {
315 public:
316 virtual ~QueryResponder();
317
318 virtual void queryResult(const char *buf, size_t len);
319 virtual void queryError(int code);
320 };
321
322 class SrvResponder;
323 class UriRewriteResponder;
324
325 LLAres();
326
327 ~LLAres();
328
329 /**
330 * Cancel all outstanding requests. The error methods of the
331 * corresponding responders will be called, with ARES_ETIMEOUT.
332 */
333 void cancel();
334
335 /**
336 * Look up the address of a host.
337 *
338 * @param name name of host to look up
339 * @param resp responder to call with result
340 * @param family AF_INET for IPv4 addresses, AF_INET6 for IPv6
341 */
342 void getHostByName(const std::string &name, HostResponder *resp,
343 int family = AF_INET) {
344 getHostByName(name.c_str(), resp, family);
345 }
346
347 /**
348 * Look up the address of a host.
349 *
350 * @param name name of host to look up
351 * @param resp responder to call with result
352 * @param family AF_INET for IPv4 addresses, AF_INET6 for IPv6
353 */
354 void getHostByName(const char *name, HostResponder *resp,
355 int family = PF_INET);
356
357 /**
358 * Look up the name associated with a socket address.
359 *
360 * @param sa socket address to look up
361 * @param salen size of socket address
362 * @param flags flags to use
363 * @param resp responder to call with result
364 */
365 void getNameInfo(const struct sockaddr &sa, socklen_t salen, int flags,
366 NameInfoResponder *resp);
367
368 /**
369 * Look up SRV (service location) records for a service name.
370 *
371 * @param name service name (e.g. "_https._tcp.login.agni.lindenlab.com")
372 * @param resp responder to call with result
373 */
374 void getSrvRecords(const std::string &name, SrvResponder *resp);
375
376 /**
377 * Rewrite a URI, using SRV (service location) records for its
378 * protocol if available. If no SRV records are published, the
379 * existing URI is handed to the responder.
380 *
381 * @param uri URI to rewrite
382 * @param resp responder to call with result
383 */
384 void rewriteURI(const std::string &uri,
385 UriRewriteResponder *resp);
386
387 /**
388 * Start a custom search.
389 *
390 * @param query query to make
391 * @param type type of query to perform
392 * @param resp responder to call with result
393 */
394 void search(const std::string &query, LLResType type,
395 QueryResponder *resp);
396
397 /**
398 * Process any outstanding queries. This method takes an optional
399 * timeout parameter (specified in microseconds). If provided, it
400 * will block the calling thread for that length of time to await
401 * possible responses. A timeout of zero will return immediately
402 * if there are no responses or timeouts to process.
403 *
404 * @param timeoutUsecs number of microseconds to block before timing out
405 * @return whether any responses were processed
406 */
407 bool process(U64 timeoutUsecs = 0);
408
409 /**
410 * Process all outstanding queries, blocking the calling thread
411 * until all have either been responded to or timed out.
412 *
413 * @return whether any responses were processed
414 */
415 bool processAll();
416
417 /**
418 * Expand a DNS-encoded compressed string into a normal string.
419 *
420 * @param encoded the encoded name (null-terminated)
421 * @param abuf the response buffer in which the string is embedded
422 * @param alen the length of the response buffer
423 * @param s the string into which to place the result
424 * @return ARES_SUCCESS on success, otherwise an error indicator
425 */
426 static int expandName(const char *encoded, const char *abuf, size_t alen,
427 std::string &s) {
428 size_t ignore;
429 return expandName(encoded, abuf, alen, s, ignore);
430 }
431
432 static int expandName(const char *encoded, const char *abuf, size_t alen,
433 std::string &s, size_t &enclen);
434
435 /**
436 * Return a string describing an error code.
437 */
438 static const char *strerror(int code);
439
440protected:
441 ares_channel chan_;
442
443};
444
445/**
446 * An ordered collection of DNS resource records.
447 */
448typedef std::vector<LLPointer<LLDnsRecord> > dns_rrs_t;
449
450/**
451 * @class LLQueryResponder
452 * @brief Base class for friendly handling of DNS query responses.
453 *
454 * This class parses a DNS response and represents it in a friendly
455 * manner.
456 *
457 * @see LLDnsRecord
458 * @see LLARecord
459 * @see LLNsRecord
460 * @see LLCnameRecord
461 * @see LLPtrRecord
462 * @see LLAaaaRecord
463 * @see LLSrvRecord
464 */
465class LLQueryResponder : public LLAres::QueryResponder
466{
467protected:
468 int mResult;
469 std::string mQuery;
470 LLResType mType;
471
472 dns_rrs_t mAnswers;
473 dns_rrs_t mAuthorities;
474 dns_rrs_t mAdditional;
475
476 /**
477 * Parse a single RR.
478 */
479 int parseRR(const char *buf, size_t len, const char *&pos,
480 LLPointer<LLDnsRecord> &r);
481 /**
482 * Parse one section of a response.
483 */
484 int parseSection(const char *buf, size_t len,
485 size_t count, const char *& pos, dns_rrs_t &rrs);
486
487 void queryResult(const char *buf, size_t len);
488 virtual void queryResult();
489
490public:
491 LLQueryResponder();
492
493 /**
494 * Indicate whether the response could be parsed successfully.
495 */
496 bool valid() const { return mResult == ARES_SUCCESS; }
497
498 /**
499 * The more detailed result of parsing the response.
500 */
501 int result() const { return mResult; }
502
503 /**
504 * Return the query embedded in the response.
505 */
506 const std::string &query() const { return mQuery; }
507
508 /**
509 * Return the contents of the "answers" section of the response.
510 */
511 const dns_rrs_t &answers() const { return mAnswers; }
512
513 /**
514 * Return the contents of the "authorities" section of the
515 * response.
516 */
517 const dns_rrs_t &authorities() const { return mAuthorities; }
518
519 /**
520 * Return the contents of the "additional records" section of the
521 * response.
522 */
523 const dns_rrs_t &additional() const { return mAdditional; }
524};
525
526/**
527 * @class LLAres::SrvResponder
528 * @brief Class for handling SRV query responses.
529 */
530class LLAres::SrvResponder : public LLQueryResponder
531{
532public:
533 friend void LLAres::getSrvRecords(const std::string &name,
534 SrvResponder *resp);
535 void queryResult();
536 void queryError(int code);
537
538 virtual void srvResult(const dns_rrs_t &ents);
539 virtual void srvError(int code);
540};
541
542/**
543 * @class LLAres::UriRewriteResponder
544 * @brief Class for handling URI rewrites based on SRV records.
545 */
546class LLAres::UriRewriteResponder : public LLQueryResponder
547{
548protected:
549 LLURI mUri;
550
551public:
552 friend void LLAres::rewriteURI(const std::string &uri,
553 UriRewriteResponder *resp);
554 void queryResult();
555 void queryError(int code);
556
557 virtual void rewriteResult(const std::vector<std::string> &uris);
558};
559
560/**
561 * Singleton responder.
562 */
563extern LLAres *gAres;
564
565/**
566 * Set up the singleton responder. It's safe to call this more than
567 * once from within a single thread, but this function is not
568 * thread safe.
569 */
570extern LLAres *ll_init_ares();
571
572#endif // LL_LLARES_H
diff --git a/linden/indra/llcommon/llassettype.cpp b/linden/indra/llcommon/llassettype.cpp
index 4b2a862..27b8310 100644
--- a/linden/indra/llcommon/llassettype.cpp
+++ b/linden/indra/llcommon/llassettype.cpp
@@ -75,7 +75,7 @@ asset_info_t asset_types[] =
75LLAssetType::EType LLAssetType::getType(const std::string& sin) 75LLAssetType::EType LLAssetType::getType(const std::string& sin)
76{ 76{
77 std::string s = sin; 77 std::string s = sin;
78 LLString::toUpper(s); 78 LLStringUtil::toUpper(s);
79 for (S32 idx = 0; ;idx++) 79 for (S32 idx = 0; ;idx++)
80 { 80 {
81 asset_info_t* info = asset_types + idx; 81 asset_info_t* info = asset_types + idx;
@@ -128,7 +128,7 @@ const char* LLAssetType::mAssetTypeNames[LLAssetType::AT_COUNT] =
128 "jpeg", 128 "jpeg",
129 "animatn", 129 "animatn",
130 "gesture", 130 "gesture",
131 "simstate", 131 "simstate"
132}; 132};
133 133
134// This table is meant for decoding to human readable form. Put any 134// This table is meant for decoding to human readable form. Put any
@@ -158,7 +158,7 @@ const char* LLAssetType::mAssetTypeHumanNames[LLAssetType::AT_COUNT] =
158 "jpeg image", 158 "jpeg image",
159 "animation", 159 "animation",
160 "gesture", 160 "gesture",
161 "simstate", 161 "simstate"
162}; 162};
163 163
164///---------------------------------------------------------------------------- 164///----------------------------------------------------------------------------
@@ -181,9 +181,14 @@ const char* LLAssetType::lookup( LLAssetType::EType type )
181// static 181// static
182LLAssetType::EType LLAssetType::lookup( const char* name ) 182LLAssetType::EType LLAssetType::lookup( const char* name )
183{ 183{
184 return lookup(ll_safe_string(name));
185}
186
187LLAssetType::EType LLAssetType::lookup( const std::string& name )
188{
184 for( S32 i = 0; i < AT_COUNT; i++ ) 189 for( S32 i = 0; i < AT_COUNT; i++ )
185 { 190 {
186 if( 0 == strcmp(name, mAssetTypeNames[i]) ) 191 if( name == mAssetTypeNames[i] )
187 { 192 {
188 // match 193 // match
189 return (EType)i; 194 return (EType)i;
@@ -208,9 +213,14 @@ const char* LLAssetType::lookupHumanReadable(LLAssetType::EType type)
208// static 213// static
209LLAssetType::EType LLAssetType::lookupHumanReadable( const char* name ) 214LLAssetType::EType LLAssetType::lookupHumanReadable( const char* name )
210{ 215{
216 return lookupHumanReadable(ll_safe_string(name));
217}
218
219LLAssetType::EType LLAssetType::lookupHumanReadable( const std::string& name )
220{
211 for( S32 i = 0; i < AT_COUNT; i++ ) 221 for( S32 i = 0; i < AT_COUNT; i++ )
212 { 222 {
213 if( 0 == strcmp(name, mAssetTypeHumanNames[i]) ) 223 if( name == mAssetTypeHumanNames[i] )
214 { 224 {
215 // match 225 // match
216 return (EType)i; 226 return (EType)i;
diff --git a/linden/indra/llcommon/llassettype.h b/linden/indra/llcommon/llassettype.h
index f5ef05b..f976df4 100644
--- a/linden/indra/llcommon/llassettype.h
+++ b/linden/indra/llcommon/llassettype.h
@@ -145,11 +145,13 @@ public:
145 }; 145 };
146 146
147 // machine transation between type and strings 147 // machine transation between type and strings
148 static EType lookup(const char* name); 148 static EType lookup(const char* name); // safe conversion to std::string, *TODO: deprecate
149 static EType lookup(const std::string& name);
149 static const char* lookup(EType type); 150 static const char* lookup(EType type);
150 151
151 // translation from a type to a human readable form. 152 // translation from a type to a human readable form.
152 static EType lookupHumanReadable( const char* name ); 153 static EType lookupHumanReadable( const char* name ); // safe conversion to std::string, *TODO: deprecate
154 static EType lookupHumanReadable( const std::string& name );
153 static const char* lookupHumanReadable(EType type); 155 static const char* lookupHumanReadable(EType type);
154 156
155 static EDragAndDropType lookupDragAndDropType( EType ); 157 static EDragAndDropType lookupDragAndDropType( EType );
diff --git a/linden/indra/llcommon/llbase64.cpp b/linden/indra/llcommon/llbase64.cpp
index 950ce6e..c2421d8 100644
--- a/linden/indra/llcommon/llbase64.cpp
+++ b/linden/indra/llcommon/llbase64.cpp
@@ -36,7 +36,7 @@
36 36
37#include <string> 37#include <string>
38 38
39#include "apr-1/apr_base64.h" 39#include "apr_base64.h"
40 40
41 41
42// static 42// static
diff --git a/linden/indra/llcommon/llchat.h b/linden/indra/llcommon/llchat.h
index a46b8aa..ea1a579 100644
--- a/linden/indra/llcommon/llchat.h
+++ b/linden/indra/llcommon/llchat.h
@@ -68,7 +68,7 @@ typedef enum e_chat_audible_level
68class LLChat 68class LLChat
69{ 69{
70public: 70public:
71 LLChat(const LLString& text = LLString::null) 71 LLChat(const std::string& text = LLStringUtil::null)
72 : mText(text), 72 : mText(text),
73 mFromName(), 73 mFromName(),
74 mFromID(), 74 mFromID(),
@@ -80,8 +80,8 @@ public:
80 mPosAgent() 80 mPosAgent()
81 { } 81 { }
82 82
83 LLString mText; // UTF-8 line of text 83 std::string mText; // UTF-8 line of text
84 LLString mFromName; // agent or object name 84 std::string mFromName; // agent or object name
85 LLUUID mFromID; // agent id or object id 85 LLUUID mFromID; // agent id or object id
86 EChatSourceType mSourceType; 86 EChatSourceType mSourceType;
87 EChatType mChatType; 87 EChatType mChatType;
diff --git a/linden/indra/llcommon/llcommon.vcproj b/linden/indra/llcommon/llcommon.vcproj
deleted file mode 100644
index f54ea13..0000000
--- a/linden/indra/llcommon/llcommon.vcproj
+++ /dev/null
@@ -1,608 +0,0 @@
1<?xml version="1.0" encoding="Windows-1252"?>
2<VisualStudioProject
3 ProjectType="Visual C++"
4 Version="7.10"
5 Name="llcommon"
6 ProjectGUID="{7BCB4B2C-8378-4186-88EA-5742B5ABE17F}"
7 RootNamespace="llcommon"
8 Keyword="Win32Proj">
9 <Platforms>
10 <Platform
11 Name="Win32"/>
12 </Platforms>
13 <Configurations>
14 <Configuration
15 Name="Debug|Win32"
16 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
17 IntermediateDirectory="$(ConfigurationName)"
18 ConfigurationType="4"
19 CharacterSet="1">
20 <Tool
21 Name="VCCLCompilerTool"
22 Optimization="0"
23 AdditionalIncludeDirectories="..\..\libraries\i686-win32\include;..\..\libraries\include\"
24 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;LL_DEBUG;XML_STATIC;APR_DECLARE_STATIC"
25 MinimalRebuild="TRUE"
26 BasicRuntimeChecks="3"
27 RuntimeLibrary="1"
28 StructMemberAlignment="4"
29 ForceConformanceInForLoopScope="TRUE"
30 UsePrecompiledHeader="0"
31 WarningLevel="3"
32 WarnAsError="TRUE"
33 Detect64BitPortabilityProblems="FALSE"
34 DebugInformationFormat="4"/>
35 <Tool
36 Name="VCCustomBuildTool"/>
37 <Tool
38 Name="VCLibrarianTool"
39 OutputFile="$(OutDir)/llcommon.lib"/>
40 <Tool
41 Name="VCMIDLTool"/>
42 <Tool
43 Name="VCPostBuildEventTool"/>
44 <Tool
45 Name="VCPreBuildEventTool"/>
46 <Tool
47 Name="VCPreLinkEventTool"/>
48 <Tool
49 Name="VCResourceCompilerTool"/>
50 <Tool
51 Name="VCWebServiceProxyGeneratorTool"/>
52 <Tool
53 Name="VCXMLDataGeneratorTool"/>
54 <Tool
55 Name="VCManagedWrapperGeneratorTool"/>
56 <Tool
57 Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
58 </Configuration>
59 <Configuration
60 Name="Release|Win32"
61 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
62 IntermediateDirectory="$(ConfigurationName)"
63 ConfigurationType="4"
64 CharacterSet="1">
65 <Tool
66 Name="VCCLCompilerTool"
67 AdditionalOptions="/Oy-"
68 GlobalOptimizations="TRUE"
69 InlineFunctionExpansion="2"
70 EnableIntrinsicFunctions="TRUE"
71 OptimizeForProcessor="3"
72 OptimizeForWindowsApplication="TRUE"
73 AdditionalIncludeDirectories="..\..\libraries\i686-win32\include;..\..\libraries\include\"
74 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;LL_RELEASE;XML_STATIC;APR_DECLARE_STATIC"
75 RuntimeLibrary="0"
76 StructMemberAlignment="0"
77 ForceConformanceInForLoopScope="TRUE"
78 UsePrecompiledHeader="0"
79 WarningLevel="3"
80 WarnAsError="TRUE"
81 Detect64BitPortabilityProblems="FALSE"
82 DebugInformationFormat="3"/>
83 <Tool
84 Name="VCCustomBuildTool"/>
85 <Tool
86 Name="VCLibrarianTool"
87 OutputFile="$(OutDir)/llcommon.lib"/>
88 <Tool
89 Name="VCMIDLTool"/>
90 <Tool
91 Name="VCPostBuildEventTool"/>
92 <Tool
93 Name="VCPreBuildEventTool"/>
94 <Tool
95 Name="VCPreLinkEventTool"/>
96 <Tool
97 Name="VCResourceCompilerTool"/>
98 <Tool
99 Name="VCWebServiceProxyGeneratorTool"/>
100 <Tool
101 Name="VCXMLDataGeneratorTool"/>
102 <Tool
103 Name="VCManagedWrapperGeneratorTool"/>
104 <Tool
105 Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
106 </Configuration>
107 <Configuration
108 Name="ReleaseNoOpt|Win32"
109 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
110 IntermediateDirectory="$(ConfigurationName)"
111 ConfigurationType="4"
112 CharacterSet="1">
113 <Tool
114 Name="VCCLCompilerTool"
115 AdditionalOptions="/Oy-"
116 Optimization="0"
117 AdditionalIncludeDirectories="..\..\libraries\i686-win32\include;..\..\libraries\include\"
118 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;LL_RELEASE;XML_STATIC;APR_DECLARE_STATIC"
119 RuntimeLibrary="0"
120 StructMemberAlignment="0"
121 ForceConformanceInForLoopScope="TRUE"
122 UsePrecompiledHeader="0"
123 WarningLevel="3"
124 WarnAsError="TRUE"
125 Detect64BitPortabilityProblems="FALSE"
126 DebugInformationFormat="3"/>
127 <Tool
128 Name="VCCustomBuildTool"/>
129 <Tool
130 Name="VCLibrarianTool"
131 OutputFile="$(OutDir)/llcommon.lib"/>
132 <Tool
133 Name="VCMIDLTool"/>
134 <Tool
135 Name="VCPostBuildEventTool"/>
136 <Tool
137 Name="VCPreBuildEventTool"/>
138 <Tool
139 Name="VCPreLinkEventTool"/>
140 <Tool
141 Name="VCResourceCompilerTool"/>
142 <Tool
143 Name="VCWebServiceProxyGeneratorTool"/>
144 <Tool
145 Name="VCXMLDataGeneratorTool"/>
146 <Tool
147 Name="VCManagedWrapperGeneratorTool"/>
148 <Tool
149 Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
150 </Configuration>
151 </Configurations>
152 <References>
153 </References>
154 <Files>
155 <Filter
156 Name="Source Files"
157 Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
158 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
159 <File
160 RelativePath=".\llapp.cpp">
161 </File>
162 <File
163 RelativePath=".\llapr.cpp">
164 </File>
165 <File
166 RelativePath=".\llares.cpp">
167 </File>
168 <File
169 RelativePath=".\llassettype.cpp">
170 </File>
171 <File
172 RelativePath=".\llbase32.cpp">
173 </File>
174 <File
175 RelativePath=".\llbase64.cpp">
176 </File>
177 <File
178 RelativePath=".\llcommon.cpp">
179 </File>
180 <File
181 RelativePath=".\llcriticaldamp.cpp">
182 </File>
183 <File
184 RelativePath=".\lldate.cpp">
185 </File>
186 <File
187 RelativePath=".\llerror.cpp">
188 </File>
189 <File
190 RelativePath=".\llerrorthread.cpp">
191 </File>
192 <File
193 RelativePath=".\llevent.cpp">
194 </File>
195 <File
196 RelativePath=".\llfasttimer.cpp">
197 </File>
198 <File
199 RelativePath=".\llfile.cpp">
200 </File>
201 <File
202 RelativePath=".\llfindlocale.cpp">
203 </File>
204 <File
205 RelativePath=".\llfixedbuffer.cpp">
206 </File>
207 <File
208 RelativePath=".\llformat.cpp">
209 </File>
210 <File
211 RelativePath=".\llframetimer.cpp">
212 </File>
213 <File
214 RelativePath=".\llheartbeat.cpp">
215 </File>
216 <File
217 RelativePath=".\llindraconfigfile.cpp">
218 </File>
219 <File
220 RelativePath=".\llliveappconfig.cpp">
221 </File>
222 <File
223 RelativePath=".\lllivefile.cpp">
224 </File>
225 <File
226 RelativePath=".\lllog.cpp">
227 </File>
228 <File
229 RelativePath=".\llmemory.cpp">
230 </File>
231 <File
232 RelativePath=".\llmemorystream.cpp">
233 </File>
234 <File
235 RelativePath=".\llmetrics.cpp">
236 </File>
237 <File
238 RelativePath=".\llmortician.cpp">
239 </File>
240 <File
241 RelativePath=".\llprocessor.cpp">
242 </File>
243 <File
244 RelativePath=".\llqueuedthread.cpp">
245 </File>
246 <File
247 RelativePath=".\llrun.cpp">
248 </File>
249 <File
250 RelativePath=".\llsd.cpp">
251 </File>
252 <File
253 RelativePath=".\llsdserialize.cpp">
254 </File>
255 <File
256 RelativePath=".\llsdserialize_xml.cpp">
257 </File>
258 <File
259 RelativePath=".\llsdutil.cpp">
260 </File>
261 <File
262 RelativePath=".\llsecondlifeurls.cpp">
263 </File>
264 <File
265 RelativePath=".\llstat.cpp">
266 </File>
267 <File
268 RelativePath=".\llstreamtools.cpp">
269 </File>
270 <File
271 RelativePath=".\llstring.cpp">
272 </File>
273 <File
274 RelativePath=".\llstringtable.cpp">
275 </File>
276 <File
277 RelativePath=".\llsys.cpp">
278 </File>
279 <File
280 RelativePath=".\llthread.cpp">
281 </File>
282 <File
283 RelativePath=".\lltimer.cpp">
284 </File>
285 <File
286 RelativePath=".\lluri.cpp">
287 </File>
288 <File
289 RelativePath=".\llworkerthread.cpp">
290 </File>
291 <File
292 RelativePath=".\metaclass.cpp">
293 </File>
294 <File
295 RelativePath=".\metaproperty.cpp">
296 </File>
297 <File
298 RelativePath=".\reflective.cpp">
299 </File>
300 <File
301 RelativePath=".\timing.cpp">
302 </File>
303 <File
304 RelativePath=".\u64.cpp">
305 </File>
306 </Filter>
307 <Filter
308 Name="Header Files"
309 Filter="h;hpp;hxx;hm;inl;inc;xsd"
310 UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
311 <File
312 RelativePath=".\bitpack.h">
313 </File>
314 <File
315 RelativePath=".\doublelinkedlist.h">
316 </File>
317 <File
318 RelativePath=".\imageids.h">
319 </File>
320 <File
321 RelativePath=".\indra_constants.h">
322 </File>
323 <File
324 RelativePath=".\linden_common.h">
325 </File>
326 <File
327 RelativePath=".\linked_lists.h">
328 </File>
329 <File
330 RelativePath=".\llagentconstants.h">
331 </File>
332 <File
333 RelativePath=".\llapp.h">
334 </File>
335 <File
336 RelativePath=".\llapr.h">
337 </File>
338 <File
339 RelativePath=".\llassettype.h">
340 </File>
341 <File
342 RelativePath=".\llassoclist.h">
343 </File>
344 <File
345 RelativePath=".\llavatarconstants.h">
346 </File>
347 <File
348 RelativePath=".\llbase32.h">
349 </File>
350 <File
351 RelativePath=".\llbase64.h">
352 </File>
353 <File
354 RelativePath=".\llboost.h">
355 </File>
356 <File
357 RelativePath=".\llchat.h">
358 </File>
359 <File
360 RelativePath=".\llclickaction.h">
361 </File>
362 <File
363 RelativePath=".\llcommon.h">
364 </File>
365 <File
366 RelativePath=".\llcriticaldamp.h">
367 </File>
368 <File
369 RelativePath=".\lldarray.h">
370 </File>
371 <File
372 RelativePath=".\lldarrayptr.h">
373 </File>
374 <File
375 RelativePath=".\lldate.h">
376 </File>
377 <File
378 RelativePath=".\lldefs.h">
379 </File>
380 <File
381 RelativePath=".\lldlinked.h">
382 </File>
383 <File
384 RelativePath=".\lldqueueptr.h">
385 </File>
386 <File
387 RelativePath=".\llendianswizzle.h">
388 </File>
389 <File
390 RelativePath=".\llenum.h">
391 </File>
392 <File
393 RelativePath=".\llerror.h">
394 </File>
395 <File
396 RelativePath=".\llerrorcontrol.h">
397 </File>
398 <File
399 RelativePath=".\llerrorthread.h">
400 </File>
401 <File
402 RelativePath=".\llevent.h">
403 </File>
404 <File
405 RelativePath=".\llextendedstatus.h">
406 </File>
407 <File
408 RelativePath=".\llfasttimer.h">
409 </File>
410 <File
411 RelativePath=".\llfile.h">
412 </File>
413 <File
414 RelativePath=".\llfixedbuffer.h">
415 </File>
416 <File
417 RelativePath=".\llformat.h">
418 </File>
419 <File
420 RelativePath=".\llframecallbackmanager.h">
421 </File>
422 <File
423 RelativePath=".\llframetimer.h">
424 </File>
425 <File
426 RelativePath=".\llhash.h">
427 </File>
428 <File
429 RelativePath=".\llheartbeat.h">
430 </File>
431 <File
432 RelativePath=".\llindexedqueue.h">
433 </File>
434 <File
435 RelativePath=".\llkeythrottle.h">
436 </File>
437 <File
438 RelativePath=".\llkeyusetracker.h">
439 </File>
440 <File
441 RelativePath=".\lllinkedqueue.h">
442 </File>
443 <File
444 RelativePath=".\llliveappconfig.h">
445 </File>
446 <File
447 RelativePath=".\lllivefile.h">
448 </File>
449 <File
450 RelativePath=".\lllocalidhashmap.h">
451 </File>
452 <File
453 RelativePath=".\lllog.h">
454 </File>
455 <File
456 RelativePath=".\lllslconstants.h">
457 </File>
458 <File
459 RelativePath=".\llmap.h">
460 </File>
461 <File
462 RelativePath=".\llmemory.h">
463 </File>
464 <File
465 RelativePath=".\llmemorystream.h">
466 </File>
467 <File
468 RelativePath=".\llmemtype.h">
469 </File>
470 <File
471 RelativePath=".\llmetrics.h">
472 </File>
473 <File
474 RelativePath=".\llmortician.h">
475 </File>
476 <File
477 RelativePath=".\llnametable.h">
478 </File>
479 <File
480 RelativePath=".\llpreprocessor.h">
481 </File>
482 <File
483 RelativePath=".\llpriqueuemap.h">
484 </File>
485 <File
486 RelativePath=".\llprocessor.h">
487 </File>
488 <File
489 RelativePath=".\llptrskiplist.h">
490 </File>
491 <File
492 RelativePath=".\llptrskipmap.h">
493 </File>
494 <File
495 RelativePath=".\llqueuedthread.h">
496 </File>
497 <File
498 RelativePath=".\llrun.h">
499 </File>
500 <File
501 RelativePath=".\llsd.h">
502 </File>
503 <File
504 RelativePath=".\llsdserialize.h">
505 </File>
506 <File
507 RelativePath=".\llsdserialize_xml.h">
508 </File>
509 <File
510 RelativePath=".\llsdutil.h">
511 </File>
512 <File
513 RelativePath=".\llsecondlifeurls.h">
514 </File>
515 <File
516 RelativePath=".\llskiplist.h">
517 </File>
518 <File
519 RelativePath=".\llskipmap.h">
520 </File>
521 <File
522 RelativePath=".\llsmoothstep.h">
523 </File>
524 <File
525 RelativePath=".\llstat.h">
526 </File>
527 <File
528 RelativePath=".\llstatenums.h">
529 </File>
530 <File
531 RelativePath=".\llstl.h">
532 </File>
533 <File
534 RelativePath=".\llstreamtools.h">
535 </File>
536 <File
537 RelativePath=".\llstrider.h">
538 </File>
539 <File
540 RelativePath=".\llstring.h">
541 </File>
542 <File
543 RelativePath=".\llstringtable.h">
544 </File>
545 <File
546 RelativePath=".\llsys.h">
547 </File>
548 <File
549 RelativePath=".\llthread.h">
550 </File>
551 <File
552 RelativePath=".\lltimer.h">
553 </File>
554 <File
555 RelativePath=".\lluri.h">
556 </File>
557 <File
558 RelativePath=".\lluuidhashmap.h">
559 </File>
560 <File
561 RelativePath=".\llversionserver.h">
562 </File>
563 <File
564 RelativePath=".\llversionviewer.h">
565 </File>
566 <File
567 RelativePath=".\llworkerthread.h">
568 </File>
569 <File
570 RelativePath=".\new_mem_ops.h">
571 </File>
572 <File
573 RelativePath=".\priqueue.h">
574 </File>
575 <File
576 RelativePath=".\processor.h">
577 </File>
578 <File
579 RelativePath=".\roles_constants.h">
580 </File>
581 <File
582 RelativePath=".\stdenums.h">
583 </File>
584 <File
585 RelativePath=".\stdtypes.h">
586 </File>
587 <File
588 RelativePath=".\string_table.h">
589 </File>
590 <File
591 RelativePath=".\timer.h">
592 </File>
593 <File
594 RelativePath=".\timing.h">
595 </File>
596 <File
597 RelativePath=".\u64.h">
598 </File>
599 </Filter>
600 <Filter
601 Name="Resource Files"
602 Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
603 UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
604 </Filter>
605 </Files>
606 <Globals>
607 </Globals>
608</VisualStudioProject>
diff --git a/linden/indra/llcommon/llcommon_vc8.vcproj b/linden/indra/llcommon/llcommon_vc8.vcproj
deleted file mode 100644
index a298499..0000000
--- a/linden/indra/llcommon/llcommon_vc8.vcproj
+++ /dev/null
@@ -1,847 +0,0 @@
1<?xml version="1.0" encoding="Windows-1252"?>
2<VisualStudioProject
3 ProjectType="Visual C++"
4 Version="8.00"
5 Name="llcommon"
6 ProjectGUID="{7BCB4B2C-8378-4186-88EA-5742B5ABE17F}"
7 RootNamespace="llcommon"
8 Keyword="Win32Proj"
9 >
10 <Platforms>
11 <Platform
12 Name="Win32"
13 />
14 </Platforms>
15 <ToolFiles>
16 </ToolFiles>
17 <Configurations>
18 <Configuration
19 Name="Debug|Win32"
20 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
21 IntermediateDirectory="$(ConfigurationName)"
22 ConfigurationType="4"
23 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
24 CharacterSet="1"
25 >
26 <Tool
27 Name="VCPreBuildEventTool"
28 />
29 <Tool
30 Name="VCCustomBuildTool"
31 />
32 <Tool
33 Name="VCXMLDataGeneratorTool"
34 />
35 <Tool
36 Name="VCWebServiceProxyGeneratorTool"
37 />
38 <Tool
39 Name="VCMIDLTool"
40 />
41 <Tool
42 Name="VCCLCompilerTool"
43 Optimization="0"
44 AdditionalIncludeDirectories="..\..\libraries\i686-win32\include;..\..\libraries\include\"
45 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_DEBUG;XML_STATIC;APR_DECLARE_STATIC"
46 MinimalRebuild="true"
47 BasicRuntimeChecks="3"
48 RuntimeLibrary="1"
49 StructMemberAlignment="4"
50 TreatWChar_tAsBuiltInType="false"
51 ForceConformanceInForLoopScope="true"
52 UsePrecompiledHeader="0"
53 WarningLevel="3"
54 WarnAsError="true"
55 Detect64BitPortabilityProblems="false"
56 DebugInformationFormat="4"
57 />
58 <Tool
59 Name="VCManagedResourceCompilerTool"
60 />
61 <Tool
62 Name="VCResourceCompilerTool"
63 />
64 <Tool
65 Name="VCPreLinkEventTool"
66 />
67 <Tool
68 Name="VCLibrarianTool"
69 OutputFile="$(OutDir)/llcommon.lib"
70 />
71 <Tool
72 Name="VCALinkTool"
73 />
74 <Tool
75 Name="VCXDCMakeTool"
76 />
77 <Tool
78 Name="VCBscMakeTool"
79 />
80 <Tool
81 Name="VCFxCopTool"
82 />
83 <Tool
84 Name="VCPostBuildEventTool"
85 />
86 </Configuration>
87 <Configuration
88 Name="Release|Win32"
89 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
90 IntermediateDirectory="$(ConfigurationName)"
91 ConfigurationType="4"
92 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
93 CharacterSet="1"
94 >
95 <Tool
96 Name="VCPreBuildEventTool"
97 />
98 <Tool
99 Name="VCCustomBuildTool"
100 />
101 <Tool
102 Name="VCXMLDataGeneratorTool"
103 />
104 <Tool
105 Name="VCWebServiceProxyGeneratorTool"
106 />
107 <Tool
108 Name="VCMIDLTool"
109 />
110 <Tool
111 Name="VCCLCompilerTool"
112 AdditionalOptions="/Oy-"
113 InlineFunctionExpansion="2"
114 EnableIntrinsicFunctions="true"
115 AdditionalIncludeDirectories="..\..\libraries\i686-win32\include;..\..\libraries\include\"
116 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE;XML_STATIC;APR_DECLARE_STATIC"
117 RuntimeLibrary="0"
118 StructMemberAlignment="0"
119 TreatWChar_tAsBuiltInType="false"
120 ForceConformanceInForLoopScope="true"
121 UsePrecompiledHeader="0"
122 WarningLevel="3"
123 WarnAsError="true"
124 Detect64BitPortabilityProblems="false"
125 DebugInformationFormat="3"
126 />
127 <Tool
128 Name="VCManagedResourceCompilerTool"
129 />
130 <Tool
131 Name="VCResourceCompilerTool"
132 />
133 <Tool
134 Name="VCPreLinkEventTool"
135 />
136 <Tool
137 Name="VCLibrarianTool"
138 OutputFile="$(OutDir)/llcommon.lib"
139 />
140 <Tool
141 Name="VCALinkTool"
142 />
143 <Tool
144 Name="VCXDCMakeTool"
145 />
146 <Tool
147 Name="VCBscMakeTool"
148 />
149 <Tool
150 Name="VCFxCopTool"
151 />
152 <Tool
153 Name="VCPostBuildEventTool"
154 />
155 </Configuration>
156 <Configuration
157 Name="ReleaseNoOpt|Win32"
158 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
159 IntermediateDirectory="$(ConfigurationName)"
160 ConfigurationType="4"
161 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
162 CharacterSet="1"
163 >
164 <Tool
165 Name="VCPreBuildEventTool"
166 />
167 <Tool
168 Name="VCCustomBuildTool"
169 />
170 <Tool
171 Name="VCXMLDataGeneratorTool"
172 />
173 <Tool
174 Name="VCWebServiceProxyGeneratorTool"
175 />
176 <Tool
177 Name="VCMIDLTool"
178 />
179 <Tool
180 Name="VCCLCompilerTool"
181 AdditionalOptions="/Oy-"
182 Optimization="0"
183 AdditionalIncludeDirectories="..\..\libraries\i686-win32\include;..\..\libraries\include\"
184 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE;XML_STATIC;APR_DECLARE_STATIC"
185 RuntimeLibrary="0"
186 StructMemberAlignment="0"
187 TreatWChar_tAsBuiltInType="false"
188 ForceConformanceInForLoopScope="true"
189 UsePrecompiledHeader="0"
190 WarningLevel="3"
191 WarnAsError="true"
192 Detect64BitPortabilityProblems="false"
193 DebugInformationFormat="3"
194 />
195 <Tool
196 Name="VCManagedResourceCompilerTool"
197 />
198 <Tool
199 Name="VCResourceCompilerTool"
200 />
201 <Tool
202 Name="VCPreLinkEventTool"
203 />
204 <Tool
205 Name="VCLibrarianTool"
206 AdditionalDependencies="psapi.lib"
207 OutputFile="$(OutDir)/llcommon.lib"
208 AdditionalLibraryDirectories=""
209 />
210 <Tool
211 Name="VCALinkTool"
212 />
213 <Tool
214 Name="VCXDCMakeTool"
215 />
216 <Tool
217 Name="VCBscMakeTool"
218 />
219 <Tool
220 Name="VCFxCopTool"
221 />
222 <Tool
223 Name="VCPostBuildEventTool"
224 />
225 </Configuration>
226 </Configurations>
227 <References>
228 </References>
229 <Files>
230 <Filter
231 Name="Source Files"
232 Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
233 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
234 >
235 <File
236 RelativePath=".\llapp.cpp"
237 >
238 </File>
239 <File
240 RelativePath=".\llapr.cpp"
241 >
242 </File>
243 <File
244 RelativePath=".\llares.cpp"
245 >
246 </File>
247 <File
248 RelativePath=".\llassettype.cpp"
249 >
250 </File>
251 <File
252 RelativePath=".\llbase32.cpp"
253 >
254 </File>
255 <File
256 RelativePath=".\llbase64.cpp"
257 >
258 </File>
259 <File
260 RelativePath=".\llcommon.cpp"
261 >
262 </File>
263 <File
264 RelativePath=".\llcriticaldamp.cpp"
265 >
266 </File>
267 <File
268 RelativePath=".\lldate.cpp"
269 >
270 </File>
271 <File
272 RelativePath=".\llerror.cpp"
273 >
274 </File>
275 <File
276 RelativePath=".\llerrorthread.cpp"
277 >
278 </File>
279 <File
280 RelativePath=".\llevent.cpp"
281 >
282 </File>
283 <File
284 RelativePath=".\llfasttimer.cpp"
285 >
286 </File>
287 <File
288 RelativePath=".\llfile.cpp"
289 >
290 </File>
291 <File
292 RelativePath=".\llfindlocale.cpp"
293 >
294 </File>
295 <File
296 RelativePath=".\llfixedbuffer.cpp"
297 >
298 </File>
299 <File
300 RelativePath=".\llformat.cpp"
301 >
302 </File>
303 <File
304 RelativePath=".\llframetimer.cpp"
305 >
306 </File>
307 <File
308 RelativePath=".\llheartbeat.cpp"
309 >
310 </File>
311 <File
312 RelativePath=".\llindraconfigfile.cpp"
313 >
314 </File>
315 <File
316 RelativePath=".\llliveappconfig.cpp"
317 >
318 </File>
319 <File
320 RelativePath=".\lllivefile.cpp"
321 >
322 </File>
323 <File
324 RelativePath=".\lllog.cpp"
325 >
326 </File>
327 <File
328 RelativePath=".\llmemory.cpp"
329 >
330 </File>
331 <File
332 RelativePath=".\llmemorystream.cpp"
333 >
334 </File>
335 <File
336 RelativePath=".\llmetrics.cpp"
337 >
338 </File>
339 <File
340 RelativePath=".\llmortician.cpp"
341 >
342 </File>
343 <File
344 RelativePath=".\llprocessor.cpp"
345 >
346 </File>
347 <File
348 RelativePath=".\llqueuedthread.cpp"
349 >
350 </File>
351 <File
352 RelativePath=".\llrun.cpp"
353 >
354 </File>
355 <File
356 RelativePath=".\llsd.cpp"
357 >
358 </File>
359 <File
360 RelativePath=".\llsdserialize.cpp"
361 >
362 </File>
363 <File
364 RelativePath=".\llsdserialize_xml.cpp"
365 >
366 </File>
367 <File
368 RelativePath=".\llsdutil.cpp"
369 >
370 </File>
371 <File
372 RelativePath=".\llsecondlifeurls.cpp"
373 >
374 </File>
375 <File
376 RelativePath=".\llstat.cpp"
377 >
378 </File>
379 <File
380 RelativePath=".\llstreamtools.cpp"
381 >
382 </File>
383 <File
384 RelativePath=".\llstring.cpp"
385 >
386 </File>
387 <File
388 RelativePath=".\llstringtable.cpp"
389 >
390 </File>
391 <File
392 RelativePath=".\llsys.cpp"
393 >
394 </File>
395 <File
396 RelativePath=".\llthread.cpp"
397 >
398 </File>
399 <File
400 RelativePath=".\lltimer.cpp"
401 >
402 </File>
403 <File
404 RelativePath=".\lluri.cpp"
405 >
406 </File>
407 <File
408 RelativePath=".\llworkerthread.cpp"
409 >
410 </File>
411 <File
412 RelativePath=".\metaclass.cpp"
413 >
414 </File>
415 <File
416 RelativePath=".\metaproperty.cpp"
417 >
418 </File>
419 <File
420 RelativePath=".\reflective.cpp"
421 >
422 </File>
423 <File
424 RelativePath=".\timing.cpp"
425 >
426 </File>
427 <File
428 RelativePath=".\u64.cpp"
429 >
430 </File>
431 </Filter>
432 <Filter
433 Name="Header Files"
434 Filter="h;hpp;hxx;hm;inl;inc;xsd"
435 UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
436 >
437 <File
438 RelativePath=".\bitpack.h"
439 >
440 </File>
441 <File
442 RelativePath=".\doublelinkedlist.h"
443 >
444 </File>
445 <File
446 RelativePath=".\imageids.h"
447 >
448 </File>
449 <File
450 RelativePath=".\indra_constants.h"
451 >
452 </File>
453 <File
454 RelativePath=".\linden_common.h"
455 >
456 </File>
457 <File
458 RelativePath=".\linked_lists.h"
459 >
460 </File>
461 <File
462 RelativePath=".\llagentconstants.h"
463 >
464 </File>
465 <File
466 RelativePath=".\llapp.h"
467 >
468 </File>
469 <File
470 RelativePath=".\llapr.h"
471 >
472 </File>
473 <File
474 RelativePath=".\llares.h"
475 >
476 </File>
477 <File
478 RelativePath=".\llassettype.h"
479 >
480 </File>
481 <File
482 RelativePath=".\llassoclist.h"
483 >
484 </File>
485 <File
486 RelativePath=".\llavatarconstants.h"
487 >
488 </File>
489 <File
490 RelativePath=".\llbase32.h"
491 >
492 </File>
493 <File
494 RelativePath=".\llbase64.h"
495 >
496 </File>
497 <File
498 RelativePath=".\llboost.h"
499 >
500 </File>
501 <File
502 RelativePath=".\llchat.h"
503 >
504 </File>
505 <File
506 RelativePath=".\llclickaction.h"
507 >
508 </File>
509 <File
510 RelativePath=".\llcommon.h"
511 >
512 </File>
513 <File
514 RelativePath=".\llcriticaldamp.h"
515 >
516 </File>
517 <File
518 RelativePath=".\lldarray.h"
519 >
520 </File>
521 <File
522 RelativePath=".\lldarrayptr.h"
523 >
524 </File>
525 <File
526 RelativePath=".\lldate.h"
527 >
528 </File>
529 <File
530 RelativePath=".\lldefs.h"
531 >
532 </File>
533 <File
534 RelativePath=".\lldlinked.h"
535 >
536 </File>
537 <File
538 RelativePath=".\lldqueueptr.h"
539 >
540 </File>
541 <File
542 RelativePath=".\llendianswizzle.h"
543 >
544 </File>
545 <File
546 RelativePath=".\llenum.h"
547 >
548 </File>
549 <File
550 RelativePath=".\llerror.h"
551 >
552 </File>
553 <File
554 RelativePath=".\llerrorcontrol.h"
555 >
556 </File>
557 <File
558 RelativePath=".\llerrorthread.h"
559 >
560 </File>
561 <File
562 RelativePath=".\llevent.h"
563 >
564 </File>
565 <File
566 RelativePath=".\llextendedstatus.h"
567 >
568 </File>
569 <File
570 RelativePath=".\llfasttimer.h"
571 >
572 </File>
573 <File
574 RelativePath=".\llfile.h"
575 >
576 </File>
577 <File
578 RelativePath=".\llfindlocale.h"
579 >
580 </File>
581 <File
582 RelativePath=".\llfixedbuffer.h"
583 >
584 </File>
585 <File
586 RelativePath=".\llformat.h"
587 >
588 </File>
589 <File
590 RelativePath=".\llframecallbackmanager.h"
591 >
592 </File>
593 <File
594 RelativePath=".\llframetimer.h"
595 >
596 </File>
597 <File
598 RelativePath=".\llhash.h"
599 >
600 </File>
601 <File
602 RelativePath=".\llindexedqueue.h"
603 >
604 </File>
605 <File
606 RelativePath=".\llindraconfigfile.h"
607 >
608 </File>
609 <File
610 RelativePath=".\lllinkedqueue.h"
611 >
612 </File>
613 <File
614 RelativePath=".\llliveappconfig.h"
615 >
616 </File>
617 <File
618 RelativePath=".\lllivefile.h"
619 >
620 </File>
621 <File
622 RelativePath=".\lllocalidhashmap.h"
623 >
624 </File>
625 <File
626 RelativePath=".\lllog.h"
627 >
628 </File>
629 <File
630 RelativePath=".\lllslconstants.h"
631 >
632 </File>
633 <File
634 RelativePath=".\llmap.h"
635 >
636 </File>
637 <File
638 RelativePath=".\llmemory.h"
639 >
640 </File>
641 <File
642 RelativePath=".\llmemorystream.h"
643 >
644 </File>
645 <File
646 RelativePath=".\llmemtype.h"
647 >
648 </File>
649 <File
650 RelativePath=".\llmetrics.h"
651 >
652 </File>
653 <File
654 RelativePath=".\llmortician.h"
655 >
656 </File>
657 <File
658 RelativePath=".\llnametable.h"
659 >
660 </File>
661 <File
662 RelativePath=".\llnametable.h"
663 >
664 </File>
665 <File
666 RelativePath=".\llpreprocessor.h"
667 >
668 </File>
669 <File
670 RelativePath=".\llpriqueuemap.h"
671 >
672 </File>
673 <File
674 RelativePath=".\llprocessor.h"
675 >
676 </File>
677 <File
678 RelativePath=".\llptrskiplist.h"
679 >
680 </File>
681 <File
682 RelativePath=".\llptrskipmap.h"
683 >
684 </File>
685 <File
686 RelativePath=".\llqueuedthread.h"
687 >
688 </File>
689 <File
690 RelativePath=".\llrun.h"
691 >
692 </File>
693 <File
694 RelativePath=".\llsd.h"
695 >
696 </File>
697 <File
698 RelativePath=".\llsdserialize.h"
699 >
700 </File>
701 <File
702 RelativePath=".\llsdserialize_xml.h"
703 >
704 </File>
705 <File
706 RelativePath=".\llsdutil.h"
707 >
708 </File>
709 <File
710 RelativePath=".\llsecondlifeurls.h"
711 >
712 </File>
713 <File
714 RelativePath=".\llskiplist.h"
715 >
716 </File>
717 <File
718 RelativePath=".\llskipmap.h"
719 >
720 </File>
721 <File
722 RelativePath=".\llstat.h"
723 >
724 </File>
725 <File
726 RelativePath=".\llstatenums.h"
727 >
728 </File>
729 <File
730 RelativePath=".\llstl.h"
731 >
732 </File>
733 <File
734 RelativePath=".\llstreamtools.h"
735 >
736 </File>
737 <File
738 RelativePath=".\llstrider.h"
739 >
740 </File>
741 <File
742 RelativePath=".\llstring.h"
743 >
744 </File>
745 <File
746 RelativePath=".\llstringtable.h"
747 >
748 </File>
749 <File
750 RelativePath=".\llsys.h"
751 >
752 </File>
753 <File
754 RelativePath=".\llthread.h"
755 >
756 </File>
757 <File
758 RelativePath=".\lltimer.h"
759 >
760 </File>
761 <File
762 RelativePath=".\lluri.h"
763 >
764 </File>
765 <File
766 RelativePath=".\lluuidhashmap.h"
767 >
768 </File>
769 <File
770 RelativePath=".\llversionserver.h"
771 >
772 </File>
773 <File
774 RelativePath=".\llversionviewer.h"
775 >
776 </File>
777 <File
778 RelativePath=".\llworkerthread.h"
779 >
780 </File>
781 <File
782 RelativePath=".\metaclass.h"
783 >
784 </File>
785 <File
786 RelativePath=".\metaclasst.h"
787 >
788 </File>
789 <File
790 RelativePath=".\metaproperty.h"
791 >
792 </File>
793 <File
794 RelativePath=".\metapropertyt.h"
795 >
796 </File>
797 <File
798 RelativePath=".\new_mem_ops.h"
799 >
800 </File>
801 <File
802 RelativePath=".\priqueue.h"
803 >
804 </File>
805 <File
806 RelativePath=".\processor.h"
807 >
808 </File>
809 <File
810 RelativePath=".\roles_constants.h"
811 >
812 </File>
813 <File
814 RelativePath=".\stdenums.h"
815 >
816 </File>
817 <File
818 RelativePath=".\stdtypes.h"
819 >
820 </File>
821 <File
822 RelativePath=".\string_table.h"
823 >
824 </File>
825 <File
826 RelativePath=".\timer.h"
827 >
828 </File>
829 <File
830 RelativePath=".\timing.h"
831 >
832 </File>
833 <File
834 RelativePath=".\u64.h"
835 >
836 </File>
837 </Filter>
838 <Filter
839 Name="Resource Files"
840 Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
841 UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
842 >
843 </Filter>
844 </Files>
845 <Globals>
846 </Globals>
847</VisualStudioProject>
diff --git a/linden/indra/llcommon/llcommon_vc9.vcproj b/linden/indra/llcommon/llcommon_vc9.vcproj
deleted file mode 100644
index 1ae534d..0000000
--- a/linden/indra/llcommon/llcommon_vc9.vcproj
+++ /dev/null
@@ -1,828 +0,0 @@
1<?xml version="1.0" encoding="Windows-1252"?>
2<VisualStudioProject
3 ProjectType="Visual C++"
4 Version="9.00"
5 Name="llcommon"
6 ProjectGUID="{7BCB4B2C-8378-4186-88EA-5742B5ABE17F}"
7 RootNamespace="llcommon"
8 Keyword="Win32Proj"
9 TargetFrameworkVersion="131072"
10 >
11 <Platforms>
12 <Platform
13 Name="Win32"
14 />
15 </Platforms>
16 <ToolFiles>
17 </ToolFiles>
18 <Configurations>
19 <Configuration
20 Name="Debug|Win32"
21 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
22 IntermediateDirectory="$(ConfigurationName)"
23 ConfigurationType="4"
24 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
25 CharacterSet="1"
26 >
27 <Tool
28 Name="VCPreBuildEventTool"
29 />
30 <Tool
31 Name="VCCustomBuildTool"
32 />
33 <Tool
34 Name="VCXMLDataGeneratorTool"
35 />
36 <Tool
37 Name="VCWebServiceProxyGeneratorTool"
38 />
39 <Tool
40 Name="VCMIDLTool"
41 />
42 <Tool
43 Name="VCCLCompilerTool"
44 Optimization="0"
45 AdditionalIncludeDirectories="..\..\libraries\i686-win32\include;..\..\libraries\include\"
46 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_DEBUG;XML_STATIC;APR_DECLARE_STATIC"
47 MinimalRebuild="true"
48 BasicRuntimeChecks="3"
49 RuntimeLibrary="1"
50 StructMemberAlignment="4"
51 TreatWChar_tAsBuiltInType="false"
52 ForceConformanceInForLoopScope="true"
53 UsePrecompiledHeader="0"
54 WarningLevel="3"
55 WarnAsError="true"
56 Detect64BitPortabilityProblems="false"
57 DebugInformationFormat="4"
58 />
59 <Tool
60 Name="VCManagedResourceCompilerTool"
61 />
62 <Tool
63 Name="VCResourceCompilerTool"
64 />
65 <Tool
66 Name="VCPreLinkEventTool"
67 />
68 <Tool
69 Name="VCLibrarianTool"
70 OutputFile="$(OutDir)/llcommon.lib"
71 />
72 <Tool
73 Name="VCALinkTool"
74 />
75 <Tool
76 Name="VCXDCMakeTool"
77 />
78 <Tool
79 Name="VCBscMakeTool"
80 />
81 <Tool
82 Name="VCFxCopTool"
83 />
84 <Tool
85 Name="VCPostBuildEventTool"
86 />
87 </Configuration>
88 <Configuration
89 Name="Release|Win32"
90 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
91 IntermediateDirectory="$(ConfigurationName)"
92 ConfigurationType="4"
93 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
94 CharacterSet="1"
95 >
96 <Tool
97 Name="VCPreBuildEventTool"
98 />
99 <Tool
100 Name="VCCustomBuildTool"
101 />
102 <Tool
103 Name="VCXMLDataGeneratorTool"
104 />
105 <Tool
106 Name="VCWebServiceProxyGeneratorTool"
107 />
108 <Tool
109 Name="VCMIDLTool"
110 />
111 <Tool
112 Name="VCCLCompilerTool"
113 AdditionalOptions="/Oy-"
114 InlineFunctionExpansion="2"
115 EnableIntrinsicFunctions="true"
116 AdditionalIncludeDirectories="..\..\libraries\i686-win32\include;..\..\libraries\include\"
117 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE;XML_STATIC;APR_DECLARE_STATIC"
118 RuntimeLibrary="0"
119 StructMemberAlignment="0"
120 TreatWChar_tAsBuiltInType="false"
121 ForceConformanceInForLoopScope="true"
122 UsePrecompiledHeader="0"
123 WarningLevel="3"
124 WarnAsError="true"
125 Detect64BitPortabilityProblems="false"
126 DebugInformationFormat="3"
127 />
128 <Tool
129 Name="VCManagedResourceCompilerTool"
130 />
131 <Tool
132 Name="VCResourceCompilerTool"
133 />
134 <Tool
135 Name="VCPreLinkEventTool"
136 />
137 <Tool
138 Name="VCLibrarianTool"
139 OutputFile="$(OutDir)/llcommon.lib"
140 />
141 <Tool
142 Name="VCALinkTool"
143 />
144 <Tool
145 Name="VCXDCMakeTool"
146 />
147 <Tool
148 Name="VCBscMakeTool"
149 />
150 <Tool
151 Name="VCFxCopTool"
152 />
153 <Tool
154 Name="VCPostBuildEventTool"
155 />
156 </Configuration>
157 <Configuration
158 Name="ReleaseNoOpt|Win32"
159 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
160 IntermediateDirectory="$(ConfigurationName)"
161 ConfigurationType="4"
162 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
163 CharacterSet="1"
164 >
165 <Tool
166 Name="VCPreBuildEventTool"
167 />
168 <Tool
169 Name="VCCustomBuildTool"
170 />
171 <Tool
172 Name="VCXMLDataGeneratorTool"
173 />
174 <Tool
175 Name="VCWebServiceProxyGeneratorTool"
176 />
177 <Tool
178 Name="VCMIDLTool"
179 />
180 <Tool
181 Name="VCCLCompilerTool"
182 AdditionalOptions="/Oy-"
183 Optimization="0"
184 AdditionalIncludeDirectories="..\..\libraries\i686-win32\include;..\..\libraries\include\"
185 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE;XML_STATIC;APR_DECLARE_STATIC"
186 RuntimeLibrary="0"
187 StructMemberAlignment="0"
188 TreatWChar_tAsBuiltInType="false"
189 ForceConformanceInForLoopScope="true"
190 UsePrecompiledHeader="0"
191 WarningLevel="3"
192 WarnAsError="true"
193 Detect64BitPortabilityProblems="false"
194 DebugInformationFormat="3"
195 />
196 <Tool
197 Name="VCManagedResourceCompilerTool"
198 />
199 <Tool
200 Name="VCResourceCompilerTool"
201 />
202 <Tool
203 Name="VCPreLinkEventTool"
204 />
205 <Tool
206 Name="VCLibrarianTool"
207 AdditionalDependencies="psapi.lib"
208 OutputFile="$(OutDir)/llcommon.lib"
209 AdditionalLibraryDirectories=""
210 />
211 <Tool
212 Name="VCALinkTool"
213 />
214 <Tool
215 Name="VCXDCMakeTool"
216 />
217 <Tool
218 Name="VCBscMakeTool"
219 />
220 <Tool
221 Name="VCFxCopTool"
222 />
223 <Tool
224 Name="VCPostBuildEventTool"
225 />
226 </Configuration>
227 </Configurations>
228 <References>
229 </References>
230 <Files>
231 <Filter
232 Name="Source Files"
233 Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
234 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
235 >
236 <File
237 RelativePath=".\llapp.cpp"
238 >
239 </File>
240 <File
241 RelativePath=".\llapr.cpp"
242 >
243 </File>
244 <File
245 RelativePath=".\llares.cpp"
246 >
247 </File>
248 <File
249 RelativePath=".\llassettype.cpp"
250 >
251 </File>
252 <File
253 RelativePath=".\llbase32.cpp"
254 >
255 </File>
256 <File
257 RelativePath=".\llbase64.cpp"
258 >
259 </File>
260 <File
261 RelativePath=".\llcommon.cpp"
262 >
263 </File>
264 <File
265 RelativePath=".\llcriticaldamp.cpp"
266 >
267 </File>
268 <File
269 RelativePath=".\lldate.cpp"
270 >
271 </File>
272 <File
273 RelativePath=".\llerror.cpp"
274 >
275 </File>
276 <File
277 RelativePath=".\llerrorthread.cpp"
278 >
279 </File>
280 <File
281 RelativePath=".\llevent.cpp"
282 >
283 </File>
284 <File
285 RelativePath=".\llfasttimer.cpp"
286 >
287 </File>
288 <File
289 RelativePath=".\llfile.cpp"
290 >
291 </File>
292 <File
293 RelativePath=".\llfindlocale.cpp"
294 >
295 </File>
296 <File
297 RelativePath=".\llfixedbuffer.cpp"
298 >
299 </File>
300 <File
301 RelativePath=".\llformat.cpp"
302 >
303 </File>
304 <File
305 RelativePath=".\llframetimer.cpp"
306 >
307 </File>
308 <File
309 RelativePath=".\llheartbeat.cpp"
310 >
311 </File>
312 <File
313 RelativePath=".\llindraconfigfile.cpp"
314 >
315 </File>
316 <File
317 RelativePath=".\llliveappconfig.cpp"
318 >
319 </File>
320 <File
321 RelativePath=".\lllivefile.cpp"
322 >
323 </File>
324 <File
325 RelativePath=".\lllog.cpp"
326 >
327 </File>
328 <File
329 RelativePath=".\llmemory.cpp"
330 >
331 </File>
332 <File
333 RelativePath=".\llmemorystream.cpp"
334 >
335 </File>
336 <File
337 RelativePath=".\llmetrics.cpp"
338 >
339 </File>
340 <File
341 RelativePath=".\llmortician.cpp"
342 >
343 </File>
344 <File
345 RelativePath=".\llprocessor.cpp"
346 >
347 </File>
348 <File
349 RelativePath=".\llqueuedthread.cpp"
350 >
351 </File>
352 <File
353 RelativePath=".\llrun.cpp"
354 >
355 </File>
356 <File
357 RelativePath=".\llsd.cpp"
358 >
359 </File>
360 <File
361 RelativePath=".\llsdserialize.cpp"
362 >
363 </File>
364 <File
365 RelativePath=".\llsdserialize_xml.cpp"
366 >
367 </File>
368 <File
369 RelativePath=".\llsdutil.cpp"
370 >
371 </File>
372 <File
373 RelativePath=".\llsecondlifeurls.cpp"
374 >
375 </File>
376 <File
377 RelativePath=".\llstat.cpp"
378 >
379 </File>
380 <File
381 RelativePath=".\llstreamtools.cpp"
382 >
383 </File>
384 <File
385 RelativePath=".\llstring.cpp"
386 >
387 </File>
388 <File
389 RelativePath=".\llstringtable.cpp"
390 >
391 </File>
392 <File
393 RelativePath=".\llsys.cpp"
394 >
395 </File>
396 <File
397 RelativePath=".\llthread.cpp"
398 >
399 </File>
400 <File
401 RelativePath=".\lltimer.cpp"
402 >
403 </File>
404 <File
405 RelativePath=".\lluri.cpp"
406 >
407 </File>
408 <File
409 RelativePath=".\llworkerthread.cpp"
410 >
411 </File>
412 <File
413 RelativePath=".\metaclass.cpp"
414 >
415 </File>
416 <File
417 RelativePath=".\metaproperty.cpp"
418 >
419 </File>
420 <File
421 RelativePath=".\reflective.cpp"
422 >
423 </File>
424 <File
425 RelativePath=".\timing.cpp"
426 >
427 </File>
428 <File
429 RelativePath=".\u64.cpp"
430 >
431 </File>
432 </Filter>
433 <Filter
434 Name="Header Files"
435 Filter="h;hpp;hxx;hm;inl;inc;xsd"
436 UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
437 >
438 <File
439 RelativePath=".\bitpack.h"
440 >
441 </File>
442 <File
443 RelativePath=".\doublelinkedlist.h"
444 >
445 </File>
446 <File
447 RelativePath=".\imageids.h"
448 >
449 </File>
450 <File
451 RelativePath=".\indra_constants.h"
452 >
453 </File>
454 <File
455 RelativePath=".\linden_common.h"
456 >
457 </File>
458 <File
459 RelativePath=".\linked_lists.h"
460 >
461 </File>
462 <File
463 RelativePath=".\llagentconstants.h"
464 >
465 </File>
466 <File
467 RelativePath=".\llapp.h"
468 >
469 </File>
470 <File
471 RelativePath=".\llapr.h"
472 >
473 </File>
474 <File
475 RelativePath=".\llares.h"
476 >
477 </File>
478 <File
479 RelativePath=".\llassettype.h"
480 >
481 </File>
482 <File
483 RelativePath=".\llassoclist.h"
484 >
485 </File>
486 <File
487 RelativePath=".\llavatarconstants.h"
488 >
489 </File>
490 <File
491 RelativePath=".\llbase32.h"
492 >
493 </File>
494 <File
495 RelativePath=".\llbase64.h"
496 >
497 </File>
498 <File
499 RelativePath=".\llboost.h"
500 >
501 </File>
502 <File
503 RelativePath=".\llchat.h"
504 >
505 </File>
506 <File
507 RelativePath=".\llclickaction.h"
508 >
509 </File>
510 <File
511 RelativePath=".\llcommon.h"
512 >
513 </File>
514 <File
515 RelativePath=".\llcriticaldamp.h"
516 >
517 </File>
518 <File
519 RelativePath=".\lldarray.h"
520 >
521 </File>
522 <File
523 RelativePath=".\lldarrayptr.h"
524 >
525 </File>
526 <File
527 RelativePath=".\lldate.h"
528 >
529 </File>
530 <File
531 RelativePath=".\lldefs.h"
532 >
533 </File>
534 <File
535 RelativePath=".\lldlinked.h"
536 >
537 </File>
538 <File
539 RelativePath=".\lldqueueptr.h"
540 >
541 </File>
542 <File
543 RelativePath=".\llendianswizzle.h"
544 >
545 </File>
546 <File
547 RelativePath=".\llenum.h"
548 >
549 </File>
550 <File
551 RelativePath=".\llerror.h"
552 >
553 </File>
554 <File
555 RelativePath=".\llerrorcontrol.h"
556 >
557 </File>
558 <File
559 RelativePath=".\llerrorthread.h"
560 >
561 </File>
562 <File
563 RelativePath=".\llevent.h"
564 >
565 </File>
566 <File
567 RelativePath=".\llextendedstatus.h"
568 >
569 </File>
570 <File
571 RelativePath=".\llfasttimer.h"
572 >
573 </File>
574 <File
575 RelativePath=".\llfile.h"
576 >
577 </File>
578 <File
579 RelativePath=".\llfindlocale.h"
580 >
581 </File>
582 <File
583 RelativePath=".\llfixedbuffer.h"
584 >
585 </File>
586 <File
587 RelativePath=".\llformat.h"
588 >
589 </File>
590 <File
591 RelativePath=".\llframecallbackmanager.h"
592 >
593 </File>
594 <File
595 RelativePath=".\llframetimer.h"
596 >
597 </File>
598 <File
599 RelativePath=".\llhash.h"
600 >
601 </File>
602 <File
603 RelativePath=".\llindexedqueue.h"
604 >
605 </File>
606 <File
607 RelativePath=".\llindraconfigfile.h"
608 >
609 </File>
610 <File
611 RelativePath=".\lllinkedqueue.h"
612 >
613 </File>
614 <File
615 RelativePath=".\llliveappconfig.h"
616 >
617 </File>
618 <File
619 RelativePath=".\lllivefile.h"
620 >
621 </File>
622 <File
623 RelativePath=".\lllocalidhashmap.h"
624 >
625 </File>
626 <File
627 RelativePath=".\lllog.h"
628 >
629 </File>
630 <File
631 RelativePath=".\lllslconstants.h"
632 >
633 </File>
634 <File
635 RelativePath=".\llmap.h"
636 >
637 </File>
638 <File
639 RelativePath=".\llmemory.h"
640 >
641 </File>
642 <File
643 RelativePath=".\llmemorystream.h"
644 >
645 </File>
646 <File
647 RelativePath=".\llmemtype.h"
648 >
649 </File>
650 <File
651 RelativePath=".\llmetrics.h"
652 >
653 </File>
654 <File
655 RelativePath=".\llmortician.h"
656 >
657 </File>
658 <File
659 RelativePath=".\llnametable.h"
660 >
661 </File>
662 <File
663 RelativePath=".\llpreprocessor.h"
664 >
665 </File>
666 <File
667 RelativePath=".\llpriqueuemap.h"
668 >
669 </File>
670 <File
671 RelativePath=".\llprocessor.h"
672 >
673 </File>
674 <File
675 RelativePath=".\llptrskiplist.h"
676 >
677 </File>
678 <File
679 RelativePath=".\llptrskipmap.h"
680 >
681 </File>
682 <File
683 RelativePath=".\llqueuedthread.h"
684 >
685 </File>
686 <File
687 RelativePath=".\llrun.h"
688 >
689 </File>
690 <File
691 RelativePath=".\llsd.h"
692 >
693 </File>
694 <File
695 RelativePath=".\llsdserialize.h"
696 >
697 </File>
698 <File
699 RelativePath=".\llsdserialize_xml.h"
700 >
701 </File>
702 <File
703 RelativePath=".\llsdutil.h"
704 >
705 </File>
706 <File
707 RelativePath=".\llsecondlifeurls.h"
708 >
709 </File>
710 <File
711 RelativePath=".\llskiplist.h"
712 >
713 </File>
714 <File
715 RelativePath=".\llskipmap.h"
716 >
717 </File>
718 <File
719 RelativePath=".\llstat.h"
720 >
721 </File>
722 <File
723 RelativePath=".\llstatenums.h"
724 >
725 </File>
726 <File
727 RelativePath=".\llstl.h"
728 >
729 </File>
730 <File
731 RelativePath=".\llstreamtools.h"
732 >
733 </File>
734 <File
735 RelativePath=".\llstrider.h"
736 >
737 </File>
738 <File
739 RelativePath=".\llstring.h"
740 >
741 </File>
742 <File
743 RelativePath=".\llstringtable.h"
744 >
745 </File>
746 <File
747 RelativePath=".\llsys.h"
748 >
749 </File>
750 <File
751 RelativePath=".\llthread.h"
752 >
753 </File>
754 <File
755 RelativePath=".\lltimer.h"
756 >
757 </File>
758 <File
759 RelativePath=".\lluri.h"
760 >
761 </File>
762 <File
763 RelativePath=".\lluuidhashmap.h"
764 >
765 </File>
766 <File
767 RelativePath=".\llversionserver.h"
768 >
769 </File>
770 <File
771 RelativePath=".\llversionviewer.h"
772 >
773 </File>
774 <File
775 RelativePath=".\llworkerthread.h"
776 >
777 </File>
778 <File
779 RelativePath=".\new_mem_ops.h"
780 >
781 </File>
782 <File
783 RelativePath=".\priqueue.h"
784 >
785 </File>
786 <File
787 RelativePath=".\processor.h"
788 >
789 </File>
790 <File
791 RelativePath=".\roles_constants.h"
792 >
793 </File>
794 <File
795 RelativePath=".\stdenums.h"
796 >
797 </File>
798 <File
799 RelativePath=".\stdtypes.h"
800 >
801 </File>
802 <File
803 RelativePath=".\string_table.h"
804 >
805 </File>
806 <File
807 RelativePath=".\timer.h"
808 >
809 </File>
810 <File
811 RelativePath=".\timing.h"
812 >
813 </File>
814 <File
815 RelativePath=".\u64.h"
816 >
817 </File>
818 </Filter>
819 <Filter
820 Name="Resource Files"
821 Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
822 UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
823 >
824 </Filter>
825 </Files>
826 <Globals>
827 </Globals>
828</VisualStudioProject>
diff --git a/linden/indra/llcommon/llcrc.cpp b/linden/indra/llcommon/llcrc.cpp
new file mode 100644
index 0000000..beb76d1
--- /dev/null
+++ b/linden/indra/llcommon/llcrc.cpp
@@ -0,0 +1,224 @@
1/**
2 * @file llcrc.cpp
3 * @brief implementation of the crc class.
4 *
5 * $LicenseInfo:firstyear=2002&license=viewergpl$
6 *
7 * Copyright (c) 2002-2008, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#include "linden_common.h"
33
34#include "llcrc.h"
35#include "llerror.h"
36
37/* Copyright (C) 1986 Gary S. Brown. You may use this program, or
38 code or tables extracted from it, as desired without restriction.*/
39
40/* First, the polynomial itself and its table of feedback terms. The */
41/* polynomial is */
42/* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 */
43/* Note that we take it "backwards" and put the highest-order term in */
44/* the lowest-order bit. The X^32 term is "implied"; the LSB is the */
45/* X^31 term, etc. The X^0 term (usually shown as "+1") results in */
46/* the MSB being 1. */
47
48/* Note that the usual hardware shift register implementation, which */
49/* is what we're using (we're merely optimizing it by doing eight-bit */
50/* chunks at a time) shifts bits into the lowest-order term. In our */
51/* implementation, that means shifting towards the right. Why do we */
52/* do it this way? Because the calculated CRC must be transmitted in */
53/* order from highest-order term to lowest-order term. UARTs transmit */
54/* characters in order from LSB to MSB. By storing the CRC this way, */
55/* we hand it to the UART in the order low-byte to high-byte; the UART */
56/* sends each low-bit to hight-bit; and the result is transmission bit */
57/* by bit from highest- to lowest-order term without requiring any bit */
58/* shuffling on our part. Reception works similarly. */
59
60/* The feedback terms table consists of 256, 32-bit entries. Notes: */
61/* */
62/* 1. The table can be generated at runtime if desired; code to do so */
63/* is shown later. It might not be obvious, but the feedback */
64/* terms simply represent the results of eight shift/xor opera- */
65/* tions for all combinations of data and CRC register values. */
66/* */
67/* 2. The CRC accumulation logic is the same for all CRC polynomials, */
68/* be they sixteen or thirty-two bits wide. You simply choose the */
69/* appropriate table. Alternatively, because the table can be */
70/* generated at runtime, you can start by generating the table for */
71/* the polynomial in question and use exactly the same "updcrc", */
72/* if your application needn't simultaneously handle two CRC */
73/* polynomials. (Note, however, that XMODEM is strange.) */
74/* */
75/* 3. For 16-bit CRCs, the table entries need be only 16 bits wide; */
76/* of course, 32-bit entries work OK if the high 16 bits are zero. */
77/* */
78/* 4. The values must be right-shifted by eight bits by the "updcrc" */
79/* logic; the shift must be unsigned (bring in zeroes). On some */
80/* hardware you could probably optimize the shift in assembler by */
81/* using byte-swap instructions. */
82
83///----------------------------------------------------------------------------
84/// Local function declarations, constants, enums, and typedefs
85///----------------------------------------------------------------------------
86
87#define UPDC32(octet,crc) (crc_32_tab[((crc) \
88 ^ ((U8)octet)) & 0xff] ^ ((crc) >> 8))
89
90
91static U32 crc_32_tab[] = { /* CRC polynomial 0xedb88320 */
920x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
930xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
940x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
950xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
960x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
970xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
980x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
990xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
1000x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
1010xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
1020x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
1030x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
1040x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
1050x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
1060x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
1070x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
1080x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
1090xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
1100x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
1110xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
1120x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
1130xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
1140xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
1150x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
1160xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
1170x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
1180xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
1190x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
1200xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
1210x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
1220xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
1230x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
1240x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
1250x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
1260x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
1270x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
1280x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
1290x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
1300xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
1310x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
1320xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
1330x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
1340xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
135};
136
137
138///----------------------------------------------------------------------------
139/// Class llcrc
140///----------------------------------------------------------------------------
141
142// Default constructor
143LLCRC::LLCRC() : mCurrent(0xffffffff)
144{
145}
146
147
148U32 LLCRC::getCRC() const
149{
150 return ~mCurrent;
151}
152
153void LLCRC::update(U8 next_byte)
154{
155 mCurrent = UPDC32(next_byte, mCurrent);
156}
157
158void LLCRC::update(const U8* buffer, size_t buffer_size)
159{
160 for (size_t i = 0; i < buffer_size; i++)
161 {
162 mCurrent = UPDC32(buffer[i], mCurrent);
163 }
164}
165
166void LLCRC::update(const std::string& filename)
167{
168 if (filename.empty())
169 {
170 llerrs << "No filename specified" << llendl;
171 return;
172 }
173
174 FILE* fp = LLFile::fopen(filename, "rb"); /* Flawfinder: ignore */
175
176 if (fp)
177 {
178 fseek(fp, 0, SEEK_END);
179 long size = ftell(fp);
180
181 fseek(fp, 0, SEEK_SET);
182
183 if (size > 0)
184 {
185 U8* data = new U8[size];
186 size_t nread;
187
188 nread = fread(data, 1, size, fp);
189 fclose(fp);
190
191 if (nread < (size_t) size)
192 {
193 llwarns << "Short read on " << filename << llendl;
194 }
195
196 update(data, nread);
197 delete[] data;
198 }
199 }
200}
201
202
203#ifdef _DEBUG
204BOOL LLCRC::testHarness()
205{
206 const S32 TEST_BUFFER_SIZE = 16;
207 const char TEST_BUFFER[TEST_BUFFER_SIZE] = "hello &#$)$&Nd0"; /* Flawfinder: ignore */
208 LLCRC c1, c2;
209 c1.update((U8*)TEST_BUFFER, TEST_BUFFER_SIZE - 1);
210 char* rh = (char*)TEST_BUFFER;
211 while(*rh != '\0')
212 {
213 c2.update(*rh);
214 ++rh;
215 }
216 return(c1.getCRC() == c2.getCRC());
217}
218#endif
219
220
221
222///----------------------------------------------------------------------------
223/// Local function definitions
224///----------------------------------------------------------------------------
diff --git a/linden/indra/llcommon/llcrc.h b/linden/indra/llcommon/llcrc.h
new file mode 100644
index 0000000..20f214e
--- /dev/null
+++ b/linden/indra/llcommon/llcrc.h
@@ -0,0 +1,73 @@
1/**
2 * @file llcrc.h
3 * @brief LLCRC class header file.
4 *
5 * $LicenseInfo:firstyear=2002&license=viewergpl$
6 *
7 * Copyright (c) 2002-2008, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#ifndef LL_LLCRC_H
33#define LL_LLCRC_H
34
35//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
36// Class llcrc
37//
38// Simple 32 bit crc. To use, instantiate an LLCRC instance and feed
39// it the bytes you want to check. It will update the internal crc as
40// you go, and you can qery it at the end. As a horribly inefficient
41// example (don't try this at work kids):
42//
43// LLCRC crc;
44// FILE* fp = LLFile::fopen(filename,"rb");
45// while(!feof(fp)) {
46// crc.update(fgetc(fp));
47// }
48// fclose(fp);
49// llinfos << "File crc: " << crc.getCRC() << llendl;
50//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
51
52class LLCRC
53{
54protected:
55 U32 mCurrent;
56
57public:
58 LLCRC();
59
60 U32 getCRC() const;
61 void update(U8 next_byte);
62 void update(const U8* buffer, size_t buffer_size);
63 void update(const std::string& filename);
64
65#ifdef _DEBUG
66 // This function runs tests to make sure the crc is
67 // working. Returns TRUE if it is.
68 static BOOL testHarness();
69#endif
70};
71
72
73#endif // LL_LLCRC_H
diff --git a/linden/indra/llcommon/lldarray.h b/linden/indra/llcommon/lldarray.h
index 45e564f..32ece4e 100644
--- a/linden/indra/llcommon/lldarray.h
+++ b/linden/indra/llcommon/lldarray.h
@@ -32,7 +32,6 @@
32#ifndef LL_LLDARRAY_H 32#ifndef LL_LLDARRAY_H
33#define LL_LLDARRAY_H 33#define LL_LLDARRAY_H
34 34
35#include "llmath.h"
36#include "llerror.h" 35#include "llerror.h"
37 36
38#include <vector> 37#include <vector>
diff --git a/linden/indra/llcommon/lldate.cpp b/linden/indra/llcommon/lldate.cpp
index 5d36d2b..a313246 100644
--- a/linden/indra/llcommon/lldate.cpp
+++ b/linden/indra/llcommon/lldate.cpp
@@ -34,7 +34,7 @@
34#include "linden_common.h" 34#include "linden_common.h"
35#include "lldate.h" 35#include "lldate.h"
36 36
37#include "apr-1/apr_time.h" 37#include "apr_time.h"
38 38
39#include <iomanip> 39#include <iomanip>
40#include <sstream> 40#include <sstream>
diff --git a/linden/indra/llcommon/llerror.cpp b/linden/indra/llcommon/llerror.cpp
index b74b288..5c7c3cd 100644
--- a/linden/indra/llcommon/llerror.cpp
+++ b/linden/indra/llcommon/llerror.cpp
@@ -102,7 +102,7 @@ namespace {
102 public: 102 public:
103 RecordToFile(const std::string& filename) 103 RecordToFile(const std::string& filename)
104 { 104 {
105 mFile.open(filename.c_str(), llofstream::out | llofstream::app); 105 mFile.open(filename, llofstream::out | llofstream::app);
106 if (!mFile) 106 if (!mFile)
107 { 107 {
108 llinfos << "Error setting log file to " << filename << llendl; 108 llinfos << "Error setting log file to " << filename << llendl;
@@ -168,7 +168,7 @@ namespace {
168 168
169 private: 169 private:
170 bool mTimestamp; 170 bool mTimestamp;
171 typedef enum ANSIState {ANSI_PROBE, ANSI_YES, ANSI_NO}; 171 enum ANSIState {ANSI_PROBE, ANSI_YES, ANSI_NO};
172 ANSIState mUseANSI; 172 ANSIState mUseANSI;
173 void colorANSI(const std::string color) 173 void colorANSI(const std::string color)
174 { 174 {
@@ -196,7 +196,7 @@ namespace {
196 virtual void recordMessage(LLError::ELevel level, 196 virtual void recordMessage(LLError::ELevel level,
197 const std::string& message) 197 const std::string& message)
198 { 198 {
199 mBuffer.addLine(message.c_str()); 199 mBuffer.addLine(message);
200 } 200 }
201 201
202 private: 202 private:
@@ -305,7 +305,7 @@ namespace
305 std::string file = dirBase + "logcontrol-dev.xml"; 305 std::string file = dirBase + "logcontrol-dev.xml";
306 306
307 llstat stat_info; 307 llstat stat_info;
308 if (LLFile::stat(file.c_str(), &stat_info)) { 308 if (LLFile::stat(file, &stat_info)) {
309 // NB: stat returns non-zero if it can't read the file, for example 309 // NB: stat returns non-zero if it can't read the file, for example
310 // if it doesn't exist. LLFile has no better abstraction for 310 // if it doesn't exist. LLFile has no better abstraction for
311 // testing for file existence. 311 // testing for file existence.
@@ -321,7 +321,7 @@ namespace
321 LLSD configuration; 321 LLSD configuration;
322 322
323 { 323 {
324 llifstream file(filename().c_str()); 324 llifstream file(filename());
325 if (file.is_open()) 325 if (file.is_open())
326 { 326 {
327 LLSDSerialize::fromXML(configuration, file); 327 LLSDSerialize::fromXML(configuration, file);
@@ -1040,17 +1040,37 @@ namespace LLError
1040 << "(" << site.mLine << ") : "; 1040 << "(" << site.mLine << ") : ";
1041 } 1041 }
1042 1042
1043 if (message.find(functionName(site.mFunction)) == std::string::npos)
1044 {
1045 #if LL_WINDOWS 1043 #if LL_WINDOWS
1046 // DevStudio: __FUNCTION__ already includes the full class name 1044 // DevStudio: __FUNCTION__ already includes the full class name
1047 #else 1045 #else
1048 if (site.mClassInfo != typeid(NoClassInfo)) 1046 if (site.mClassInfo != typeid(NoClassInfo))
1047 {
1048 prefix << className(site.mClassInfo) << "::";
1049 }
1050 #endif
1051 prefix << site.mFunction << ": ";
1052
1053 if (site.mPrintOnce)
1054 {
1055 std::map<std::string, unsigned int>::iterator messageIter = s.uniqueLogMessages.find(message);
1056 if (messageIter != s.uniqueLogMessages.end())
1057 {
1058 messageIter->second++;
1059 unsigned int num_messages = messageIter->second;
1060 if (num_messages == 10 || num_messages == 50 || (num_messages % 100) == 0)
1061 {
1062 prefix << "ONCE (" << num_messages << "th time seen): ";
1063 }
1064 else
1065 {
1066 return;
1067 }
1068 }
1069 else
1049 { 1070 {
1050 prefix << className(site.mClassInfo) << "::"; 1071 prefix << "ONCE: ";
1072 s.uniqueLogMessages[message] = 1;
1051 } 1073 }
1052 #endif
1053 prefix << site.mFunction << ": ";
1054 } 1074 }
1055 1075
1056 if (site.mPrintOnce) 1076 if (site.mPrintOnce)
diff --git a/linden/indra/llcommon/llevent.cpp b/linden/indra/llcommon/llevent.cpp
index 33af028..7d701a1 100644
--- a/linden/indra/llcommon/llevent.cpp
+++ b/linden/indra/llcommon/llevent.cpp
@@ -219,7 +219,7 @@ std::vector<LLListenerEntry> LLSimpleDispatcher::getListeners() const
219bool LLSimpleDispatcher::fireEvent(LLPointer<LLEvent> event, LLSD filter) 219bool LLSimpleDispatcher::fireEvent(LLPointer<LLEvent> event, LLSD filter)
220{ 220{
221 std::vector<LLListenerEntry>::iterator itor; 221 std::vector<LLListenerEntry>::iterator itor;
222 LLString filter_string = filter.asString(); 222 std::string filter_string = filter.asString();
223 for (itor=mListeners.begin(); itor!=mListeners.end(); ++itor) 223 for (itor=mListeners.begin(); itor!=mListeners.end(); ++itor)
224 { 224 {
225 LLListenerEntry& entry = *itor; 225 LLListenerEntry& entry = *itor;
diff --git a/linden/indra/llcommon/llfile.cpp b/linden/indra/llcommon/llfile.cpp
index fc0d481..b32437f 100644
--- a/linden/indra/llcommon/llfile.cpp
+++ b/linden/indra/llcommon/llfile.cpp
@@ -32,6 +32,10 @@
32 * $/LicenseInfo$ 32 * $/LicenseInfo$
33 */ 33 */
34 34
35#if LL_WINDOWS
36#include <windows.h>
37#endif
38
35#include "linden_common.h" 39#include "linden_common.h"
36#include "llfile.h" 40#include "llfile.h"
37#include "llstring.h" 41#include "llstring.h"
@@ -40,7 +44,7 @@
40using namespace std; 44using namespace std;
41 45
42// static 46// static
43int LLFile::mkdir(const char* dirname, int perms) 47int LLFile::mkdir(const std::string& dirname, int perms)
44{ 48{
45#if LL_WINDOWS 49#if LL_WINDOWS
46 // permissions are ignored on Windows 50 // permissions are ignored on Windows
@@ -48,12 +52,12 @@ int LLFile::mkdir(const char* dirname, int perms)
48 llutf16string utf16dirname = utf8str_to_utf16str(utf8dirname); 52 llutf16string utf16dirname = utf8str_to_utf16str(utf8dirname);
49 return _wmkdir(utf16dirname.c_str()); 53 return _wmkdir(utf16dirname.c_str());
50#else 54#else
51 return ::mkdir(dirname, (mode_t)perms); 55 return ::mkdir(dirname.c_str(), (mode_t)perms);
52#endif 56#endif
53} 57}
54 58
55// static 59// static
56int LLFile::rmdir(const char* dirname) 60int LLFile::rmdir(const std::string& dirname)
57{ 61{
58#if LL_WINDOWS 62#if LL_WINDOWS
59 // permissions are ignored on Windows 63 // permissions are ignored on Windows
@@ -61,29 +65,29 @@ int LLFile::rmdir(const char* dirname)
61 llutf16string utf16dirname = utf8str_to_utf16str(utf8dirname); 65 llutf16string utf16dirname = utf8str_to_utf16str(utf8dirname);
62 return _wrmdir(utf16dirname.c_str()); 66 return _wrmdir(utf16dirname.c_str());
63#else 67#else
64 return ::rmdir(dirname); 68 return ::rmdir(dirname.c_str());
65#endif 69#endif
66} 70}
67 71
68// static 72// static
69LLFILE* LLFile::fopen(const char* filename, const char* mode) /* Flawfinder: ignore */ 73LLFILE* LLFile::fopen(const std::string& filename, const char* mode) /* Flawfinder: ignore */
70{ 74{
71#if LL_WINDOWS 75#if LL_WINDOWS
72 std::string utf8filename = filename; 76 std::string utf8filename = filename;
73 std::string utf8mode = mode; 77 std::string utf8mode = std::string(mode);
74 llutf16string utf16filename = utf8str_to_utf16str(utf8filename); 78 llutf16string utf16filename = utf8str_to_utf16str(utf8filename);
75 llutf16string utf16mode = utf8str_to_utf16str(utf8mode); 79 llutf16string utf16mode = utf8str_to_utf16str(utf8mode);
76 return _wfopen(utf16filename.c_str(),utf16mode.c_str()); 80 return _wfopen(utf16filename.c_str(),utf16mode.c_str());
77#else 81#else
78 return ::fopen(filename,mode); /* Flawfinder: ignore */ 82 return ::fopen(filename.c_str(),mode); /* Flawfinder: ignore */
79#endif 83#endif
80} 84}
81 85
82LLFILE* LLFile::_fsopen(const char* filename, const char* mode, int sharingFlag) 86LLFILE* LLFile::_fsopen(const std::string& filename, const char* mode, int sharingFlag)
83{ 87{
84#if LL_WINDOWS 88#if LL_WINDOWS
85 std::string utf8filename = filename; 89 std::string utf8filename = filename;
86 std::string utf8mode = mode; 90 std::string utf8mode = std::string(mode);
87 llutf16string utf16filename = utf8str_to_utf16str(utf8filename); 91 llutf16string utf16filename = utf8str_to_utf16str(utf8filename);
88 llutf16string utf16mode = utf8str_to_utf16str(utf8mode); 92 llutf16string utf16mode = utf8str_to_utf16str(utf8mode);
89 return _wfsopen(utf16filename.c_str(),utf16mode.c_str(),sharingFlag); 93 return _wfsopen(utf16filename.c_str(),utf16mode.c_str(),sharingFlag);
@@ -93,18 +97,18 @@ LLFILE* LLFile::_fsopen(const char* filename, const char* mode, int sharingFlag)
93#endif 97#endif
94} 98}
95 99
96int LLFile::remove(const char* filename) 100int LLFile::remove(const std::string& filename)
97{ 101{
98#if LL_WINDOWS 102#if LL_WINDOWS
99 std::string utf8filename = filename; 103 std::string utf8filename = filename;
100 llutf16string utf16filename = utf8str_to_utf16str(utf8filename); 104 llutf16string utf16filename = utf8str_to_utf16str(utf8filename);
101 return _wremove(utf16filename.c_str()); 105 return _wremove(utf16filename.c_str());
102#else 106#else
103 return ::remove(filename); 107 return ::remove(filename.c_str());
104#endif 108#endif
105} 109}
106 110
107int LLFile::rename(const char* filename, const char* newname) 111int LLFile::rename(const std::string& filename, const std::string& newname)
108{ 112{
109#if LL_WINDOWS 113#if LL_WINDOWS
110 std::string utf8filename = filename; 114 std::string utf8filename = filename;
@@ -113,19 +117,63 @@ int LLFile::rename(const char* filename, const char* newname)
113 llutf16string utf16newname = utf8str_to_utf16str(utf8newname); 117 llutf16string utf16newname = utf8str_to_utf16str(utf8newname);
114 return _wrename(utf16filename.c_str(),utf16newname.c_str()); 118 return _wrename(utf16filename.c_str(),utf16newname.c_str());
115#else 119#else
116 return ::rename(filename,newname); 120 return ::rename(filename.c_str(),newname.c_str());
117#endif 121#endif
118} 122}
119 123
120int LLFile::stat(const char* filename, llstat* filestatus) 124int LLFile::stat(const std::string& filename, llstat* filestatus)
121{ 125{
122#if LL_WINDOWS 126#if LL_WINDOWS
123 std::string utf8filename = filename; 127 std::string utf8filename = filename;
124 llutf16string utf16filename = utf8str_to_utf16str(utf8filename); 128 llutf16string utf16filename = utf8str_to_utf16str(utf8filename);
125 return _wstat(utf16filename.c_str(),filestatus); 129 return _wstat(utf16filename.c_str(),filestatus);
126#else 130#else
127 return ::stat(filename,filestatus); 131 return ::stat(filename.c_str(),filestatus);
132#endif
133}
134
135bool LLFile::isdir(const std::string& filename)
136{
137 llstat st;
138
139 return stat(filename, &st) == 0 && S_ISDIR(st.st_mode);
140}
141
142bool LLFile::isfile(const std::string& filename)
143{
144 llstat st;
145
146 return stat(filename, &st) == 0 && S_ISREG(st.st_mode);
147}
148
149const char *LLFile::tmpdir()
150{
151 static std::string utf8path;
152
153 if (utf8path.empty())
154 {
155 char sep;
156#if LL_WINDOWS
157 sep = '\\';
158
159 DWORD len = GetTempPathW(0, L"");
160 llutf16string utf16path;
161 utf16path.resize(len + 1);
162 len = GetTempPathW(static_cast<DWORD>(utf16path.size()), &utf16path[0]);
163 utf8path = utf16str_to_utf8str(utf16path);
164#else
165 sep = '/';
166
167 char *env = getenv("TMPDIR");
168
169 utf8path = env ? env : "/tmp/";
128#endif 170#endif
171 if (utf8path[utf8path.size() - 1] != sep)
172 {
173 utf8path += sep;
174 }
175 }
176 return utf8path.c_str();
129} 177}
130 178
131 179
@@ -133,7 +181,7 @@ int LLFile::stat(const char* filename, llstat* filestatus)
133 181
134#if USE_LLFILESTREAMS 182#if USE_LLFILESTREAMS
135 183
136LLFILE * LLFile::_Fiopen(const char *filename, std::ios::openmode mode,int) // protection currently unused 184LLFILE * LLFile::_Fiopen(const std::string& filename, std::ios::openmode mode,int) // protection currently unused
137{ // open a file 185{ // open a file
138 static const char *mods[] = 186 static const char *mods[] =
139 { // fopen mode strings corresponding to valid[i] 187 { // fopen mode strings corresponding to valid[i]
@@ -202,7 +250,7 @@ void llifstream::close()
202 } 250 }
203} 251}
204 252
205void llifstream::open(const char* _Filename, /* Flawfinder: ignore */ 253void llifstream::open(const std::string& _Filename, /* Flawfinder: ignore */
206 ios_base::openmode _Mode, 254 ios_base::openmode _Mode,
207 int _Prot) 255 int _Prot)
208{ // open a C stream with specified mode 256{ // open a C stream with specified mode
@@ -234,7 +282,7 @@ llifstream::~llifstream()
234 delete _Filebuffer; 282 delete _Filebuffer;
235} 283}
236 284
237llifstream::llifstream(const char *_Filename, 285llifstream::llifstream(const std::string& _Filename,
238 ios_base::openmode _Mode, 286 ios_base::openmode _Mode,
239 int _Prot) 287 int _Prot)
240 : std::basic_istream< char , std::char_traits< char > >(NULL,true),_Filebuffer(NULL),_ShouldClose(false) 288 : std::basic_istream< char , std::char_traits< char > >(NULL,true),_Filebuffer(NULL),_ShouldClose(false)
@@ -253,7 +301,7 @@ bool llofstream::is_open() const
253 return false; 301 return false;
254} 302}
255 303
256void llofstream::open(const char* _Filename, /* Flawfinder: ignore */ 304void llofstream::open(const std::string& _Filename, /* Flawfinder: ignore */
257 ios_base::openmode _Mode, 305 ios_base::openmode _Mode,
258 int _Prot) 306 int _Prot)
259{ // open a C stream with specified mode 307{ // open a C stream with specified mode
@@ -279,7 +327,7 @@ void llofstream::close()
279 } 327 }
280} 328}
281 329
282llofstream::llofstream(const char *_Filename, 330llofstream::llofstream(const std::string& _Filename,
283 std::ios_base::openmode _Mode, 331 std::ios_base::openmode _Mode,
284 int _Prot) 332 int _Prot)
285 : std::basic_ostream<char,std::char_traits < char > >(NULL,true),_Filebuffer(NULL),_ShouldClose(false) 333 : std::basic_ostream<char,std::char_traits < char > >(NULL,true),_Filebuffer(NULL),_ShouldClose(false)
diff --git a/linden/indra/llcommon/llfile.h b/linden/indra/llcommon/llfile.h
index 189edbf..f3e3af5 100644
--- a/linden/indra/llcommon/llfile.h
+++ b/linden/indra/llcommon/llfile.h
@@ -50,31 +50,45 @@ typedef FILE LLFILE;
50#define USE_LLFILESTREAMS 0 50#define USE_LLFILESTREAMS 0
51#endif 51#endif
52 52
53#include <sys/stat.h>
53 54
54#if LL_WINDOWS 55#if LL_WINDOWS
55// windows version of stat function and stat data structure are called _stat 56// windows version of stat function and stat data structure are called _stat
56typedef struct _stat llstat; 57typedef struct _stat llstat;
57#else 58#else
58#include <sys/stat.h>
59typedef struct stat llstat; 59typedef struct stat llstat;
60#endif 60#endif
61 61
62#ifndef S_ISREG
63# define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
64#endif
65
66#ifndef S_ISDIR
67# define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR)
68#endif
69
70#include "llstring.h" // safe char* -> std::string conversion
71
62class LLFile 72class LLFile
63{ 73{
64public: 74public:
65 // All these functions take UTF8 path/filenames. 75 // All these functions take UTF8 path/filenames.
66 static LLFILE* fopen(const char* filename,const char* accessmode); /* Flawfinder: ignore */ 76 static LLFILE* fopen(const std::string& filename,const char* accessmode); /* Flawfinder: ignore */
67 static LLFILE* _fsopen(const char* filename,const char* accessmode,int sharingFlag); 77 static LLFILE* _fsopen(const std::string& filename,const char* accessmode,int sharingFlag);
68 78
69 // perms is a permissions mask like 0777 or 0700. In most cases it will 79 // perms is a permissions mask like 0777 or 0700. In most cases it will
70 // be overridden by the user's umask. It is ignored on Windows. 80 // be overridden by the user's umask. It is ignored on Windows.
71 static int mkdir(const char* filename, int perms = 0700); 81 static int mkdir(const std::string& filename, int perms = 0700);
72 82
73 static int rmdir(const char* filename); 83 static int rmdir(const std::string& filename);
74 static int remove(const char* filename); 84 static int remove(const std::string& filename);
75 static int rename(const char* filename,const char* newname); 85 static int rename(const std::string& filename,const std::string& newname);
76 static int stat(const char* filename,llstat* file_status); 86 static int stat(const std::string& filename,llstat* file_status);
77 static LLFILE * _Fiopen(const char *filename, std::ios::openmode mode,int); // protection currently unused 87 static bool isdir(const std::string& filename);
88 static bool isfile(const std::string& filename);
89 static LLFILE * _Fiopen(const std::string& filename, std::ios::openmode mode,int); // protection currently unused
90
91 static const char * tmpdir();
78}; 92};
79 93
80 94
@@ -93,7 +107,7 @@ public:
93 { // construct unopened 107 { // construct unopened
94 } 108 }
95 109
96 explicit llifstream(const char *_Filename, 110 explicit llifstream(const std::string& _Filename,
97 ios_base::openmode _Mode = ios_base::in, 111 ios_base::openmode _Mode = ios_base::in,
98 int _Prot = (int)ios_base::_Openprot); 112 int _Prot = (int)ios_base::_Openprot);
99 113
@@ -110,7 +124,7 @@ public:
110 return _Filebuffer; 124 return _Filebuffer;
111 } 125 }
112 bool is_open() const; 126 bool is_open() const;
113 void open(const char* _Filename, /* Flawfinder: ignore */ 127 void open(const std::string& _Filename, /* Flawfinder: ignore */
114 ios_base::openmode _Mode = ios_base::in, 128 ios_base::openmode _Mode = ios_base::in,
115 int _Prot = (int)ios_base::_Openprot); 129 int _Prot = (int)ios_base::_Openprot);
116 void close(); 130 void close();
@@ -133,7 +147,7 @@ public:
133 { // construct unopened 147 { // construct unopened
134 } 148 }
135 149
136 explicit llofstream(const char *_Filename, 150 explicit llofstream(const std::string& _Filename,
137 std::ios_base::openmode _Mode = ios_base::out, 151 std::ios_base::openmode _Mode = ios_base::out,
138 int _Prot = (int)std::ios_base::_Openprot); 152 int _Prot = (int)std::ios_base::_Openprot);
139 153
@@ -154,7 +168,7 @@ public:
154 168
155 bool is_open() const; 169 bool is_open() const;
156 170
157 void open(const char *_Filename,ios_base::openmode _Mode = ios_base::out,int _Prot = (int)ios_base::_Openprot); /* Flawfinder: ignore */ 171 void open(const std::string& _Filename,ios_base::openmode _Mode = ios_base::out,int _Prot = (int)ios_base::_Openprot); /* Flawfinder: ignore */
158 172
159 void close(); 173 void close();
160 174
@@ -167,8 +181,45 @@ private:
167 181
168#else 182#else
169//Use standard file streams on non windows platforms 183//Use standard file streams on non windows platforms
170#define llifstream std::ifstream 184//#define llifstream std::ifstream
171#define llofstream std::ofstream 185//#define llofstream std::ofstream
186
187class llifstream : public std::ifstream
188{
189public:
190 llifstream() : std::ifstream()
191 {
192 }
193
194 explicit llifstream(const std::string& _Filename, std::_Ios_Openmode _Mode = in)
195 : std::ifstream(_Filename.c_str(), _Mode)
196 {
197 }
198 void open(const std::string& _Filename, std::_Ios_Openmode _Mode = in) /* Flawfinder: ignore */
199 {
200 std::ifstream::open(_Filename.c_str(), _Mode);
201 }
202};
203
204
205class llofstream : public std::ofstream
206{
207public:
208 llofstream() : std::ofstream()
209 {
210 }
211
212 explicit llofstream(const std::string& _Filename, std::_Ios_Openmode _Mode = out)
213 : std::ofstream(_Filename.c_str(), _Mode)
214 {
215 }
216
217 void open(const std::string& _Filename, std::_Ios_Openmode _Mode = out) /* Flawfinder: ignore */
218 {
219 std::ofstream::open(_Filename.c_str(), _Mode);
220 }
221
222};
172 223
173#endif 224#endif
174 225
diff --git a/linden/indra/llcommon/llfixedbuffer.cpp b/linden/indra/llcommon/llfixedbuffer.cpp
index 776de0d..a3ebae1 100644
--- a/linden/indra/llcommon/llfixedbuffer.cpp
+++ b/linden/indra/llcommon/llfixedbuffer.cpp
@@ -54,7 +54,7 @@ void LLFixedBuffer::clear()
54} 54}
55 55
56 56
57void LLFixedBuffer::addLine(const LLString& utf8line) 57void LLFixedBuffer::addLine(const std::string& utf8line)
58{ 58{
59 LLWString wstring = utf8str_to_wstring(utf8line); 59 LLWString wstring = utf8str_to_wstring(utf8line);
60 LLFixedBuffer::addLine(wstring); 60 LLFixedBuffer::addLine(wstring);
diff --git a/linden/indra/llcommon/llfixedbuffer.h b/linden/indra/llcommon/llfixedbuffer.h
index 06a7f45..1641bee 100644
--- a/linden/indra/llcommon/llfixedbuffer.h
+++ b/linden/indra/llcommon/llfixedbuffer.h
@@ -52,7 +52,7 @@ public:
52 std::deque<S32> mLineLengths; 52 std::deque<S32> mLineLengths;
53 53
54 void clear(); // Clear the buffer, and reset it. 54 void clear(); // Clear the buffer, and reset it.
55 virtual void addLine(const LLString& utf8line); 55 virtual void addLine(const std::string& utf8line);
56 virtual void addLine(const LLWString& line); 56 virtual void addLine(const LLWString& line);
57 57
58 // Get lines currently in the buffer, up to max_size chars, max_length lines 58 // Get lines currently in the buffer, up to max_size chars, max_length lines
diff --git a/linden/indra/llcommon/llframetimer.cpp b/linden/indra/llcommon/llframetimer.cpp
index 96e5014..e4e8a18 100644
--- a/linden/indra/llcommon/llframetimer.cpp
+++ b/linden/indra/llcommon/llframetimer.cpp
@@ -53,7 +53,6 @@ void LLFrameTimer::updateFrameTime()
53 sTotalTime = total_time; 53 sTotalTime = total_time;
54 sTotalSeconds = U64_to_F64(sTotalTime) * USEC_TO_SEC_F64; 54 sTotalSeconds = U64_to_F64(sTotalTime) * USEC_TO_SEC_F64;
55 sFrameTime = U64_to_F64(sTotalTime - sStartTotalTime) * USEC_TO_SEC_F64; 55 sFrameTime = U64_to_F64(sTotalTime - sStartTotalTime) * USEC_TO_SEC_F64;
56 sFrameCount++;
57} 56}
58 57
59void LLFrameTimer::start() 58void LLFrameTimer::start()
diff --git a/linden/indra/llcommon/llframetimer.h b/linden/indra/llcommon/llframetimer.h
index 11c4cfc..d13018f 100644
--- a/linden/indra/llcommon/llframetimer.h
+++ b/linden/indra/llcommon/llframetimer.h
@@ -67,10 +67,14 @@ public:
67 return sTotalSeconds; 67 return sTotalSeconds;
68 } 68 }
69 69
70 // Call this method once per frame to update the current frame time. 70 // Call this method once per frame to update the current frame time. This is actually called
71 // at some other times as well
71 static void updateFrameTime(); 72 static void updateFrameTime();
72 73
73 static S32 getFrameCount() { return sFrameCount; } 74 // Call this method once, and only once, per frame to update the current frame count.
75 static void updateFrameCount() { sFrameCount++; }
76
77 static U32 getFrameCount() { return sFrameCount; }
74 78
75 static F32 getFrameDeltaTimeF32(); 79 static F32 getFrameDeltaTimeF32();
76 80
diff --git a/linden/indra/llcommon/llhash.h b/linden/indra/llcommon/llhash.h
index 716d9df..e259a11 100644
--- a/linden/indra/llcommon/llhash.h
+++ b/linden/indra/llcommon/llhash.h
@@ -38,7 +38,9 @@
38#include <hash_map> 38#include <hash_map>
39#include <algorithm> 39#include <algorithm>
40#elif LL_DARWIN || LL_LINUX 40#elif LL_DARWIN || LL_LINUX
41# if GCC_VERSION >= 30400 // gcc 3.4 and up 41# if GCC_VERSION >= 40300 // gcc 4.3 and up
42# include <backward/hashtable.h>
43# elif GCC_VERSION >= 30400 // gcc 3.4 and up
42# include <ext/hashtable.h> 44# include <ext/hashtable.h>
43# elif __GNUC__ >= 3 45# elif __GNUC__ >= 3
44# include <ext/stl_hashtable.h> 46# include <ext/stl_hashtable.h>
diff --git a/linden/indra/llcommon/llheartbeat.cpp b/linden/indra/llcommon/llheartbeat.cpp
index 13bcd46..b67d3f2 100644
--- a/linden/indra/llcommon/llheartbeat.cpp
+++ b/linden/indra/llcommon/llheartbeat.cpp
@@ -72,8 +72,13 @@ LLHeartbeat::rawSend()
72 if (mSuppressed) 72 if (mSuppressed)
73 return 0; // Pretend we succeeded. 73 return 0; // Pretend we succeeded.
74 74
75 int result;
76#ifndef LL_DARWIN
75 union sigval dummy; 77 union sigval dummy;
76 int result = sigqueue(getppid(), LL_HEARTBEAT_SIGNAL, dummy); 78 result = sigqueue(getppid(), LL_HEARTBEAT_SIGNAL, dummy);
79#else
80 result = kill(getppid(), LL_HEARTBEAT_SIGNAL);
81#endif
77 if (result == 0) 82 if (result == 0)
78 return 0; // success 83 return 0; // success
79 84
diff --git a/linden/indra/llcommon/llindraconfigfile.cpp b/linden/indra/llcommon/llindraconfigfile.cpp
index 7ef1a9b..60b498d 100644
--- a/linden/indra/llcommon/llindraconfigfile.cpp
+++ b/linden/indra/llcommon/llindraconfigfile.cpp
@@ -81,7 +81,7 @@ void LLIndraConfigFile::loadFile()
81 LLSD config; 81 LLSD config;
82 82
83 { 83 {
84 llifstream file(filename().c_str()); 84 llifstream file(filename());
85 if (file.is_open()) 85 if (file.is_open())
86 { 86 {
87 LLSDSerialize::fromXML(config, file); 87 LLSDSerialize::fromXML(config, file);
diff --git a/linden/indra/llcommon/llkeythrottle.h b/linden/indra/llcommon/llkeythrottle.h
index 8314269..eb1519a 100644
--- a/linden/indra/llcommon/llkeythrottle.h
+++ b/linden/indra/llcommon/llkeythrottle.h
@@ -55,33 +55,40 @@ class LLKeyThrottleImpl
55protected: 55protected:
56 struct Entry { 56 struct Entry {
57 U32 count; 57 U32 count;
58 BOOL blocked; 58 bool blocked;
59 59
60 Entry() : count(0), blocked(FALSE) { } 60 Entry() : count(0), blocked(false) { }
61 }; 61 };
62 62
63 typedef std::map<T, Entry> EntryMap; 63 typedef std::map<T, Entry> EntryMap;
64 64
65 EntryMap * prevMap; 65 EntryMap* prevMap;
66 EntryMap * currMap; 66 EntryMap* currMap;
67 67
68 U32 countLimit; 68 U32 countLimit;
69 // maximum number of keys allowed per interval 69 // maximum number of keys allowed per interval
70 70
71 U64 interval_usec; 71 U64 intervalLength; // each map covers this time period (usec or frame number)
72 // each map covers this time period 72 U64 startTime; // start of the time period (usec or frame number)
73 U64 start_usec;
74 // currMap started counting at this time 73 // currMap started counting at this time
75 // prevMap covers the previous interval 74 // prevMap covers the previous interval
76 75
77 LLKeyThrottleImpl() : prevMap(0), currMap(0), 76 LLKeyThrottleImpl() :
78 countLimit(0), interval_usec(0), 77 prevMap(NULL),
79 start_usec(0) { }; 78 currMap(NULL),
79 countLimit(0),
80 intervalLength(1),
81 startTime(0)
82 {}
80 83
81 static U64 getTime() 84 static U64 getTime()
82 { 85 {
83 return LLFrameTimer::getTotalTime(); 86 return LLFrameTimer::getTotalTime();
84 } 87 }
88 static U64 getFrame() // Return the current frame number
89 {
90 return (U64) LLFrameTimer::getFrameCount();
91 }
85}; 92};
86 93
87 94
@@ -89,17 +96,12 @@ template< class T >
89class LLKeyThrottle 96class LLKeyThrottle
90{ 97{
91public: 98public:
92 LLKeyThrottle(U32 limit, F32 interval) 99 // @param realtime = FALSE for frame-based throttle, TRUE for usec
100 // real-time throttle
101 LLKeyThrottle(U32 limit, F32 interval, BOOL realtime = TRUE)
93 : m(* new LLKeyThrottleImpl<T>) 102 : m(* new LLKeyThrottleImpl<T>)
94 { 103 {
95 // limit is the maximum number of keys 104 setParameters( limit, interval, realtime );
96 // allowed per interval (in seconds)
97 m.countLimit = limit;
98 m.interval_usec = (U64)(interval * USEC_PER_SEC);
99 m.start_usec = LLKeyThrottleImpl<T>::getTime();
100
101 m.prevMap = new typename LLKeyThrottleImpl<T>::EntryMap;
102 m.currMap = new typename LLKeyThrottleImpl<T>::EntryMap;
103 } 105 }
104 106
105 ~LLKeyThrottle() 107 ~LLKeyThrottle()
@@ -118,18 +120,26 @@ public:
118 // call each time the key wants use 120 // call each time the key wants use
119 State noteAction(const T& id, S32 weight = 1) 121 State noteAction(const T& id, S32 weight = 1)
120 { 122 {
121 U64 now = LLKeyThrottleImpl<T>::getTime(); 123 U64 now = 0;
124 if ( mIsRealtime )
125 {
126 now = LLKeyThrottleImpl<T>::getTime();
127 }
128 else
129 {
130 now = LLKeyThrottleImpl<T>::getFrame();
131 }
122 132
123 if (now >= (m.start_usec + m.interval_usec)) 133 if (now >= (m.startTime + m.intervalLength))
124 { 134 {
125 if (now < (m.start_usec + 2 * m.interval_usec)) 135 if (now < (m.startTime + 2 * m.intervalLength))
126 { 136 {
127 // prune old data 137 // prune old data
128 delete m.prevMap; 138 delete m.prevMap;
129 m.prevMap = m.currMap; 139 m.prevMap = m.currMap;
130 m.currMap = new typename LLKeyThrottleImpl<T>::EntryMap; 140 m.currMap = new typename LLKeyThrottleImpl<T>::EntryMap;
131 141
132 m.start_usec += m.interval_usec; 142 m.startTime += m.intervalLength;
133 } 143 }
134 else 144 else
135 { 145 {
@@ -139,12 +149,12 @@ public:
139 m.prevMap = new typename LLKeyThrottleImpl<T>::EntryMap; 149 m.prevMap = new typename LLKeyThrottleImpl<T>::EntryMap;
140 m.currMap = new typename LLKeyThrottleImpl<T>::EntryMap; 150 m.currMap = new typename LLKeyThrottleImpl<T>::EntryMap;
141 151
142 m.start_usec = now; 152 m.startTime = now;
143 } 153 }
144 } 154 }
145 155
146 U32 prevCount = 0; 156 U32 prevCount = 0;
147 BOOL prevBlocked = FALSE; 157 bool prevBlocked = false;
148 158
149 typename LLKeyThrottleImpl<T>::EntryMap::const_iterator prev = m.prevMap->find(id); 159 typename LLKeyThrottleImpl<T>::EntryMap::const_iterator prev = m.prevMap->find(id);
150 if (prev != m.prevMap->end()) 160 if (prev != m.prevMap->end())
@@ -166,7 +176,7 @@ public:
166 // (now) time. 176 // (now) time.
167 177
168 // compute current, windowed rate 178 // compute current, windowed rate
169 F64 timeInCurrent = ((F64)(now - m.start_usec) / m.interval_usec); 179 F64 timeInCurrent = ((F64)(now - m.startTime) / m.intervalLength);
170 F64 averageCount = curr.count + prevCount * (1.0 - timeInCurrent); 180 F64 averageCount = curr.count + prevCount * (1.0 - timeInCurrent);
171 181
172 curr.blocked |= averageCount > m.countLimit; 182 curr.blocked |= averageCount > m.countLimit;
@@ -193,17 +203,17 @@ public:
193 noteAction(id); 203 noteAction(id);
194 typename LLKeyThrottleImpl<T>::Entry& curr = (*m.currMap)[id]; 204 typename LLKeyThrottleImpl<T>::Entry& curr = (*m.currMap)[id];
195 curr.count = llmax(m.countLimit, curr.count); 205 curr.count = llmax(m.countLimit, curr.count);
196 curr.blocked = TRUE; 206 curr.blocked = true;
197 } 207 }
198 208
199 // returns TRUE if key is blocked 209 // returns true if key is blocked
200 BOOL isThrottled(const T& id) const 210 bool isThrottled(const T& id) const
201 { 211 {
202 if (m.currMap->empty() 212 if (m.currMap->empty()
203 && m.prevMap->empty()) 213 && m.prevMap->empty())
204 { 214 {
205 // most of the time we'll fall in here 215 // most of the time we'll fall in here
206 return FALSE; 216 return false;
207 } 217 }
208 218
209 // NOTE, we ignore the case where id is in the map but the map is stale. 219 // NOTE, we ignore the case where id is in the map but the map is stale.
@@ -221,11 +231,49 @@ public:
221 { 231 {
222 return entry->second.blocked; 232 return entry->second.blocked;
223 } 233 }
224 return FALSE; 234 return false;
235 }
236
237 // Get the throttling parameters
238 void getParameters( U32 & out_limit, F32 & out_interval, BOOL & out_realtime )
239 {
240 out_limit = m.countLimit;
241 out_interval = m.intervalLength;
242 out_realtime = mIsRealtime;
243 }
244
245 // Set the throttling behavior
246 void setParameters( U32 limit, F32 interval, BOOL realtime )
247 {
248 // limit is the maximum number of keys
249 // allowed per interval (in seconds or frames)
250 mIsRealtime = realtime;
251 m.countLimit = limit;
252 if ( mIsRealtime )
253 {
254 m.intervalLength = (U64)(interval * USEC_PER_SEC);
255 m.startTime = LLKeyThrottleImpl<T>::getTime();
256 }
257 else
258 {
259 m.intervalLength = (U64)interval;
260 m.startTime = LLKeyThrottleImpl<T>::getFrame();
261 }
262
263 if ( m.intervalLength == 0 )
264 { // Don't allow zero intervals
265 m.intervalLength = 1;
266 }
267
268 delete m.prevMap;
269 m.prevMap = new typename LLKeyThrottleImpl<T>::EntryMap;
270 delete m.currMap;
271 m.currMap = new typename LLKeyThrottleImpl<T>::EntryMap;
225 } 272 }
226 273
227protected: 274protected:
228 LLKeyThrottleImpl<T>& m; 275 LLKeyThrottleImpl<T>& m;
276 BOOL mIsRealtime; // TRUE to be time based (default), FALSE for frame based
229}; 277};
230 278
231#endif 279#endif
diff --git a/linden/indra/llcommon/llliveappconfig.cpp b/linden/indra/llcommon/llliveappconfig.cpp
index ad11987..a11f5b0 100644
--- a/linden/indra/llcommon/llliveappconfig.cpp
+++ b/linden/indra/llcommon/llliveappconfig.cpp
@@ -51,7 +51,7 @@ void LLLiveAppConfig::loadFile()
51{ 51{
52 llinfos << "LLLiveAppConfig::loadFile(): reading from " 52 llinfos << "LLLiveAppConfig::loadFile(): reading from "
53 << filename() << llendl; 53 << filename() << llendl;
54 llifstream file(filename().c_str()); 54 llifstream file(filename());
55 LLSD config; 55 LLSD config;
56 if (file.is_open()) 56 if (file.is_open())
57 { 57 {
diff --git a/linden/indra/llcommon/lllivefile.cpp b/linden/indra/llcommon/lllivefile.cpp
index 6e027ef..8ac6bb4 100644
--- a/linden/indra/llcommon/lllivefile.cpp
+++ b/linden/indra/llcommon/lllivefile.cpp
@@ -93,7 +93,7 @@ bool LLLiveFile::Impl::check()
93 93
94 // Stat the file to see if it exists and when it was last modified. 94 // Stat the file to see if it exists and when it was last modified.
95 llstat stat_data; 95 llstat stat_data;
96 int res = LLFile::stat(mFilename.c_str(), &stat_data); 96 int res = LLFile::stat(mFilename, &stat_data);
97 97
98 if (res) 98 if (res)
99 { 99 {
diff --git a/linden/indra/llcommon/lllslconstants.h b/linden/indra/llcommon/lllslconstants.h
index 508fb42..24120a2 100644
--- a/linden/indra/llcommon/lllslconstants.h
+++ b/linden/indra/llcommon/lllslconstants.h
@@ -126,6 +126,9 @@ const S32 LSL_PRIM_SCULPT_TYPE_SPHERE = 1;
126const S32 LSL_PRIM_SCULPT_TYPE_TORUS = 2; 126const S32 LSL_PRIM_SCULPT_TYPE_TORUS = 2;
127const S32 LSL_PRIM_SCULPT_TYPE_PLANE = 3; 127const S32 LSL_PRIM_SCULPT_TYPE_PLANE = 3;
128const S32 LSL_PRIM_SCULPT_TYPE_CYLINDER = 4; 128const S32 LSL_PRIM_SCULPT_TYPE_CYLINDER = 4;
129const S32 LSL_PRIM_SCULPT_TYPE_MASK = 7;
130const S32 LSL_PRIM_SCULPT_FLAG_INVERT = 64;
131const S32 LSL_PRIM_SCULPT_FLAG_MIRROR = 128;
129 132
130const S32 LSL_ALL_SIDES = -1; 133const S32 LSL_ALL_SIDES = -1;
131const S32 LSL_LINK_ROOT = 1; 134const S32 LSL_LINK_ROOT = 1;
@@ -181,4 +184,7 @@ const S32 OBJECT_OWNER = 6;
181const S32 OBJECT_GROUP = 7; 184const S32 OBJECT_GROUP = 7;
182const S32 OBJECT_CREATOR = 8; 185const S32 OBJECT_CREATOR = 8;
183 186
187// llTextBox() magic token string - yes this is a hack. sue me.
188const std::string TEXTBOX_MAGIC_TOKEN = "!!llTextBox!!";
189
184#endif 190#endif
diff --git a/linden/indra/llcommon/llmd5.cpp b/linden/indra/llcommon/llmd5.cpp
new file mode 100644
index 0000000..a0ac92f
--- /dev/null
+++ b/linden/indra/llcommon/llmd5.cpp
@@ -0,0 +1,531 @@
1/**
2 * @file llmd5.cpp
3 *
4 * $LicenseInfo:firstyear=2001&license=viewergpl$
5 *
6 * Copyright (c) 2001-2008, Linden Research, Inc.
7 *
8 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement
12 * ("Other License"), formally executed by you and Linden Lab. Terms of
13 * the GPL can be found in doc/GPL-license.txt in this distribution, or
14 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
15 *
16 * There are special exceptions to the terms and conditions of the GPL as
17 * it is applied to this Source Code. View the full text of the exception
18 * in the file doc/FLOSS-exception.txt in this software distribution, or
19 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
20 *
21 * By copying, modifying or distributing this software, you acknowledge
22 * that you have read and understood your obligations described above,
23 * and agree to abide by those obligations.
24 *
25 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
26 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
27 * COMPLETENESS OR PERFORMANCE.
28 * $/LicenseInfo$
29 */
30
31// llMD5.CC - source code for the C++/object oriented translation and
32// modification of MD5.
33//
34// Adapted to Linden Lab by Frank Filipanits, 6/25/2002
35// Fixed potential memory leak, James Cook, 6/27/2002
36
37// Translation and modification (c) 1995 by Mordechai T. Abzug
38
39// This translation/ modification is provided "as is," without express or
40// implied warranty of any kind.
41
42// The translator/ modifier does not claim (1) that MD5 will do what you think
43// it does; (2) that this translation/ modification is accurate; or (3) that
44// this software is "merchantible." (Language for this disclaimer partially
45// copied from the disclaimer below).
46
47/* based on:
48
49 MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
50 MDDRIVER.C - test driver for MD2, MD4 and MD5
51
52
53 Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
54rights reserved.
55
56License to copy and use this software is granted provided that it
57is identified as the "RSA Data Security, Inc. MD5 Message-Digest
58Algorithm" in all material mentioning or referencing this software
59or this function.
60
61License is also granted to make and use derivative works provided
62that such works are identified as "derived from the RSA Data
63Security, Inc. MD5 Message-Digest Algorithm" in all material
64mentioning or referencing the derived work.
65
66RSA Data Security, Inc. makes no representations concerning either
67the merchantability of this software or the suitability of this
68software for any particular purpose. It is provided "as is"
69without express or implied warranty of any kind.
70
71These notices must be retained in any copies of any part of this
72documentation and/or software.
73
74 */
75
76
77
78
79
80#include "linden_common.h"
81
82#include "llmd5.h"
83
84#include <cassert>
85
86// how many bytes to grab at a time when checking files
87const int LLMD5::BLOCK_LEN = 4096;
88
89
90// LLMD5 simple initialization method
91
92LLMD5::LLMD5()
93{
94 init();
95}
96
97
98
99
100// MD5 block update operation. Continues an MD5 message-digest
101// operation, processing another message block, and updating the
102// context.
103
104void LLMD5::update (const uint1 *input, const uint4 input_length) {
105
106 uint4 input_index, buffer_index;
107 uint4 buffer_space; // how much space is left in buffer
108
109 if (finalized){ // so we can't update!
110 std::cerr << "LLMD5::update: Can't update a finalized digest!" << std::endl;
111 return;
112 }
113
114 // Compute number of bytes mod 64
115 buffer_index = (unsigned int)((count[0] >> 3) & 0x3F);
116
117 // Update number of bits
118 if ( (count[0] += ((uint4) input_length << 3))<((uint4) input_length << 3) )
119 count[1]++;
120
121 count[1] += ((uint4)input_length >> 29);
122
123
124 buffer_space = 64 - buffer_index; // how much space is left in buffer
125
126 // Transform as many times as possible.
127 if (input_length >= buffer_space) { // ie. we have enough to fill the buffer
128 // fill the rest of the buffer and transform
129 memcpy( /* Flawfinder: ignore */
130 buffer + buffer_index,
131 input,
132 buffer_space);
133 transform (buffer);
134
135 // now, transform each 64-byte piece of the input, bypassing the buffer
136 if (input == NULL || input_length == 0){
137 std::cerr << "LLMD5::update: Invalid input!" << std::endl;
138 return;
139 }
140
141 for (input_index = buffer_space; input_index + 63 < input_length;
142 input_index += 64)
143 transform (input+input_index);
144
145 buffer_index = 0; // so we can buffer remaining
146 }
147 else
148 input_index=0; // so we can buffer the whole input
149
150
151 // and here we do the buffering:
152 memcpy(buffer+buffer_index, input+input_index, input_length-input_index); /* Flawfinder: ignore */
153}
154
155
156
157// MD5 update for files.
158// Like above, except that it works on files (and uses above as a primitive.)
159
160void LLMD5::update(FILE* file){
161
162 unsigned char buffer[BLOCK_LEN]; /* Flawfinder: ignore */
163 int len;
164
165 while ( (len=(int)fread(buffer, 1, BLOCK_LEN, file)) )
166 update(buffer, len);
167
168 fclose (file);
169
170}
171
172
173
174
175
176
177// MD5 update for istreams.
178// Like update for files; see above.
179
180void LLMD5::update(std::istream& stream){
181
182 unsigned char buffer[BLOCK_LEN]; /* Flawfinder: ignore */
183 int len;
184
185 while (stream.good()){
186 stream.read( (char*)buffer, BLOCK_LEN); /* Flawfinder: ignore */ // note that return value of read is unusable.
187 len=stream.gcount();
188 update(buffer, len);
189 }
190
191}
192
193
194
195
196
197// MD5 finalization. Ends an MD5 message-digest operation, writing the
198// the message digest and zeroizing the context.
199
200
201void LLMD5::finalize (){
202
203 unsigned char bits[8]; /* Flawfinder: ignore */
204 unsigned int index, padLen;
205 static uint1 PADDING[64]={
206 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
207 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
208 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
209 };
210
211 if (finalized){
212 std::cerr << "LLMD5::finalize: Already finalized this digest!" << std::endl;
213 return;
214 }
215
216 // Save number of bits
217 encode (bits, count, 8);
218
219 // Pad out to 56 mod 64.
220 index = (uint4) ((count[0] >> 3) & 0x3f);
221 padLen = (index < 56) ? (56 - index) : (120 - index);
222 update (PADDING, padLen);
223
224 // Append length (before padding)
225 update (bits, 8);
226
227 // Store state in digest
228 encode (digest, state, 16);
229
230 // Zeroize sensitive information
231 memset (buffer, 0, sizeof(*buffer));
232
233 finalized=1;
234
235}
236
237
238
239
240LLMD5::LLMD5(FILE *file){
241
242 init(); // must be called be all constructors
243 update(file);
244 finalize ();
245}
246
247
248
249
250LLMD5::LLMD5(std::istream& stream){
251
252 init(); // must called by all constructors
253 update (stream);
254 finalize();
255}
256
257// Digest a string of the format ("%s:%i" % (s, number))
258LLMD5::LLMD5(const unsigned char *string, const unsigned int number)
259{
260 const char *colon = ":";
261 char tbuf[16]; /* Flawfinder: ignore */
262 init();
263 update(string, (U32)strlen((const char *) string)); /* Flawfinder: ignore */
264 update((const unsigned char *) colon, (U32)strlen(colon)); /* Flawfinder: ignore */
265 snprintf(tbuf, sizeof(tbuf), "%i", number); /* Flawfinder: ignore */
266 update((const unsigned char *) tbuf, (U32)strlen(tbuf)); /* Flawfinder: ignore */
267 finalize();
268}
269
270// Digest a string
271LLMD5::LLMD5(const unsigned char *s)
272{
273 init();
274 update(s, (U32)strlen((const char *) s)); /* Flawfinder: ignore */
275 finalize();
276}
277
278void LLMD5::raw_digest(unsigned char *s)
279{
280 if (!finalized)
281 {
282 std::cerr << "LLMD5::raw_digest: Can't get digest if you haven't "<<
283 "finalized the digest!" << std::endl;
284 s[0] = '\0';
285 return;
286 }
287
288 memcpy(s, digest, 16); /* Flawfinder: ignore */
289 return;
290}
291
292
293
294void LLMD5::hex_digest(char *s)
295{
296 int i;
297
298 if (!finalized)
299 {
300 std::cerr << "LLMD5::hex_digest: Can't get digest if you haven't "<<
301 "finalized the digest!" <<std::endl;
302 s[0] = '\0';
303 return;
304 }
305
306 for (i=0; i<16; i++)
307 {
308 sprintf(s+i*2, "%02x", digest[i]); /* Flawfinder: ignore */
309 }
310
311 s[32]='\0';
312
313 return;
314}
315
316
317
318
319
320std::ostream& operator<<(std::ostream &stream, LLMD5 context)
321{
322 char s[33]; /* Flawfinder: ignore */
323 context.hex_digest(s);
324 stream << s;
325 return stream;
326}
327
328
329
330
331// PRIVATE METHODS:
332
333
334
335void LLMD5::init(){
336 finalized=0; // we just started!
337
338 // Nothing counted, so count=0
339 count[0] = 0;
340 count[1] = 0;
341
342 // Load magic initialization constants.
343 state[0] = 0x67452301;
344 state[1] = 0xefcdab89;
345 state[2] = 0x98badcfe;
346 state[3] = 0x10325476;
347}
348
349
350
351// Constants for MD5Transform routine.
352// Although we could use C++ style constants, defines are actually better,
353// since they let us easily evade scope clashes.
354
355#define S11 7
356#define S12 12
357#define S13 17
358#define S14 22
359#define S21 5
360#define S22 9
361#define S23 14
362#define S24 20
363#define S31 4
364#define S32 11
365#define S33 16
366#define S34 23
367#define S41 6
368#define S42 10
369#define S43 15
370#define S44 21
371
372// #defines are faster then inline, etc because the compiler is not required to inline.
373// Timing tests prove that this works ~40% faster on win with msvc++2k3 over using static inline.
374
375/* F, G, H and I are basic MD5 functions.
376 */
377#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
378#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
379#define H(x, y, z) ((x) ^ (y) ^ (z))
380#define I(x, y, z) ((y) ^ ((x) | (~z)))
381
382/* ROTATE_LEFT rotates x left n bits.
383 */
384#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
385
386/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
387Rotation is separate from addition to prevent recomputation.
388 */
389#define FF(a, b, c, d, x, s, ac) { \
390 (a) += F ((b), (c), (d)) + (x) + (U32)(ac); \
391 (a) = ROTATE_LEFT ((a), (s)); \
392 (a) += (b); \
393 }
394#define GG(a, b, c, d, x, s, ac) { \
395 (a) += G ((b), (c), (d)) + (x) + (U32)(ac); \
396 (a) = ROTATE_LEFT ((a), (s)); \
397 (a) += (b); \
398 }
399#define HH(a, b, c, d, x, s, ac) { \
400 (a) += H ((b), (c), (d)) + (x) + (U32)(ac); \
401 (a) = ROTATE_LEFT ((a), (s)); \
402 (a) += (b); \
403 }
404#define II(a, b, c, d, x, s, ac) { \
405 (a) += I ((b), (c), (d)) + (x) + (U32)(ac); \
406 (a) = ROTATE_LEFT ((a), (s)); \
407 (a) += (b); \
408 }
409
410
411
412// LLMD5 basic transformation. Transforms state based on block.
413void LLMD5::transform (const U8 block[64]){
414
415 uint4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
416
417 decode (x, block, 64);
418
419 assert(!finalized); // not just a user error, since the method is private
420
421 /* Round 1 */
422 FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
423 FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
424 FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
425 FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
426 FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
427 FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
428 FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
429 FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
430 FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
431 FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
432 FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
433 FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
434 FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
435 FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
436 FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
437 FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
438
439 /* Round 2 */
440 GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
441 GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
442 GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
443 GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
444 GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
445 GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
446 GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
447 GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
448 GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
449 GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
450 GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
451 GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
452 GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
453 GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
454 GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
455 GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
456
457 /* Round 3 */
458 HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
459 HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
460 HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
461 HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
462 HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
463 HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
464 HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
465 HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
466 HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
467 HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
468 HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
469 HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
470 HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
471 HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
472 HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
473 HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
474
475 /* Round 4 */
476 II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
477 II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
478 II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
479 II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
480 II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
481 II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
482 II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
483 II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
484 II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
485 II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
486 II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
487 II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
488 II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
489 II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
490 II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
491 II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
492
493 state[0] += a;
494 state[1] += b;
495 state[2] += c;
496 state[3] += d;
497
498 // Zeroize sensitive information.
499 memset ( (uint1 *) x, 0, sizeof(x));
500
501}
502
503
504
505// Encodes input (UINT4) into output (unsigned char). Assumes len is
506// a multiple of 4.
507void LLMD5::encode (uint1 *output, const uint4 *input, const uint4 len) {
508
509 unsigned int i, j;
510
511 for (i = 0, j = 0; j < len; i++, j += 4) {
512 output[j] = (uint1) (input[i] & 0xff);
513 output[j+1] = (uint1) ((input[i] >> 8) & 0xff);
514 output[j+2] = (uint1) ((input[i] >> 16) & 0xff);
515 output[j+3] = (uint1) ((input[i] >> 24) & 0xff);
516 }
517}
518
519
520
521
522// Decodes input (unsigned char) into output (UINT4). Assumes len is
523// a multiple of 4.
524void LLMD5::decode (uint4 *output, const uint1 *input, const uint4 len){
525
526 unsigned int i, j;
527
528 for (i = 0, j = 0; j < len; i++, j += 4)
529 output[i] = ((uint4)input[j]) | (((uint4)input[j+1]) << 8) |
530 (((uint4)input[j+2]) << 16) | (((uint4)input[j+3]) << 24);
531}
diff --git a/linden/indra/llcommon/llmd5.h b/linden/indra/llcommon/llmd5.h
new file mode 100644
index 0000000..6d21b31
--- /dev/null
+++ b/linden/indra/llcommon/llmd5.h
@@ -0,0 +1,133 @@
1/**
2 * @file llmd5.h
3 *
4 * $LicenseInfo:firstyear=2001&license=viewergpl$
5 *
6 * Copyright (c) 2001-2008, Linden Research, Inc.
7 *
8 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement
12 * ("Other License"), formally executed by you and Linden Lab. Terms of
13 * the GPL can be found in doc/GPL-license.txt in this distribution, or
14 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
15 *
16 * There are special exceptions to the terms and conditions of the GPL as
17 * it is applied to this Source Code. View the full text of the exception
18 * in the file doc/FLOSS-exception.txt in this software distribution, or
19 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
20 *
21 * By copying, modifying or distributing this software, you acknowledge
22 * that you have read and understood your obligations described above,
23 * and agree to abide by those obligations.
24 *
25 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
26 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
27 * COMPLETENESS OR PERFORMANCE.
28 * $/LicenseInfo$
29 */
30
31#ifndef LL_LLMD5_H
32#define LL_LLMD5_H
33
34// LLMD5.CC - source code for the C++/object oriented translation and
35// modification of MD5.
36
37// Translation and modification (c) 1995 by Mordechai T. Abzug
38
39// This translation/ modification is provided "as is," without express or
40// implied warranty of any kind.
41
42// The translator/ modifier does not claim (1) that MD5 will do what you think
43// it does; (2) that this translation/ modification is accurate; or (3) that
44// this software is "merchantible." (Language for this disclaimer partially
45// copied from the disclaimer below).
46
47/* based on:
48
49 MD5.H - header file for MD5C.C
50 MDDRIVER.C - test driver for MD2, MD4 and MD5
51
52 Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
53rights reserved.
54
55License to copy and use this software is granted provided that it
56is identified as the "RSA Data Security, Inc. MD5 Message-Digest
57Algorithm" in all material mentioning or referencing this software
58or this function.
59
60License is also granted to make and use derivative works provided
61that such works are identified as "derived from the RSA Data
62Security, Inc. MD5 Message-Digest Algorithm" in all material
63mentioning or referencing the derived work.
64
65RSA Data Security, Inc. makes no representations concerning either
66the merchantability of this software or the suitability of this
67software for any particular purpose. It is provided "as is"
68without express or implied warranty of any kind.
69
70These notices must be retained in any copies of any part of this
71documentation and/or software.
72
73*/
74
75// use for the raw digest output
76const int MD5RAW_BYTES = 16;
77
78// use for outputting hex digests
79const int MD5HEX_STR_SIZE = 33; // char hex[MD5HEX_STR_SIZE]; with null
80const int MD5HEX_STR_BYTES = 32; // message system fixed size
81
82class LLMD5 {
83// first, some types:
84 typedef unsigned int uint4; // assumes integer is 4 words long
85 typedef unsigned short int uint2; // assumes short integer is 2 words long
86 typedef unsigned char uint1; // assumes char is 1 word long
87
88// how many bytes to grab at a time when checking files
89 static const int BLOCK_LEN;
90
91public:
92// methods for controlled operation:
93 LLMD5 (); // simple initializer
94 void update (const uint1 *input, const uint4 input_length);
95 void update (std::istream& stream);
96 void update (FILE *file);
97 void finalize ();
98
99// constructors for special circumstances. All these constructors finalize
100// the MD5 context.
101 LLMD5 (const unsigned char *string); // digest string, finalize
102 LLMD5 (std::istream& stream); // digest stream, finalize
103 LLMD5 (FILE *file); // digest file, close, finalize
104 LLMD5 (const unsigned char *string, const unsigned int number);
105
106// methods to acquire finalized result
107 void raw_digest(unsigned char *array); // provide 16-byte array for binary data
108 void hex_digest(char *string); // provide 33-byte array for ascii-hex string
109 friend std::ostream& operator<< (std::ostream&, LLMD5 context);
110
111
112
113private:
114
115
116// next, the private data:
117 uint4 state[4];
118 uint4 count[2]; // number of *bits*, mod 2^64
119 uint1 buffer[64]; // input buffer
120 uint1 digest[16];
121 uint1 finalized;
122
123// last, the private methods, mostly static:
124 void init (); // called by all constructors
125 void transform (const uint1 *buffer); // does the real update work. Note
126 // that length is implied to be 64.
127
128 static void encode (uint1 *dest, const uint4 *src, const uint4 length);
129 static void decode (uint4 *dest, const uint1 *src, const uint4 length);
130
131};
132
133#endif // LL_LLMD5_H
diff --git a/linden/indra/llcommon/llmemory.cpp b/linden/indra/llcommon/llmemory.cpp
index 9b6f893..3fec50f 100644
--- a/linden/indra/llcommon/llmemory.cpp
+++ b/linden/indra/llcommon/llmemory.cpp
@@ -335,7 +335,6 @@ U64 getCurrentRSS()
335U64 getCurrentRSS() 335U64 getCurrentRSS()
336{ 336{
337 U64 residentSize = 0; 337 U64 residentSize = 0;
338
339 task_basic_info_data_t basicInfo; 338 task_basic_info_data_t basicInfo;
340 mach_msg_type_number_t basicInfoCount = TASK_BASIC_INFO_COUNT; 339 mach_msg_type_number_t basicInfoCount = TASK_BASIC_INFO_COUNT;
341 if (task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&basicInfo, &basicInfoCount) == KERN_SUCCESS) 340 if (task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&basicInfo, &basicInfoCount) == KERN_SUCCESS)
diff --git a/linden/indra/llcommon/llmemtype.h b/linden/indra/llcommon/llmemtype.h
index 4a4702b..bd80930 100644
--- a/linden/indra/llcommon/llmemtype.h
+++ b/linden/indra/llcommon/llmemtype.h
@@ -80,6 +80,7 @@ public:
80 MTYPE_SPACE_PARTITION, 80 MTYPE_SPACE_PARTITION,
81 MTYPE_PIPELINE, 81 MTYPE_PIPELINE,
82 MTYPE_AVATAR, 82 MTYPE_AVATAR,
83 MTYPE_AVATAR_MESH,
83 MTYPE_PARTICLES, 84 MTYPE_PARTICLES,
84 MTYPE_REGIONS, 85 MTYPE_REGIONS,
85 MTYPE_INVENTORY, 86 MTYPE_INVENTORY,
diff --git a/linden/indra/llcommon/llpreprocessor.h b/linden/indra/llcommon/llpreprocessor.h
index e99b103..4809a2f 100644
--- a/linden/indra/llcommon/llpreprocessor.h
+++ b/linden/indra/llcommon/llpreprocessor.h
@@ -64,6 +64,9 @@
64 #ifndef LL_MSVC 64 #ifndef LL_MSVC
65 #define LL_MSVC 1 65 #define LL_MSVC 1
66 #endif 66 #endif
67 #if _MSC_VER < 1400
68 #define LL_MSVC7 //Visual C++ 2003 or earlier
69 #endif
67#endif 70#endif
68 71
69// Deal with minor differences on Unixy OSes. 72// Deal with minor differences on Unixy OSes.
@@ -104,9 +107,7 @@ using snprintf_hack::snprintf;
104#if defined(LL_WINDOWS) 107#if defined(LL_WINDOWS)
105#define BOOST_REGEX_NO_LIB 1 108#define BOOST_REGEX_NO_LIB 1
106#define CURL_STATICLIB 1 109#define CURL_STATICLIB 1
107 110#define XML_STATIC
108//#define LL_LCD_COMPILE 0
109
110#endif // LL_WINDOWS 111#endif // LL_WINDOWS
111 112
112 113
diff --git a/linden/indra/llcommon/llprocessor.cpp b/linden/indra/llcommon/llprocessor.cpp
index 1c0f7e0..f132b86 100644
--- a/linden/indra/llcommon/llprocessor.cpp
+++ b/linden/indra/llcommon/llprocessor.cpp
@@ -2216,12 +2216,12 @@ bool CProcessor::CPUInfoToText(char *strBuffer, unsigned int uiMaxLen)
2216 return true; 2216 return true;
2217} 2217}
2218 2218
2219// bool CProcessor::WriteInfoTextFile(const char *strFilename) 2219// bool CProcessor::WriteInfoTextFile(const std::string& strFilename)
2220// =========================================================== 2220// ===========================================================
2221// Takes use of CProcessor::CPUInfoToText and saves the string to a 2221// Takes use of CProcessor::CPUInfoToText and saves the string to a
2222// file 2222// file
2223/////////////////////////////////////////////////////////////////// 2223///////////////////////////////////////////////////////////////////
2224bool CProcessor::WriteInfoTextFile(const char *strFilename) 2224bool CProcessor::WriteInfoTextFile(const std::string& strFilename)
2225{ 2225{
2226 char buf[16384]; /* Flawfinder: ignore */ 2226 char buf[16384]; /* Flawfinder: ignore */
2227 2227
diff --git a/linden/indra/llcommon/llprocessor.h b/linden/indra/llcommon/llprocessor.h
index a188b1a..6abbd96 100644
--- a/linden/indra/llcommon/llprocessor.h
+++ b/linden/indra/llcommon/llprocessor.h
@@ -188,7 +188,7 @@ public:
188 F64 GetCPUFrequency(unsigned int uiMeasureMSecs); 188 F64 GetCPUFrequency(unsigned int uiMeasureMSecs);
189 const ProcessorInfo *GetCPUInfo(); 189 const ProcessorInfo *GetCPUInfo();
190 bool CPUInfoToText(char *strBuffer, unsigned int uiMaxLen); 190 bool CPUInfoToText(char *strBuffer, unsigned int uiMaxLen);
191 bool WriteInfoTextFile(const char *strFilename); 191 bool WriteInfoTextFile(const std::string& strFilename);
192}; 192};
193 193
194 194
diff --git a/linden/indra/llcommon/llptrskiplist.h b/linden/indra/llcommon/llptrskiplist.h
index f1df27a..ebd297d 100644
--- a/linden/indra/llcommon/llptrskiplist.h
+++ b/linden/indra/llcommon/llptrskiplist.h
@@ -33,6 +33,7 @@
33#define LL_LLPTRSKIPLIST_H 33#define LL_LLPTRSKIPLIST_H
34 34
35#include "llerror.h" 35#include "llerror.h"
36#include "llrand.h"
36//#include "vmath.h" 37//#include "vmath.h"
37#include "llrand.h" 38#include "llrand.h"
38 39
diff --git a/linden/indra/llcommon/llrand.cpp b/linden/indra/llcommon/llrand.cpp
new file mode 100644
index 0000000..bc8c867
--- /dev/null
+++ b/linden/indra/llcommon/llrand.cpp
@@ -0,0 +1,176 @@
1/**
2 * @file llrand.cpp
3 * @brief Global random generator.
4 *
5 * $LicenseInfo:firstyear=2000&license=viewergpl$
6 *
7 * Copyright (c) 2000-2008, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#include "linden_common.h"
33
34#include "llrand.h"
35#include "lluuid.h"
36
37/**
38 * Through analysis, we have decided that we want to take values which
39 * are close enough to 1.0 to map back to 0.0. We came to this
40 * conclusion from noting that:
41 *
42 * [0.0, 1.0)
43 *
44 * when scaled to the integer set:
45 *
46 * [0, 4)
47 *
48 * there is some value close enough to 1.0 that when multiplying by 4,
49 * gets truncated to 4. Therefore:
50 *
51 * [0,1-eps] => 0
52 * [1,2-eps] => 1
53 * [2,3-eps] => 2
54 * [3,4-eps] => 3
55 *
56 * So 0 gets uneven distribution if we simply clamp. The actual
57 * clamp utilized in this file is to map values out of range back
58 * to 0 to restore uniform distribution.
59 *
60 * Also, for clamping floats when asking for a distribution from
61 * [0.0,g) we have determined that for values of g < 0.5, then
62 * rand*g=g, which is not the desired result. As above, we clamp to 0
63 * to restore uniform distribution.
64 */
65
66// *NOTE: The system rand implementation is probably not correct.
67#define LL_USE_SYSTEM_RAND 0
68
69#if LL_USE_SYSTEM_RAND
70#include <cstdlib>
71#endif
72
73#if LL_USE_SYSTEM_RAND
74class LLSeedRand
75{
76public:
77 LLSeedRand()
78 {
79#if LL_WINDOWS
80 srand(LLUUID::getRandomSeed());
81#else
82 srand48(LLUUID::getRandomSeed());
83#endif
84 }
85};
86static LLSeedRand sRandomSeeder;
87inline F64 ll_internal_random_double()
88{
89#if LL_WINDOWS
90 return (F64)rand() / (F64)RAND_MAX;
91#else
92 return drand48();
93#endif
94}
95inline F32 ll_internal_random_float()
96{
97#if LL_WINDOWS
98 return (F32)rand() / (F32)RAND_MAX;
99#else
100 return (F32)drand48();
101#endif
102}
103#else
104static LLRandLagFib2281 gRandomGenerator(LLUUID::getRandomSeed());
105inline F64 ll_internal_random_double()
106{
107 // *HACK: Through experimentation, we have found that dual core
108 // CPUs (or at least multi-threaded processes) seem to
109 // occasionally give an obviously incorrect random number -- like
110 // 5^15 or something. Sooooo, clamp it as described above.
111 F64 rv = gRandomGenerator();
112 if(!((rv >= 0.0) && (rv < 1.0))) return fmod(rv, 1.0);
113 return rv;
114}
115
116inline F32 ll_internal_random_float()
117{
118 // The clamping rules are described above.
119 F32 rv = (F32)gRandomGenerator();
120 if(!((rv >= 0.0f) && (rv < 1.0f))) return fmod(rv, 1.f);
121 return rv;
122}
123#endif
124
125S32 ll_rand()
126{
127 return ll_rand(RAND_MAX);
128}
129
130S32 ll_rand(S32 val)
131{
132 // The clamping rules are described above.
133 S32 rv = (S32)(ll_internal_random_double() * val);
134 if(rv == val) return 0;
135 return rv;
136}
137
138F32 ll_frand()
139{
140 return ll_internal_random_float();
141}
142
143F32 ll_frand(F32 val)
144{
145 // The clamping rules are described above.
146 F32 rv = ll_internal_random_float() * val;
147 if(val > 0)
148 {
149 if(rv >= val) return 0.0f;
150 }
151 else
152 {
153 if(rv <= val) return 0.0f;
154 }
155 return rv;
156}
157
158F64 ll_drand()
159{
160 return ll_internal_random_double();
161}
162
163F64 ll_drand(F64 val)
164{
165 // The clamping rules are described above.
166 F64 rv = ll_internal_random_double() * val;
167 if(val > 0)
168 {
169 if(rv >= val) return 0.0;
170 }
171 else
172 {
173 if(rv <= val) return 0.0;
174 }
175 return rv;
176}
diff --git a/linden/indra/llcommon/llrand.h b/linden/indra/llcommon/llrand.h
new file mode 100644
index 0000000..0a28213
--- /dev/null
+++ b/linden/indra/llcommon/llrand.h
@@ -0,0 +1,132 @@
1/**
2 * @file llrand.h
3 * @brief Information, functions, and typedefs for randomness.
4 *
5 * $LicenseInfo:firstyear=2000&license=viewergpl$
6 *
7 * Copyright (c) 2000-2008, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#ifndef LL_LLRAND_H
33#define LL_LLRAND_H
34
35#include <boost/random/lagged_fibonacci.hpp>
36#include <boost/random/mersenne_twister.hpp>
37
38/**
39 * Use the boost random number generators if you want a stateful
40 * random numbers. If you want more random numbers, use the
41 * c-functions since they will generate faster/better randomness
42 * across the process.
43 *
44 * I tested some of the boost random engines, and picked a good double
45 * generator and a good integer generator. I also took some timings
46 * for them on linux using gcc 3.3.5. The harness also did some other
47 * fairly trivial operations to try to limit compiler optimizations,
48 * so these numbers are only good for relative comparisons.
49 *
50 * usec/inter algorithm
51 * 0.21 boost::minstd_rand0
52 * 0.039 boost:lagged_fibonacci19937
53 * 0.036 boost:lagged_fibonacci607
54 * 0.44 boost::hellekalek1995
55 * 0.44 boost::ecuyer1988
56 * 0.042 boost::rand48
57 * 0.043 boost::mt11213b
58 * 0.028 stdlib random()
59 * 0.05 stdlib lrand48()
60 * 0.034 stdlib rand()
61 * 0.020 the old & lame LLRand
62 */
63
64/**
65 *@brief Generate a float from [0, RAND_MAX).
66 */
67S32 ll_rand();
68
69/**
70 *@brief Generate a float from [0, val) or (val, 0].
71 */
72S32 ll_rand(S32 val);
73
74/**
75 *@brief Generate a float from [0, 1.0).
76 */
77F32 ll_frand();
78
79/**
80 *@brief Generate a float from [0, val) or (val, 0].
81 */
82F32 ll_frand(F32 val);
83
84/**
85 *@brief Generate a double from [0, 1.0).
86 */
87F64 ll_drand();
88
89/**
90 *@brief Generate a double from [0, val) or (val, 0].
91 */
92F64 ll_drand(F64 val);
93
94/**
95 * @brief typedefs for good boost lagged fibonacci.
96 * @see boost::lagged_fibonacci
97 *
98 * These generators will quickly generate doubles. Note the memory
99 * requirements, because they are somewhat high. I chose the smallest
100 * one, and one comparable in speed but higher periodicity without
101 * outrageous memory requirements.
102 * To use:
103 * LLRandLagFib607 foo((U32)time(NULL));
104 * double bar = foo();
105 */
106
107typedef boost::lagged_fibonacci607 LLRandLagFib607;
108/**<
109 * lengh of cycle: 2^32,000
110 * memory: 607*sizeof(double) (about 5K)
111 */
112
113typedef boost::lagged_fibonacci2281 LLRandLagFib2281;
114/**<
115 * lengh of cycle: 2^120,000
116 * memory: 2281*sizeof(double) (about 17K)
117 */
118
119/**
120 * @breif typedefs for a good boost mersenne twister implementation.
121 * @see boost::mersenne_twister
122 *
123 * This fairly quickly generates U32 values
124 * To use:
125 * LLRandMT19937 foo((U32)time(NULL));
126 * U32 bar = foo();
127 *
128 * lengh of cycle: 2^19,937-1
129 * memory: about 2496 bytes
130 */
131typedef boost::mt11213b LLRandMT19937;
132#endif
diff --git a/linden/indra/llcommon/llsd.cpp b/linden/indra/llcommon/llsd.cpp
index fa0531b..2c32184 100644
--- a/linden/indra/llcommon/llsd.cpp
+++ b/linden/indra/llcommon/llsd.cpp
@@ -42,10 +42,11 @@
42#endif 42#endif
43 43
44#ifdef NAME_UNNAMED_NAMESPACE 44#ifdef NAME_UNNAMED_NAMESPACE
45namespace LLSDUnnamedNamespace { 45namespace LLSDUnnamedNamespace
46#else 46#else
47namespace { 47namespace
48#endif 48#endif
49{
49 class ImplMap; 50 class ImplMap;
50 class ImplArray; 51 class ImplArray;
51} 52}
@@ -127,10 +128,10 @@ public:
127 virtual void erase(Integer) { } 128 virtual void erase(Integer) { }
128 virtual const LLSD& ref(Integer) const { return undef(); } 129 virtual const LLSD& ref(Integer) const { return undef(); }
129 130
130 virtual LLSD::map_const_iterator beginMap() const { return LLSD::map_const_iterator(); } 131 virtual LLSD::map_const_iterator beginMap() const { return endMap(); }
131 virtual LLSD::map_const_iterator endMap() const { return LLSD::map_const_iterator(); } 132 virtual LLSD::map_const_iterator endMap() const { static const std::map<String, LLSD> empty; return empty.end(); }
132 virtual LLSD::array_const_iterator beginArray() const { return LLSD::array_const_iterator(); } 133 virtual LLSD::array_const_iterator beginArray() const { return endArray(); }
133 virtual LLSD::array_const_iterator endArray() const { return LLSD::array_const_iterator(); } 134 virtual LLSD::array_const_iterator endArray() const { static const std::vector<LLSD> empty; return empty.end(); }
134 135
135 static const LLSD& undef(); 136 static const LLSD& undef();
136 137
@@ -139,10 +140,11 @@ public:
139}; 140};
140 141
141#ifdef NAME_UNNAMED_NAMESPACE 142#ifdef NAME_UNNAMED_NAMESPACE
142namespace LLSDUnnamedNamespace { 143namespace LLSDUnnamedNamespace
143#else 144#else
144namespace { 145namespace
145#endif 146#endif
147{
146 template<LLSD::Type T, class Data, class DataRef = Data> 148 template<LLSD::Type T, class Data, class DataRef = Data>
147 class ImplBase : public LLSD::Impl 149 class ImplBase : public LLSD::Impl
148 ///< This class handles most of the work for a subclass of Impl 150 ///< This class handles most of the work for a subclass of Impl
@@ -185,6 +187,11 @@ namespace {
185 }; 187 };
186 188
187 LLSD::String ImplBoolean::asString() const 189 LLSD::String ImplBoolean::asString() const
190 // *NOTE: The reason that false is not converted to "false" is
191 // because that would break roundtripping,
192 // e.g. LLSD(false).asString().asBoolean(). There are many
193 // reasons for wanting LLSD("false").asBoolean() == true, such
194 // as "everything else seems to work that way".
188 { return mValue ? "true" : ""; } 195 { return mValue ? "true" : ""; }
189 196
190 197
@@ -650,10 +657,11 @@ U32 LLSD::Impl::sOutstandingCount = 0;
650 657
651 658
652#ifdef NAME_UNNAMED_NAMESPACE 659#ifdef NAME_UNNAMED_NAMESPACE
653namespace LLSDUnnamedNamespace { 660namespace LLSDUnnamedNamespace
654#else 661#else
655namespace { 662namespace
656#endif 663#endif
664{
657 inline LLSD::Impl& safe(LLSD::Impl* impl) 665 inline LLSD::Impl& safe(LLSD::Impl* impl)
658 { return LLSD::Impl::safe(impl); } 666 { return LLSD::Impl::safe(impl); }
659 667
diff --git a/linden/indra/llcommon/llsd.h b/linden/indra/llcommon/llsd.h
index 3f53735..98a6692 100644
--- a/linden/indra/llcommon/llsd.h
+++ b/linden/indra/llcommon/llsd.h
@@ -40,7 +40,7 @@
40 40
41#include "lldate.h" 41#include "lldate.h"
42#include "lluri.h" 42#include "lluri.h"
43#include "../llmath/lluuid.h" 43#include "lluuid.h"
44 44
45/** 45/**
46 LLSD provides a flexible data system similar to the data facilities of 46 LLSD provides a flexible data system similar to the data facilities of
@@ -394,7 +394,7 @@ std::ostream& operator<<(std::ostream& s, const LLSD& llsd);
394 - as UTF8 encoded strings (making not like UUID<->String) 394 - as UTF8 encoded strings (making not like UUID<->String)
395 - as Base64 or Base96 encoded (making like UUID<->String) 395 - as Base64 or Base96 encoded (making like UUID<->String)
396 - Conversions to std::string and LLUUID do not result in easy assignment 396 - Conversions to std::string and LLUUID do not result in easy assignment
397 to std::string, LLString or LLUUID due to non-unique conversion paths 397 to std::string, std::string or LLUUID due to non-unique conversion paths
398*/ 398*/
399 399
400#endif // LL_LLSD_NEW_H 400#endif // LL_LLSD_NEW_H
diff --git a/linden/indra/llcommon/llsdserialize.cpp b/linden/indra/llcommon/llsdserialize.cpp
index a556d5d..d42842d 100644
--- a/linden/indra/llcommon/llsdserialize.cpp
+++ b/linden/indra/llcommon/llsdserialize.cpp
@@ -37,7 +37,7 @@
37#include "llstreamtools.h" // for fullread 37#include "llstreamtools.h" // for fullread
38 38
39#include <iostream> 39#include <iostream>
40#include "apr-1/apr_base64.h" 40#include "apr_base64.h"
41 41
42#if !LL_WINDOWS 42#if !LL_WINDOWS
43#include <netinet/in.h> // htonl & ntohl 43#include <netinet/in.h> // htonl & ntohl
@@ -146,12 +146,15 @@ bool LLSDSerialize::deserialize(LLSD& sd, std::istream& str, S32 max_bytes)
146 * Create the parser as appropriate 146 * Create the parser as appropriate
147 */ 147 */
148 if (legacy_no_header) 148 if (legacy_no_header)
149 { 149 { // Create a LLSD XML parser, and parse the first chunk read above
150 LLSDXMLParser* x = new LLSDXMLParser; 150 LLSDXMLParser* x = new LLSDXMLParser();
151 x->parsePart(hdr_buf, inbuf); 151 x->parsePart(hdr_buf, inbuf); // Parse the first part that was already read
152 p = x; 152 x->parseLines(str, sd); // Parse the rest of it
153 delete x;
154 return true;
153 } 155 }
154 else if (header == LLSD_BINARY_HEADER) 156
157 if (header == LLSD_BINARY_HEADER)
155 { 158 {
156 p = new LLSDBinaryParser; 159 p = new LLSDBinaryParser;
157 } 160 }
@@ -300,7 +303,8 @@ static const char BINARY_FALSE_SERIAL = '0';
300/** 303/**
301 * LLSDParser 304 * LLSDParser
302 */ 305 */
303LLSDParser::LLSDParser() : mCheckLimits(true), mMaxBytesLeft(0) 306LLSDParser::LLSDParser()
307 : mCheckLimits(true), mMaxBytesLeft(0), mParseLines(false)
304{ 308{
305} 309}
306 310
@@ -316,6 +320,15 @@ S32 LLSDParser::parse(std::istream& istr, LLSD& data, S32 max_bytes)
316} 320}
317 321
318 322
323// Parse using routine to get() lines, faster than parse()
324S32 LLSDParser::parseLines(std::istream& istr, LLSD& data)
325{
326 mCheckLimits = false;
327 mParseLines = false; // was true, Emergency fix DEV-17785 parsing newline failure
328 return doParse(istr, data);
329}
330
331
319int LLSDParser::get(std::istream& istr) const 332int LLSDParser::get(std::istream& istr) const
320{ 333{
321 if(mCheckLimits) --mMaxBytesLeft; 334 if(mCheckLimits) --mMaxBytesLeft;
@@ -1217,8 +1230,7 @@ void LLSDFormatter::realFormat(const std::string& format)
1217 1230
1218void LLSDFormatter::formatReal(LLSD::Real real, std::ostream& ostr) const 1231void LLSDFormatter::formatReal(LLSD::Real real, std::ostream& ostr) const
1219{ 1232{
1220 char buffer[MAX_STRING]; /* Flawfinder: ignore */ 1233 std::string buffer = llformat(mRealFormat.c_str(), real);
1221 snprintf(buffer, MAX_STRING, mRealFormat.c_str(), real); /* Flawfinder: ignore */
1222 ostr << buffer; 1234 ostr << buffer;
1223} 1235}
1224 1236
diff --git a/linden/indra/llcommon/llsdserialize.h b/linden/indra/llcommon/llsdserialize.h
index f5282b4..94ad824 100644
--- a/linden/indra/llcommon/llsdserialize.h
+++ b/linden/indra/llcommon/llsdserialize.h
@@ -83,6 +83,18 @@ public:
83 */ 83 */
84 S32 parse(std::istream& istr, LLSD& data, S32 max_bytes); 84 S32 parse(std::istream& istr, LLSD& data, S32 max_bytes);
85 85
86 /** Like parse(), but uses a different call (istream.getline()) to read by lines
87 * This API is better suited for XML, where the parse cannot tell
88 * where the document actually ends.
89 */
90 S32 parseLines(std::istream& istr, LLSD& data);
91
92 /**
93 * @brief Resets the parser so parse() or parseLines() can be called again for another <llsd> chunk.
94 */
95 void reset() { doReset(); };
96
97
86protected: 98protected:
87 /** 99 /**
88 * @brief Pure virtual base for doing the parse. 100 * @brief Pure virtual base for doing the parse.
@@ -100,6 +112,11 @@ protected:
100 */ 112 */
101 virtual S32 doParse(std::istream& istr, LLSD& data) const = 0; 113 virtual S32 doParse(std::istream& istr, LLSD& data) const = 0;
102 114
115 /**
116 * @brief Virtual default function for resetting the parser
117 */
118 virtual void doReset() {};
119
103 /* @name Simple istream helper methods 120 /* @name Simple istream helper methods
104 * 121 *
105 * These helper methods exist to help correctly use the 122 * These helper methods exist to help correctly use the
@@ -191,6 +208,11 @@ protected:
191 * @brief The maximum number of bytes left to be parsed. 208 * @brief The maximum number of bytes left to be parsed.
192 */ 209 */
193 mutable S32 mMaxBytesLeft; 210 mutable S32 mMaxBytesLeft;
211
212 /**
213 * @brief Use line-based reading to get text
214 */
215 bool mParseLines;
194}; 216};
195 217
196/** 218/**
@@ -301,6 +323,11 @@ protected:
301 */ 323 */
302 virtual S32 doParse(std::istream& istr, LLSD& data) const; 324 virtual S32 doParse(std::istream& istr, LLSD& data) const;
303 325
326 /**
327 * @brief Virtual default function for resetting the parser
328 */
329 virtual void doReset();
330
304private: 331private:
305 class Impl; 332 class Impl;
306 Impl& impl; 333 Impl& impl;
@@ -674,7 +701,7 @@ public:
674 U32 options = LLSDFormatter::OPTIONS_NONE); 701 U32 options = LLSDFormatter::OPTIONS_NONE);
675 702
676 /** 703 /**
677 * @breif Examine a stream, and parse 1 sd object out based on contents. 704 * @brief Examine a stream, and parse 1 sd object out based on contents.
678 * 705 *
679 * @param sd [out] The data found on the stream 706 * @param sd [out] The data found on the stream
680 * @param str The incoming stream 707 * @param str The incoming stream
@@ -718,13 +745,23 @@ public:
718 return f->format(sd, str, LLSDFormatter::OPTIONS_PRETTY); 745 return f->format(sd, str, LLSDFormatter::OPTIONS_PRETTY);
719 } 746 }
720 747
721 static S32 fromXML(LLSD& sd, std::istream& str) 748 static S32 fromXMLEmbedded(LLSD& sd, std::istream& str)
722 { 749 {
723 // no need for max_bytes since xml formatting is not 750 // no need for max_bytes since xml formatting is not
724 // subvertable by bad sizes. 751 // subvertable by bad sizes.
725 LLPointer<LLSDXMLParser> p = new LLSDXMLParser; 752 LLPointer<LLSDXMLParser> p = new LLSDXMLParser;
726 return p->parse(str, sd, LLSDSerialize::SIZE_UNLIMITED); 753 return p->parse(str, sd, LLSDSerialize::SIZE_UNLIMITED);
727 } 754 }
755 static S32 fromXMLDocument(LLSD& sd, std::istream& str)
756 {
757 LLPointer<LLSDXMLParser> p = new LLSDXMLParser();
758 return p->parseLines(str, sd);
759 }
760 static S32 fromXML(LLSD& sd, std::istream& str)
761 {
762 return fromXMLEmbedded(sd, str);
763// return fromXMLDocument(sd, str);
764 }
728 765
729 /* 766 /*
730 * Binary Methods 767 * Binary Methods
diff --git a/linden/indra/llcommon/llsdserialize_xml.cpp b/linden/indra/llcommon/llsdserialize_xml.cpp
index 7de0c35..690ab67 100644
--- a/linden/indra/llcommon/llsdserialize_xml.cpp
+++ b/linden/indra/llcommon/llsdserialize_xml.cpp
@@ -35,7 +35,7 @@
35#include <iostream> 35#include <iostream>
36#include <deque> 36#include <deque>
37 37
38#include "apr-1/apr_base64.h" 38#include "apr_base64.h"
39 39
40extern "C" 40extern "C"
41{ 41{
@@ -63,7 +63,7 @@ S32 LLSDXMLFormatter::format(const LLSD& data, std::ostream& ostr, U32 options)
63{ 63{
64 std::streamsize old_precision = ostr.precision(25); 64 std::streamsize old_precision = ostr.precision(25);
65 65
66 LLString post = ""; 66 std::string post;
67 if (options & LLSDFormatter::OPTIONS_PRETTY) 67 if (options & LLSDFormatter::OPTIONS_PRETTY)
68 { 68 {
69 post = "\n"; 69 post = "\n";
@@ -79,8 +79,8 @@ S32 LLSDXMLFormatter::format(const LLSD& data, std::ostream& ostr, U32 options)
79S32 LLSDXMLFormatter::format_impl(const LLSD& data, std::ostream& ostr, U32 options, U32 level) const 79S32 LLSDXMLFormatter::format_impl(const LLSD& data, std::ostream& ostr, U32 options, U32 level) const
80{ 80{
81 S32 format_count = 1; 81 S32 format_count = 1;
82 LLString pre = ""; 82 std::string pre;
83 LLString post = ""; 83 std::string post;
84 84
85 if (options & LLSDFormatter::OPTIONS_PRETTY) 85 if (options & LLSDFormatter::OPTIONS_PRETTY)
86 { 86 {
@@ -262,12 +262,13 @@ public:
262 ~Impl(); 262 ~Impl();
263 263
264 S32 parse(std::istream& input, LLSD& data); 264 S32 parse(std::istream& input, LLSD& data);
265 S32 parseLines(std::istream& input, LLSD& data);
265 266
266 void parsePart(const char *buf, int len); 267 void parsePart(const char *buf, int len);
267 268
268private:
269 void reset(); 269 void reset();
270 270
271private:
271 void startElementHandler(const XML_Char* name, const XML_Char** attributes); 272 void startElementHandler(const XML_Char* name, const XML_Char** attributes);
272 void endElementHandler(const XML_Char* name); 273 void endElementHandler(const XML_Char* name);
273 void characterDataHandler(const XML_Char* data, int length); 274 void characterDataHandler(const XML_Char* data, int length);
@@ -307,8 +308,8 @@ private:
307 LLSD mResult; 308 LLSD mResult;
308 S32 mParseCount; 309 S32 mParseCount;
309 310
310 bool mInLLSDElement; 311 bool mInLLSDElement; // true if we're on LLSD
311 bool mGracefullStop; 312 bool mGracefullStop; // true if we found the </llsd
312 313
313 typedef std::deque<LLSD*> LLSDRefStack; 314 typedef std::deque<LLSD*> LLSDRefStack;
314 LLSDRefStack mStack; 315 LLSDRefStack mStack;
@@ -319,15 +320,12 @@ private:
319 320
320 std::string mCurrentKey; 321 std::string mCurrentKey;
321 std::ostringstream mCurrentContent; 322 std::ostringstream mCurrentContent;
322
323 bool mPreStaged;
324}; 323};
325 324
326 325
327LLSDXMLParser::Impl::Impl() 326LLSDXMLParser::Impl::Impl()
328{ 327{
329 mParser = XML_ParserCreate(NULL); 328 mParser = XML_ParserCreate(NULL);
330 mPreStaged = false;
331 reset(); 329 reset();
332} 330}
333 331
@@ -336,7 +334,7 @@ LLSDXMLParser::Impl::~Impl()
336 XML_ParserFree(mParser); 334 XML_ParserFree(mParser);
337} 335}
338 336
339bool is_eol(char c) 337inline bool is_eol(char c)
340{ 338{
341 return (c == '\n' || c == '\r'); 339 return (c == '\n' || c == '\r');
342} 340}
@@ -356,9 +354,9 @@ static unsigned get_till_eol(std::istream& input, char *buf, unsigned bufsize)
356 unsigned count = 0; 354 unsigned count = 0;
357 while (count < bufsize && input.good()) 355 while (count < bufsize && input.good())
358 { 356 {
359 input.get(buf[count]); 357 char c = input.get();
360 count++; 358 buf[count++] = c;
361 if (is_eol(buf[count - 1])) 359 if (is_eol(c))
362 break; 360 break;
363 } 361 }
364 return count; 362 return count;
@@ -366,7 +364,6 @@ static unsigned get_till_eol(std::istream& input, char *buf, unsigned bufsize)
366 364
367S32 LLSDXMLParser::Impl::parse(std::istream& input, LLSD& data) 365S32 LLSDXMLParser::Impl::parse(std::istream& input, LLSD& data)
368{ 366{
369 reset();
370 XML_Status status; 367 XML_Status status;
371 368
372 static const int BUFFER_SIZE = 1024; 369 static const int BUFFER_SIZE = 1024;
@@ -420,14 +417,86 @@ S32 LLSDXMLParser::Impl::parse(std::istream& input, LLSD& data)
420 return mParseCount; 417 return mParseCount;
421} 418}
422 419
423void LLSDXMLParser::Impl::reset() 420
421S32 LLSDXMLParser::Impl::parseLines(std::istream& input, LLSD& data)
424{ 422{
425 if (mPreStaged) 423 XML_Status status = XML_STATUS_OK;
424
425 data = LLSD();
426
427 static const int BUFFER_SIZE = 1024;
428
429 //static char last_buffer[ BUFFER_SIZE ];
430 //std::streamsize last_num_read;
431
432 // Must get rid of any leading \n, otherwise the stream gets into an error/eof state
433 clear_eol(input);
434
435 while( !mGracefullStop
436 && input.good()
437 && !input.eof())
426 { 438 {
427 mPreStaged = false; 439 void* buffer = XML_GetBuffer(mParser, BUFFER_SIZE);
428 return; 440 /*
441 * If we happened to end our last buffer right at the end of the llsd, but the
442 * stream is still going we will get a null buffer here. Check for mGracefullStop.
443 * -- I don't think this is actually true - zero 2008-05-09
444 */
445 if (!buffer)
446 {
447 break;
448 }
449
450 // Get one line
451 input.getline((char*)buffer, BUFFER_SIZE);
452 std::streamsize num_read = input.gcount();
453
454 //memcpy( last_buffer, buffer, num_read );
455 //last_num_read = num_read;
456
457 if ( num_read > 0 )
458 {
459 if (!input.good() )
460 { // Clear state that's set when we run out of buffer
461 input.clear();
462 }
463
464 // Don't parse the NULL at the end which might be added if \n was absorbed by getline()
465 char * text = (char *) buffer;
466 if ( text[num_read - 1] == 0)
467 {
468 num_read--;
469 }
470 }
471
472 status = XML_ParseBuffer(mParser, num_read, false);
473 if (status == XML_STATUS_ERROR)
474 {
475 break;
476 }
429 } 477 }
430 478
479 if (status != XML_STATUS_ERROR
480 && !mGracefullStop)
481 { // Parse last bit
482 status = XML_ParseBuffer(mParser, 0, true);
483 }
484
485 if (status == XML_STATUS_ERROR
486 && !mGracefullStop)
487 {
488 llinfos << "LLSDXMLParser::Impl::parseLines: XML_STATUS_ERROR" << llendl;
489 return LLSDParser::PARSE_FAILURE;
490 }
491
492 clear_eol(input);
493 data = mResult;
494 return mParseCount;
495}
496
497
498void LLSDXMLParser::Impl::reset()
499{
431 mResult.clear(); 500 mResult.clear();
432 mParseCount = 0; 501 mParseCount = 0;
433 502
@@ -476,14 +545,15 @@ LLSDXMLParser::Impl::findAttribute(const XML_Char* name, const XML_Char** pairs)
476 545
477void LLSDXMLParser::Impl::parsePart(const char* buf, int len) 546void LLSDXMLParser::Impl::parsePart(const char* buf, int len)
478{ 547{
479 void * buffer = XML_GetBuffer(mParser, len); 548 if ( buf != NULL
480 if (buffer != NULL && buf != NULL) 549 && len > 0 )
481 { 550 {
482 memcpy(buffer, buf, len); 551 XML_Status status = XML_Parse(mParser, buf, len, false);
552 if (status == XML_STATUS_ERROR)
553 {
554 llinfos << "Unexpected XML parsing error at start" << llendl;
555 }
483 } 556 }
484 XML_ParseBuffer(mParser, len, false);
485
486 mPreStaged = true;
487} 557}
488 558
489void LLSDXMLParser::Impl::startElementHandler(const XML_Char* name, const XML_Char** attributes) 559void LLSDXMLParser::Impl::startElementHandler(const XML_Char* name, const XML_Char** attributes)
@@ -738,5 +808,18 @@ void LLSDXMLParser::parsePart(const char *buf, int len)
738// virtual 808// virtual
739S32 LLSDXMLParser::doParse(std::istream& input, LLSD& data) const 809S32 LLSDXMLParser::doParse(std::istream& input, LLSD& data) const
740{ 810{
741 return impl.parse(input, data); 811// Remove code - emergency fix DEV-17785 parsing newline failure
812// if (mParseLines)
813// {
814 // Use line-based reading (faster code)
815// return impl.parseLines(input, data);
816// }
817
818 return impl.parse(input, data);
819}
820
821// virtual
822void LLSDXMLParser::doReset()
823{
824 impl.reset();
742} 825}
diff --git a/linden/indra/llcommon/llsdutil.cpp b/linden/indra/llcommon/llsdutil.cpp
index d1ccce0..b619fb6 100644
--- a/linden/indra/llcommon/llsdutil.cpp
+++ b/linden/indra/llcommon/llsdutil.cpp
@@ -46,124 +46,6 @@
46 46
47#include "llsdserialize.h" 47#include "llsdserialize.h"
48 48
49// vector3
50LLSD ll_sd_from_vector3(const LLVector3& vec)
51{
52 LLSD rv;
53 rv.append((F64)vec.mV[VX]);
54 rv.append((F64)vec.mV[VY]);
55 rv.append((F64)vec.mV[VZ]);
56 return rv;
57}
58
59LLVector3 ll_vector3_from_sd(const LLSD& sd, S32 start_index)
60{
61 LLVector3 rv;
62 rv.mV[VX] = (F32)sd[start_index].asReal();
63 rv.mV[VY] = (F32)sd[++start_index].asReal();
64 rv.mV[VZ] = (F32)sd[++start_index].asReal();
65 return rv;
66}
67
68// vector4
69LLSD ll_sd_from_vector4(const LLVector4& vec)
70{
71 LLSD rv;
72 rv.append((F64)vec.mV[VX]);
73 rv.append((F64)vec.mV[VY]);
74 rv.append((F64)vec.mV[VZ]);
75 rv.append((F64)vec.mV[VW]);
76 return rv;
77}
78
79LLVector4 ll_vector4_from_sd(const LLSD& sd, S32 start_index)
80{
81 LLVector4 rv;
82 rv.mV[VX] = (F32)sd[start_index].asReal();
83 rv.mV[VY] = (F32)sd[++start_index].asReal();
84 rv.mV[VZ] = (F32)sd[++start_index].asReal();
85 rv.mV[VW] = (F32)sd[++start_index].asReal();
86 return rv;
87}
88
89// vector3d
90LLSD ll_sd_from_vector3d(const LLVector3d& vec)
91{
92 LLSD rv;
93 rv.append(vec.mdV[VX]);
94 rv.append(vec.mdV[VY]);
95 rv.append(vec.mdV[VZ]);
96 return rv;
97}
98
99LLVector3d ll_vector3d_from_sd(const LLSD& sd, S32 start_index)
100{
101 LLVector3d rv;
102 rv.mdV[VX] = sd[start_index].asReal();
103 rv.mdV[VY] = sd[++start_index].asReal();
104 rv.mdV[VZ] = sd[++start_index].asReal();
105 return rv;
106}
107
108//vector2
109LLSD ll_sd_from_vector2(const LLVector2& vec)
110{
111 LLSD rv;
112 rv.append((F64)vec.mV[VX]);
113 rv.append((F64)vec.mV[VY]);
114 return rv;
115}
116
117LLVector2 ll_vector2_from_sd(const LLSD& sd)
118{
119 LLVector2 rv;
120 rv.mV[VX] = (F32)sd[0].asReal();
121 rv.mV[VY] = (F32)sd[1].asReal();
122 return rv;
123}
124
125// Quaternion
126LLSD ll_sd_from_quaternion(const LLQuaternion& quat)
127{
128 LLSD rv;
129 rv.append((F64)quat.mQ[VX]);
130 rv.append((F64)quat.mQ[VY]);
131 rv.append((F64)quat.mQ[VZ]);
132 rv.append((F64)quat.mQ[VW]);
133 return rv;
134}
135
136LLQuaternion ll_quaternion_from_sd(const LLSD& sd)
137{
138 LLQuaternion quat;
139 quat.mQ[VX] = (F32)sd[0].asReal();
140 quat.mQ[VY] = (F32)sd[1].asReal();
141 quat.mQ[VZ] = (F32)sd[2].asReal();
142 quat.mQ[VW] = (F32)sd[3].asReal();
143 return quat;
144}
145
146// color4
147LLSD ll_sd_from_color4(const LLColor4& c)
148{
149 LLSD rv;
150 rv.append(c.mV[0]);
151 rv.append(c.mV[1]);
152 rv.append(c.mV[2]);
153 rv.append(c.mV[3]);
154 return rv;
155}
156
157LLColor4 ll_color4_from_sd(const LLSD& sd)
158{
159 LLColor4 c;
160 c.mV[0] = (F32)sd[0].asReal();
161 c.mV[1] = (F32)sd[1].asReal();
162 c.mV[2] = (F32)sd[2].asReal();
163 c.mV[3] = (F32)sd[3].asReal();
164 return c;
165}
166
167// U32 49// U32
168LLSD ll_sd_from_U32(const U32 val) 50LLSD ll_sd_from_U32(const U32 val)
169{ 51{
@@ -263,12 +145,11 @@ LLSD ll_binary_from_string(const LLSD& sd)
263{ 145{
264 std::vector<U8> binary_value; 146 std::vector<U8> binary_value;
265 147
266 LLString string_value = sd.asString(); 148 std::string string_value = sd.asString();
267 const char* string_p = string_value.c_str(); 149 for (std::string::iterator iter = string_value.begin();
268 while (*string_p) 150 iter != string_value.end(); ++iter)
269 { 151 {
270 binary_value.push_back(*string_p); 152 binary_value.push_back(*iter);
271 string_p++;
272 } 153 }
273 154
274 binary_value.push_back('\0'); 155 binary_value.push_back('\0');
@@ -303,8 +184,9 @@ char* ll_pretty_print_sd(const LLSD& sd)
303} 184}
304 185
305//compares the structure of an LLSD to a template LLSD and stores the 186//compares the structure of an LLSD to a template LLSD and stores the
306//"valid" values in a 3rd LLSD. Default values are stored in the template 187//"valid" values in a 3rd LLSD. Default values pulled from the template
307// 188//if the tested LLSD does not contain the key/value pair.
189//Excess values in the test LLSD are ignored in the resultant_llsd.
308//If the llsd to test has a specific key to a map and the values 190//If the llsd to test has a specific key to a map and the values
309//are not of the same type, false is returned or if the LLSDs are not 191//are not of the same type, false is returned or if the LLSDs are not
310//of the same value. Ordering of arrays matters 192//of the same value. Ordering of arrays matters
diff --git a/linden/indra/llcommon/llsdutil.h b/linden/indra/llcommon/llsdutil.h
index ae6d694..905c031 100644
--- a/linden/indra/llcommon/llsdutil.h
+++ b/linden/indra/llcommon/llsdutil.h
@@ -35,35 +35,34 @@
35#define LL_LLSDUTIL_H 35#define LL_LLSDUTIL_H
36 36
37#include "llsd.h" 37#include "llsd.h"
38#include "../llmath/v3math.h"
39#include "../llmath/v4math.h"
40#include "../llmath/v3dmath.h"
41#include "../llmath/v2math.h"
42#include "../llmath/llquaternion.h"
43#include "../llmath/v4color.h"
44#include "../llprimitive/lltextureanim.h"
45 38
46// vector3 39// vector3
40class LLVector3;
47LLSD ll_sd_from_vector3(const LLVector3& vec); 41LLSD ll_sd_from_vector3(const LLVector3& vec);
48LLVector3 ll_vector3_from_sd(const LLSD& sd, S32 start_index = 0); 42LLVector3 ll_vector3_from_sd(const LLSD& sd, S32 start_index = 0);
49 43
50// vector4 44// vector4
45class LLVector4;
51LLSD ll_sd_from_vector4(const LLVector4& vec); 46LLSD ll_sd_from_vector4(const LLVector4& vec);
52LLVector4 ll_vector4_from_sd(const LLSD& sd, S32 start_index = 0); 47LLVector4 ll_vector4_from_sd(const LLSD& sd, S32 start_index = 0);
53 48
54// vector3d (double) 49// vector3d (double)
50class LLVector3d;
55LLSD ll_sd_from_vector3d(const LLVector3d& vec); 51LLSD ll_sd_from_vector3d(const LLVector3d& vec);
56LLVector3d ll_vector3d_from_sd(const LLSD& sd, S32 start_index = 0); 52LLVector3d ll_vector3d_from_sd(const LLSD& sd, S32 start_index = 0);
57 53
58// vector2 54// vector2
55class LLVector2;
59LLSD ll_sd_from_vector2(const LLVector2& vec); 56LLSD ll_sd_from_vector2(const LLVector2& vec);
60LLVector2 ll_vector2_from_sd(const LLSD& sd); 57LLVector2 ll_vector2_from_sd(const LLSD& sd);
61 58
62// Quaternion 59// Quaternion
60class LLQuaternion;
63LLSD ll_sd_from_quaternion(const LLQuaternion& quat); 61LLSD ll_sd_from_quaternion(const LLQuaternion& quat);
64LLQuaternion ll_quaternion_from_sd(const LLSD& sd); 62LLQuaternion ll_quaternion_from_sd(const LLSD& sd);
65 63
66// color4 64// color4
65class LLColor4;
67LLSD ll_sd_from_color4(const LLColor4& c); 66LLSD ll_sd_from_color4(const LLColor4& c);
68LLColor4 ll_color4_from_sd(const LLSD& sd); 67LLColor4 ll_color4_from_sd(const LLSD& sd);
69 68
@@ -93,9 +92,11 @@ char* ll_pretty_print_sd(const LLSD& sd);
93 92
94//compares the structure of an LLSD to a template LLSD and stores the 93//compares the structure of an LLSD to a template LLSD and stores the
95//"valid" values in a 3rd LLSD. Default values 94//"valid" values in a 3rd LLSD. Default values
96//are pulled from the template. Ordering of arrays matters 95//are pulled from the template. Extra keys/values in the test
96//are ignored in the resultant LLSD. Ordering of arrays matters
97//Returns false if the test is of same type but values differ in type 97//Returns false if the test is of same type but values differ in type
98//Otherwise, returns true 98//Otherwise, returns true
99
99BOOL compare_llsd_with_template( 100BOOL compare_llsd_with_template(
100 const LLSD& llsd_to_test, 101 const LLSD& llsd_to_test,
101 const LLSD& template_llsd, 102 const LLSD& template_llsd,
diff --git a/linden/indra/llcommon/llsecondlifeurls.cpp b/linden/indra/llcommon/llsecondlifeurls.cpp
index 46b8cde..ee478fe 100644
--- a/linden/indra/llcommon/llsecondlifeurls.cpp
+++ b/linden/indra/llcommon/llsecondlifeurls.cpp
@@ -32,56 +32,56 @@
32#include "linden_common.h" 32#include "linden_common.h"
33#include "llsecondlifeurls.h" 33#include "llsecondlifeurls.h"
34 34
35const char CREATE_ACCOUNT_URL[] = 35const std::string CREATE_ACCOUNT_URL (
36 "http://secondlife.com/registration/"; 36 "http://secondlife.com/registration/");
37 37
38const char MANAGE_ACCOUNT[] = 38const std::string MANAGE_ACCOUNT (
39 "http://secondlife.com/account/"; 39 "http://secondlife.com/account/");
40 40
41const char AUCTION_URL[] = 41const std::string AUCTION_URL (
42 "http://secondlife.com/auctions/auction-detail.php?id="; 42 "http://secondlife.com/auctions/auction-detail.php?id=");
43 43
44const char EVENTS_URL[] = 44const std::string EVENTS_URL (
45 "http://secondlife.com/events/"; 45 "http://secondlife.com/events/");
46 46
47const char TIER_UP_URL[] = 47const std::string TIER_UP_URL (
48 "http://secondlife.com/app/landtier"; 48 "http://secondlife.com/app/landtier");
49 49
50const char LAND_URL[] = 50const std::string LAND_URL (
51 "http://secondlife.com/app/landtier"; 51 "http://secondlife.com/app/landtier");
52 52
53const char UPGRADE_TO_PREMIUM_URL[] = 53const std::string UPGRADE_TO_PREMIUM_URL (
54 "http://secondlife.com/app/upgrade/"; 54 "http://secondlife.com/app/upgrade/");
55 55
56const char DIRECTX_9_URL[] = 56const std::string DIRECTX_9_URL (
57 "http://secondlife.com/support/"; 57 "http://secondlife.com/support/");
58 58
59const char AMD_AGP_URL[] = 59const std::string AMD_AGP_URL (
60 "http://secondlife.com/support/"; 60 "http://secondlife.com/support/");
61 61
62const char VIA_URL[] = 62const std::string VIA_URL (
63 "http://secondlife.com/support/"; 63 "http://secondlife.com/support/");
64 64
65const char SUPPORT_URL[] = 65const std::string SUPPORT_URL (
66 "http://secondlife.com/support/"; 66 "http://secondlife.com/support/");
67 67
68const char INTEL_CHIPSET_URL[] = 68const std::string INTEL_CHIPSET_URL (
69 "http://secondlife.com/support/"; 69 "http://secondlife.com/support/");
70 70
71const char SIS_CHIPSET_URL[] = 71const std::string SIS_CHIPSET_URL (
72 "http://secondlife.com/support/"; 72 "http://secondlife.com/support/");
73 73
74const char BLOGS_URL[] = 74const std::string BLOGS_URL (
75 "http://blog.secondlife.com/"; 75 "http://blog.secondlife.com/");
76 76
77const char BUY_CURRENCY_URL[] = 77const std::string BUY_CURRENCY_URL (
78 "http://secondlife.com/app/currency/"; 78 "http://secondlife.com/app/currency/");
79 79
80const char LSL_DOC_URL[] = 80const std::string LSL_DOC_URL (
81 "http://secondlife.com/app/lsldoc/"; 81 "http://secondlife.com/app/lsldoc/");
82 82
83const char SL_KB_URL[] = 83const std::string SL_KB_URL (
84 "http://secondlife.com/knowledgebase/"; 84 "http://secondlife.com/knowledgebase/");
85
86const char RELEASE_NOTES[] = "releasenotes.txt";
87 85
86const std::string RELEASE_NOTES_BASE_URL (
87 "http://secondlife.com/app/releasenotes/");
diff --git a/linden/indra/llcommon/llsecondlifeurls.h b/linden/indra/llcommon/llsecondlifeurls.h
index 3fe086a..f612d5e 100644
--- a/linden/indra/llcommon/llsecondlifeurls.h
+++ b/linden/indra/llcommon/llsecondlifeurls.h
@@ -33,46 +33,46 @@
33#define LL_LLSECONDLIFEURLS_H 33#define LL_LLSECONDLIFEURLS_H
34 34
35// Account registration web page 35// Account registration web page
36extern const char CREATE_ACCOUNT_URL[]; 36extern const std::string CREATE_ACCOUNT_URL;
37 37
38// Manage Account 38// Manage Account
39extern const char MANAGE_ACCOUNT[]; 39extern const std::string MANAGE_ACCOUNT;
40 40
41extern const char AUCTION_URL[]; 41extern const std::string AUCTION_URL;
42 42
43extern const char EVENTS_URL[]; 43extern const std::string EVENTS_URL;
44 44
45// Tier up to a new land level. 45// Tier up to a new land level.
46extern const char TIER_UP_URL[]; 46extern const std::string TIER_UP_URL;
47 47
48// Tier up to a new land level. 48// Tier up to a new land level.
49extern const char LAND_URL[]; 49extern const std::string LAND_URL;
50 50
51// Upgrade from basic membership to premium membership 51// Upgrade from basic membership to premium membership
52extern const char UPGRADE_TO_PREMIUM_URL[]; 52extern const std::string UPGRADE_TO_PREMIUM_URL;
53 53
54// How to get DirectX 9 54// How to get DirectX 9
55extern const char DIRECTX_9_URL[]; 55extern const std::string DIRECTX_9_URL;
56 56
57// Out of date VIA chipset 57// Out of date VIA chipset
58extern const char VIA_URL[]; 58extern const std::string VIA_URL;
59 59
60// Support URL 60// Support URL
61extern const char SUPPORT_URL[]; 61extern const std::string SUPPORT_URL;
62 62
63// Linden Blogs page 63// Linden Blogs page
64extern const char BLOGS_URL[]; 64extern const std::string BLOGS_URL;
65 65
66// Currency page 66// Currency page
67extern const char BUY_CURRENCY_URL[]; 67extern const std::string BUY_CURRENCY_URL;
68 68
69// LSL script wiki 69// LSL script wiki
70extern const char LSL_DOC_URL[]; 70extern const std::string LSL_DOC_URL;
71 71
72// SL KnowledgeBase page 72// SL KnowledgeBase page
73extern const char SL_KB_URL[]; 73extern const std::string SL_KB_URL;
74 74
75// Local Url Release Notes 75// Release Notes Redirect URL for Server and Viewer
76extern const char RELEASE_NOTES[]; 76extern const std::string RELEASE_NOTES_BASE_URL;
77 77
78#endif 78#endif
diff --git a/linden/indra/llcommon/llstat.cpp b/linden/indra/llcommon/llstat.cpp
index 11e4c64..4b79fcb 100644
--- a/linden/indra/llcommon/llstat.cpp
+++ b/linden/indra/llcommon/llstat.cpp
@@ -76,10 +76,11 @@ public:
76 76
77U64 LLStatAccum::impl::sScaleTimes[IMPL_NUM_SCALES] = 77U64 LLStatAccum::impl::sScaleTimes[IMPL_NUM_SCALES] =
78{ 78{
79 USEC_PER_SEC / 10, // 100 millisec
79 USEC_PER_SEC * 1, // seconds 80 USEC_PER_SEC * 1, // seconds
80 USEC_PER_SEC * 60, // minutes 81 USEC_PER_SEC * 60, // minutes
81 USEC_PER_SEC * 60 * 2 // minutes 82 USEC_PER_SEC * 60 * 2 // two minutes
82#if 0 83#if ENABLE_LONG_TIME_STATS
83 // enable these when more time scales are desired 84 // enable these when more time scales are desired
84 USEC_PER_SEC * 60*60, // hours 85 USEC_PER_SEC * 60*60, // hours
85 USEC_PER_SEC * 24*60*60, // days 86 USEC_PER_SEC * 24*60*60, // days
diff --git a/linden/indra/llcommon/llstat.h b/linden/indra/llcommon/llstat.h
index a0a86e6..0a7e014 100644
--- a/linden/indra/llcommon/llstat.h
+++ b/linden/indra/llcommon/llstat.h
@@ -37,6 +37,9 @@
37#include "lltimer.h" 37#include "lltimer.h"
38#include "llframetimer.h" 38#include "llframetimer.h"
39 39
40// Set this if longer stats are needed
41#define ENABLE_LONG_TIME_STATS 0
42
40// 43//
41// Accumulates statistics for an arbitrary length of time. 44// Accumulates statistics for an arbitrary length of time.
42// Does this by maintaining a chain of accumulators, each one 45// Does this by maintaining a chain of accumulators, each one
@@ -52,19 +55,22 @@ protected:
52 55
53public: 56public:
54 enum TimeScale { 57 enum TimeScale {
58 SCALE_100MS,
55 SCALE_SECOND, 59 SCALE_SECOND,
56 SCALE_MINUTE, 60 SCALE_MINUTE,
57 SCALE_TWO_MINUTE, 61 SCALE_TWO_MINUTE,
62#if ENABLE_LONG_TIME_STATS
58 SCALE_HOUR, 63 SCALE_HOUR,
59 SCALE_DAY, 64 SCALE_DAY,
60 SCALE_WEEK, 65 SCALE_WEEK,
61 66#endif
62 NUM_SCALES 67 NUM_SCALES
63 }; 68 };
64 69
65 F32 meanValue(TimeScale scale) const; 70 F32 meanValue(TimeScale scale) const;
66 // see the subclasses for the specific meaning of value 71 // see the subclasses for the specific meaning of value
67 72
73 F32 meanValueOverLast100ms() const { return meanValue(SCALE_100MS); }
68 F32 meanValueOverLastSecond() const { return meanValue(SCALE_SECOND); } 74 F32 meanValueOverLastSecond() const { return meanValue(SCALE_SECOND); }
69 F32 meanValueOverLastMinute() const { return meanValue(SCALE_MINUTE); } 75 F32 meanValueOverLastMinute() const { return meanValue(SCALE_MINUTE); }
70 76
diff --git a/linden/indra/llcommon/llstatenums.h b/linden/indra/llcommon/llstatenums.h
index bde6ade..6866586 100644
--- a/linden/indra/llcommon/llstatenums.h
+++ b/linden/indra/llcommon/llstatenums.h
@@ -63,7 +63,8 @@ enum
63 LL_SIM_STAT_SIMPHYSICSSTEPMS, 63 LL_SIM_STAT_SIMPHYSICSSTEPMS,
64 LL_SIM_STAT_SIMPHYSICSSHAPEMS, 64 LL_SIM_STAT_SIMPHYSICSSHAPEMS,
65 LL_SIM_STAT_SIMPHYSICSOTHERMS, 65 LL_SIM_STAT_SIMPHYSICSOTHERMS,
66 LL_SIM_STAT_SIMPHYSICSMEMORY 66 LL_SIM_STAT_SIMPHYSICSMEMORY,
67 LL_SIM_STAT_SCRIPT_EPS,
67}; 68};
68 69
69#endif 70#endif
diff --git a/linden/indra/llcommon/llstl.h b/linden/indra/llcommon/llstl.h
index 9a24185..4486727 100644
--- a/linden/indra/llcommon/llstl.h
+++ b/linden/indra/llcommon/llstl.h
@@ -105,6 +105,7 @@ struct DeletePairedPointer
105 template<typename T> void operator()(T &ptr) const 105 template<typename T> void operator()(T &ptr) const
106 { 106 {
107 delete ptr.second; 107 delete ptr.second;
108 ptr.second = NULL;
108 } 109 }
109}; 110};
110struct DeletePairedPointerArray 111struct DeletePairedPointerArray
@@ -112,6 +113,7 @@ struct DeletePairedPointerArray
112 template<typename T> void operator()(T &ptr) const 113 template<typename T> void operator()(T &ptr) const
113 { 114 {
114 delete[] ptr.second; 115 delete[] ptr.second;
116 ptr.second = NULL;
115 } 117 }
116}; 118};
117 119
diff --git a/linden/indra/llcommon/llstring.cpp b/linden/indra/llcommon/llstring.cpp
index a1f19ad..6a8efa8 100644
--- a/linden/indra/llcommon/llstring.cpp
+++ b/linden/indra/llcommon/llstring.cpp
@@ -1,6 +1,6 @@
1/** 1/**
2 * @file llstring.cpp 2 * @file llstring.cpp
3 * @brief String utility functions and the LLString class. 3 * @brief String utility functions and the std::string class.
4 * 4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$ 5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 * 6 *
@@ -47,6 +47,12 @@ std::string ll_safe_string(const char* in)
47 return std::string(); 47 return std::string();
48} 48}
49 49
50std::string ll_safe_string(const char* in, S32 maxlen)
51{
52 if(in) return std::string(in, maxlen);
53 return std::string();
54}
55
50U8 hex_as_nybble(char hex) 56U8 hex_as_nybble(char hex)
51{ 57{
52 if((hex >= '0') && (hex <= '9')) 58 if((hex >= '0') && (hex <= '9'))
@@ -65,12 +71,12 @@ U8 hex_as_nybble(char hex)
65} 71}
66 72
67 73
68bool _read_file_into_string(std::string& str, const char* filename) 74bool _read_file_into_string(std::string& str, const std::string& filename)
69{ 75{
70 llifstream ifs(filename, llifstream::binary); 76 llifstream ifs(filename, llifstream::binary);
71 if (!ifs.is_open()) 77 if (!ifs.is_open())
72 { 78 {
73 llinfos << "Unable to open file" << filename << llendl; 79 llinfos << "Unable to open file " << filename << llendl;
74 return false; 80 return false;
75 } 81 }
76 82
@@ -174,20 +180,6 @@ S32 utf16chars_to_wchar(const U16* inchars, llwchar* outchar)
174 return inchars - base; 180 return inchars - base;
175} 181}
176 182
177S32 utf16chars_to_utf8chars(const U16* inchars, char* outchars, S32* nchars8p)
178{
179 // Get 32 bit char32
180 llwchar char32;
181 S32 nchars16 = utf16chars_to_wchar(inchars, &char32);
182 // Convert to utf8
183 S32 nchars8 = wchar_to_utf8chars(char32, outchars);
184 if (nchars8p)
185 {
186 *nchars8p = nchars8;
187 }
188 return nchars16;
189}
190
191llutf16string wstring_to_utf16str(const LLWString &utf32str, S32 len) 183llutf16string wstring_to_utf16str(const LLWString &utf32str, S32 len)
192{ 184{
193 llutf16string out; 185 llutf16string out;
@@ -216,7 +208,7 @@ llutf16string wstring_to_utf16str(const LLWString &utf32str)
216 return wstring_to_utf16str(utf32str, len); 208 return wstring_to_utf16str(utf32str, len);
217} 209}
218 210
219llutf16string utf8str_to_utf16str ( const LLString& utf8str ) 211llutf16string utf8str_to_utf16str ( const std::string& utf8str )
220{ 212{
221 LLWString wstr = utf8str_to_wstring ( utf8str ); 213 LLWString wstr = utf8str_to_wstring ( utf8str );
222 return wstring_to_utf16str ( wstr ); 214 return wstring_to_utf16str ( wstr );
@@ -492,210 +484,10 @@ std::string utf16str_to_utf8str(const llutf16string& utf16str, S32 len)
492 return wstring_to_utf8str(utf16str_to_wstring(utf16str, len), len); 484 return wstring_to_utf8str(utf16str_to_wstring(utf16str, len), len);
493} 485}
494 486
495
496//LLWString wstring_truncate(const LLWString &wstr, const S32 max_len)
497//{
498// return wstr.substr(0, llmin((S32)wstr.length(), max_len));
499//}
500//
501//
502//LLWString wstring_trim(const LLWString &wstr)
503//{
504// LLWString outstr;
505// outstr = wstring_trimhead(wstr);
506// outstr = wstring_trimtail(outstr);
507// return outstr;
508//}
509//
510//
511//LLWString wstring_trimhead(const LLWString &wstr)
512//{
513// if(wstr.empty())
514// {
515// return wstr;
516// }
517//
518// S32 i = 0;
519// while((i < (S32)wstr.length()) && iswspace(wstr[i]))
520// {
521// i++;
522// }
523// return wstr.substr(i, wstr.length() - i);
524//}
525//
526//
527//LLWString wstring_trimtail(const LLWString &wstr)
528//{
529// if(wstr.empty())
530// {
531// return wstr;
532// }
533//
534// S32 len = (S32)wstr.length();
535//
536// S32 i = len - 1;
537// while (i >= 0 && iswspace(wstr[i]))
538// {
539// i--;
540// }
541//
542// if (i >= 0)
543// {
544// return wstr.substr(0, i + 1);
545// }
546// return wstr;
547//}
548//
549//
550//LLWString wstring_copyinto(const LLWString &dest, const LLWString &src, const S32 insert_offset)
551//{
552// llassert( insert_offset <= (S32)dest.length() );
553//
554// LLWString out_str = dest.substr(0, insert_offset);
555// out_str += src;
556// LLWString tail = dest.substr(insert_offset);
557// out_str += tail;
558//
559// return out_str;
560//}
561
562
563//LLWString wstring_detabify(const LLWString &wstr, const S32 num_spaces)
564//{
565// LLWString out_str;
566// // Replace tabs with spaces
567// for (S32 i = 0; i < (S32)wstr.length(); i++)
568// {
569// if (wstr[i] == '\t')
570// {
571// for (S32 j = 0; j < num_spaces; j++)
572// out_str += ' ';
573// }
574// else
575// {
576// out_str += wstr[i];
577// }
578// }
579// return out_str;
580//}
581
582
583//LLWString wstring_makeASCII(const LLWString &wstr)
584//{
585// // Replace non-ASCII chars with replace_char
586// LLWString out_str = wstr;
587// for (S32 i = 0; i < (S32)out_str.length(); i++)
588// {
589// if (out_str[i] > 0x7f)
590// {
591// out_str[i] = LL_UNKNOWN_CHAR;
592// }
593// }
594// return out_str;
595//}
596
597
598//LLWString wstring_substChar(const LLWString &wstr, const llwchar target_char, const llwchar replace_char)
599//{
600// // Replace all occurences of target_char with replace_char
601// LLWString out_str = wstr;
602// for (S32 i = 0; i < (S32)out_str.length(); i++)
603// {
604// if (out_str[i] == target_char)
605// {
606// out_str[i] = replace_char;
607// }
608// }
609// return out_str;
610//}
611//
612//
613//LLWString wstring_tolower(const LLWString &wstr)
614//{
615// LLWString out_str = wstr;
616// for (S32 i = 0; i < (S32)out_str.length(); i++)
617// {
618// out_str[i] = towlower(out_str[i]);
619// }
620// return out_str;
621//}
622//
623//
624//LLWString wstring_convert_to_lf(const LLWString &wstr)
625//{
626// const llwchar CR = 13;
627// // Remove carriage returns from string with CRLF
628// LLWString out_str;
629//
630// for (S32 i = 0; i < (S32)wstr.length(); i++)
631// {
632// if (wstr[i] != CR)
633// {
634// out_str += wstr[i];
635// }
636// }
637// return out_str;
638//}
639//
640//
641//LLWString wstring_convert_to_crlf(const LLWString &wstr)
642//{
643// const llwchar LF = 10;
644// const llwchar CR = 13;
645// // Remove carriage returns from string with CRLF
646// LLWString out_str;
647//
648// for (S32 i = 0; i < (S32)wstr.length(); i++)
649// {
650// if (wstr[i] == LF)
651// {
652// out_str += CR;
653// }
654// out_str += wstr[i];
655// }
656// return out_str;
657//}
658
659
660//S32 wstring_compare_insensitive(const LLWString &lhs, const LLWString &rhs)
661//{
662//
663// if (lhs == rhs)
664// {
665// return 0;
666// }
667//
668// if (lhs.empty())
669// {
670// return rhs.empty() ? 0 : 1;
671// }
672//
673// if (rhs.empty())
674// {
675// return -1;
676// }
677//
678//#ifdef LL_LINUX
679// // doesn't work because gcc 2.95 doesn't correctly implement c_str(). Sigh...
680// llerrs << "wstring_compare_insensitive doesn't work on Linux!" << llendl;
681// return 0;
682//#else
683// LLWString lhs_lower = lhs;
684// LLWString::toLower(lhs_lower);
685// std::string lhs_lower = wstring_to_utf8str(lhs_lower);
686// LLWString rhs_lower = lhs;
687// LLWString::toLower(rhs_lower);
688// std::string rhs_lower = wstring_to_utf8str(rhs_lower);
689//
690// return strcmp(lhs_lower.c_str(), rhs_lower.c_str());
691//#endif
692//}
693
694
695std::string utf8str_trim(const std::string& utf8str) 487std::string utf8str_trim(const std::string& utf8str)
696{ 488{
697 LLWString wstr = utf8str_to_wstring(utf8str); 489 LLWString wstr = utf8str_to_wstring(utf8str);
698 LLWString::trim(wstr); 490 LLWStringUtil::trim(wstr);
699 return wstring_to_utf8str(wstr); 491 return wstring_to_utf8str(wstr);
700} 492}
701 493
@@ -703,7 +495,7 @@ std::string utf8str_trim(const std::string& utf8str)
703std::string utf8str_tolower(const std::string& utf8str) 495std::string utf8str_tolower(const std::string& utf8str)
704{ 496{
705 LLWString out_str = utf8str_to_wstring(utf8str); 497 LLWString out_str = utf8str_to_wstring(utf8str);
706 LLWString::toLower(out_str); 498 LLWStringUtil::toLower(out_str);
707 return wstring_to_utf8str(out_str); 499 return wstring_to_utf8str(out_str);
708} 500}
709 501
@@ -712,7 +504,7 @@ S32 utf8str_compare_insensitive(const std::string& lhs, const std::string& rhs)
712{ 504{
713 LLWString wlhs = utf8str_to_wstring(lhs); 505 LLWString wlhs = utf8str_to_wstring(lhs);
714 LLWString wrhs = utf8str_to_wstring(rhs); 506 LLWString wrhs = utf8str_to_wstring(rhs);
715 return LLWString::compareInsensitive(wlhs.c_str(), wrhs.c_str()); 507 return LLWStringUtil::compareInsensitive(wlhs, wrhs);
716} 508}
717 509
718std::string utf8str_truncate(const std::string& utf8str, const S32 max_len) 510std::string utf8str_truncate(const std::string& utf8str, const S32 max_len)
@@ -756,7 +548,7 @@ std::string utf8str_substChar(
756 const llwchar replace_char) 548 const llwchar replace_char)
757{ 549{
758 LLWString wstr = utf8str_to_wstring(utf8str); 550 LLWString wstr = utf8str_to_wstring(utf8str);
759 LLWString::replaceChar(wstr, target_char, replace_char); 551 LLWStringUtil::replaceChar(wstr, target_char, replace_char);
760 //wstr = wstring_substChar(wstr, target_char, replace_char); 552 //wstr = wstring_substChar(wstr, target_char, replace_char);
761 return wstring_to_utf8str(wstr); 553 return wstring_to_utf8str(wstr);
762} 554}
@@ -764,7 +556,7 @@ std::string utf8str_substChar(
764std::string utf8str_makeASCII(const std::string& utf8str) 556std::string utf8str_makeASCII(const std::string& utf8str)
765{ 557{
766 LLWString wstr = utf8str_to_wstring(utf8str); 558 LLWString wstr = utf8str_to_wstring(utf8str);
767 LLWString::_makeASCII(wstr); 559 LLWStringUtil::_makeASCII(wstr);
768 return wstring_to_utf8str(wstr); 560 return wstring_to_utf8str(wstr);
769} 561}
770 562
@@ -929,6 +721,32 @@ namespace LLStringFn
929 } 721 }
930 } 722 }
931 } 723 }
724
725 // https://wiki.lindenlab.com/wiki/Unicode_Guidelines has details on
726 // allowable code points for XML. Specifically, they are:
727 // 0x09, 0x0a, 0x0d, and 0x20 on up. JC
728 std::string strip_invalid_xml(const std::string& input)
729 {
730 std::string output;
731 output.reserve( input.size() );
732 std::string::const_iterator it = input.begin();
733 while (it != input.end())
734 {
735 // Must compare as unsigned for >=
736 // Test most likely match first
737 const unsigned char c = (unsigned char)*it;
738 if ( c >= (unsigned char)0x20 // SPACE
739 || c == (unsigned char)0x09 // TAB
740 || c == (unsigned char)0x0a // LINE_FEED
741 || c == (unsigned char)0x0d ) // CARRIAGE_RETURN
742 {
743 output.push_back(c);
744 }
745 ++it;
746 }
747 return output;
748 }
749
932} 750}
933 751
934 752
@@ -938,19 +756,19 @@ namespace LLStringFn
938#ifdef _DEBUG 756#ifdef _DEBUG
939 757
940template<class T> 758template<class T>
941void LLStringBase<T>::testHarness() 759void LLStringUtilBase<T>::testHarness()
942{ 760{
943 LLString s1; 761 std::string s1;
944 762
945 llassert( s1.c_str() == NULL ); 763 llassert( s1.c_str() == NULL );
946 llassert( s1.size() == 0 ); 764 llassert( s1.size() == 0 );
947 llassert( s1.empty() ); 765 llassert( s1.empty() );
948 766
949 LLString s2( "hello"); 767 std::string s2( "hello");
950 llassert( !strcmp( s2.c_str(), "hello" ) ); 768 llassert( !strcmp( s2.c_str(), "hello" ) );
951 llassert( s2.size() == 5 ); 769 llassert( s2.size() == 5 );
952 llassert( !s2.empty() ); 770 llassert( !s2.empty() );
953 LLString s3( s2 ); 771 std::string s3( s2 );
954 772
955 llassert( "hello" == s2 ); 773 llassert( "hello" == s2 );
956 llassert( s2 == "hello" ); 774 llassert( s2 == "hello" );
@@ -959,12 +777,12 @@ void LLStringBase<T>::testHarness()
959 llassert( "gello" != s2 ); 777 llassert( "gello" != s2 );
960 llassert( s2 != "gello" ); 778 llassert( s2 != "gello" );
961 779
962 LLString s4 = s2; 780 std::string s4 = s2;
963 llassert( !s4.empty() ); 781 llassert( !s4.empty() );
964 s4.empty(); 782 s4.empty();
965 llassert( s4.empty() ); 783 llassert( s4.empty() );
966 784
967 LLString s5(""); 785 std::string s5("");
968 llassert( s5.empty() ); 786 llassert( s5.empty() );
969 787
970 llassert( isValidIndex(s5, 0) ); 788 llassert( isValidIndex(s5, 0) );
@@ -978,8 +796,8 @@ void LLStringBase<T>::testHarness()
978 llassert( s4 == "hello again!hello again!" ); 796 llassert( s4 == "hello again!hello again!" );
979 797
980 798
981 LLString s6 = s2 + " " + s2; 799 std::string s6 = s2 + " " + s2;
982 LLString s7 = s6; 800 std::string s7 = s6;
983 llassert( s6 == s7 ); 801 llassert( s6 == s7 );
984 llassert( !( s6 != s7) ); 802 llassert( !( s6 != s7) );
985 llassert( !(s6 < s7) ); 803 llassert( !(s6 < s7) );
@@ -1002,10 +820,10 @@ void LLStringBase<T>::testHarness()
1002 s2.insert( 1, "awn, don't yel"); 820 s2.insert( 1, "awn, don't yel");
1003 llassert( s2 == "yawn, don't yell"); 821 llassert( s2 == "yawn, don't yell");
1004 822
1005 LLString s8 = s2.substr( 6, 5 ); 823 std::string s8 = s2.substr( 6, 5 );
1006 llassert( s8 == "don't" ); 824 llassert( s8 == "don't" );
1007 825
1008 LLString s9 = " \t\ntest \t\t\n "; 826 std::string s9 = " \t\ntest \t\t\n ";
1009 trim(s9); 827 trim(s9);
1010 llassert( s9 == "test" ); 828 llassert( s9 == "test" );
1011 829
@@ -1020,17 +838,17 @@ void LLStringBase<T>::testHarness()
1020 llassert( s9 == "abc123&*(abc" ); 838 llassert( s9 == "abc123&*(abc" );
1021 839
1022 840
1023 LLString s10( 10, 'x' ); 841 std::string s10( 10, 'x' );
1024 llassert( s10 == "xxxxxxxxxx" ); 842 llassert( s10 == "xxxxxxxxxx" );
1025 843
1026 LLString s11( "monkey in the middle", 7, 2 ); 844 std::string s11( "monkey in the middle", 7, 2 );
1027 llassert( s11 == "in" ); 845 llassert( s11 == "in" );
1028 846
1029 LLString s12; //empty 847 std::string s12; //empty
1030 s12 += "foo"; 848 s12 += "foo";
1031 llassert( s12 == "foo" ); 849 llassert( s12 == "foo" );
1032 850
1033 LLString s13; //empty 851 std::string s13; //empty
1034 s13 += 'f'; 852 s13 += 'f';
1035 llassert( s13 == "f" ); 853 llassert( s13 == "f" );
1036} 854}
diff --git a/linden/indra/llcommon/llstring.h b/linden/indra/llcommon/llstring.h
index 82ebdc9..60a4492 100644
--- a/linden/indra/llcommon/llstring.h
+++ b/linden/indra/llcommon/llstring.h
@@ -1,6 +1,6 @@
1/** 1/**
2 * @file llstring.h 2 * @file llstring.h
3 * @brief String utility functions and LLString class. 3 * @brief String utility functions and std::string class.
4 * 4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$ 5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 * 6 *
@@ -39,15 +39,8 @@
39 39
40const char LL_UNKNOWN_CHAR = '?'; 40const char LL_UNKNOWN_CHAR = '?';
41 41
42class LLVector3; 42#if LL_DARWIN || LL_LINUX || LL_SOLARIS
43class LLVector3d; 43// Template specialization of char_traits for U16s. Only necessary on Mac and Linux (exists on Windows already)
44class LLQuaternion;
45class LLUUID;
46class LLColor4;
47class LLColor4U;
48
49#if (LL_DARWIN || LL_SOLARIS || (LL_LINUX && __GNUC__ > 2))
50// Template specialization of char_traits for U16s. Only necessary on Mac for now (exists on Windows, unused/broken on Linux/gcc2.95)
51namespace std 44namespace std
52{ 45{
53template<> 46template<>
@@ -162,79 +155,29 @@ public:
162 static BOOL isDigit(llwchar a) { return iswdigit(a) != 0; } 155 static BOOL isDigit(llwchar a) { return iswdigit(a) != 0; }
163}; 156};
164 157
165//RN: I used a templated base class instead of a pure interface class to minimize code duplication 158// Allowing assignments from non-strings into format_map_t is apparently
166// but it might be worthwhile to just go with two implementations (LLString and LLWString) of 159// *really* error-prone, so subclass std::string with just basic c'tors.
167// an interface class, unless we can think of a good reason to have a std::basic_string polymorphic base 160class FormatMapString : public std::string
168 161{
169//**************************************************************** 162public:
170// NOTA BENE: do *NOT* dynamically allocate memory inside of LLStringBase as the {*()^#%*)#%W^*)#%*)STL implentation 163 FormatMapString() : std::string() {};
171// of basic_string doesn't provide a virtual destructor. If we need to allocate resources specific to LLString 164 FormatMapString(const char* s) : std::string(s) {};
172// then we should either customize std::basic_string to linden::basic_string or change LLString to be a wrapper 165 FormatMapString(const std::string& s) : std::string(s) {};
173// that contains an instance of std::basic_string. Similarly, overriding methods defined in std::basic_string will *not* 166};
174// be called in a polymorphic manner (passing an instance of basic_string to a particular function)
175//****************************************************************
176 167
177template <class T> 168template <class T>
178class LLStringBase : public std::basic_string<T> 169class LLStringUtilBase
179{ 170{
180public: 171public:
181 typedef typename std::basic_string<T>::size_type size_type; 172 typedef typename std::basic_string<T>::size_type size_type;
182 173
183 // naming convention follows those set for LLUUID
184// static LLStringBase null; // deprecated for std::string compliance
185// static LLStringBase zero_length; // deprecated for std::string compliance
186
187
188 // standard constructors
189 LLStringBase() : std::basic_string<T>() {}
190 LLStringBase(const LLStringBase& s): std::basic_string<T>(s) {}
191 LLStringBase(const std::basic_string<T>& s) : std::basic_string<T>(s) {}
192 LLStringBase(const std::basic_string<T>& s, size_type pos, size_type n = std::basic_string<T>::npos)
193 : std::basic_string<T>(s, pos, n) {}
194 LLStringBase(size_type count, const T& c) : std::basic_string<T>() { assign(count, c);}
195 // custom constructors
196 LLStringBase(const T* s);
197 LLStringBase(const T* s, size_type n);
198 LLStringBase(const T* s, size_type pos, size_type n );
199
200#if LL_LINUX || LL_SOLARIS
201 void clear() { assign(null); }
202
203 LLStringBase<T>& assign(const T* s);
204 LLStringBase<T>& assign(const T* s, size_type n);
205 LLStringBase<T>& assign(const LLStringBase& s);
206 LLStringBase<T>& assign(size_type n, const T& c);
207 LLStringBase<T>& assign(const T* a, const T* b);
208 LLStringBase<T>& assign(typename LLStringBase<T>::iterator &it1, typename LLStringBase<T>::iterator &it2);
209 LLStringBase<T>& assign(typename LLStringBase<T>::const_iterator &it1, typename LLStringBase<T>::const_iterator &it2);
210
211 // workaround for bug in gcc2 STL headers.
212 #if ((__GNUC__ <= 2) && (!defined _STLPORT_VERSION))
213 const T* c_str () const
214 {
215 if (length () == 0)
216 {
217 static const T zero = 0;
218 return &zero;
219 }
220
221 //terminate ();
222 { string_char_traits<T>::assign(const_cast<T*>(data())[length()], string_char_traits<T>::eos()); }
223
224 return data ();
225 }
226 #endif
227#endif
228
229 bool operator==(const T* _Right) const { return _Right ? (std::basic_string<T>::compare(_Right) == 0) : this->empty(); }
230
231public: 174public:
232 ///////////////////////////////////////////////////////////////////////////////////////// 175 /////////////////////////////////////////////////////////////////////////////////////////
233 // Static Utility functions that operate on std::strings 176 // Static Utility functions that operate on std::strings
234 177
235 static LLStringBase null; 178 static std::basic_string<T> null;
236 179
237 typedef std::map<std::string, std::string> format_map_t; 180 typedef std::map<FormatMapString, FormatMapString> format_map_t;
238 static S32 format(std::basic_string<T>& s, const format_map_t& fmt_map); 181 static S32 format(std::basic_string<T>& s, const format_map_t& fmt_map);
239 182
240 static BOOL isValidIndex(const std::basic_string<T>& string, size_type i) 183 static BOOL isValidIndex(const std::basic_string<T>& string, size_type i)
@@ -266,8 +209,8 @@ public:
266 /** 209 /**
267 * @brief Unsafe way to make ascii characters. You should probably 210 * @brief Unsafe way to make ascii characters. You should probably
268 * only call this when interacting with the host operating system. 211 * only call this when interacting with the host operating system.
269 * The 1 byte LLString does not work correctly. 212 * The 1 byte std::string does not work correctly.
270 * The 2 and 4 byte LLString probably work, so LLWString::_makeASCII 213 * The 2 and 4 byte std::string probably work, so LLWStringUtil::_makeASCII
271 * should work. 214 * should work.
272 */ 215 */
273 static void _makeASCII(std::basic_string<T>& string); 216 static void _makeASCII(std::basic_string<T>& string);
@@ -289,11 +232,13 @@ public:
289 // Like strcmp but also handles empty strings. Uses 232 // Like strcmp but also handles empty strings. Uses
290 // current locale. 233 // current locale.
291 static S32 compareStrings(const T* lhs, const T* rhs); 234 static S32 compareStrings(const T* lhs, const T* rhs);
235 static S32 compareStrings(const std::basic_string<T>& lhs, const std::basic_string<T>& rhs);
292 236
293 // case insensitive version of above. Uses current locale on 237 // case insensitive version of above. Uses current locale on
294 // Win32, and falls back to a non-locale aware comparison on 238 // Win32, and falls back to a non-locale aware comparison on
295 // Linux. 239 // Linux.
296 static S32 compareInsensitive(const T* lhs, const T* rhs); 240 static S32 compareInsensitive(const T* lhs, const T* rhs);
241 static S32 compareInsensitive(const std::basic_string<T>& lhs, const std::basic_string<T>& rhs);
297 242
298 // Case sensitive comparison with good handling of numbers. Does not use current locale. 243 // Case sensitive comparison with good handling of numbers. Does not use current locale.
299 // a.k.a. strdictcmp() 244 // a.k.a. strdictcmp()
@@ -320,21 +265,21 @@ public:
320 265
321}; 266};
322 267
323template<class T> LLStringBase<T> LLStringBase<T>::null; 268template<class T> std::basic_string<T> LLStringUtilBase<T>::null;
324 269
325typedef LLStringBase<char> LLString; 270typedef LLStringUtilBase<char> LLStringUtil;
326typedef LLStringBase<llwchar> LLWString; 271typedef LLStringUtilBase<llwchar> LLWStringUtil;
272typedef std::basic_string<llwchar> LLWString;
327 273
328//@ Use this where we want to disallow input in the form of "foo" 274//@ Use this where we want to disallow input in the form of "foo"
329// This is used to catch places where english text is embedded in the code 275// This is used to catch places where english text is embedded in the code
330// instead of in a translatable XUI file. 276// instead of in a translatable XUI file.
331class LLStringExplicit : public LLString 277class LLStringExplicit : public std::string
332{ 278{
333public: 279public:
334 explicit LLStringExplicit(const char* s) : LLString(s) {} 280 explicit LLStringExplicit(const char* s) : std::string(s) {}
335 LLStringExplicit(const LLString& s) : LLString(s) {} 281 LLStringExplicit(const std::string& s) : std::string(s) {}
336 LLStringExplicit(const std::string& s) : LLString(s) {} 282 LLStringExplicit(const std::string& s, size_type pos, size_type n = std::string::npos) : std::string(s, pos, n) {}
337 LLStringExplicit(const std::string& s, size_type pos, size_type n = std::string::npos) : LLString(s, pos, n) {}
338}; 283};
339 284
340struct LLDictionaryLess 285struct LLDictionaryLess
@@ -342,7 +287,7 @@ struct LLDictionaryLess
342public: 287public:
343 bool operator()(const std::string& a, const std::string& b) 288 bool operator()(const std::string& a, const std::string& b)
344 { 289 {
345 return (LLString::precedesDict(a, b) ? true : false); 290 return (LLStringUtil::precedesDict(a, b) ? true : false);
346 } 291 }
347}; 292};
348 293
@@ -371,6 +316,7 @@ inline std::string chop_tail_copy(
371 * pointer is NULL. 316 * pointer is NULL.
372 */ 317 */
373std::string ll_safe_string(const char* in); 318std::string ll_safe_string(const char* in);
319std::string ll_safe_string(const char* in, S32 maxlen);
374 320
375/** 321/**
376 * @brief This translates a nybble stored as a hex value from 0-f back 322 * @brief This translates a nybble stored as a hex value from 0-f back
@@ -387,7 +333,7 @@ U8 hex_as_nybble(char hex);
387 * @param filename The full name of the file to read. 333 * @param filename The full name of the file to read.
388 * @return Returns true on success. If false, str is unmodified. 334 * @return Returns true on success. If false, str is unmodified.
389 */ 335 */
390bool _read_file_into_string(std::string& str, const char* filename); 336bool _read_file_into_string(std::string& str, const std::string& filename);
391 337
392/** 338/**
393 * Unicode support 339 * Unicode support
@@ -409,20 +355,17 @@ LLWString utf16str_to_wstring(const llutf16string &utf16str);
409llutf16string wstring_to_utf16str(const LLWString &utf32str, S32 len); 355llutf16string wstring_to_utf16str(const LLWString &utf32str, S32 len);
410llutf16string wstring_to_utf16str(const LLWString &utf32str); 356llutf16string wstring_to_utf16str(const LLWString &utf32str);
411 357
412llutf16string utf8str_to_utf16str ( const LLString& utf8str, S32 len); 358llutf16string utf8str_to_utf16str ( const std::string& utf8str, S32 len);
413llutf16string utf8str_to_utf16str ( const LLString& utf8str ); 359llutf16string utf8str_to_utf16str ( const std::string& utf8str );
414 360
415LLWString utf8str_to_wstring(const std::string &utf8str, S32 len); 361LLWString utf8str_to_wstring(const std::string &utf8str, S32 len);
416LLWString utf8str_to_wstring(const std::string &utf8str); 362LLWString utf8str_to_wstring(const std::string &utf8str);
417// Same function, better name. JC 363// Same function, better name. JC
418inline LLWString utf8string_to_wstring(const std::string& utf8_string) { return utf8str_to_wstring(utf8_string); } 364inline LLWString utf8string_to_wstring(const std::string& utf8_string) { return utf8str_to_wstring(utf8_string); }
419 365
420// Special hack for llfilepicker.cpp: 366//
421S32 utf16chars_to_utf8chars(const U16* inchars, char* outchars, S32* nchars8 = 0);
422S32 utf16chars_to_wchar(const U16* inchars, llwchar* outchar);
423S32 wchar_to_utf8chars(llwchar inchar, char* outchars); 367S32 wchar_to_utf8chars(llwchar inchar, char* outchars);
424 368
425//
426std::string wstring_to_utf8str(const LLWString &utf32str, S32 len); 369std::string wstring_to_utf8str(const LLWString &utf32str, S32 len);
427std::string wstring_to_utf8str(const LLWString &utf32str); 370std::string wstring_to_utf8str(const LLWString &utf32str);
428 371
@@ -484,15 +427,6 @@ std::string mbcsstring_makeASCII(const std::string& str);
484std::string utf8str_removeCRLF(const std::string& utf8str); 427std::string utf8str_removeCRLF(const std::string& utf8str);
485 428
486 429
487template <class T>
488std::ostream& operator<<(std::ostream &s, const LLStringBase<T> &str)
489{
490 s << ((std::basic_string<T>)str);
491 return s;
492}
493
494std::ostream& operator<<(std::ostream &s, const LLWString &wstr);
495
496#if LL_WINDOWS 430#if LL_WINDOWS
497/* @name Windows string helpers 431/* @name Windows string helpers
498 */ 432 */
@@ -528,7 +462,7 @@ std::string ll_convert_wide_to_string(const wchar_t* in);
528#endif // LL_WINDOWS 462#endif // LL_WINDOWS
529 463
530/** 464/**
531 * Many of the 'strip' and 'replace' methods of LLStringBase need 465 * Many of the 'strip' and 'replace' methods of LLStringUtilBase need
532 * specialization to work with the signed char type. 466 * specialization to work with the signed char type.
533 * Sadly, it is not possible (AFAIK) to specialize a single method of 467 * Sadly, it is not possible (AFAIK) to specialize a single method of
534 * a template class. 468 * a template class.
@@ -581,30 +515,68 @@ namespace LLStringFn
581 */ 515 */
582 void replace_nonprintable_and_pipe(std::basic_string<llwchar>& str, 516 void replace_nonprintable_and_pipe(std::basic_string<llwchar>& str,
583 llwchar replacement); 517 llwchar replacement);
518
519 /**
520 * @brief Remove all characters that are not allowed in XML 1.0.
521 * Returns a copy of the string with those characters removed.
522 * Works with US ASCII and UTF-8 encoded strings. JC
523 */
524 std::string strip_invalid_xml(const std::string& input);
584} 525}
585 526
586//////////////////////////////////////////////////////////// 527////////////////////////////////////////////////////////////
587 528
529// LLStringBase::format()
530//
531// This function takes a string 's' and a map 'fmt_map' of strings-to-strings.
532// All occurances of strings in 's' from the left-hand side of 'fmt_map' are
533// then replaced with the corresponding right-hand side of 'fmt_map', non-
534// recursively. The function returns the number of substitutions made.
535
588// static 536// static
589template<class T> 537template<class T>
590S32 LLStringBase<T>::format(std::basic_string<T>& s, const format_map_t& fmt_map) 538S32 LLStringUtilBase<T>::format(std::basic_string<T>& s, const format_map_t& fmt_map)
591{ 539{
592 typedef typename std::basic_string<T>::size_type string_size_type_t; 540 typedef typename std::basic_string<T>::size_type string_size_type_t;
541 string_size_type_t scanstart = 0;
593 S32 res = 0; 542 S32 res = 0;
594 for (format_map_t::const_iterator iter = fmt_map.begin(); iter != fmt_map.end(); ++iter) 543
544 // Look for the first match of any keyword, replace that keyword,
545 // repeat from the end of the replacement string. This avoids
546 // accidentally performing substitution on a substituted string.
547 while (1)
595 { 548 {
596 U32 fmtlen = iter->first.size(); 549 string_size_type_t first_match_pos = scanstart;
597 string_size_type_t n = 0; 550 string_size_type_t first_match_str_length = 0;
598 while (1) 551 std::basic_string<T> first_match_str_replacement;
552
553 for (format_map_t::const_iterator iter = fmt_map.begin();
554 iter != fmt_map.end();
555 ++iter)
599 { 556 {
600 n = s.find(iter->first, n); 557 string_size_type_t n = s.find(iter->first, scanstart);
601 if (n == std::basic_string<T>::npos) 558 if (n != std::basic_string<T>::npos &&
559 (n < first_match_pos ||
560 0 == first_match_str_length))
602 { 561 {
603 break; 562 first_match_pos = n;
563 first_match_str_length = iter->first.length();
564 first_match_str_replacement = iter->second;
604 } 565 }
605 s.erase(n, fmtlen); 566 }
606 s.insert(n, iter->second); 567
607 n += fmtlen; 568 if (0 == first_match_str_length)
569 {
570 // no more keys found to substitute from this point
571 // in the string forward.
572 break;
573 }
574 else
575 {
576 s.erase(first_match_pos, first_match_str_length);
577 s.insert(first_match_pos, first_match_str_replacement);
578 scanstart = first_match_pos +
579 first_match_str_replacement.length();
608 ++res; 580 ++res;
609 } 581 }
610 } 582 }
@@ -613,7 +585,7 @@ S32 LLStringBase<T>::format(std::basic_string<T>& s, const format_map_t& fmt_map
613 585
614// static 586// static
615template<class T> 587template<class T>
616S32 LLStringBase<T>::compareStrings(const T* lhs, const T* rhs) 588S32 LLStringUtilBase<T>::compareStrings(const T* lhs, const T* rhs)
617{ 589{
618 S32 result; 590 S32 result;
619 if( lhs == rhs ) 591 if( lhs == rhs )
@@ -637,9 +609,16 @@ S32 LLStringBase<T>::compareStrings(const T* lhs, const T* rhs)
637 return result; 609 return result;
638} 610}
639 611
612//static
613template<class T>
614S32 LLStringUtilBase<T>::compareStrings(const std::basic_string<T>& lhs, const std::basic_string<T>& rhs)
615{
616 return LLStringOps::collate(lhs.c_str(), rhs.c_str());
617}
618
640// static 619// static
641template<class T> 620template<class T>
642S32 LLStringBase<T>::compareInsensitive(const T* lhs, const T* rhs ) 621S32 LLStringUtilBase<T>::compareInsensitive(const T* lhs, const T* rhs )
643{ 622{
644 S32 result; 623 S32 result;
645 if( lhs == rhs ) 624 if( lhs == rhs )
@@ -658,22 +637,32 @@ S32 LLStringBase<T>::compareInsensitive(const T* lhs, const T* rhs )
658 } 637 }
659 else 638 else
660 { 639 {
661 LLStringBase<T> lhs_string(lhs); 640 std::basic_string<T> lhs_string(lhs);
662 LLStringBase<T> rhs_string(rhs); 641 std::basic_string<T> rhs_string(rhs);
663 LLStringBase<T>::toUpper(lhs_string); 642 LLStringUtilBase<T>::toUpper(lhs_string);
664 LLStringBase<T>::toUpper(rhs_string); 643 LLStringUtilBase<T>::toUpper(rhs_string);
665 result = LLStringOps::collate(lhs_string.c_str(), rhs_string.c_str()); 644 result = LLStringOps::collate(lhs_string.c_str(), rhs_string.c_str());
666 } 645 }
667 return result; 646 return result;
668} 647}
669 648
649//static
650template<class T>
651S32 LLStringUtilBase<T>::compareInsensitive(const std::basic_string<T>& lhs, const std::basic_string<T>& rhs)
652{
653 std::basic_string<T> lhs_string(lhs);
654 std::basic_string<T> rhs_string(rhs);
655 LLStringUtilBase<T>::toUpper(lhs_string);
656 LLStringUtilBase<T>::toUpper(rhs_string);
657 return LLStringOps::collate(lhs_string.c_str(), rhs_string.c_str());
658}
670 659
671// Case sensitive comparison with good handling of numbers. Does not use current locale. 660// Case sensitive comparison with good handling of numbers. Does not use current locale.
672// a.k.a. strdictcmp() 661// a.k.a. strdictcmp()
673 662
674//static 663//static
675template<class T> 664template<class T>
676S32 LLStringBase<T>::compareDict(const std::basic_string<T>& astr, const std::basic_string<T>& bstr) 665S32 LLStringUtilBase<T>::compareDict(const std::basic_string<T>& astr, const std::basic_string<T>& bstr)
677{ 666{
678 const T* a = astr.c_str(); 667 const T* a = astr.c_str();
679 const T* b = bstr.c_str(); 668 const T* b = bstr.c_str();
@@ -712,8 +701,9 @@ S32 LLStringBase<T>::compareDict(const std::basic_string<T>& astr, const std::ba
712 return ca-cb; 701 return ca-cb;
713} 702}
714 703
704// static
715template<class T> 705template<class T>
716S32 LLStringBase<T>::compareDictInsensitive(const std::basic_string<T>& astr, const std::basic_string<T>& bstr) 706S32 LLStringUtilBase<T>::compareDictInsensitive(const std::basic_string<T>& astr, const std::basic_string<T>& bstr)
717{ 707{
718 const T* a = astr.c_str(); 708 const T* a = astr.c_str();
719 const T* b = bstr.c_str(); 709 const T* b = bstr.c_str();
@@ -748,11 +738,11 @@ S32 LLStringBase<T>::compareDictInsensitive(const std::basic_string<T>& astr, co
748// Puts compareDict() in a form appropriate for LL container classes to use for sorting. 738// Puts compareDict() in a form appropriate for LL container classes to use for sorting.
749// static 739// static
750template<class T> 740template<class T>
751BOOL LLStringBase<T>::precedesDict( const std::basic_string<T>& a, const std::basic_string<T>& b ) 741BOOL LLStringUtilBase<T>::precedesDict( const std::basic_string<T>& a, const std::basic_string<T>& b )
752{ 742{
753 if( a.size() && b.size() ) 743 if( a.size() && b.size() )
754 { 744 {
755 return (LLStringBase<T>::compareDict(a.c_str(), b.c_str()) < 0); 745 return (LLStringUtilBase<T>::compareDict(a.c_str(), b.c_str()) < 0);
756 } 746 }
757 else 747 else
758 { 748 {
@@ -760,108 +750,9 @@ BOOL LLStringBase<T>::precedesDict( const std::basic_string<T>& a, const std::ba
760 } 750 }
761} 751}
762 752
763// Constructors
764template<class T>
765LLStringBase<T>::LLStringBase(const T* s ) : std::basic_string<T>()
766{
767 if (s) assign(s);
768}
769
770template<class T>
771LLStringBase<T>::LLStringBase(const T* s, size_type n ) : std::basic_string<T>()
772{
773 if (s) assign(s, n);
774}
775
776// Init from a substring
777template<class T>
778LLStringBase<T>::LLStringBase(const T* s, size_type pos, size_type n ) : std::basic_string<T>()
779{
780 if( s )
781 {
782 assign(s + pos, n);
783 }
784 else
785 {
786 assign(LLStringBase<T>::null);
787 }
788}
789
790#if LL_LINUX || LL_SOLARIS
791template<class T>
792LLStringBase<T>& LLStringBase<T>::assign(const T* s)
793{
794 if (s)
795 {
796 std::basic_string<T>::assign(s);
797 }
798 else
799 {
800 assign(LLStringBase<T>::null);
801 }
802 return *this;
803}
804
805template<class T>
806LLStringBase<T>& LLStringBase<T>::assign(const T* s, size_type n)
807{
808 if (s)
809 {
810 std::basic_string<T>::assign(s, n);
811 }
812 else
813 {
814 assign(LLStringBase<T>::null);
815 }
816 return *this;
817}
818
819template<class T>
820LLStringBase<T>& LLStringBase<T>::assign(const LLStringBase<T>& s)
821{
822 std::basic_string<T>::assign(s);
823 return *this;
824}
825
826template<class T>
827LLStringBase<T>& LLStringBase<T>::assign(size_type n, const T& c)
828{
829 std::basic_string<T>::assign(n, c);
830 return *this;
831}
832
833template<class T>
834LLStringBase<T>& LLStringBase<T>::assign(const T* a, const T* b)
835{
836 if (a > b)
837 assign(LLStringBase<T>::null);
838 else
839 assign(a, (size_type) (b-a));
840 return *this;
841}
842
843template<class T>
844LLStringBase<T>& LLStringBase<T>::assign(typename LLStringBase<T>::iterator &it1, typename LLStringBase<T>::iterator &it2)
845{
846 assign(LLStringBase<T>::null);
847 while(it1 != it2)
848 *this += *it1++;
849 return *this;
850}
851
852template<class T>
853LLStringBase<T>& LLStringBase<T>::assign(typename LLStringBase<T>::const_iterator &it1, typename LLStringBase<T>::const_iterator &it2)
854{
855 assign(LLStringBase<T>::null);
856 while(it1 != it2)
857 *this += *it1++;
858 return *this;
859}
860#endif
861
862//static 753//static
863template<class T> 754template<class T>
864void LLStringBase<T>::toUpper(std::basic_string<T>& string) 755void LLStringUtilBase<T>::toUpper(std::basic_string<T>& string)
865{ 756{
866 if( !string.empty() ) 757 if( !string.empty() )
867 { 758 {
@@ -875,7 +766,7 @@ void LLStringBase<T>::toUpper(std::basic_string<T>& string)
875 766
876//static 767//static
877template<class T> 768template<class T>
878void LLStringBase<T>::toLower(std::basic_string<T>& string) 769void LLStringUtilBase<T>::toLower(std::basic_string<T>& string)
879{ 770{
880 if( !string.empty() ) 771 if( !string.empty() )
881 { 772 {
@@ -889,7 +780,7 @@ void LLStringBase<T>::toLower(std::basic_string<T>& string)
889 780
890//static 781//static
891template<class T> 782template<class T>
892void LLStringBase<T>::trimHead(std::basic_string<T>& string) 783void LLStringUtilBase<T>::trimHead(std::basic_string<T>& string)
893{ 784{
894 if( !string.empty() ) 785 if( !string.empty() )
895 { 786 {
@@ -904,7 +795,7 @@ void LLStringBase<T>::trimHead(std::basic_string<T>& string)
904 795
905//static 796//static
906template<class T> 797template<class T>
907void LLStringBase<T>::trimTail(std::basic_string<T>& string) 798void LLStringUtilBase<T>::trimTail(std::basic_string<T>& string)
908{ 799{
909 if( string.size() ) 800 if( string.size() )
910 { 801 {
@@ -923,7 +814,7 @@ void LLStringBase<T>::trimTail(std::basic_string<T>& string)
923// Replace line feeds with carriage return-line feed pairs. 814// Replace line feeds with carriage return-line feed pairs.
924//static 815//static
925template<class T> 816template<class T>
926void LLStringBase<T>::addCRLF(std::basic_string<T>& string) 817void LLStringUtilBase<T>::addCRLF(std::basic_string<T>& string)
927{ 818{
928 const T LF = 10; 819 const T LF = 10;
929 const T CR = 13; 820 const T CR = 13;
@@ -964,7 +855,7 @@ void LLStringBase<T>::addCRLF(std::basic_string<T>& string)
964// Remove all carriage returns 855// Remove all carriage returns
965//static 856//static
966template<class T> 857template<class T>
967void LLStringBase<T>::removeCRLF(std::basic_string<T>& string) 858void LLStringUtilBase<T>::removeCRLF(std::basic_string<T>& string)
968{ 859{
969 const T CR = 13; 860 const T CR = 13;
970 861
@@ -985,7 +876,7 @@ void LLStringBase<T>::removeCRLF(std::basic_string<T>& string)
985 876
986//static 877//static
987template<class T> 878template<class T>
988void LLStringBase<T>::replaceChar( std::basic_string<T>& string, T target, T replacement ) 879void LLStringUtilBase<T>::replaceChar( std::basic_string<T>& string, T target, T replacement )
989{ 880{
990 size_type found_pos = 0; 881 size_type found_pos = 0;
991 for (found_pos = string.find(target, found_pos); 882 for (found_pos = string.find(target, found_pos);
@@ -998,7 +889,7 @@ void LLStringBase<T>::replaceChar( std::basic_string<T>& string, T target, T rep
998 889
999//static 890//static
1000template<class T> 891template<class T>
1001void LLStringBase<T>::replaceNonstandardASCII( std::basic_string<T>& string, T replacement ) 892void LLStringUtilBase<T>::replaceNonstandardASCII( std::basic_string<T>& string, T replacement )
1002{ 893{
1003 const char LF = 10; 894 const char LF = 10;
1004 const S8 MIN = 32; 895 const S8 MIN = 32;
@@ -1018,12 +909,12 @@ void LLStringBase<T>::replaceNonstandardASCII( std::basic_string<T>& string, T r
1018 909
1019//static 910//static
1020template<class T> 911template<class T>
1021void LLStringBase<T>::replaceTabsWithSpaces( std::basic_string<T>& str, size_type spaces_per_tab ) 912void LLStringUtilBase<T>::replaceTabsWithSpaces( std::basic_string<T>& str, size_type spaces_per_tab )
1022{ 913{
1023 const T TAB = '\t'; 914 const T TAB = '\t';
1024 const T SPACE = ' '; 915 const T SPACE = ' ';
1025 916
1026 LLStringBase<T> out_str; 917 std::basic_string<T> out_str;
1027 // Replace tabs with spaces 918 // Replace tabs with spaces
1028 for (size_type i = 0; i < str.length(); i++) 919 for (size_type i = 0; i < str.length(); i++)
1029 { 920 {
@@ -1042,7 +933,7 @@ void LLStringBase<T>::replaceTabsWithSpaces( std::basic_string<T>& str, size_typ
1042 933
1043//static 934//static
1044template<class T> 935template<class T>
1045BOOL LLStringBase<T>::containsNonprintable(const std::basic_string<T>& string) 936BOOL LLStringUtilBase<T>::containsNonprintable(const std::basic_string<T>& string)
1046{ 937{
1047 const char MIN = 32; 938 const char MIN = 32;
1048 BOOL rv = FALSE; 939 BOOL rv = FALSE;
@@ -1059,7 +950,7 @@ BOOL LLStringBase<T>::containsNonprintable(const std::basic_string<T>& string)
1059 950
1060//static 951//static
1061template<class T> 952template<class T>
1062void LLStringBase<T>::stripNonprintable(std::basic_string<T>& string) 953void LLStringUtilBase<T>::stripNonprintable(std::basic_string<T>& string)
1063{ 954{
1064 const char MIN = 32; 955 const char MIN = 32;
1065 size_type j = 0; 956 size_type j = 0;
@@ -1090,7 +981,7 @@ void LLStringBase<T>::stripNonprintable(std::basic_string<T>& string)
1090} 981}
1091 982
1092template<class T> 983template<class T>
1093void LLStringBase<T>::_makeASCII(std::basic_string<T>& string) 984void LLStringUtilBase<T>::_makeASCII(std::basic_string<T>& string)
1094{ 985{
1095 // Replace non-ASCII chars with LL_UNKNOWN_CHAR 986 // Replace non-ASCII chars with LL_UNKNOWN_CHAR
1096 for (size_type i = 0; i < string.length(); i++) 987 for (size_type i = 0; i < string.length(); i++)
@@ -1104,7 +995,7 @@ void LLStringBase<T>::_makeASCII(std::basic_string<T>& string)
1104 995
1105// static 996// static
1106template<class T> 997template<class T>
1107void LLStringBase<T>::copy( T* dst, const T* src, size_type dst_size ) 998void LLStringUtilBase<T>::copy( T* dst, const T* src, size_type dst_size )
1108{ 999{
1109 if( dst_size > 0 ) 1000 if( dst_size > 0 )
1110 { 1001 {
@@ -1120,7 +1011,7 @@ void LLStringBase<T>::copy( T* dst, const T* src, size_type dst_size )
1120 1011
1121// static 1012// static
1122template<class T> 1013template<class T>
1123void LLStringBase<T>::copyInto(std::basic_string<T>& dst, const std::basic_string<T>& src, size_type offset) 1014void LLStringUtilBase<T>::copyInto(std::basic_string<T>& dst, const std::basic_string<T>& src, size_type offset)
1124{ 1015{
1125 if ( offset == dst.length() ) 1016 if ( offset == dst.length() )
1126 { 1017 {
@@ -1141,7 +1032,7 @@ void LLStringBase<T>::copyInto(std::basic_string<T>& dst, const std::basic_strin
1141// True if this is the head of s. 1032// True if this is the head of s.
1142//static 1033//static
1143template<class T> 1034template<class T>
1144BOOL LLStringBase<T>::isHead( const std::basic_string<T>& string, const T* s ) 1035BOOL LLStringUtilBase<T>::isHead( const std::basic_string<T>& string, const T* s )
1145{ 1036{
1146 if( string.empty() ) 1037 if( string.empty() )
1147 { 1038 {
@@ -1155,14 +1046,14 @@ BOOL LLStringBase<T>::isHead( const std::basic_string<T>& string, const T* s )
1155} 1046}
1156 1047
1157template<class T> 1048template<class T>
1158BOOL LLStringBase<T>::convertToBOOL(const std::basic_string<T>& string, BOOL& value) 1049BOOL LLStringUtilBase<T>::convertToBOOL(const std::basic_string<T>& string, BOOL& value)
1159{ 1050{
1160 if( string.empty() ) 1051 if( string.empty() )
1161 { 1052 {
1162 return FALSE; 1053 return FALSE;
1163 } 1054 }
1164 1055
1165 LLStringBase<T> temp( string ); 1056 std::basic_string<T> temp( string );
1166 trim(temp); 1057 trim(temp);
1167 if( 1058 if(
1168 (temp == "1") || 1059 (temp == "1") ||
@@ -1192,7 +1083,7 @@ BOOL LLStringBase<T>::convertToBOOL(const std::basic_string<T>& string, BOOL& va
1192} 1083}
1193 1084
1194template<class T> 1085template<class T>
1195BOOL LLStringBase<T>::convertToU8(const std::basic_string<T>& string, U8& value) 1086BOOL LLStringUtilBase<T>::convertToU8(const std::basic_string<T>& string, U8& value)
1196{ 1087{
1197 S32 value32 = 0; 1088 S32 value32 = 0;
1198 BOOL success = convertToS32(string, value32); 1089 BOOL success = convertToS32(string, value32);
@@ -1205,7 +1096,7 @@ BOOL LLStringBase<T>::convertToU8(const std::basic_string<T>& string, U8& value)
1205} 1096}
1206 1097
1207template<class T> 1098template<class T>
1208BOOL LLStringBase<T>::convertToS8(const std::basic_string<T>& string, S8& value) 1099BOOL LLStringUtilBase<T>::convertToS8(const std::basic_string<T>& string, S8& value)
1209{ 1100{
1210 S32 value32 = 0; 1101 S32 value32 = 0;
1211 BOOL success = convertToS32(string, value32); 1102 BOOL success = convertToS32(string, value32);
@@ -1218,7 +1109,7 @@ BOOL LLStringBase<T>::convertToS8(const std::basic_string<T>& string, S8& value)
1218} 1109}
1219 1110
1220template<class T> 1111template<class T>
1221BOOL LLStringBase<T>::convertToS16(const std::basic_string<T>& string, S16& value) 1112BOOL LLStringUtilBase<T>::convertToS16(const std::basic_string<T>& string, S16& value)
1222{ 1113{
1223 S32 value32 = 0; 1114 S32 value32 = 0;
1224 BOOL success = convertToS32(string, value32); 1115 BOOL success = convertToS32(string, value32);
@@ -1231,7 +1122,7 @@ BOOL LLStringBase<T>::convertToS16(const std::basic_string<T>& string, S16& valu
1231} 1122}
1232 1123
1233template<class T> 1124template<class T>
1234BOOL LLStringBase<T>::convertToU16(const std::basic_string<T>& string, U16& value) 1125BOOL LLStringUtilBase<T>::convertToU16(const std::basic_string<T>& string, U16& value)
1235{ 1126{
1236 S32 value32 = 0; 1127 S32 value32 = 0;
1237 BOOL success = convertToS32(string, value32); 1128 BOOL success = convertToS32(string, value32);
@@ -1244,14 +1135,14 @@ BOOL LLStringBase<T>::convertToU16(const std::basic_string<T>& string, U16& valu
1244} 1135}
1245 1136
1246template<class T> 1137template<class T>
1247BOOL LLStringBase<T>::convertToU32(const std::basic_string<T>& string, U32& value) 1138BOOL LLStringUtilBase<T>::convertToU32(const std::basic_string<T>& string, U32& value)
1248{ 1139{
1249 if( string.empty() ) 1140 if( string.empty() )
1250 { 1141 {
1251 return FALSE; 1142 return FALSE;
1252 } 1143 }
1253 1144
1254 LLStringBase<T> temp( string ); 1145 std::basic_string<T> temp( string );
1255 trim(temp); 1146 trim(temp);
1256 U32 v; 1147 U32 v;
1257 std::basic_istringstream<T> i_stream((std::basic_string<T>)temp); 1148 std::basic_istringstream<T> i_stream((std::basic_string<T>)temp);
@@ -1271,14 +1162,14 @@ BOOL LLStringBase<T>::convertToU32(const std::basic_string<T>& string, U32& valu
1271} 1162}
1272 1163
1273template<class T> 1164template<class T>
1274BOOL LLStringBase<T>::convertToS32(const std::basic_string<T>& string, S32& value) 1165BOOL LLStringUtilBase<T>::convertToS32(const std::basic_string<T>& string, S32& value)
1275{ 1166{
1276 if( string.empty() ) 1167 if( string.empty() )
1277 { 1168 {
1278 return FALSE; 1169 return FALSE;
1279 } 1170 }
1280 1171
1281 LLStringBase<T> temp( string ); 1172 std::basic_string<T> temp( string );
1282 trim(temp); 1173 trim(temp);
1283 S32 v; 1174 S32 v;
1284 std::basic_istringstream<T> i_stream((std::basic_string<T>)temp); 1175 std::basic_istringstream<T> i_stream((std::basic_string<T>)temp);
@@ -1298,7 +1189,7 @@ BOOL LLStringBase<T>::convertToS32(const std::basic_string<T>& string, S32& valu
1298} 1189}
1299 1190
1300template<class T> 1191template<class T>
1301BOOL LLStringBase<T>::convertToF32(const std::basic_string<T>& string, F32& value) 1192BOOL LLStringUtilBase<T>::convertToF32(const std::basic_string<T>& string, F32& value)
1302{ 1193{
1303 F64 value64 = 0.0; 1194 F64 value64 = 0.0;
1304 BOOL success = convertToF64(string, value64); 1195 BOOL success = convertToF64(string, value64);
@@ -1311,14 +1202,14 @@ BOOL LLStringBase<T>::convertToF32(const std::basic_string<T>& string, F32& valu
1311} 1202}
1312 1203
1313template<class T> 1204template<class T>
1314BOOL LLStringBase<T>::convertToF64(const std::basic_string<T>& string, F64& value) 1205BOOL LLStringUtilBase<T>::convertToF64(const std::basic_string<T>& string, F64& value)
1315{ 1206{
1316 if( string.empty() ) 1207 if( string.empty() )
1317 { 1208 {
1318 return FALSE; 1209 return FALSE;
1319 } 1210 }
1320 1211
1321 LLStringBase<T> temp( string ); 1212 std::basic_string<T> temp( string );
1322 trim(temp); 1213 trim(temp);
1323 F64 v; 1214 F64 v;
1324 std::basic_istringstream<T> i_stream((std::basic_string<T>)temp); 1215 std::basic_istringstream<T> i_stream((std::basic_string<T>)temp);
@@ -1338,7 +1229,7 @@ BOOL LLStringBase<T>::convertToF64(const std::basic_string<T>& string, F64& valu
1338} 1229}
1339 1230
1340template<class T> 1231template<class T>
1341void LLStringBase<T>::truncate(std::basic_string<T>& string, size_type count) 1232void LLStringUtilBase<T>::truncate(std::basic_string<T>& string, size_type count)
1342{ 1233{
1343 size_type cur_size = string.size(); 1234 size_type cur_size = string.size();
1344 string.resize(count < cur_size ? count : cur_size); 1235 string.resize(count < cur_size ? count : cur_size);
diff --git a/linden/indra/llcommon/llsys.cpp b/linden/indra/llcommon/llsys.cpp
index 1285851..cb2e34a 100644
--- a/linden/indra/llcommon/llsys.cpp
+++ b/linden/indra/llcommon/llsys.cpp
@@ -143,28 +143,22 @@ LLOSInfo::LLOSInfo() :
143 143
144 std::string csdversion = utf16str_to_utf8str(osvi.szCSDVersion); 144 std::string csdversion = utf16str_to_utf8str(osvi.szCSDVersion);
145 // Display version, service pack (if any), and build number. 145 // Display version, service pack (if any), and build number.
146 char tmp[MAX_STRING]; /* Flawfinder: ignore */ 146 std::string tmpstr;
147 if(osvi.dwMajorVersion <= 4) 147 if(osvi.dwMajorVersion <= 4)
148 { 148 {
149 snprintf( /* Flawfinder: ignore */ 149 tmpstr = llformat("version %d.%d %s (Build %d)",
150 tmp, 150 osvi.dwMajorVersion,
151 sizeof(tmp), 151 osvi.dwMinorVersion,
152 "version %d.%d %s (Build %d)", 152 csdversion.c_str(),
153 osvi.dwMajorVersion, 153 (osvi.dwBuildNumber & 0xffff));
154 osvi.dwMinorVersion,
155 csdversion.c_str(),
156 (osvi.dwBuildNumber & 0xffff));
157 } 154 }
158 else 155 else
159 { 156 {
160 snprintf( /* Flawfinder: ignore */ 157 tmpstr = llformat("%s (Build %d)",
161 tmp, 158 csdversion.c_str(),
162 sizeof(tmp), 159 (osvi.dwBuildNumber & 0xffff));
163 "%s (Build %d)",
164 csdversion.c_str(),
165 (osvi.dwBuildNumber & 0xffff));
166 } 160 }
167 mOSString = mOSStringSimple + tmp; 161 mOSString = mOSStringSimple + tmpstr;
168 } 162 }
169 break; 163 break;
170 164
@@ -397,7 +391,7 @@ LLCPUInfo::LLCPUInfo()
397 mCPUString = out.str(); 391 mCPUString = out.str();
398 392
399#elif LL_LINUX 393#elif LL_LINUX
400 std::map< LLString, LLString > cpuinfo; 394 std::map< std::string, std::string > cpuinfo;
401 LLFILE* cpuinfo_fp = LLFile::fopen(CPUINFO_FILE, "rb"); 395 LLFILE* cpuinfo_fp = LLFile::fopen(CPUINFO_FILE, "rb");
402 if(cpuinfo_fp) 396 if(cpuinfo_fp)
403 { 397 {
@@ -420,21 +414,21 @@ LLCPUInfo::LLCPUInfo()
420 if (nlspot == NULL) 414 if (nlspot == NULL)
421 nlspot = line + strlen( line ); // Fallback to terminating NUL 415 nlspot = line + strlen( line ); // Fallback to terminating NUL
422 std::string linename( line, tabspot ); 416 std::string linename( line, tabspot );
423 LLString llinename(linename); 417 std::string llinename(linename);
424 LLString::toLower(llinename); 418 LLStringUtil::toLower(llinename);
425 std::string lineval( spacespot + 1, nlspot ); 419 std::string lineval( spacespot + 1, nlspot );
426 cpuinfo[ llinename ] = lineval; 420 cpuinfo[ llinename ] = lineval;
427 } 421 }
428 fclose(cpuinfo_fp); 422 fclose(cpuinfo_fp);
429 } 423 }
430# if LL_X86 424# if LL_X86
431 LLString flags = " " + cpuinfo["flags"] + " "; 425 std::string flags = " " + cpuinfo["flags"] + " ";
432 LLString::toLower(flags); 426 LLStringUtil::toLower(flags);
433 mHasSSE = ( flags.find( " sse " ) != std::string::npos ); 427 mHasSSE = ( flags.find( " sse " ) != std::string::npos );
434 mHasSSE2 = ( flags.find( " sse2 " ) != std::string::npos ); 428 mHasSSE2 = ( flags.find( " sse2 " ) != std::string::npos );
435 429
436 F64 mhz; 430 F64 mhz;
437 if (LLString::convertToF64(cpuinfo["cpu mhz"], mhz) 431 if (LLStringUtil::convertToF64(cpuinfo["cpu mhz"], mhz)
438 && 200.0 < mhz && mhz < 10000.0) 432 && 200.0 < mhz && mhz < 10000.0)
439 { 433 {
440 mCPUMhz = (S32)llrint(mhz); 434 mCPUMhz = (S32)llrint(mhz);
@@ -658,18 +652,17 @@ std::ostream& operator<<(std::ostream& s, const LLMemoryInfo& info)
658 return s; 652 return s;
659} 653}
660 654
661BOOL gunzip_file(const char *srcfile, const char *dstfile) 655BOOL gunzip_file(const std::string& srcfile, const std::string& dstfile)
662{ 656{
663 char tmpfile[LL_MAX_PATH]; /* Flawfinder: ignore */ 657 std::string tmpfile;
664 const S32 UNCOMPRESS_BUFFER_SIZE = 32768; 658 const S32 UNCOMPRESS_BUFFER_SIZE = 32768;
665 BOOL retval = FALSE; 659 BOOL retval = FALSE;
666 gzFile src = NULL; 660 gzFile src = NULL;
667 U8 buffer[UNCOMPRESS_BUFFER_SIZE]; 661 U8 buffer[UNCOMPRESS_BUFFER_SIZE];
668 LLFILE *dst = NULL; 662 LLFILE *dst = NULL;
669 S32 bytes = 0; 663 S32 bytes = 0;
670 (void *) strcpy(tmpfile, dstfile); /* Flawfinder: ignore */ 664 tmpfile = dstfile + ".t";
671 (void *) strncat(tmpfile, ".t", sizeof(tmpfile) - strlen(tmpfile) -1); /* Flawfinder: ignore */ 665 src = gzopen(srcfile.c_str(), "rb");
672 src = gzopen(srcfile, "rb");
673 if (! src) goto err; 666 if (! src) goto err;
674 dst = LLFile::fopen(tmpfile, "wb"); /* Flawfinder: ignore */ 667 dst = LLFile::fopen(tmpfile, "wb"); /* Flawfinder: ignore */
675 if (! dst) goto err; 668 if (! dst) goto err;
@@ -693,18 +686,17 @@ err:
693 return retval; 686 return retval;
694} 687}
695 688
696BOOL gzip_file(const char *srcfile, const char *dstfile) 689BOOL gzip_file(const std::string& srcfile, const std::string& dstfile)
697{ 690{
698 const S32 COMPRESS_BUFFER_SIZE = 32768; 691 const S32 COMPRESS_BUFFER_SIZE = 32768;
699 char tmpfile[LL_MAX_PATH]; /* Flawfinder: ignore */ 692 std::string tmpfile;
700 BOOL retval = FALSE; 693 BOOL retval = FALSE;
701 U8 buffer[COMPRESS_BUFFER_SIZE]; 694 U8 buffer[COMPRESS_BUFFER_SIZE];
702 gzFile dst = NULL; 695 gzFile dst = NULL;
703 LLFILE *src = NULL; 696 LLFILE *src = NULL;
704 S32 bytes = 0; 697 S32 bytes = 0;
705 (void *) strcpy(tmpfile, dstfile); /* Flawfinder: ignore */ 698 tmpfile = dstfile + ".t";
706 (void *) strncat(tmpfile, ".t", sizeof(tmpfile) - strlen(tmpfile) -1); /* Flawfinder: ignore */ 699 dst = gzopen(tmpfile.c_str(), "wb"); /* Flawfinder: ignore */
707 dst = gzopen(tmpfile, "wb"); /* Flawfinder: ignore */
708 if (! dst) goto err; 700 if (! dst) goto err;
709 src = LLFile::fopen(srcfile, "rb"); /* Flawfinder: ignore */ 701 src = LLFile::fopen(srcfile, "rb"); /* Flawfinder: ignore */
710 if (! src) goto err; 702 if (! src) goto err;
diff --git a/linden/indra/llcommon/llsys.h b/linden/indra/llcommon/llsys.h
index da7f07e..b764ca9 100644
--- a/linden/indra/llcommon/llsys.h
+++ b/linden/indra/llcommon/llsys.h
@@ -127,9 +127,9 @@ std::ostream& operator<<(std::ostream& s, const LLCPUInfo& info);
127std::ostream& operator<<(std::ostream& s, const LLMemoryInfo& info); 127std::ostream& operator<<(std::ostream& s, const LLMemoryInfo& info);
128 128
129// gunzip srcfile into dstfile. Returns FALSE on error. 129// gunzip srcfile into dstfile. Returns FALSE on error.
130BOOL gunzip_file(const char *srcfile, const char *dstfile); 130BOOL gunzip_file(const std::string& srcfile, const std::string& dstfile);
131// gzip srcfile into dstfile. Returns FALSE on error. 131// gzip srcfile into dstfile. Returns FALSE on error.
132BOOL gzip_file(const char *srcfile, const char *dstfile); 132BOOL gzip_file(const std::string& srcfile, const std::string& dstfile);
133 133
134extern LLCPUInfo gSysCPU; 134extern LLCPUInfo gSysCPU;
135 135
diff --git a/linden/indra/llcommon/llthread.cpp b/linden/indra/llcommon/llthread.cpp
index 48ebc4b..e07170b 100644
--- a/linden/indra/llcommon/llthread.cpp
+++ b/linden/indra/llcommon/llthread.cpp
@@ -31,7 +31,7 @@
31#include "linden_common.h" 31#include "linden_common.h"
32#include "llapr.h" 32#include "llapr.h"
33 33
34#include "apr-1/apr_portable.h" 34#include "apr_portable.h"
35 35
36#include "llthread.h" 36#include "llthread.h"
37 37
diff --git a/linden/indra/llcommon/llthread.h b/linden/indra/llcommon/llthread.h
index 608b218..9da3134 100644
--- a/linden/indra/llcommon/llthread.h
+++ b/linden/indra/llcommon/llthread.h
@@ -36,7 +36,7 @@
36#include "llapp.h" 36#include "llapp.h"
37#include "llmemory.h" 37#include "llmemory.h"
38 38
39#include "apr-1/apr_thread_cond.h" 39#include "apr_thread_cond.h"
40 40
41class LLThread; 41class LLThread;
42class LLMutex; 42class LLMutex;
diff --git a/linden/indra/llcommon/lltimer.cpp b/linden/indra/llcommon/lltimer.cpp
index 25d9897..967570d 100644
--- a/linden/indra/llcommon/lltimer.cpp
+++ b/linden/indra/llcommon/lltimer.cpp
@@ -429,10 +429,9 @@ BOOL LLTimer::knownBadTimer()
429// 429//
430/////////////////////////////////////////////////////////////////////////////// 430///////////////////////////////////////////////////////////////////////////////
431 431
432U32 time_corrected() 432time_t time_corrected()
433{ 433{
434 U32 corrected_time = (U32)time(NULL) + gUTCOffset; 434 return time(NULL) + gUTCOffset;
435 return corrected_time;
436} 435}
437 436
438 437
@@ -452,27 +451,25 @@ BOOL is_daylight_savings()
452} 451}
453 452
454 453
455struct tm* utc_to_pacific_time(S32 utc_time, BOOL pacific_daylight_time) 454struct tm* utc_to_pacific_time(time_t utc_time, BOOL pacific_daylight_time)
456{ 455{
457 time_t unix_time = (time_t)utc_time;
458
459 S32 pacific_offset_hours; 456 S32 pacific_offset_hours;
460 if (pacific_daylight_time) 457 if (pacific_daylight_time)
461 { 458 {
462 pacific_offset_hours = -7; 459 pacific_offset_hours = 7;
463 } 460 }
464 else 461 else
465 { 462 {
466 pacific_offset_hours = -8; 463 pacific_offset_hours = 8;
467 } 464 }
468 465
469 // We subtract off the PST/PDT offset _before_ getting 466 // We subtract off the PST/PDT offset _before_ getting
470 // "UTC" time, because this will handle wrapping around 467 // "UTC" time, because this will handle wrapping around
471 // for 5 AM UTC -> 10 PM PDT of the previous day. 468 // for 5 AM UTC -> 10 PM PDT of the previous day.
472 unix_time += pacific_offset_hours * MIN_PER_HOUR * SEC_PER_MIN; 469 utc_time -= pacific_offset_hours * MIN_PER_HOUR * SEC_PER_MIN;
473 470
474 // Internal buffer to PST/PDT (see above) 471 // Internal buffer to PST/PDT (see above)
475 struct tm* internal_time = gmtime(&unix_time); 472 struct tm* internal_time = gmtime(&utc_time);
476 473
477 /* 474 /*
478 // Don't do this, this won't correctly tell you if daylight savings is active in CA or not. 475 // Don't do this, this won't correctly tell you if daylight savings is active in CA or not.
@@ -486,7 +483,7 @@ struct tm* utc_to_pacific_time(S32 utc_time, BOOL pacific_daylight_time)
486} 483}
487 484
488 485
489void microsecondsToTimecodeString(U64 current_time, char *tcstring) 486void microsecondsToTimecodeString(U64 current_time, std::string& tcstring)
490{ 487{
491 U64 hours; 488 U64 hours;
492 U64 minutes; 489 U64 minutes;
@@ -504,11 +501,11 @@ void microsecondsToTimecodeString(U64 current_time, char *tcstring)
504 subframes = current_time / (U64)42; 501 subframes = current_time / (U64)42;
505 subframes %= 100; 502 subframes %= 100;
506 503
507 sprintf(tcstring,"%3.3d:%2.2d:%2.2d:%2.2d.%2.2d",(int)hours,(int)minutes,(int)seconds,(int)frames,(int)subframes); /* Flawfinder: ignore */ 504 tcstring = llformat("%3.3d:%2.2d:%2.2d:%2.2d.%2.2d",(int)hours,(int)minutes,(int)seconds,(int)frames,(int)subframes);
508} 505}
509 506
510 507
511void secondsToTimecodeString(F32 current_time, char *tcstring) 508void secondsToTimecodeString(F32 current_time, std::string& tcstring)
512{ 509{
513 microsecondsToTimecodeString((U64)((F64)(SEC_TO_MICROSEC*current_time)), tcstring); 510 microsecondsToTimecodeString((U64)((F64)(SEC_TO_MICROSEC*current_time)), tcstring);
514} 511}
@@ -541,7 +538,7 @@ void LLEventTimer::updateClass()
541 { 538 {
542 LLEventTimer* timer = *iter++; 539 LLEventTimer* timer = *iter++;
543 F32 et = timer->mEventTimer.getElapsedTimeF32(); 540 F32 et = timer->mEventTimer.getElapsedTimeF32();
544 if (et > timer->mPeriod) { 541 if (timer->mEventTimer.getStarted() && et > timer->mPeriod) {
545 timer->mEventTimer.reset(); 542 timer->mEventTimer.reset();
546 if ( timer->tick() ) 543 if ( timer->tick() )
547 { 544 {
diff --git a/linden/indra/llcommon/lltimer.h b/linden/indra/llcommon/lltimer.h
index 91b93d6..8d94276 100644
--- a/linden/indra/llcommon/lltimer.h
+++ b/linden/indra/llcommon/lltimer.h
@@ -35,6 +35,7 @@
35#if LL_LINUX || LL_DARWIN 35#if LL_LINUX || LL_DARWIN
36#include <sys/time.h> 36#include <sys/time.h>
37#endif 37#endif
38#include <limits.h>
38 39
39#include "stdtypes.h" 40#include "stdtypes.h"
40 41
@@ -117,7 +118,35 @@ void ms_sleep(U32 ms);
117 118
118// Returns the correct UTC time in seconds, like time(NULL). 119// Returns the correct UTC time in seconds, like time(NULL).
119// Useful on the viewer, which may have its local clock set wrong. 120// Useful on the viewer, which may have its local clock set wrong.
120U32 time_corrected(); 121time_t time_corrected();
122
123static inline time_t time_min()
124{
125 if (sizeof(time_t) == 4)
126 {
127 return (time_t) INT_MIN;
128 } else {
129#ifdef LLONG_MIN
130 return (time_t) LLONG_MIN;
131#else
132 return (time_t) LONG_MIN;
133#endif
134 }
135}
136
137static inline time_t time_max()
138{
139 if (sizeof(time_t) == 4)
140 {
141 return (time_t) INT_MAX;
142 } else {
143#ifdef LLONG_MAX
144 return (time_t) LLONG_MAX;
145#else
146 return (time_t) LONG_MAX;
147#endif
148 }
149}
121 150
122// Correction factor used by time_corrected() above. 151// Correction factor used by time_corrected() above.
123extern S32 gUTCOffset; 152extern S32 gUTCOffset;
@@ -131,10 +160,10 @@ BOOL is_daylight_savings();
131// S32 utc_time; 160// S32 utc_time;
132// utc_time = time_corrected(); 161// utc_time = time_corrected();
133// struct tm* internal_time = utc_to_pacific_time(utc_time, gDaylight); 162// struct tm* internal_time = utc_to_pacific_time(utc_time, gDaylight);
134struct tm* utc_to_pacific_time(S32 utc_time, BOOL pacific_daylight_time); 163struct tm* utc_to_pacific_time(time_t utc_time, BOOL pacific_daylight_time);
135 164
136void microsecondsToTimecodeString(U64 current_time, char *tcstring); 165void microsecondsToTimecodeString(U64 current_time, std::string& tcstring);
137void secondsToTimecodeString(F32 current_time, char *tcstring); 166void secondsToTimecodeString(F32 current_time, std::string& tcstring);
138 167
139// class for scheduling a function to be called at a given frequency (approximate, inprecise) 168// class for scheduling a function to be called at a given frequency (approximate, inprecise)
140class LLEventTimer 169class LLEventTimer
diff --git a/linden/indra/llcommon/lluri.cpp b/linden/indra/llcommon/lluri.cpp
index 7db8f3b..b83036b 100644
--- a/linden/indra/llcommon/lluri.cpp
+++ b/linden/indra/llcommon/lluri.cpp
@@ -38,7 +38,7 @@
38#include "llsd.h" 38#include "llsd.h"
39#include <iomanip> 39#include <iomanip>
40 40
41#include "../llmath/lluuid.h" 41#include "lluuid.h"
42 42
43// system includes 43// system includes
44#include <boost/tokenizer.hpp> 44#include <boost/tokenizer.hpp>
diff --git a/linden/indra/llcommon/lluuid.cpp b/linden/indra/llcommon/lluuid.cpp
new file mode 100644
index 0000000..7e4eb50
--- /dev/null
+++ b/linden/indra/llcommon/lluuid.cpp
@@ -0,0 +1,923 @@
1/**
2 * @file lluuid.cpp
3 *
4 * $LicenseInfo:firstyear=2000&license=viewergpl$
5 *
6 * Copyright (c) 2000-2008, Linden Research, Inc.
7 *
8 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement
12 * ("Other License"), formally executed by you and Linden Lab. Terms of
13 * the GPL can be found in doc/GPL-license.txt in this distribution, or
14 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
15 *
16 * There are special exceptions to the terms and conditions of the GPL as
17 * it is applied to this Source Code. View the full text of the exception
18 * in the file doc/FLOSS-exception.txt in this software distribution, or
19 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
20 *
21 * By copying, modifying or distributing this software, you acknowledge
22 * that you have read and understood your obligations described above,
23 * and agree to abide by those obligations.
24 *
25 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
26 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
27 * COMPLETENESS OR PERFORMANCE.
28 * $/LicenseInfo$
29 */
30
31#include "linden_common.h"
32
33// We can't use WIN32_LEAN_AND_MEAN here, needs lots of includes.
34#if LL_WINDOWS
35# undef WIN32_LEAN_AND_MEAN
36# include <winsock2.h>
37# include <windows.h>
38#endif
39
40#include "lldefs.h"
41#include "llerror.h"
42
43#include "lluuid.h"
44#include "llerror.h"
45#include "llrand.h"
46#include "llmd5.h"
47#include "llstring.h"
48#include "lltimer.h"
49
50const LLUUID LLUUID::null;
51const LLTransactionID LLTransactionID::tnull;
52
53/*
54
55NOT DONE YET!!!
56
57static char BASE85_TABLE[] = {
58 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
59 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
60 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
61 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
62 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
63 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
64 'y', 'z', '!', '#', '$', '%', '&', '(', ')', '*',
65 '+', '-', ';', '[', '=', '>', '?', '@', '^', '_',
66 '`', '{', '|', '}', '~', '\0'
67};
68
69
70void encode( char * fiveChars, unsigned int word ) throw( )
71{
72for( int ix = 0; ix < 5; ++ix ) {
73fiveChars[4-ix] = encodeTable[ word % 85];
74word /= 85;
75}
76}
77
78To decode:
79unsigned int decode( char const * fiveChars ) throw( bad_input_data )
80{
81unsigned int ret = 0;
82for( int ix = 0; ix < 5; ++ix ) {
83char * s = strchr( encodeTable, fiveChars[ ix ] );
84if( s == 0 ) throw bad_input_data();
85ret = ret * 85 + (s-encodeTable);
86}
87return ret;
88}
89
90void LLUUID::toBase85(char* out)
91{
92 U32* me = (U32*)&(mData[0]);
93 for(S32 i = 0; i < 4; ++i)
94 {
95 char* o = &out[i*i];
96 for(S32 j = 0; j < 5; ++j)
97 {
98 o[4-j] = BASE85_TABLE[ me[i] % 85];
99 word /= 85;
100 }
101 }
102}
103
104unsigned int decode( char const * fiveChars ) throw( bad_input_data )
105{
106 unsigned int ret = 0;
107 for( S32 ix = 0; ix < 5; ++ix )
108 {
109 char * s = strchr( encodeTable, fiveChars[ ix ] );
110 ret = ret * 85 + (s-encodeTable);
111 }
112 return ret;
113}
114*/
115
116#define LL_USE_JANKY_RANDOM_NUMBER_GENERATOR 0
117#if LL_USE_JANKY_RANDOM_NUMBER_GENERATOR
118/**
119 * @brief a global for
120 */
121static U64 sJankyRandomSeed(LLUUID::getRandomSeed());
122
123/**
124 * @brief generate a random U32.
125 */
126U32 janky_fast_random_bytes()
127{
128 sJankyRandomSeed = U64L(1664525) * sJankyRandomSeed + U64L(1013904223);
129 return (U32)sJankyRandomSeed;
130}
131
132/**
133 * @brief generate a random U32 from [0, val)
134 */
135U32 janky_fast_random_byes_range(U32 val)
136{
137 sJankyRandomSeed = U64L(1664525) * sJankyRandomSeed + U64L(1013904223);
138 return (U32)(sJankyRandomSeed) % val;
139}
140
141/**
142 * @brief generate a random U32 from [0, val)
143 */
144U32 janky_fast_random_seeded_bytes(U32 seed, U32 val)
145{
146 seed = U64L(1664525) * (U64)(seed) + U64L(1013904223);
147 return (U32)(seed) % val;
148}
149#endif
150
151// Common to all UUID implementations
152void LLUUID::toString(std::string& out) const
153{
154 out = llformat(
155 "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
156 (U8)(mData[0]),
157 (U8)(mData[1]),
158 (U8)(mData[2]),
159 (U8)(mData[3]),
160 (U8)(mData[4]),
161 (U8)(mData[5]),
162 (U8)(mData[6]),
163 (U8)(mData[7]),
164 (U8)(mData[8]),
165 (U8)(mData[9]),
166 (U8)(mData[10]),
167 (U8)(mData[11]),
168 (U8)(mData[12]),
169 (U8)(mData[13]),
170 (U8)(mData[14]),
171 (U8)(mData[15]));
172}
173
174// *TODO: deprecate
175void LLUUID::toString(char *out) const
176{
177 std::string buffer;
178 toString(buffer);
179 strcpy(out,buffer.c_str()); /* Flawfinder: ignore */
180}
181
182void LLUUID::toCompressedString(std::string& out) const
183{
184 char bytes[UUID_BYTES+1];
185 memcpy(bytes, mData, UUID_BYTES); /* Flawfinder: ignore */
186 bytes[UUID_BYTES] = '\0';
187 out.assign(bytes, UUID_BYTES);
188}
189
190// *TODO: deprecate
191void LLUUID::toCompressedString(char *out) const
192{
193 memcpy(out, mData, UUID_BYTES); /* Flawfinder: ignore */
194 out[UUID_BYTES] = '\0';
195}
196
197std::string LLUUID::getString() const
198{
199 return asString();
200}
201
202std::string LLUUID::asString() const
203{
204 std::string str;
205 toString(str);
206 return str;
207}
208
209BOOL LLUUID::set(const char* in_string, BOOL emit)
210{
211 return set(ll_safe_string(in_string));
212}
213
214BOOL LLUUID::set(const std::string& in_string, BOOL emit)
215{
216 BOOL broken_format = FALSE;
217
218 // empty strings should make NULL uuid
219 if (in_string.empty())
220 {
221 setNull();
222 return TRUE;
223 }
224
225 if (in_string.length() != (UUID_STR_LENGTH - 1)) /* Flawfinder: ignore */
226 {
227 // I'm a moron. First implementation didn't have the right UUID format.
228 // Shouldn't see any of these any more
229 if (in_string.length() == (UUID_STR_LENGTH - 2)) /* Flawfinder: ignore */
230 {
231 if(emit)
232 {
233 llinfos << "Warning! Using broken UUID string format" << llendl;
234 }
235 broken_format = TRUE;
236 }
237 else
238 {
239 // Bad UUID string. Spam as INFO, as most cases we don't care.
240 if(emit)
241 {
242 llinfos << "Bad UUID string: " << in_string << llendl;
243 }
244 setNull();
245 return FALSE;
246 }
247 }
248
249 U8 cur_pos = 0;
250 S32 i;
251 for (i = 0; i < UUID_BYTES; i++)
252 {
253 if ((i == 4) || (i == 6) || (i == 8) || (i == 10))
254 {
255 cur_pos++;
256 if (broken_format && (i==10))
257 {
258 // Missing - in the broken format
259 cur_pos--;
260 }
261 }
262
263 mData[i] = 0;
264
265 if ((in_string[cur_pos] >= '0') && (in_string[cur_pos] <= '9'))
266 {
267 mData[i] += (U8)(in_string[cur_pos] - '0');
268 }
269 else if ((in_string[cur_pos] >= 'a') && (in_string[cur_pos] <='f'))
270 {
271 mData[i] += (U8)(10 + in_string[cur_pos] - 'a');
272 }
273 else if ((in_string[cur_pos] >= 'A') && (in_string[cur_pos] <='F'))
274 {
275 mData[i] += (U8)(10 + in_string[cur_pos] - 'A');
276 }
277 else
278 {
279 if(emit)
280 {
281 llwarns << "Invalid UUID string character" << llendl;
282 }
283 setNull();
284 return FALSE;
285 }
286
287 mData[i] = mData[i] << 4;
288 cur_pos++;
289
290 if ((in_string[cur_pos] >= '0') && (in_string[cur_pos] <= '9'))
291 {
292 mData[i] += (U8)(in_string[cur_pos] - '0');
293 }
294 else if ((in_string[cur_pos] >= 'a') && (in_string[cur_pos] <='f'))
295 {
296 mData[i] += (U8)(10 + in_string[cur_pos] - 'a');
297 }
298 else if ((in_string[cur_pos] >= 'A') && (in_string[cur_pos] <='F'))
299 {
300 mData[i] += (U8)(10 + in_string[cur_pos] - 'A');
301 }
302 else
303 {
304 if(emit)
305 {
306 llwarns << "Invalid UUID string character" << llendl;
307 }
308 setNull();
309 return FALSE;
310 }
311 cur_pos++;
312 }
313
314 return TRUE;
315}
316
317BOOL LLUUID::validate(const std::string& in_string)
318{
319 BOOL broken_format = FALSE;
320 if (in_string.length() != (UUID_STR_LENGTH - 1)) /* Flawfinder: ignore */
321 {
322 // I'm a moron. First implementation didn't have the right UUID format.
323 if (in_string.length() == (UUID_STR_LENGTH - 2)) /* Flawfinder: ignore */
324 {
325 broken_format = TRUE;
326 }
327 else
328 {
329 return FALSE;
330 }
331 }
332
333 U8 cur_pos = 0;
334 for (U32 i = 0; i < 16; i++)
335 {
336 if ((i == 4) || (i == 6) || (i == 8) || (i == 10))
337 {
338 cur_pos++;
339 if (broken_format && (i==10))
340 {
341 // Missing - in the broken format
342 cur_pos--;
343 }
344 }
345
346 if ((in_string[cur_pos] >= '0') && (in_string[cur_pos] <= '9'))
347 {
348 }
349 else if ((in_string[cur_pos] >= 'a') && (in_string[cur_pos] <='f'))
350 {
351 }
352 else if ((in_string[cur_pos] >= 'A') && (in_string[cur_pos] <='F'))
353 {
354 }
355 else
356 {
357 return FALSE;
358 }
359
360 cur_pos++;
361
362 if ((in_string[cur_pos] >= '0') && (in_string[cur_pos] <= '9'))
363 {
364 }
365 else if ((in_string[cur_pos] >= 'a') && (in_string[cur_pos] <='f'))
366 {
367 }
368 else if ((in_string[cur_pos] >= 'A') && (in_string[cur_pos] <='F'))
369 {
370 }
371 else
372 {
373 return FALSE;
374 }
375 cur_pos++;
376 }
377 return TRUE;
378}
379
380const LLUUID& LLUUID::operator^=(const LLUUID& rhs)
381{
382 U32* me = (U32*)&(mData[0]);
383 const U32* other = (U32*)&(rhs.mData[0]);
384 for(S32 i = 0; i < 4; ++i)
385 {
386 me[i] = me[i] ^ other[i];
387 }
388 return *this;
389}
390
391LLUUID LLUUID::operator^(const LLUUID& rhs) const
392{
393 LLUUID id(*this);
394 id ^= rhs;
395 return id;
396}
397
398void LLUUID::combine(const LLUUID& other, LLUUID& result) const
399{
400 LLMD5 md5_uuid;
401 md5_uuid.update((unsigned char*)mData, 16);
402 md5_uuid.update((unsigned char*)other.mData, 16);
403 md5_uuid.finalize();
404 md5_uuid.raw_digest(result.mData);
405}
406
407LLUUID LLUUID::combine(const LLUUID &other) const
408{
409 LLUUID combination;
410 combine(other, combination);
411 return combination;
412}
413
414std::ostream& operator<<(std::ostream& s, const LLUUID &uuid)
415{
416 std::string uuid_str;
417 uuid.toString(uuid_str);
418 s << uuid_str;
419 return s;
420}
421
422std::istream& operator>>(std::istream &s, LLUUID &uuid)
423{
424 U32 i;
425 char uuid_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */
426 for (i = 0; i < UUID_STR_LENGTH-1; i++)
427 {
428 s >> uuid_str[i];
429 }
430 uuid_str[i] = '\0';
431 uuid.set(std::string(uuid_str));
432 return s;
433}
434
435static void get_random_bytes(void *buf, int nbytes)
436{
437 int i;
438 char *cp = (char *) buf;
439
440 // *NOTE: If we are not using the janky generator ll_rand()
441 // generates at least 3 good bytes of data since it is 0 to
442 // RAND_MAX. This could be made more efficient by copying all the
443 // bytes.
444 for (i=0; i < nbytes; i++)
445#if LL_USE_JANKY_RANDOM_NUMBER_GENERATOR
446 *cp++ = janky_fast_random_bytes() & 0xFF;
447#else
448 *cp++ = ll_rand() & 0xFF;
449#endif
450 return;
451}
452
453#if LL_WINDOWS
454typedef struct _ASTAT_
455{
456 ADAPTER_STATUS adapt;
457 NAME_BUFFER NameBuff [30];
458}ASTAT, * PASTAT;
459
460// static
461S32 LLUUID::getNodeID(unsigned char * node_id)
462{
463 ASTAT Adapter;
464 NCB Ncb;
465 UCHAR uRetCode;
466 LANA_ENUM lenum;
467 int i;
468 int retval = 0;
469
470 memset( &Ncb, 0, sizeof(Ncb) );
471 Ncb.ncb_command = NCBENUM;
472 Ncb.ncb_buffer = (UCHAR *)&lenum;
473 Ncb.ncb_length = sizeof(lenum);
474 uRetCode = Netbios( &Ncb );
475 // printf( "The NCBENUM return code is: 0x%x \n", uRetCode );
476
477 for(i=0; i < lenum.length ;i++)
478 {
479 memset( &Ncb, 0, sizeof(Ncb) );
480 Ncb.ncb_command = NCBRESET;
481 Ncb.ncb_lana_num = lenum.lana[i];
482
483 uRetCode = Netbios( &Ncb );
484 // printf( "The NCBRESET on LANA %d return code is: 0x%x \n",
485 // lenum.lana[i], uRetCode );
486
487 memset( &Ncb, 0, sizeof (Ncb) );
488 Ncb.ncb_command = NCBASTAT;
489 Ncb.ncb_lana_num = lenum.lana[i];
490
491 strcpy( (char *)Ncb.ncb_callname, "* " ); /* Flawfinder: ignore */
492 Ncb.ncb_buffer = (unsigned char *)&Adapter;
493 Ncb.ncb_length = sizeof(Adapter);
494
495 uRetCode = Netbios( &Ncb );
496// printf( "The NCBASTAT on LANA %d return code is: 0x%x \n",
497// lenum.lana[i], uRetCode );
498 if ( uRetCode == 0 )
499 {
500// printf( "The Ethernet Number on LANA %d is: %02x%02x%02x%02x%02x%02x\n",
501// lenum.lana[i],
502// Adapter.adapt.adapter_address[0],
503// Adapter.adapt.adapter_address[1],
504// Adapter.adapt.adapter_address[2],
505// Adapter.adapt.adapter_address[3],
506// Adapter.adapt.adapter_address[4],
507// Adapter.adapt.adapter_address[5] );
508 memcpy(node_id,Adapter.adapt.adapter_address,6); /* Flawfinder: ignore */
509 retval = 1;
510
511 }
512 }
513 return retval;
514}
515
516#elif LL_DARWIN
517// Mac OS X version of the UUID generation code...
518/*
519 * Get an ethernet hardware address, if we can find it...
520 */
521#include <unistd.h>
522#include <sys/types.h>
523#include <sys/time.h>
524#include <sys/socket.h>
525#include <sys/ioctl.h>
526#include <net/if.h>
527#include <net/if_types.h>
528#include <net/if_dl.h>
529#include <net/route.h>
530#include <ifaddrs.h>
531
532// static
533S32 LLUUID::getNodeID(unsigned char *node_id)
534{
535 int i;
536 unsigned char *a = NULL;
537 struct ifaddrs *ifap, *ifa;
538 int rv;
539 S32 result = 0;
540
541 if ((rv=getifaddrs(&ifap))==-1)
542 {
543 return -1;
544 }
545 if (ifap == NULL)
546 {
547 return -1;
548 }
549
550 for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next)
551 {
552// printf("Interface %s, address family %d, ", ifa->ifa_name, ifa->ifa_addr->sa_family);
553 for(i=0; i< ifa->ifa_addr->sa_len; i++)
554 {
555// printf("%02X ", (unsigned char)ifa->ifa_addr->sa_data[i]);
556 }
557// printf("\n");
558
559 if(ifa->ifa_addr->sa_family == AF_LINK)
560 {
561 // This is a link-level address
562 struct sockaddr_dl *lla = (struct sockaddr_dl *)ifa->ifa_addr;
563
564// printf("\tLink level address, type %02X\n", lla->sdl_type);
565
566 if(lla->sdl_type == IFT_ETHER)
567 {
568 // Use the first ethernet MAC in the list.
569 // For some reason, the macro LLADDR() defined in net/if_dl.h doesn't expand correctly. This is what it would do.
570 a = (unsigned char *)&((lla)->sdl_data);
571 a += (lla)->sdl_nlen;
572
573 if (!a[0] && !a[1] && !a[2] && !a[3] && !a[4] && !a[5])
574 {
575 continue;
576 }
577
578 if (node_id)
579 {
580 memcpy(node_id, a, 6);
581 result = 1;
582 }
583
584 // We found one.
585 break;
586 }
587 }
588 }
589 freeifaddrs(ifap);
590
591 return result;
592}
593
594#else
595
596// Linux version of the UUID generation code...
597/*
598 * Get the ethernet hardware address, if we can find it...
599 */
600#include <unistd.h>
601#include <fcntl.h>
602#include <errno.h>
603#include <sys/types.h>
604#include <sys/time.h>
605#include <sys/stat.h>
606#include <sys/file.h>
607#include <sys/ioctl.h>
608#include <sys/socket.h>
609#include <net/if.h>
610#define HAVE_NETINET_IN_H
611#ifdef HAVE_NETINET_IN_H
612#include <netinet/in.h>
613#if LL_SOLARIS
614#include <sys/sockio.h>
615#elif !LL_DARWIN
616#include <linux/sockios.h>
617#endif
618#endif
619
620// static
621S32 LLUUID::getNodeID(unsigned char *node_id)
622{
623 int sd;
624 struct ifreq ifr, *ifrp;
625 struct ifconf ifc;
626 char buf[1024];
627 int n, i;
628 unsigned char *a;
629
630/*
631 * BSD 4.4 defines the size of an ifreq to be
632 * max(sizeof(ifreq), sizeof(ifreq.ifr_name)+ifreq.ifr_addr.sa_len
633 * However, under earlier systems, sa_len isn't present, so the size is
634 * just sizeof(struct ifreq)
635 */
636#ifdef HAVE_SA_LEN
637#ifndef max
638#define max(a,b) ((a) > (b) ? (a) : (b))
639#endif
640#define ifreq_size(i) max(sizeof(struct ifreq),\
641 sizeof((i).ifr_name)+(i).ifr_addr.sa_len)
642#else
643#define ifreq_size(i) sizeof(struct ifreq)
644#endif /* HAVE_SA_LEN*/
645
646 sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
647 if (sd < 0) {
648 return -1;
649 }
650 memset(buf, 0, sizeof(buf));
651 ifc.ifc_len = sizeof(buf);
652 ifc.ifc_buf = buf;
653 if (ioctl (sd, SIOCGIFCONF, (char *)&ifc) < 0) {
654 close(sd);
655 return -1;
656 }
657 n = ifc.ifc_len;
658 for (i = 0; i < n; i+= ifreq_size(*ifr) ) {
659 ifrp = (struct ifreq *)((char *) ifc.ifc_buf+i);
660 strncpy(ifr.ifr_name, ifrp->ifr_name, IFNAMSIZ); /* Flawfinder: ignore */
661#ifdef SIOCGIFHWADDR
662 if (ioctl(sd, SIOCGIFHWADDR, &ifr) < 0)
663 continue;
664 a = (unsigned char *) &ifr.ifr_hwaddr.sa_data;
665#else
666#ifdef SIOCGENADDR
667 if (ioctl(sd, SIOCGENADDR, &ifr) < 0)
668 continue;
669 a = (unsigned char *) ifr.ifr_enaddr;
670#else
671 /*
672 * XXX we don't have a way of getting the hardware
673 * address
674 */
675 close(sd);
676 return 0;
677#endif /* SIOCGENADDR */
678#endif /* SIOCGIFHWADDR */
679 if (!a[0] && !a[1] && !a[2] && !a[3] && !a[4] && !a[5])
680 continue;
681 if (node_id) {
682 memcpy(node_id, a, 6); /* Flawfinder: ignore */
683 close(sd);
684 return 1;
685 }
686 }
687 close(sd);
688 return 0;
689}
690
691#endif
692
693S32 LLUUID::cmpTime(uuid_time_t *t1, uuid_time_t *t2)
694{
695 // Compare two time values.
696
697 if (t1->high < t2->high) return -1;
698 if (t1->high > t2->high) return 1;
699 if (t1->low < t2->low) return -1;
700 if (t1->low > t2->low) return 1;
701 return 0;
702}
703
704void LLUUID::getSystemTime(uuid_time_t *timestamp)
705{
706 // Get system time with 100ns precision. Time is since Oct 15, 1582.
707#if LL_WINDOWS
708 ULARGE_INTEGER time;
709 GetSystemTimeAsFileTime((FILETIME *)&time);
710 // NT keeps time in FILETIME format which is 100ns ticks since
711 // Jan 1, 1601. UUIDs use time in 100ns ticks since Oct 15, 1582.
712 // The difference is 17 Days in Oct + 30 (Nov) + 31 (Dec)
713 // + 18 years and 5 leap days.
714 time.QuadPart +=
715 (unsigned __int64) (1000*1000*10) // seconds
716 * (unsigned __int64) (60 * 60 * 24) // days
717 * (unsigned __int64) (17+30+31+365*18+5); // # of days
718
719 timestamp->high = time.HighPart;
720 timestamp->low = time.LowPart;
721#else
722 struct timeval tp;
723 gettimeofday(&tp, 0);
724
725 // Offset between UUID formatted times and Unix formatted times.
726 // UUID UTC base time is October 15, 1582.
727 // Unix base time is January 1, 1970.
728 U64 uuid_time = ((U64)tp.tv_sec * 10000000) + (tp.tv_usec * 10) +
729 U64L(0x01B21DD213814000);
730 timestamp->high = (U32) (uuid_time >> 32);
731 timestamp->low = (U32) (uuid_time & 0xFFFFFFFF);
732#endif
733}
734
735void LLUUID::getCurrentTime(uuid_time_t *timestamp)
736{
737 // Get current time as 60 bit 100ns ticks since whenever.
738 // Compensate for the fact that real clock resolution is less
739 // than 100ns.
740
741 const U32 uuids_per_tick = 1024;
742
743 static uuid_time_t time_last;
744 static U32 uuids_this_tick;
745 static BOOL init = FALSE;
746
747 if (!init) {
748 getSystemTime(&time_last);
749 uuids_this_tick = uuids_per_tick;
750 init = TRUE;
751 }
752
753 uuid_time_t time_now = {0,0};
754
755 while (1) {
756 getSystemTime(&time_now);
757
758 // if clock reading changed since last UUID generated
759 if (cmpTime(&time_last, &time_now)) {
760 // reset count of uuid's generated with this clock reading
761 uuids_this_tick = 0;
762 break;
763 }
764 if (uuids_this_tick < uuids_per_tick) {
765 uuids_this_tick++;
766 break;
767 }
768 // going too fast for our clock; spin
769 }
770
771 time_last = time_now;
772
773 if (uuids_this_tick != 0) {
774 if (time_now.low & 0x80000000) {
775 time_now.low += uuids_this_tick;
776 if (!(time_now.low & 0x80000000))
777 time_now.high++;
778 } else
779 time_now.low += uuids_this_tick;
780 }
781
782 timestamp->high = time_now.high;
783 timestamp->low = time_now.low;
784}
785
786void LLUUID::generate()
787{
788 // Create a UUID.
789 uuid_time_t timestamp;
790
791 static unsigned char node_id[6]; /* Flawfinder: ignore */
792 static int has_init = 0;
793
794 // Create a UUID.
795 static uuid_time_t time_last = {0,0};
796 static U16 clock_seq = 0;
797#if LL_USE_JANKY_RANDOM_NUMBER_GENERATOR
798 static U32 seed = 0L; // dummy seed. reset it below
799#endif
800 if (!has_init)
801 {
802 if (getNodeID(node_id) <= 0)
803 {
804 get_random_bytes(node_id, 6);
805 /*
806 * Set multicast bit, to prevent conflicts
807 * with IEEE 802 addresses obtained from
808 * network cards
809 */
810 node_id[0] |= 0x80;
811 }
812
813 getCurrentTime(&time_last);
814#if LL_USE_JANKY_RANDOM_NUMBER_GENERATOR
815 seed = time_last.low;
816#endif
817
818#if LL_USE_JANKY_RANDOM_NUMBER_GENERATOR
819 clock_seq = (U16)janky_fast_random_seeded_bytes(seed, 65536);
820#else
821 clock_seq = (U16)ll_rand(65536);
822#endif
823 has_init = 1;
824 }
825
826 // get current time
827 getCurrentTime(&timestamp);
828
829 // if clock went backward change clockseq
830 if (cmpTime(&timestamp, &time_last) == -1) {
831 clock_seq = (clock_seq + 1) & 0x3FFF;
832 if (clock_seq == 0) clock_seq++;
833 }
834
835 memcpy(mData+10, node_id, 6); /* Flawfinder: ignore */
836 U32 tmp;
837 tmp = timestamp.low;
838 mData[3] = (unsigned char) tmp;
839 tmp >>= 8;
840 mData[2] = (unsigned char) tmp;
841 tmp >>= 8;
842 mData[1] = (unsigned char) tmp;
843 tmp >>= 8;
844 mData[0] = (unsigned char) tmp;
845
846 tmp = (U16) timestamp.high;
847 mData[5] = (unsigned char) tmp;
848 tmp >>= 8;
849 mData[4] = (unsigned char) tmp;
850
851 tmp = (timestamp.high >> 16) | 0x1000;
852 mData[7] = (unsigned char) tmp;
853 tmp >>= 8;
854 mData[6] = (unsigned char) tmp;
855
856 tmp = clock_seq;
857 mData[9] = (unsigned char) tmp;
858 tmp >>= 8;
859 mData[8] = (unsigned char) tmp;
860
861 LLMD5 md5_uuid;
862
863 md5_uuid.update(mData,16);
864 md5_uuid.finalize();
865 md5_uuid.raw_digest(mData);
866
867 time_last = timestamp;
868}
869
870void LLUUID::generate(const std::string& hash_string)
871{
872 LLMD5 md5_uuid((U8*)hash_string.c_str());
873 md5_uuid.raw_digest(mData);
874}
875
876U32 LLUUID::getRandomSeed()
877{
878 static unsigned char seed[16]; /* Flawfinder: ignore */
879
880 getNodeID(&seed[0]);
881 seed[6]='\0';
882 seed[7]='\0';
883 getSystemTime((uuid_time_t *)(&seed[8]));
884
885 LLMD5 md5_seed;
886
887 md5_seed.update(seed,16);
888 md5_seed.finalize();
889 md5_seed.raw_digest(seed);
890
891 return(*(U32 *)seed);
892}
893
894BOOL LLUUID::parseUUID(const std::string& buf, LLUUID* value)
895{
896 if( buf.empty() || value == NULL)
897 {
898 return FALSE;
899 }
900
901 std::string temp( buf );
902 LLStringUtil::trim(temp);
903 if( LLUUID::validate( temp ) )
904 {
905 value->set( temp );
906 return TRUE;
907 }
908 return FALSE;
909}
910
911LLAssetID LLTransactionID::makeAssetID(const LLUUID& session) const
912{
913 LLAssetID result;
914 if (isNull())
915 {
916 result.setNull();
917 }
918 else
919 {
920 combine(session, result);
921 }
922 return result;
923}
diff --git a/linden/indra/llcommon/lluuid.h b/linden/indra/llcommon/lluuid.h
new file mode 100644
index 0000000..3b057fb
--- /dev/null
+++ b/linden/indra/llcommon/lluuid.h
@@ -0,0 +1,331 @@
1/**
2 * @file lluuid.h
3 *
4 * $LicenseInfo:firstyear=2000&license=viewergpl$
5 *
6 * Copyright (c) 2000-2008, Linden Research, Inc.
7 *
8 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement
12 * ("Other License"), formally executed by you and Linden Lab. Terms of
13 * the GPL can be found in doc/GPL-license.txt in this distribution, or
14 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
15 *
16 * There are special exceptions to the terms and conditions of the GPL as
17 * it is applied to this Source Code. View the full text of the exception
18 * in the file doc/FLOSS-exception.txt in this software distribution, or
19 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
20 *
21 * By copying, modifying or distributing this software, you acknowledge
22 * that you have read and understood your obligations described above,
23 * and agree to abide by those obligations.
24 *
25 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
26 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
27 * COMPLETENESS OR PERFORMANCE.
28 * $/LicenseInfo$
29 */
30
31#ifndef LL_LLUUID_H
32#define LL_LLUUID_H
33
34#include <iostream>
35#include <set>
36#include "stdtypes.h"
37
38const S32 UUID_BYTES = 16;
39const S32 UUID_WORDS = 4;
40const S32 UUID_STR_LENGTH = 37; // actually wrong, should be 36 and use size below
41const S32 UUID_STR_SIZE = 37;
42const S32 UUID_BASE85_LENGTH = 21; // including the trailing NULL.
43
44struct uuid_time_t {
45 U32 high;
46 U32 low;
47 };
48
49class LLUUID
50{
51public:
52 //
53 // CREATORS
54 //
55 LLUUID();
56 explicit LLUUID(const char *in_string); // Convert from string.
57 explicit LLUUID(const std::string& in_string); // Convert from string.
58 LLUUID(const LLUUID &in);
59 LLUUID &operator=(const LLUUID &rhs);
60
61 ~LLUUID();
62
63 //
64 // MANIPULATORS
65 //
66 void generate(); // Generate a new UUID
67 void generate(const std::string& stream); //Generate a new UUID based on hash of input stream
68 BOOL set(const char *in_string, BOOL emit = TRUE); // Convert from string, if emit is FALSE, do not emit warnings
69 BOOL set(const std::string& in_string, BOOL emit = TRUE); // Convert from string, if emit is FALSE, do not emit warnings
70 void setNull(); // Faster than setting to LLUUID::null.
71
72 S32 cmpTime(uuid_time_t *t1, uuid_time_t *t2);
73 static void getSystemTime(uuid_time_t *timestamp);
74 void getCurrentTime(uuid_time_t *timestamp);
75
76 //
77 // ACCESSORS
78 //
79 BOOL isNull() const; // Faster than comparing to LLUUID::null.
80 BOOL notNull() const; // Faster than comparing to LLUUID::null.
81 // JC: This is dangerous. It allows UUIDs to be cast automatically
82 // to integers, among other things. Use isNull() or notNull().
83 // operator bool() const;
84
85 // JC: These must return real bool's (not BOOLs) or else use of the STL
86 // will generate bool-to-int performance warnings.
87 bool operator==(const LLUUID &rhs) const;
88 bool operator!=(const LLUUID &rhs) const;
89 bool operator<(const LLUUID &rhs) const;
90 bool operator>(const LLUUID &rhs) const;
91
92 // xor functions. Useful since any two random uuids xored together
93 // will yield a determinate third random unique id that can be
94 // used as a key in a single uuid that represents 2.
95 const LLUUID& operator^=(const LLUUID& rhs);
96 LLUUID operator^(const LLUUID& rhs) const;
97
98 // similar to functions above, but not invertible
99 // yields a third random UUID that can be reproduced from the two inputs
100 // but which, given the result and one of the inputs can't be used to
101 // deduce the other input
102 LLUUID combine(const LLUUID& other) const;
103 void combine(const LLUUID& other, LLUUID& result) const;
104
105 friend std::ostream& operator<<(std::ostream& s, const LLUUID &uuid);
106 friend std::istream& operator>>(std::istream& s, LLUUID &uuid);
107
108 void toString(char *out) const; // Does not allocate memory, needs 36 characters (including \0)
109 void toString(std::string& out) const;
110 void toCompressedString(char *out) const; // Does not allocate memory, needs 17 characters (including \0)
111 void toCompressedString(std::string& out) const;
112
113 std::string asString() const;
114 std::string getString() const;
115
116 U16 getCRC16() const;
117 U32 getCRC32() const;
118
119 static BOOL validate(const std::string& in_string); // Validate that the UUID string is legal.
120
121 static const LLUUID null;
122
123 static U32 getRandomSeed();
124 static S32 getNodeID(unsigned char * node_id);
125
126 static BOOL parseUUID(const std::string& buf, LLUUID* value);
127
128 U8 mData[UUID_BYTES];
129};
130
131
132// Construct
133inline LLUUID::LLUUID()
134{
135 setNull();
136}
137
138
139// Faster than copying from memory
140inline void LLUUID::setNull()
141{
142 U32 *word = (U32 *)mData;
143 word[0] = 0;
144 word[1] = 0;
145 word[2] = 0;
146 word[3] = 0;
147}
148
149
150// Compare
151inline bool LLUUID::operator==(const LLUUID& rhs) const
152{
153 U32 *tmp = (U32 *)mData;
154 U32 *rhstmp = (U32 *)rhs.mData;
155 // Note: binary & to avoid branching
156 return
157 (tmp[0] == rhstmp[0]) &
158 (tmp[1] == rhstmp[1]) &
159 (tmp[2] == rhstmp[2]) &
160 (tmp[3] == rhstmp[3]);
161}
162
163
164inline bool LLUUID::operator!=(const LLUUID& rhs) const
165{
166 U32 *tmp = (U32 *)mData;
167 U32 *rhstmp = (U32 *)rhs.mData;
168 // Note: binary | to avoid branching
169 return
170 (tmp[0] != rhstmp[0]) |
171 (tmp[1] != rhstmp[1]) |
172 (tmp[2] != rhstmp[2]) |
173 (tmp[3] != rhstmp[3]);
174}
175
176/*
177// JC: This is dangerous. It allows UUIDs to be cast automatically
178// to integers, among other things. Use isNull() or notNull().
179inline LLUUID::operator bool() const
180{
181 U32 *word = (U32 *)mData;
182 return (word[0] | word[1] | word[2] | word[3]) > 0;
183}
184*/
185
186inline BOOL LLUUID::notNull() const
187{
188 U32 *word = (U32 *)mData;
189 return (word[0] | word[1] | word[2] | word[3]) > 0;
190}
191
192// Faster than == LLUUID::null because doesn't require
193// as much memory access.
194inline BOOL LLUUID::isNull() const
195{
196 U32 *word = (U32 *)mData;
197 // If all bits are zero, return !0 == TRUE
198 return !(word[0] | word[1] | word[2] | word[3]);
199}
200
201// Copy constructor
202inline LLUUID::LLUUID(const LLUUID& rhs)
203{
204 U32 *tmp = (U32 *)mData;
205 U32 *rhstmp = (U32 *)rhs.mData;
206 tmp[0] = rhstmp[0];
207 tmp[1] = rhstmp[1];
208 tmp[2] = rhstmp[2];
209 tmp[3] = rhstmp[3];
210}
211
212inline LLUUID::~LLUUID()
213{
214}
215
216// Assignment
217inline LLUUID& LLUUID::operator=(const LLUUID& rhs)
218{
219 // No need to check the case where this==&rhs. The branch is slower than the write.
220 U32 *tmp = (U32 *)mData;
221 U32 *rhstmp = (U32 *)rhs.mData;
222 tmp[0] = rhstmp[0];
223 tmp[1] = rhstmp[1];
224 tmp[2] = rhstmp[2];
225 tmp[3] = rhstmp[3];
226
227 return *this;
228}
229
230
231inline LLUUID::LLUUID(const char *in_string)
232{
233 if (!in_string || in_string[0] == 0)
234 {
235 setNull();
236 return;
237 }
238
239 set(in_string);
240}
241
242inline LLUUID::LLUUID(const std::string& in_string)
243{
244 if (in_string.empty())
245 {
246 setNull();
247 return;
248 }
249
250 set(in_string);
251}
252
253// IW: DON'T "optimize" these w/ U32s or you'll scoogie the sort order
254// IW: this will make me very sad
255inline bool LLUUID::operator<(const LLUUID &rhs) const
256{
257 U32 i;
258 for( i = 0; i < (UUID_BYTES - 1); i++ )
259 {
260 if( mData[i] != rhs.mData[i] )
261 {
262 return (mData[i] < rhs.mData[i]);
263 }
264 }
265 return (mData[UUID_BYTES - 1] < rhs.mData[UUID_BYTES - 1]);
266}
267
268inline bool LLUUID::operator>(const LLUUID &rhs) const
269{
270 U32 i;
271 for( i = 0; i < (UUID_BYTES - 1); i++ )
272 {
273 if( mData[i] != rhs.mData[i] )
274 {
275 return (mData[i] > rhs.mData[i]);
276 }
277 }
278 return (mData[UUID_BYTES - 1] > rhs.mData[UUID_BYTES - 1]);
279}
280
281inline U16 LLUUID::getCRC16() const
282{
283 // A UUID is 16 bytes, or 8 shorts.
284 U16 *short_data = (U16*)mData;
285 U16 out = 0;
286 out += short_data[0];
287 out += short_data[1];
288 out += short_data[2];
289 out += short_data[3];
290 out += short_data[4];
291 out += short_data[5];
292 out += short_data[6];
293 out += short_data[7];
294 return out;
295}
296
297inline U32 LLUUID::getCRC32() const
298{
299 U32 *tmp = (U32*)mData;
300 return tmp[0] + tmp[1] + tmp[2] + tmp[3];
301}
302
303
304// Helper structure for ordering lluuids in stl containers.
305// eg: std::map<LLUUID, LLWidget*, lluuid_less> widget_map;
306struct lluuid_less
307{
308 bool operator()(const LLUUID& lhs, const LLUUID& rhs) const
309 {
310 return (lhs < rhs) ? true : false;
311 }
312};
313
314typedef std::set<LLUUID, lluuid_less> uuid_list_t;
315
316/*
317 * Sub-classes for keeping transaction IDs and asset IDs
318 * straight.
319 */
320typedef LLUUID LLAssetID;
321
322class LLTransactionID : public LLUUID
323{
324public:
325 LLTransactionID() : LLUUID() { }
326
327 static const LLTransactionID tnull;
328 LLAssetID makeAssetID(const LLUUID& session) const;
329};
330
331#endif
diff --git a/linden/indra/llcommon/llversionserver.h b/linden/indra/llcommon/llversionserver.h
index e3ceadf..0b88ce8 100644
--- a/linden/indra/llcommon/llversionserver.h
+++ b/linden/indra/llcommon/llversionserver.h
@@ -33,9 +33,9 @@
33#define LL_LLVERSIONSERVER_H 33#define LL_LLVERSIONSERVER_H
34 34
35const S32 LL_VERSION_MAJOR = 1; 35const S32 LL_VERSION_MAJOR = 1;
36const S32 LL_VERSION_MINOR = 21; 36const S32 LL_VERSION_MINOR = 24;
37const S32 LL_VERSION_PATCH = 1; 37const S32 LL_VERSION_PATCH = 0;
38const S32 LL_VERSION_BUILD = 86526; 38const S32 LL_VERSION_BUILD = 93453;
39 39
40const char * const LL_CHANNEL = "Second Life Server"; 40const char * const LL_CHANNEL = "Second Life Server";
41 41
diff --git a/linden/indra/llcommon/llversionviewer.h b/linden/indra/llcommon/llversionviewer.h
index 9b3cf80..4820f68 100644
--- a/linden/indra/llcommon/llversionviewer.h
+++ b/linden/indra/llcommon/llversionviewer.h
@@ -33,8 +33,8 @@
33#define LL_LLVERSIONVIEWER_H 33#define LL_LLVERSIONVIEWER_H
34 34
35const S32 LL_VERSION_MAJOR = 1; 35const S32 LL_VERSION_MAJOR = 1;
36const S32 LL_VERSION_MINOR = 20; 36const S32 LL_VERSION_MINOR = 21;
37const S32 LL_VERSION_PATCH = 15; 37const S32 LL_VERSION_PATCH = 0;
38const S32 LL_VERSION_BUILD = 0; 38const S32 LL_VERSION_BUILD = 0;
39 39
40const char * const LL_CHANNEL = "Second Life Release"; 40const char * const LL_CHANNEL = "Second Life Release";
diff --git a/linden/indra/llcommon/metapropertyt.h b/linden/indra/llcommon/metapropertyt.h
index 5c25ec4..73c2a7a 100644
--- a/linden/indra/llcommon/metapropertyt.h
+++ b/linden/indra/llcommon/metapropertyt.h
@@ -86,13 +86,6 @@ inline const LLReflective* LLMetaPropertyT<std::string>::get(const LLReflective*
86} 86}
87 87
88template <> 88template <>
89inline const LLReflective* LLMetaPropertyT<LLString>::get(const LLReflective* object) const
90{
91 checkObjectClass(object);
92 return NULL;
93}
94
95template <>
96inline const LLReflective* LLMetaPropertyT<LLUUID>::get(const LLReflective* object) const 89inline const LLReflective* LLMetaPropertyT<LLUUID>::get(const LLReflective* object) const
97{ 90{
98 checkObjectClass(object); 91 checkObjectClass(object);
@@ -112,12 +105,6 @@ inline LLSD LLMetaPropertyT<std::string>::getLLSD(const LLReflective* object) co
112} 105}
113 106
114template <> 107template <>
115inline LLSD LLMetaPropertyT<LLString>::getLLSD(const LLReflective* object) const
116{
117 return *(getProperty(object));
118}
119
120template <>
121inline LLSD LLMetaPropertyT<LLUUID>::getLLSD(const LLReflective* object) const 108inline LLSD LLMetaPropertyT<LLUUID>::getLLSD(const LLReflective* object) const
122{ 109{
123 return *(getProperty(object)); 110 return *(getProperty(object));
diff --git a/linden/indra/llcommon/roles_constants.h b/linden/indra/llcommon/roles_constants.h
index 956a9de..ee2986b 100644
--- a/linden/indra/llcommon/roles_constants.h
+++ b/linden/indra/llcommon/roles_constants.h
@@ -143,11 +143,18 @@ const U64 GP_NOTICES_RECEIVE = 0x1LL << 43; // Receive Notices and View Notice
143const U64 GP_PROPOSAL_START = 0x1LL << 44; // Start Proposal 143const U64 GP_PROPOSAL_START = 0x1LL << 44; // Start Proposal
144const U64 GP_PROPOSAL_VOTE = 0x1LL << 45; // Vote on Proposal 144const U64 GP_PROPOSAL_VOTE = 0x1LL << 45; // Vote on Proposal
145 145
146// Group chat moderation related
147const U64 GP_SESSION_JOIN = 0x1LL << 16; //can join session
148const U64 GP_SESSION_VOICE = 0x1LL << 27; //can hear/talk
149const U64 GP_SESSION_MODERATOR = 0x1LL << 37; //can mute people's session
150
146const U64 GP_DEFAULT_MEMBER = GP_ACCOUNTING_ACCOUNTABLE 151const U64 GP_DEFAULT_MEMBER = GP_ACCOUNTING_ACCOUNTABLE
147 | GP_LAND_ALLOW_SET_HOME 152 | GP_LAND_ALLOW_SET_HOME
148 | GP_NOTICES_RECEIVE 153 | GP_NOTICES_RECEIVE
149 | GP_PROPOSAL_START 154 | GP_PROPOSAL_START
150 | GP_PROPOSAL_VOTE 155 | GP_PROPOSAL_VOTE
156 | GP_SESSION_JOIN
157 | GP_SESSION_VOICE
151 ; 158 ;
152 159
153const U64 GP_DEFAULT_OFFICER = GP_ACCOUNTING_ACCOUNTABLE 160const U64 GP_DEFAULT_OFFICER = GP_ACCOUNTING_ACCOUNTABLE
@@ -188,5 +195,8 @@ const U64 GP_DEFAULT_OFFICER = GP_ACCOUNTING_ACCOUNTABLE
188 | GP_PROPOSAL_VOTE 195 | GP_PROPOSAL_VOTE
189 | GP_ROLE_ASSIGN_MEMBER_LIMITED 196 | GP_ROLE_ASSIGN_MEMBER_LIMITED
190 | GP_ROLE_PROPERTIES 197 | GP_ROLE_PROPERTIES
198 | GP_SESSION_MODERATOR
199 | GP_SESSION_JOIN
200 | GP_SESSION_VOICE
191 ; 201 ;
192#endif 202#endif
diff --git a/linden/indra/llcommon/stdtypes.h b/linden/indra/llcommon/stdtypes.h
index c1f5303..44f67f2 100644
--- a/linden/indra/llcommon/stdtypes.h
+++ b/linden/indra/llcommon/stdtypes.h
@@ -31,6 +31,8 @@
31#ifndef LL_STDTYPES_H 31#ifndef LL_STDTYPES_H
32#define LL_STDTYPES_H 32#define LL_STDTYPES_H
33 33
34#include <cfloat>
35
34typedef signed char S8; 36typedef signed char S8;
35typedef unsigned char U8; 37typedef unsigned char U8;
36typedef signed short S16; 38typedef signed short S16;
diff --git a/linden/indra/llcommon/u64.cpp b/linden/indra/llcommon/u64.cpp
index bbeed9f..5aebdb3 100644
--- a/linden/indra/llcommon/u64.cpp
+++ b/linden/indra/llcommon/u64.cpp
@@ -34,10 +34,10 @@
34#include "u64.h" 34#include "u64.h"
35 35
36 36
37U64 str_to_U64(const char *str) 37U64 str_to_U64(const std::string& str)
38{ 38{
39 U64 result = 0; 39 U64 result = 0;
40 const char *aptr = strpbrk(str,"0123456789"); 40 const char *aptr = strpbrk(str.c_str(),"0123456789");
41 41
42 if (!aptr) 42 if (!aptr)
43 { 43 {
@@ -54,8 +54,9 @@ U64 str_to_U64(const char *str)
54} 54}
55 55
56 56
57char* U64_to_str(U64 value, char* result, S32 result_size) 57std::string U64_to_str(U64 value)
58{ 58{
59 std::string res;
59 U32 part1,part2,part3; 60 U32 part1,part2,part3;
60 61
61 part3 = (U32)(value % (U64)10000000); 62 part3 = (U32)(value % (U64)10000000);
@@ -70,31 +71,26 @@ char* U64_to_str(U64 value, char* result, S32 result_size)
70 71
71 if (part1) 72 if (part1)
72 { 73 {
73 snprintf( /* Flawfinder: ignore */ 74 res = llformat("%u%07u%07u",part1,part2,part3);
74 result,
75 result_size,
76 "%u%07u%07u",
77 part1,part2,part3);
78 } 75 }
79 else if (part2) 76 else if (part2)
80 { 77 {
81 snprintf( /* Flawfinder: ignore */ 78 res = llformat("%u%07u",part2,part3);
82 result,
83 result_size,
84 "%u%07u",
85 part2,part3);
86 } 79 }
87 else 80 else
88 { 81 {
89 snprintf( /* Flawfinder: ignore */ 82 res = llformat("%u",part3);
90 result,
91 result_size,
92 "%u",
93 part3);
94 } 83 }
95 return (result); 84 return res;
96} 85}
97 86
87char* U64_to_str(U64 value, char* result, S32 result_size)
88{
89 std::string res = U64_to_str(value);
90 LLStringUtil::copy(result, res.c_str(), result_size);
91 return result;
92}
93
98F64 U64_to_F64(const U64 value) 94F64 U64_to_F64(const U64 value)
99{ 95{
100 S64 top_bits = (S64)(value >> 1); 96 S64 top_bits = (S64)(value >> 1);
diff --git a/linden/indra/llcommon/u64.h b/linden/indra/llcommon/u64.h
index ab06836..3d45fc3 100644
--- a/linden/indra/llcommon/u64.h
+++ b/linden/indra/llcommon/u64.h
@@ -38,7 +38,14 @@
38 * @param str The string to parse. 38 * @param str The string to parse.
39 * @return Returns the first U64 value found in the string or 0 on failure. 39 * @return Returns the first U64 value found in the string or 0 on failure.
40 */ 40 */
41U64 str_to_U64(const char* str); 41U64 str_to_U64(const std::string& str);
42
43/**
44 * @brief Given a U64 value, return a printable representation.
45 * @param value The U64 to turn into a printable character array.
46 * @return Returns the result string.
47 */
48std::string U64_to_str(U64 value);
42 49
43/** 50/**
44 * @brief Given a U64 value, return a printable representation. 51 * @brief Given a U64 value, return a printable representation.