summaryrefslogtreecommitdiff
path: root/indra/llcommon/lluuid.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon/lluuid.cpp')
-rw-r--r--indra/llcommon/lluuid.cpp110
1 files changed, 54 insertions, 56 deletions
diff --git a/indra/llcommon/lluuid.cpp b/indra/llcommon/lluuid.cpp
index 200add404f..b9bd27aa17 100644
--- a/indra/llcommon/lluuid.cpp
+++ b/indra/llcommon/lluuid.cpp
@@ -25,12 +25,10 @@
#include "linden_common.h"
- // We can't use WIN32_LEAN_AND_MEAN here, needs lots of includes.
#if LL_WINDOWS
#include "llwin32headers.h"
-// ugh, this is ugly. We need to straighten out our linking for this library
-#pragma comment(lib, "IPHLPAPI.lib")
#include <iphlpapi.h>
+#include <nb30.h>
#endif
#include "llapp.h"
@@ -50,7 +48,7 @@
const LLUUID LLUUID::null;
const LLTransactionID LLTransactionID::tnull;
-// static
+// static
LLMutex* LLUUID::mMutex = NULL;
@@ -187,7 +185,7 @@ void LLUUID::toString(char* out) const
void LLUUID::toCompressedString(std::string& out) const
{
char bytes[UUID_BYTES + 1];
- memcpy(bytes, mData, UUID_BYTES); /* Flawfinder: ignore */
+ memcpy(bytes, mData, UUID_BYTES); /* Flawfinder: ignore */
bytes[UUID_BYTES] = '\0';
out.assign(bytes, UUID_BYTES);
}
@@ -195,7 +193,7 @@ void LLUUID::toCompressedString(std::string& out) const
// *TODO: deprecate
void LLUUID::toCompressedString(char* out) const
{
- memcpy(out, mData, UUID_BYTES); /* Flawfinder: ignore */
+ memcpy(out, mData, UUID_BYTES); /* Flawfinder: ignore */
out[UUID_BYTES] = '\0';
}
@@ -211,33 +209,33 @@ std::string LLUUID::asString() const
return str;
}
-BOOL LLUUID::set(const char* in_string, BOOL emit)
+bool LLUUID::set(const char* in_string, bool emit)
{
return set(ll_safe_string(in_string), emit);
}
-BOOL LLUUID::set(const std::string& in_string, BOOL emit)
+bool LLUUID::set(const std::string& in_string, bool emit)
{
- BOOL broken_format = FALSE;
+ bool broken_format = false;
// empty strings should make NULL uuid
if (in_string.empty())
{
setNull();
- return TRUE;
+ return true;
}
- if (in_string.length() != (UUID_STR_LENGTH - 1)) /* Flawfinder: ignore */
+ if (in_string.length() != (UUID_STR_LENGTH - 1)) /* Flawfinder: ignore */
{
// I'm a moron. First implementation didn't have the right UUID format.
// Shouldn't see any of these any more
- if (in_string.length() == (UUID_STR_LENGTH - 2)) /* Flawfinder: ignore */
+ if (in_string.length() == (UUID_STR_LENGTH - 2)) /* Flawfinder: ignore */
{
if (emit)
{
LL_WARNS() << "Warning! Using broken UUID string format" << LL_ENDL;
}
- broken_format = TRUE;
+ broken_format = true;
}
else
{
@@ -248,7 +246,7 @@ BOOL LLUUID::set(const std::string& in_string, BOOL emit)
LL_WARNS() << "Bad UUID string: " << in_string << LL_ENDL;
}
setNull();
- return FALSE;
+ return false;
}
}
@@ -287,7 +285,7 @@ BOOL LLUUID::set(const std::string& in_string, BOOL emit)
LL_WARNS() << "Invalid UUID string character" << LL_ENDL;
}
setNull();
- return FALSE;
+ return false;
}
mData[i] = mData[i] << 4;
@@ -312,27 +310,27 @@ BOOL LLUUID::set(const std::string& in_string, BOOL emit)
LL_WARNS() << "Invalid UUID string character" << LL_ENDL;
}
setNull();
- return FALSE;
+ return false;
}
cur_pos++;
}
- return TRUE;
+ return true;
}
-BOOL LLUUID::validate(const std::string& in_string)
+bool LLUUID::validate(const std::string& in_string)
{
- BOOL broken_format = FALSE;
- if (in_string.length() != (UUID_STR_LENGTH - 1)) /* Flawfinder: ignore */
+ bool broken_format = false;
+ if (in_string.length() != (UUID_STR_LENGTH - 1)) /* Flawfinder: ignore */
{
// I'm a moron. First implementation didn't have the right UUID format.
- if (in_string.length() == (UUID_STR_LENGTH - 2)) /* Flawfinder: ignore */
+ if (in_string.length() == (UUID_STR_LENGTH - 2)) /* Flawfinder: ignore */
{
- broken_format = TRUE;
+ broken_format = true;
}
else
{
- return FALSE;
+ return false;
}
}
@@ -360,7 +358,7 @@ BOOL LLUUID::validate(const std::string& in_string)
}
else
{
- return FALSE;
+ return false;
}
cur_pos++;
@@ -376,11 +374,11 @@ BOOL LLUUID::validate(const std::string& in_string)
}
else
{
- return FALSE;
+ return false;
}
cur_pos++;
}
- return TRUE;
+ return true;
}
const LLUUID& LLUUID::operator^=(const LLUUID& rhs)
@@ -431,7 +429,7 @@ std::ostream& operator<<(std::ostream& s, const LLUUID& uuid)
std::istream& operator>>(std::istream& s, LLUUID& uuid)
{
U32 i;
- char uuid_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */
+ char uuid_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */
for (i = 0; i < UUID_STR_LENGTH - 1; i++)
{
s >> uuid_str[i];
@@ -459,7 +457,7 @@ static void get_random_bytes(void* buf, int nbytes)
return;
}
-#if LL_WINDOWS
+#if LL_WINDOWS
typedef struct _ASTAT_
{
@@ -468,7 +466,7 @@ typedef struct _ASTAT_
}ASTAT, * PASTAT;
// static
-S32 LLUUID::getNodeID(unsigned char* node_id)
+S32 LLUUID::getNodeID(unsigned char* node_id)
{
ASTAT Adapter;
NCB Ncb;
@@ -495,14 +493,14 @@ S32 LLUUID::getNodeID(unsigned char* node_id)
Ncb.ncb_command = NCBASTAT;
Ncb.ncb_lana_num = lenum.lana[i];
- strcpy((char*)Ncb.ncb_callname, "* "); /* Flawfinder: ignore */
+ strcpy((char*)Ncb.ncb_callname, "* "); /* Flawfinder: ignore */
Ncb.ncb_buffer = (unsigned char*)&Adapter;
Ncb.ncb_length = sizeof(Adapter);
uRetCode = Netbios(&Ncb);
if (uRetCode == 0)
{
- memcpy(node_id, Adapter.adapt.adapter_address, 6); /* Flawfinder: ignore */
+ memcpy(node_id, Adapter.adapt.adapter_address, 6); /* Flawfinder: ignore */
retval = 1;
}
}
@@ -510,7 +508,7 @@ S32 LLUUID::getNodeID(unsigned char* node_id)
}
#elif LL_DARWIN
-// Mac OS X version of the UUID generation code...
+// macOS version of the UUID generation code...
/*
* Get an ethernet hardware address, if we can find it...
*/
@@ -545,19 +543,19 @@ S32 LLUUID::getNodeID(unsigned char* node_id)
for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next)
{
- // printf("Interface %s, address family %d, ", ifa->ifa_name, ifa->ifa_addr->sa_family);
+ // printf("Interface %s, address family %d, ", ifa->ifa_name, ifa->ifa_addr->sa_family);
for (i = 0; i < ifa->ifa_addr->sa_len; i++)
{
- // printf("%02X ", (unsigned char)ifa->ifa_addr->sa_data[i]);
+ // printf("%02X ", (unsigned char)ifa->ifa_addr->sa_data[i]);
}
- // printf("\n");
+ // printf("\n");
if (ifa->ifa_addr->sa_family == AF_LINK)
{
// This is a link-level address
struct sockaddr_dl* lla = (struct sockaddr_dl*)ifa->ifa_addr;
- // printf("\tLink level address, type %02X\n", lla->sdl_type);
+ // printf("\tLink level address, type %02X\n", lla->sdl_type);
if (lla->sdl_type == IFT_ETHER)
{
@@ -614,11 +612,11 @@ S32 LLUUID::getNodeID(unsigned char* node_id)
// static
S32 LLUUID::getNodeID(unsigned char* node_id)
{
- int sd;
- struct ifreq ifr, * ifrp;
- struct ifconf ifc;
+ int sd;
+ struct ifreq ifr, * ifrp;
+ struct ifconf ifc;
char buf[1024];
- int n, i;
+ int n, i;
unsigned char* a;
/*
@@ -651,7 +649,7 @@ S32 LLUUID::getNodeID(unsigned char* node_id)
n = ifc.ifc_len;
for (i = 0; i < n; i += ifreq_size(*ifr)) {
ifrp = (struct ifreq*)((char*)ifc.ifc_buf + i);
- strncpy(ifr.ifr_name, ifrp->ifr_name, IFNAMSIZ); /* Flawfinder: ignore */
+ strncpy(ifr.ifr_name, ifrp->ifr_name, IFNAMSIZ); /* Flawfinder: ignore */
#ifdef SIOCGIFHWADDR
if (ioctl(sd, SIOCGIFHWADDR, &ifr) < 0)
continue;
@@ -673,7 +671,7 @@ S32 LLUUID::getNodeID(unsigned char* node_id)
if (!a[0] && !a[1] && !a[2] && !a[3] && !a[4] && !a[5])
continue;
if (node_id) {
- memcpy(node_id, a, 6); /* Flawfinder: ignore */
+ memcpy(node_id, a, 6); /* Flawfinder: ignore */
close(sd);
return 1;
}
@@ -736,12 +734,12 @@ void LLUUID::getCurrentTime(uuid_time_t* timestamp)
static uuid_time_t time_last;
static U32 uuids_this_tick;
- static BOOL init = FALSE;
+ static bool init = false;
if (!init) {
getSystemTime(&time_last);
uuids_this_tick = uuids_per_tick;
- init = TRUE;
+ init = true;
mMutex = new LLMutex();
}
@@ -784,7 +782,7 @@ void LLUUID::generate()
// Create a UUID.
uuid_time_t timestamp;
- static unsigned char node_id[6]; /* Flawfinder: ignore */
+ static unsigned char node_id[6]; /* Flawfinder: ignore */
static int has_init = 0;
// Create a UUID.
@@ -826,16 +824,16 @@ void LLUUID::generate()
// if clock hasn't changed or went backward, change clockseq
if (cmpTime(&timestamp, &time_last) != 1)
{
- LLMutexLock lock(mMutex);
+ LLMutexLock lock(mMutex);
clock_seq = (clock_seq + 1) & 0x3FFF;
if (clock_seq == 0)
clock_seq++;
- our_clock_seq = clock_seq; // Ensure we're using a different clock_seq value from previous time
+ our_clock_seq = clock_seq; // Ensure we're using a different clock_seq value from previous time
}
time_last = timestamp;
- memcpy(mData + 10, node_id, 6); /* Flawfinder: ignore */
+ memcpy(mData + 10, node_id, 6); /* Flawfinder: ignore */
U32 tmp;
tmp = timestamp.low;
mData[3] = (unsigned char)tmp;
@@ -872,7 +870,7 @@ void LLUUID::generate(const std::string& hash_string)
U32 LLUUID::getRandomSeed()
{
- static unsigned char seed[16]; /* Flawfinder: ignore */
+ static unsigned char seed[16]; /* Flawfinder: ignore */
getNodeID(&seed[0]);
@@ -889,11 +887,11 @@ U32 LLUUID::getRandomSeed()
return U32(seed64) ^ U32(seed64 >> 32);
}
-BOOL LLUUID::parseUUID(const std::string& buf, LLUUID* value)
+bool LLUUID::parseUUID(const std::string& buf, LLUUID* value)
{
if (buf.empty() || value == NULL)
{
- return FALSE;
+ return false;
}
std::string temp(buf);
@@ -901,9 +899,9 @@ BOOL LLUUID::parseUUID(const std::string& buf, LLUUID* value)
if (LLUUID::validate(temp))
{
value->set(temp);
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
//static
@@ -989,7 +987,7 @@ bool LLUUID::operator!=(const LLUUID& rhs) const
}
*/
-BOOL LLUUID::notNull() const
+bool LLUUID::notNull() const
{
U32* word = (U32*)mData;
return (word[0] | word[1] | word[2] | word[3]) > 0;
@@ -997,10 +995,10 @@ BOOL LLUUID::notNull() const
// Faster than == LLUUID::null because doesn't require
// as much memory access.
-BOOL LLUUID::isNull() const
+bool LLUUID::isNull() const
{
U32* word = (U32*)mData;
- // If all bits are zero, return !0 == TRUE
+ // If all bits are zero, return !0 == true
return !(word[0] | word[1] | word[2] | word[3]);
}