diff --git a/README b/README index dfe4257c..b64ee6de 100644 --- a/README +++ b/README @@ -23,8 +23,6 @@ Lnav requires the following software packages: readline - The readline line editing library. zlib - The zlib compression library. bz2 - The bzip2 compression library. - openssl - The OpenSSL cryptographic library. (Only the hash - functions from this library are used.) INSTALLATION diff --git a/docs/source/intro.rst b/docs/source/intro.rst index 23bcddfc..9c313af0 100644 --- a/docs/source/intro.rst +++ b/docs/source/intro.rst @@ -20,7 +20,6 @@ When compiling from source, the following dependencies are required: * `PCRE `_ -- Versions greater than 8.20 give better performance since the PCRE JIT will be leveraged. * `SQLite `_ -* `OpenSSL `_ * `ZLib `_ * `Bzip2 `_ * `Readline `_ diff --git a/src/data_parser.hh b/src/data_parser.hh index 996d2fce..d5981911 100644 --- a/src/data_parser.hh +++ b/src/data_parser.hh @@ -32,7 +32,7 @@ #include -#include +#include "spookyhash/SpookyV2.h" #include #include @@ -173,7 +173,7 @@ public: static FILE *TRACE_FILE; - typedef byte_array schema_id_t; + typedef byte_array<16> schema_id_t; struct element; /* typedef std::list element_list_t; */ @@ -421,7 +421,7 @@ private: element_list_t ELEMENT_LIST_T(el_stack), ELEMENT_LIST_T(free_row), ELEMENT_LIST_T(key_comps), ELEMENT_LIST_T(value), ELEMENT_LIST_T(prefix); - SHA_CTX context; + SpookyHash context; POINT_TRACE("pairup_start"); @@ -558,7 +558,7 @@ private: POINT_TRACE("pairup_stack"); - SHA_Init(&context); + context.Init(0, 0); while (!el_stack.empty()) { element_list_t::iterator kv_iter = el_stack.begin(); if (kv_iter->e_token == DNT_VALUE) { @@ -595,7 +595,7 @@ private: if (schema != NULL) { - SHA_Update(&context, key_val.c_str(), key_val.length()); + context.Update(key_val.c_str(), key_val.length()); } while (!free_row.empty()) { @@ -658,7 +658,7 @@ private: value.e_sub_elements->begin(), value.e_sub_elements->end()); pairs_out.clear(); - SHA_Init(&context); + context.Init(0, 0); } } @@ -700,7 +700,7 @@ private: // columns is significant. I don't think we want to // use the token ID since some columns values might vary // between rows. - SHA_Update(&context, " ", 1); + context.Update(" ", 1); } break; @@ -711,7 +711,7 @@ private: std::string key_val = this->get_element_string( free_row.front()); - SHA_Update(&context, key_val.c_str(), key_val.length()); + context.Update(key_val.c_str(), key_val.length()); } break; } @@ -733,7 +733,8 @@ private: } if (schema != NULL) { - SHA_Final(this->dp_schema_id.ba_data, &context); + context.Final((uint64 *)(this->dp_schema_id.ba_data), + (uint64 *)((uint64 *)(this->dp_schema_id.ba_data)+1)); } }; diff --git a/src/lnav_util.cc b/src/lnav_util.cc index 45147cd9..593d0275 100644 --- a/src/lnav_util.cc +++ b/src/lnav_util.cc @@ -44,12 +44,12 @@ std::string hash_string(const std::string &str) { - byte_array hash; - SHA_CTX context; + byte_array<16> hash; + SpookyHash context; - SHA_Init(&context); - SHA_Update(&context, str.c_str(), str.length()); - SHA_Final(hash.out(), &context); + context.Init(0, 0); + context.Update(str.c_str(), str.length()); + context.Final((uint64 *)hash.out(), (uint64 *)((uint64 *)(hash.out())+1)); return hash.to_string(); } diff --git a/src/lnav_util.hh b/src/lnav_util.hh index bb2bff5d..50a4eb57 100644 --- a/src/lnav_util.hh +++ b/src/lnav_util.hh @@ -37,7 +37,7 @@ #include #include -#include +#include "spookyhash/SpookyV2.h" #include @@ -90,15 +90,15 @@ std::string time_ago(time_t last_time); #error "off_t has unhandled size..." #endif -struct sha_updater { - sha_updater(SHA_CTX *context) : su_context(context) { }; +struct hash_updater { + hash_updater(SpookyHash *context) : su_context(context) { }; void operator()(const std::string &str) { - SHA_Update(this->su_context, str.c_str(), str.length()); + this->su_context->Update(str.c_str(), str.length()); } - SHA_CTX *su_context; + SpookyHash *su_context; }; std::string hash_string(const std::string &str); diff --git a/src/log_format.hh b/src/log_format.hh index c8d53efb..23028a9f 100644 --- a/src/log_format.hh +++ b/src/log_format.hh @@ -241,7 +241,7 @@ public: * * @param ba The SHA-1 hash of the constant parts of this log line. */ - void set_schema(const byte_array<20> &ba) + void set_schema(const byte_array<16> &ba) { memcpy(this->ll_schema, ba.in(), sizeof(this->ll_schema)); }; @@ -255,7 +255,7 @@ public: * @return True if the first four bytes of the given schema match the * schema stored in this log line. */ - bool match_schema(const byte_array<20> &ba) const + bool match_schema(const byte_array<16> &ba) const { return memcmp(this->ll_schema, ba.in(), sizeof(this->ll_schema)) == 0; } diff --git a/src/sequence_matcher.cc b/src/sequence_matcher.cc index 96204653..e6798e29 100644 --- a/src/sequence_matcher.cc +++ b/src/sequence_matcher.cc @@ -29,7 +29,7 @@ #include "config.h" -#include +#include "spookyhash/SpookyV2.h" #include "sequence_matcher.hh" @@ -65,18 +65,18 @@ sequence_matcher::sequence_matcher(field_col_t &example) void sequence_matcher::identity(const std::vector &values, id_t &id_out) { - SHA_CTX context; + SpookyHash context; int lpc = 0; - SHA_Init(&context); + context.Init(0, 0); for (std::list::iterator iter = sm_fields.begin(); iter != sm_fields.end(); ++iter, lpc++) { if (iter->sf_type == FT_VARIABLE) { - SHA_Update(&context, - values[lpc].c_str(), - values[lpc].length() + 1); + context.Update( values[lpc].c_str(), + values[lpc].length() + 1); } } - SHA_Final(id_out.ba_data, &context); + context.Final((uint64 *)id_out.ba_data, + (uint64 *)((uint64 *)(id_out.ba_data)+1)); } diff --git a/src/sequence_matcher.hh b/src/sequence_matcher.hh index 7d9d9596..05295ee0 100644 --- a/src/sequence_matcher.hh +++ b/src/sequence_matcher.hh @@ -41,7 +41,7 @@ public: typedef std::vector field_row_t; typedef std::list field_col_t; - typedef byte_array<20> id_t; + typedef byte_array<16> id_t; enum field_type_t { FT_VARIABLE, diff --git a/src/session_data.cc b/src/session_data.cc index 1a2923e5..32f1a94e 100644 --- a/src/session_data.cc +++ b/src/session_data.cc @@ -37,7 +37,7 @@ #include #include -#include +#include "spookyhash/SpookyV2.h" #include @@ -243,17 +243,17 @@ static void cleanup_session_data(void) void init_session(void) { - byte_array hash; - SHA_CTX context; + byte_array<16> hash; + SpookyHash context; lnav_data.ld_session_time = time(NULL); - SHA_Init(&context); - sha_updater updater(&context); + context.Init(0, 0); + hash_updater updater(&context); for_each(lnav_data.ld_file_names.begin(), lnav_data.ld_file_names.end(), object_field(updater, &pair::first)); - SHA_Final(hash.out(), &context); + context.Final((uint64 *)hash.out(), (uint64 *)((uint64 *)(hash.out())+1)); lnav_data.ld_session_id = hash.to_string(); } diff --git a/src/spookyhash/SpookyV2.h b/src/spookyhash/SpookyV2.h index 4ccc0d52..4ddb37cc 100644 --- a/src/spookyhash/SpookyV2.h +++ b/src/spookyhash/SpookyV2.h @@ -26,6 +26,8 @@ // slower than MD5. // +#ifndef _SPOOKYHASH_V2_H +#define _SPOOKYHASH_V2_H #include #ifdef _MSC_VER @@ -296,4 +298,4 @@ private: }; - +#endif diff --git a/test/drive_sequencer.cc b/test/drive_sequencer.cc index 89e6e55f..dbc15eca 100644 --- a/test/drive_sequencer.cc +++ b/test/drive_sequencer.cc @@ -38,8 +38,6 @@ #include #include -#include - #include #include #include