diff options
Diffstat (limited to 'linden/indra/llmessage/llsdmessagereader.cpp')
-rwxr-xr-x | linden/indra/llmessage/llsdmessagereader.cpp | 68 |
1 files changed, 61 insertions, 7 deletions
diff --git a/linden/indra/llmessage/llsdmessagereader.cpp b/linden/indra/llmessage/llsdmessagereader.cpp index 6312bee..6742edb 100755 --- a/linden/indra/llmessage/llsdmessagereader.cpp +++ b/linden/indra/llmessage/llsdmessagereader.cpp | |||
@@ -1,7 +1,38 @@ | |||
1 | /** | ||
2 | * @file llsdmessagereader.cpp | ||
3 | * @brief LLSDMessageReader class implementation. | ||
4 | * | ||
5 | * Copyright (c) 2007-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * Second Life Viewer Source Code | ||
8 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
9 | * to you under the terms of the GNU General Public License, version 2.0 | ||
10 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
11 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
12 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
13 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
14 | * | ||
15 | * There are special exceptions to the terms and conditions of the GPL as | ||
16 | * it is applied to this Source Code. View the full text of the exception | ||
17 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
18 | * online at http://secondlife.com/developers/opensource/flossexception | ||
19 | * | ||
20 | * By copying, modifying or distributing this software, you acknowledge | ||
21 | * that you have read and understood your obligations described above, | ||
22 | * and agree to abide by those obligations. | ||
23 | * | ||
24 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
25 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
26 | * COMPLETENESS OR PERFORMANCE. | ||
27 | */ | ||
28 | |||
29 | #include "linden_common.h" | ||
30 | |||
1 | #include "llsdmessagereader.h" | 31 | #include "llsdmessagereader.h" |
2 | #include "llsdutil.h" | 32 | |
3 | #include "llmessagebuilder.h" | 33 | #include "llmessagebuilder.h" |
4 | #include "llsdmessagebuilder.h" | 34 | #include "llsdmessagebuilder.h" |
35 | #include "llsdutil.h" | ||
5 | 36 | ||
6 | LLSDMessageReader::LLSDMessageReader() | 37 | LLSDMessageReader::LLSDMessageReader() |
7 | { | 38 | { |
@@ -15,11 +46,30 @@ LLSDMessageReader::~LLSDMessageReader() | |||
15 | 46 | ||
16 | LLSD getLLSD(const LLSD& input, const char* block, const char* var, S32 blocknum) | 47 | LLSD getLLSD(const LLSD& input, const char* block, const char* var, S32 blocknum) |
17 | { | 48 | { |
18 | if(input[block].isArray()) | 49 | // babbage: log error to llerrs if variable not found to mimic |
50 | // LLTemplateMessageReader::getData behaviour | ||
51 | if(NULL == block) | ||
52 | { | ||
53 | llerrs << "NULL block name" << llendl; | ||
54 | return LLSD(); | ||
55 | } | ||
56 | if(NULL == var) | ||
57 | { | ||
58 | llerrs << "NULL var name" << llendl; | ||
59 | return LLSD(); | ||
60 | } | ||
61 | if(! input[block].isArray()) | ||
19 | { | 62 | { |
20 | return input[block][blocknum][var]; | 63 | llerrs << "block " << block << " not found" << llendl; |
64 | return LLSD(); | ||
21 | } | 65 | } |
22 | return LLSD(); | 66 | |
67 | LLSD result = input[block][blocknum][var]; | ||
68 | if(result.isUndefined()) | ||
69 | { | ||
70 | llerrs << "var " << var << " not found" << llendl; | ||
71 | } | ||
72 | return result; | ||
23 | } | 73 | } |
24 | 74 | ||
25 | //virtual | 75 | //virtual |
@@ -167,8 +217,12 @@ void LLSDMessageReader::getIPPort(const char *block, const char *var, | |||
167 | void LLSDMessageReader::getString(const char *block, const char *var, | 217 | void LLSDMessageReader::getString(const char *block, const char *var, |
168 | S32 buffer_size, char *buffer, S32 blocknum) | 218 | S32 buffer_size, char *buffer, S32 blocknum) |
169 | { | 219 | { |
220 | if(buffer_size <= 0) | ||
221 | { | ||
222 | llwarns << "buffer_size <= 0" << llendl; | ||
223 | return; | ||
224 | } | ||
170 | std::string data = getLLSD(mMessage, block, var, blocknum); | 225 | std::string data = getLLSD(mMessage, block, var, blocknum); |
171 | |||
172 | S32 data_size = data.size(); | 226 | S32 data_size = data.size(); |
173 | if (data_size >= buffer_size) | 227 | if (data_size >= buffer_size) |
174 | { | 228 | { |
@@ -241,7 +295,7 @@ void LLSDMessageReader::clearMessage() | |||
241 | //virtual | 295 | //virtual |
242 | const char* LLSDMessageReader::getMessageName() const | 296 | const char* LLSDMessageReader::getMessageName() const |
243 | { | 297 | { |
244 | return mMessageName.c_str(); | 298 | return mMessageName; |
245 | } | 299 | } |
246 | 300 | ||
247 | // virtual | 301 | // virtual |
@@ -256,7 +310,7 @@ void LLSDMessageReader::copyToBuilder(LLMessageBuilder& builder) const | |||
256 | builder.copyFromLLSD(mMessage); | 310 | builder.copyFromLLSD(mMessage); |
257 | } | 311 | } |
258 | 312 | ||
259 | void LLSDMessageReader::setMessage(const std::string& name, const LLSD& message) | 313 | void LLSDMessageReader::setMessage(const char* name, const LLSD& message) |
260 | { | 314 | { |
261 | mMessageName = name; | 315 | mMessageName = name; |
262 | // TODO: Validate | 316 | // TODO: Validate |