summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorDon Kjer <don@lindenlab.com>2007-05-01 21:39:25 +0000
committerDon Kjer <don@lindenlab.com>2007-05-01 21:39:25 +0000
commit4ecb9cb63e4993b3b4bc65d73ed255139b5c3f75 (patch)
tree48d9bb9a1ae468ecdbd53cf21a598d66ee8eced3 /indra/llcommon
parentf5e9ce7e47694e349a4eb28b052016b11e1bdf81 (diff)
svn merge -r 59163:61099 svn+ssh://svn/svn/linden/branches/release-candidate into release
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/bitpack.cpp148
-rw-r--r--indra/llcommon/indra_constants.h6
-rw-r--r--indra/llcommon/llbase32.h38
-rw-r--r--indra/llcommon/llsdserialize_xml.cpp13
-rw-r--r--indra/llcommon/llsdutil.cpp61
-rw-r--r--indra/llcommon/llsdutil.h11
-rw-r--r--indra/llcommon/lluri.cpp40
-rw-r--r--indra/llcommon/lluri.h13
8 files changed, 129 insertions, 201 deletions
diff --git a/indra/llcommon/bitpack.cpp b/indra/llcommon/bitpack.cpp
deleted file mode 100644
index 4acd533600..0000000000
--- a/indra/llcommon/bitpack.cpp
+++ /dev/null
@@ -1,148 +0,0 @@
-/**
- * @file bitpack.cpp
- * @brief Convert data to packed bit stream
- *
- * Copyright (c) 2000-$CurrentYear$, Linden Research, Inc.
- * $License$
- */
-
-#include "linden_common.h"
-
-#include "bitpack.h"
-
-#if 0
-#include <stdio.h>
-#include <stdlib.h>
-#include "stdtypes.h"
-
-U8 gLoad, gUnLoad;
-U32 gLoadSize, gUnLoadSize, gTotalBits;
-
-const U32 gMaxDataBits = 8;
-
-/////////////////////////////////////////////////////////////////////////////////////////
-#if 0
-void bit_pack(U8 *outbase, U32 *outptr, U8 *total_data, U32 total_dsize)
-{
- U32 max_data_bits = gMaxDataBits;
- U32 load_size = gLoadSize, total_bits = gTotalBits;
- U32 dsize;
-
- U8 data;
- U8 load = gLoad;
-
- while (total_dsize > 0)
- {
- if (total_dsize > max_data_bits)
- {
- dsize = max_data_bits;
- total_dsize -= max_data_bits;
- }
- else
- {
- dsize = total_dsize;
- total_dsize = 0;
- }
-
- data = *total_data++;
-
- data <<= (max_data_bits - dsize);
- while (dsize > 0)
- {
- if (load_size == max_data_bits)
- {
- *(outbase + (*outptr)++) = load;
- load_size = 0;
- load = 0x00;
- }
- load <<= 1;
- load |= (data >> (max_data_bits - 1));
- data <<= 1;
- load_size++;
- total_bits++;
- dsize--;
- }
- }
-
- gLoad = load;
- gLoadSize = load_size;
- gTotalBits = total_bits;
-}
-#endif
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-void bit_pack_reset()
-{
- gLoad = 0x0;
- gLoadSize = 0;
- gTotalBits = 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-void bit_pack_flush(U8 *outbase, U32 *outptr)
-{
- if (gLoadSize)
- {
- gTotalBits += gLoadSize;
- gLoad <<= (gMaxDataBits - gLoadSize);
- outbase[(*outptr)++] = gLoad;
- gLoadSize = 0;
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////////////
-#if 0
-void bit_unpack(U8 *total_retval, U32 total_dsize, U8 *indata, U32 *inptr)
-{
- U32 max_data_bits = gMaxDataBits;
- U32 unload_size = gUnLoadSize;
- U32 dsize;
- U8 *retval;
- U8 unload = gUnLoad;
-
- while (total_dsize > 0)
- {
- if (total_dsize > max_data_bits)
- {
- dsize = max_data_bits;
- total_dsize -= max_data_bits;
- }
- else
- {
- dsize = total_dsize;
- total_dsize = 0;
- }
-
- retval = total_data++;
- *retval = 0x00;
- while (dsize > 0)
- {
- if (unload_size == 0)
- {
- unload = indata[(*inptr)++];
- unload_size = max_data_bits;
- }
- *retval <<= 1;
- *retval |= (unload >> (max_data_bits - 1));
- unload_size--;
- unload <<= 1;
- dsize--;
- }
- }
-
- gUnLoad = unload;
- gUnLoadSize = unload_size;
-}
-#endif
-
-
-///////////////////////////////////////////////////////////////////////////////////////
-
-void bit_unpack_reset()
-{
- gUnLoad = 0;
- gUnLoadSize = 0;
-}
-#endif
diff --git a/indra/llcommon/indra_constants.h b/indra/llcommon/indra_constants.h
index 20499d4ad3..7f1c48a215 100644
--- a/indra/llcommon/indra_constants.h
+++ b/indra/llcommon/indra_constants.h
@@ -12,10 +12,6 @@
#include "stdtypes.h"
#include "lluuid.h"
-// Viewer object cache version, change if object update
-// format changes. JC
-const U32 INDRA_OBJECT_CACHE_VERSION = 11;
-
// At 45 Hz collisions seem stable and objects seem
// to settle down at a reasonable rate.
// JC 3/18/2003
@@ -97,11 +93,11 @@ const U32 DEFAULT_USER_SERVER_PORT = 12036;
const U32 DEFAULT_RPC_SERVER_PORT = 12037;
const U32 DEFAULT_LOG_DATA_SERVER_PORT = 12039;
const U32 DEFAULT_BACKBONE_PORT = 12040;
-const U32 DEFAULT_CGI_SERVICES_PORT = 12045;
const U32 DEFAULT_LOCAL_ASSET_PORT = 12041;
//const U32 DEFAULT_BACKBONE_CAP_PORT = 12042; // Deprecated
const U32 DEFAULT_CAP_PROXY_PORT = 12043;
const U32 DEFAULT_INV_DATA_SERVER_PORT = 12044;
+const U32 DEFAULT_CGI_SERVICES_PORT = 12045;
// For automatic port discovery when running multiple viewers on one host
const U32 PORT_DISCOVERY_RANGE_MIN = 13000;
diff --git a/indra/llcommon/llbase32.h b/indra/llcommon/llbase32.h
index 5fd06f9e30..6927607c8f 100644
--- a/indra/llcommon/llbase32.h
+++ b/indra/llcommon/llbase32.h
@@ -1,19 +1,19 @@
-/**
- * @file llbase32.h
- * @brief base32 encoding that returns a std::string
- * @author James Cook
- *
- * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
- * $License$
- */
-
-#ifndef LLBASE32_H
-#define LLBASE32_h
-
-class LLBase32
-{
-public:
- static std::string encode(const U8* input, size_t input_size);
-};
-
-#endif
+/**
+ * @file llbase32.h
+ * @brief base32 encoding that returns a std::string
+ * @author James Cook
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+#ifndef LLBASE32_H
+#define LLBASE32_h
+
+class LLBase32
+{
+public:
+ static std::string encode(const U8* input, size_t input_size);
+};
+
+#endif
diff --git a/indra/llcommon/llsdserialize_xml.cpp b/indra/llcommon/llsdserialize_xml.cpp
index 796cd9f9f4..c5ab369d0f 100644
--- a/indra/llcommon/llsdserialize_xml.cpp
+++ b/indra/llcommon/llsdserialize_xml.cpp
@@ -234,7 +234,7 @@ public:
Impl();
~Impl();
- LLSD parse(std::istream& input);
+ S32 parse(std::istream& input, LLSD& data);
void parsePart(const char *buf, int len);
@@ -336,7 +336,7 @@ static unsigned get_till_eol(std::istream& input, char *buf, unsigned bufsize)
return count;
}
-LLSD LLSDXMLParser::Impl::parse(std::istream& input)
+S32 LLSDXMLParser::Impl::parse(std::istream& input, LLSD& data)
{
reset();
XML_Status status;
@@ -380,11 +380,13 @@ LLSD LLSDXMLParser::Impl::parse(std::istream& input)
{
((char*) buffer)[count? count - 1 : 0] = '\0';
llinfos << "LLSDXMLParser::Impl::parse: XML_STATUS_ERROR parsing:" << (char*) buffer << llendl;
- return LLSD();
+ data = LLSD();
+ return -1;
}
clear_eol(input);
- return mResult;
+ data = mResult;
+ return 1;
}
void LLSDXMLParser::Impl::reset()
@@ -703,6 +705,5 @@ void LLSDXMLParser::parsePart(const char *buf, int len)
// virtual
S32 LLSDXMLParser::parse(std::istream& input, LLSD& data) const
{
- data = impl.parse(input);
- return 0;
+ return impl.parse(input, data);
}
diff --git a/indra/llcommon/llsdutil.cpp b/indra/llcommon/llsdutil.cpp
index a6ac2fb12b..57a024ecee 100644
--- a/indra/llcommon/llsdutil.cpp
+++ b/indra/llcommon/llsdutil.cpp
@@ -21,7 +21,7 @@
# include <arpa/inet.h>
#endif
-
+#include "llsdserialize.h"
// vector3
LLSD ll_sd_from_vector3(const LLVector3& vec)
@@ -42,6 +42,27 @@ LLVector3 ll_vector3_from_sd(const LLSD& sd, S32 start_index)
return rv;
}
+// vector4
+LLSD ll_sd_from_vector4(const LLVector4& vec)
+{
+ LLSD rv;
+ rv.append((F64)vec.mV[VX]);
+ rv.append((F64)vec.mV[VY]);
+ rv.append((F64)vec.mV[VZ]);
+ rv.append((F64)vec.mV[VW]);
+ return rv;
+}
+
+LLVector4 ll_vector4_from_sd(const LLSD& sd, S32 start_index)
+{
+ LLVector4 rv;
+ rv.mV[VX] = (F32)sd[start_index].asReal();
+ rv.mV[VY] = (F32)sd[++start_index].asReal();
+ rv.mV[VZ] = (F32)sd[++start_index].asReal();
+ rv.mV[VW] = (F32)sd[++start_index].asReal();
+ return rv;
+}
+
// vector3d
LLSD ll_sd_from_vector3d(const LLVector3d& vec)
{
@@ -208,9 +229,39 @@ U32 ll_ipaddr_from_sd(const LLSD& sd)
LLSD ll_string_from_binary(const LLSD& sd)
{
std::vector<U8> value = sd.asBinary();
- char* c_str = new char[value.size() + 1];
- memcpy(c_str, &value[0], value.size());
- c_str[value.size()] = '\0';
+ std::string str;
+ str.resize(value.size());
+ memcpy(&str[0], &value[0], value.size());
+ return str;
+}
- return c_str;
+// Converts an LLSD string to an LLSD binary
+LLSD ll_binary_from_string(const LLSD& sd)
+{
+ std::vector<U8> binary_value;
+
+ LLString string_value = sd.asString();
+ const char* string_p = string_value.c_str();
+ while (*string_p)
+ {
+ binary_value.push_back(*string_p);
+ string_p++;
+ }
+
+ binary_value.push_back('\0');
+
+ return binary_value;
+}
+
+char* ll_print_sd(const LLSD& sd)
+{
+ const U32 bufferSize = 10 * 1024;
+ static char buffer[bufferSize];
+ std::ostringstream stream;
+ //stream.rdbuf()->pubsetbuf(buffer, bufferSize);
+ stream << LLSDOStreamer<LLSDXMLFormatter>(sd);
+ stream << std::ends;
+ strncpy(buffer, stream.str().c_str(), bufferSize);
+ buffer[bufferSize - 1] = '\0';
+ return buffer;
}
diff --git a/indra/llcommon/llsdutil.h b/indra/llcommon/llsdutil.h
index 44e9429d7f..860232044e 100644
--- a/indra/llcommon/llsdutil.h
+++ b/indra/llcommon/llsdutil.h
@@ -13,6 +13,7 @@
#include "llsd.h"
#include "../llmath/v3math.h"
+#include "../llmath/v4math.h"
#include "../llmath/v3dmath.h"
#include "../llmath/v2math.h"
#include "../llmath/llquaternion.h"
@@ -23,6 +24,10 @@
LLSD ll_sd_from_vector3(const LLVector3& vec);
LLVector3 ll_vector3_from_sd(const LLSD& sd, S32 start_index = 0);
+// vector4
+LLSD ll_sd_from_vector4(const LLVector4& vec);
+LLVector4 ll_vector4_from_sd(const LLSD& sd, S32 start_index = 0);
+
// vector3d (double)
LLSD ll_sd_from_vector3d(const LLVector3d& vec);
LLVector3d ll_vector3d_from_sd(const LLSD& sd, S32 start_index = 0);
@@ -54,4 +59,10 @@ U32 ll_ipaddr_from_sd(const LLSD& sd);
// Binary to string
LLSD ll_string_from_binary(const LLSD& sd);
+//String to binary
+LLSD ll_binary_from_string(const LLSD& sd);
+
+// Serializes sd to static buffer and returns pointer, useful for gdb debugging.
+char* ll_print_sd(const LLSD& sd);
+
#endif // LL_LLSDUTIL_H
diff --git a/indra/llcommon/lluri.cpp b/indra/llcommon/lluri.cpp
index bf0d2cb21e..52270376f8 100644
--- a/indra/llcommon/lluri.cpp
+++ b/indra/llcommon/lluri.cpp
@@ -195,6 +195,19 @@ LLURI LLURI::buildHTTP(const std::string& prefix,
result.mEscapedPath += "/" + escapePathComponent(it->asString());
}
}
+ else if(path.isString())
+ {
+ result.mEscapedPath += "/" + escapePathComponent(path.asString());
+ }
+ else if(path.isUndefined())
+ {
+ // do nothing
+ }
+ else
+ {
+ llwarns << "Valid path arguments to buildHTTP are array, string, or undef, you passed type"
+ << path.type() << llendl;
+ }
result.mEscapedOpaque = "//" + result.mEscapedAuthority +
result.mEscapedPath;
return result;
@@ -265,17 +278,22 @@ namespace {
}
}
-
+#if LL_ENABLE_JANKY_DEPRECATED_WEB_SERVICE_CALLS
// static
-LLURI LLURI::buildAgentPresenceURI(const LLUUID& agent_id, LLApp* app)
+LLURI LLURI::buildBulkAgentNamesURI(LLApp* app)
{
- return buildBackboneURL(app, "agent", agent_id.asString(), "presence");
-}
+ std::string host = "localhost:12040";
-// static
-LLURI LLURI::buildBulkAgentPresenceURI(LLApp* app)
-{
- return buildBackboneURL(app, "agent", "presence");
+ if (app)
+ {
+ host = app->getOption("backbone-host-port").asString();
+ }
+
+ LLSD path = LLSD::emptyArray();
+ path.append("agent");
+ path.append("names");
+
+ return buildHTTP(host, path);
}
// static
@@ -302,7 +320,7 @@ LLURI LLURI::buildAgentSessionURI(const LLUUID& agent_id, LLApp* app)
}
// static
-LLURI LLURI::buildInventoryHostURI(const LLUUID& agent_id, LLApp* app)
+LLURI LLURI::buildAgentNameURI(const LLUUID& agent_id, LLApp* app)
{
std::string host = "localhost:12040";
@@ -314,8 +332,7 @@ LLURI LLURI::buildInventoryHostURI(const LLUUID& agent_id, LLApp* app)
LLSD path = LLSD::emptyArray();
path.append("agent");
path.append(agent_id);
- path.append("inventory");
- path.append("host");
+ path.append("name");
return buildHTTP(host, path);
}
@@ -348,6 +365,7 @@ LLURI LLURI::buildAgentLoginInfoURI(const LLUUID& agent_id, const std::string& d
return buildHTTP(dataserver, path);
}
+#endif // LL_ENABLE_JANKY_DEPRECATED_WEB_SERVICE_CALLS
std::string LLURI::asString() const
{
diff --git a/indra/llcommon/lluri.h b/indra/llcommon/lluri.h
index 865a3b21a0..f42cc102e6 100644
--- a/indra/llcommon/lluri.h
+++ b/indra/llcommon/lluri.h
@@ -77,13 +77,12 @@ public:
static std::string unescape(const std::string& str);
// Functions for building specific URIs for web services
- static LLURI buildAgentPresenceURI(const LLUUID& agent_id, LLApp* app);
- static LLURI buildBulkAgentPresenceURI(LLApp* app);
- static LLURI buildBulkAgentNamesURI(LLApp* app);
- static LLURI buildAgentSessionURI(const LLUUID& agent_id, LLApp* app);
- static LLURI buildAgentLoginInfoURI(const LLUUID& agent_id, const std::string& dataserver);
- static LLURI buildInventoryHostURI(const LLUUID& agent_id, LLApp* app);
- static LLURI buildAgentNameURI(const LLUUID& agent_id, LLApp* app);
+ // *NOTE: DEPRECATED. use the service builder instead.
+ //static LLURI buildBulkAgentNamesURI(LLApp* app);
+ //static LLURI buildAgentSessionURI(const LLUUID& agent_id, LLApp* app);
+ //static LLURI buildAgentLoginInfoURI(const LLUUID& agent_id, const std::string& dataserver);
+ //static LLURI buildAgentNameURI(const LLUUID& agent_id, LLApp* app);
+
private:
std::string mScheme;
std::string mEscapedOpaque;