-
Notifications
You must be signed in to change notification settings - Fork 0
/
hashsum.h
95 lines (78 loc) · 1.74 KB
/
hashsum.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// hashsum.h : включаемый файл для стандартных системных включаемых файлов
// или включаемые файлы для конкретного проекта.
#pragma once
#include <functional>
//
typedef std::function<size_t(std::istream& istr, unsigned short digest_size, unsigned char out[64])> hash_digest_impl;
static const std::size_t HASH_LINE_SIZE = 24;
static const std::size_t FILE_BUF_SIZE = (1024 * 8);
static const int MAX_THREAD_COUNT = 8;
enum class HashResult : unsigned short {
Initial,
Wait,
Taken,
Success,
Failed,
HashMismatch,
FileError,
};
enum class GS : int {
OK = 0,
ERR_HASH = 1,
ERR_FILE = 2,
ERR_FORMAT = 3,
ERR_UNKNOWN = 4
};
//#define GS_OK 0
//#define GS_ERR_HASH 1
//#define GS_ERR_FILE 2
//#define GS_ERR_FORMAT 3
//#define GS_ERR_UNKNOWN 4
static
const char* VERSION = "0.1.1";
static
const char* RES_UNKNOWN_NAME = "initial";
static
const char* RES_SUCCESS_NAME = "OK";
static
const char* RES_FILE_ERR_NAME = "file error";
static
const char* RES_DEFAULT_NAME = "unknown";
static
const char* RES_HASH_MISMATCH_NAME = "hash mismatch";
static bool flag_verbose = true;
static bool flag_stdin = false;
static bool flag_noasync = false;
static long errcount{
0
};
static unsigned long long ln{
1
};
#ifdef STAT_FEATURE
using namespace std::chrono;
static bool flag_statistics = false;
static std::atomic_ullong total_size{
0
};
//statistics
static std::atomic_ulong worker_take_fail{
0
};
static std::atomic_ulong worker_wait{
0
};
static unsigned long main_wait;
static std::atomic_ulong worker_wait_time{
0
};
static unsigned long main_wait_time{
0
};
static std::atomic_ulong read_time{
0
};
static std::atomic_ulong calc_time{
0
};
#endif