2016-02-05 20:01:51 +00:00
|
|
|
/* Copyright 2015, 2016, Michele Santullo
|
2015-11-09 16:50:56 +00:00
|
|
|
* This file is part of "dindexer".
|
|
|
|
*
|
|
|
|
* "dindexer" is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* "dindexer" is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with "dindexer". If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef idBE93AF97FA4343ECA2BC8FB1FD3E5E60
|
|
|
|
#define idBE93AF97FA4343ECA2BC8FB1FD3E5E60
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
#include <string>
|
2015-11-10 17:48:22 +00:00
|
|
|
#include <vector>
|
2016-06-15 13:57:52 +00:00
|
|
|
#include <ciso646>
|
2015-11-09 16:50:56 +00:00
|
|
|
|
2016-01-05 12:49:27 +00:00
|
|
|
namespace mchlib {
|
2015-11-09 16:50:56 +00:00
|
|
|
struct TigerHash {
|
|
|
|
TigerHash ( void ) = default;
|
|
|
|
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
uint64_t part_a;
|
|
|
|
uint64_t part_b;
|
|
|
|
uint64_t part_c;
|
|
|
|
};
|
|
|
|
uint64_t data[3];
|
|
|
|
uint8_t byte_data[sizeof(uint64_t) * 3];
|
|
|
|
};
|
2016-06-15 13:57:52 +00:00
|
|
|
|
|
|
|
bool operator== (const TigerHash& parOther) const { return part_a == parOther.part_a and part_b == parOther.part_b and part_c == parOther.part_c; }
|
2015-11-09 16:50:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static_assert(sizeof(TigerHash) == 24, "Wrong struct size");
|
|
|
|
|
2015-11-11 12:28:04 +00:00
|
|
|
void tiger_file ( const std::string& parPath, TigerHash& parHashFile, TigerHash& parHashDir, uint64_t& parSizeOut );
|
2015-11-09 16:50:56 +00:00
|
|
|
void tiger_init_hash ( TigerHash& parHash );
|
2015-11-27 20:34:42 +00:00
|
|
|
std::string tiger_to_string ( const TigerHash& parHash, bool parUpcase=false );
|
2016-06-15 13:57:52 +00:00
|
|
|
TigerHash string_to_tiger ( const std::string& parString );
|
2015-11-10 17:48:22 +00:00
|
|
|
void tiger_data ( const std::string& parData, TigerHash& parHash );
|
|
|
|
void tiger_data ( const std::vector<char>& parData, TigerHash& parHash );
|
2016-01-05 12:49:27 +00:00
|
|
|
} //namespace mchlib
|
2015-11-09 16:50:56 +00:00
|
|
|
|
|
|
|
#endif
|