From df1ef68cd8e8582724ce1192bfc202e0b9aeaf0c Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 28 Sep 2021 19:24:31 +0300 Subject: Get rid of C++ modules related code and rename *.mxx files to *.hxx --- libbutl/sha1.mxx | 135 ------------------------------------------------------- 1 file changed, 135 deletions(-) delete mode 100644 libbutl/sha1.mxx (limited to 'libbutl/sha1.mxx') diff --git a/libbutl/sha1.mxx b/libbutl/sha1.mxx deleted file mode 100644 index f6fafc0..0000000 --- a/libbutl/sha1.mxx +++ /dev/null @@ -1,135 +0,0 @@ -// file : libbutl/sha1.mxx -*- C++ -*- -// license : MIT; see accompanying LICENSE file - -#ifndef __cpp_modules_ts -#pragma once -#endif - -// C includes. - -#ifndef __cpp_lib_modules_ts -#include // istream -#include -#include // size_t -#include -#include // strlen() -#endif - -// Other includes. - -#ifdef __cpp_modules_ts -export module butl.sha1; -#ifdef __cpp_lib_modules_ts -import std.core; -#endif -#endif - -#include - -LIBBUTL_MODEXPORT namespace butl -{ - // SHA1 checksum calculator. - // - // For a single chunk of data a sum can be obtained in one line, for - // example: - // - // cerr << sha1 ("123").string () << endl; - // - class LIBBUTL_SYMEXPORT sha1 - { - public: - sha1 () {reset ();} - - // Append binary data. - // - void - append (const void*, std::size_t); - - sha1 (const void* b, std::size_t n): sha1 () {append (b, n);} - - // Append string. - // - // Note that the hash includes the '\0' terminator. Failed that, a call - // with an empty string will be indistinguishable from no call at all. - // - void - append (const std::string& s) {append (s.c_str (), s.size () + 1);} - - void - append (const char* s) {append (s, std::strlen (s) + 1);} - - explicit - sha1 (const std::string& s): sha1 () {append (s);} - - explicit - sha1 (const char* s): sha1 () {append (s);} - - // Append stream. - // - // Note that currently the stream is expected to be bufstreambuf-based - // (e.g., ifdstream). - // - void - append (std::istream&); - - explicit - sha1 (std::istream& i): sha1 () {append (i);} - - // Check if any data has been hashed. - // - bool - empty () const {return empty_;} - - // Reset to the default-constructed state. - // - void - reset (); - - // Extract result. - // - // It can be obtained as either a 20-byte binary digest or as a 40- - // character hex-encoded C-string. - // - using digest_type = std::uint8_t[20]; - - const digest_type& - binary () const; - - const char* - string () const; - - std::string - abbreviated_string (std::size_t n) const - { - return std::string (string (), n < 40 ? n : 40); - } - - private: - struct context // Note: identical to SHA1_CTX. - { - union { - std::uint8_t b8[20]; - std::uint32_t b32[5]; - } h; - union { - std::uint8_t b8[8]; - std::uint64_t b64[1]; - } c; - union { - std::uint8_t b8[64]; - std::uint32_t b32[16]; - } m; - std::uint8_t count; - }; - - union - { - mutable context ctx_; - mutable char buf_[sizeof (context)]; // Also used to store string rep. - }; - - mutable digest_type bin_; - mutable bool done_; - bool empty_; - }; -} -- cgit v1.1