From 1dae91d7354aef57625e3508b23a4bb21de242e8 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Mon, 19 Jul 2010 17:15:32 -0400 Subject: EXT-8360 WIP - propagating COF item name changes various places --- indra/llcommon/llmd5.cpp | 37 ++++++++++++++++++++++++------------- indra/llcommon/llmd5.h | 11 +++++++---- 2 files changed, 31 insertions(+), 17 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/llmd5.cpp b/indra/llcommon/llmd5.cpp index da9cb94e13..cc73c3e45c 100644 --- a/indra/llcommon/llmd5.cpp +++ b/indra/llcommon/llmd5.cpp @@ -171,11 +171,6 @@ void LLMD5::update(FILE* file){ } - - - - - // MD5 update for istreams. // Like update for files; see above. @@ -192,9 +187,10 @@ void LLMD5::update(std::istream& stream){ } - - - +void LLMD5::update(const std::string& s) +{ + update((unsigned char *)s.c_str(),s.length()); +} // MD5 finalization. Ends an MD5 message-digest operation, writing the // the message digest and zeroizing the context. @@ -277,7 +273,7 @@ LLMD5::LLMD5(const unsigned char *s) finalize(); } -void LLMD5::raw_digest(unsigned char *s) +void LLMD5::raw_digest(unsigned char *s) const { if (!finalized) { @@ -293,7 +289,7 @@ void LLMD5::raw_digest(unsigned char *s) -void LLMD5::hex_digest(char *s) +void LLMD5::hex_digest(char *s) const { int i; @@ -319,6 +315,7 @@ void LLMD5::hex_digest(char *s) + std::ostream& operator<<(std::ostream &stream, LLMD5 context) { char s[33]; /* Flawfinder: ignore */ @@ -327,13 +324,25 @@ std::ostream& operator<<(std::ostream &stream, LLMD5 context) return stream; } +bool operator==(const LLMD5& a, const LLMD5& b) +{ + unsigned char a_guts[16]; + unsigned char b_guts[16]; + a.raw_digest(a_guts); + b.raw_digest(b_guts); + if (memcmp(a_guts,b_guts,16)==0) + return true; + else + return false; +} - +bool operator!=(const LLMD5& a, const LLMD5& b) +{ + return !(a==b); +} // PRIVATE METHODS: - - void LLMD5::init(){ finalized=0; // we just started! @@ -531,3 +540,5 @@ void LLMD5::decode (uint4 *output, const uint1 *input, const uint4 len){ output[i] = ((uint4)input[j]) | (((uint4)input[j+1]) << 8) | (((uint4)input[j+2]) << 16) | (((uint4)input[j+3]) << 24); } + + diff --git a/indra/llcommon/llmd5.h b/indra/llcommon/llmd5.h index df9d7324ab..4e68ba0d5e 100644 --- a/indra/llcommon/llmd5.h +++ b/indra/llcommon/llmd5.h @@ -95,6 +95,7 @@ public: void update (const uint1 *input, const uint4 input_length); void update (std::istream& stream); void update (FILE *file); + void update (const std::string& str); void finalize (); // constructors for special circumstances. All these constructors finalize @@ -105,11 +106,10 @@ public: LLMD5 (const unsigned char *string, const unsigned int number); // methods to acquire finalized result - void raw_digest(unsigned char *array); // provide 16-byte array for binary data - void hex_digest(char *string); // provide 33-byte array for ascii-hex string - friend std::ostream& operator<< (std::ostream&, LLMD5 context); - + void raw_digest(unsigned char *array) const; // provide 16-byte array for binary data + void hex_digest(char *string) const; // provide 33-byte array for ascii-hex string + friend std::ostream& operator<< (std::ostream&, LLMD5 context); private: @@ -131,4 +131,7 @@ private: }; +LL_COMMON_API bool operator==(const LLMD5& a, const LLMD5& b); +LL_COMMON_API bool operator!=(const LLMD5& a, const LLMD5& b); + #endif // LL_LLMD5_H -- cgit v1.2.3