mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2026-11-03 10:12:50 +00:00
Update nlohmann::json library to 3.9.0
Cleanup codes.
This commit is contained in:
6 files changed
+4081
-3298
No files matched your search
+4029
-3247
File diff suppressed because it is too large.
Load diff
+37
-36
@@ -9,7 +9,7 @@ namespace md5 {
|
|||||||
* T denotes the integer part of the i-th element of the function:
|
* T denotes the integer part of the i-th element of the function:
|
||||||
* T[i] = 4294967296 * abs(sin(i)), where i is in radians.
|
* T[i] = 4294967296 * abs(sin(i)), where i is in radians.
|
||||||
*/
|
*/
|
||||||
const unsigned int T[64] = {
|
const uint32_t T[64] = {
|
||||||
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
|
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
|
||||||
0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
|
0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
|
||||||
0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
|
0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,
|
||||||
@@ -23,24 +23,24 @@ namespace md5 {
|
|||||||
/*
|
/*
|
||||||
* Constants for the MD5 Transform routine as defined in RFC 1321
|
* Constants for the MD5 Transform routine as defined in RFC 1321
|
||||||
*/
|
*/
|
||||||
const unsigned int S1[4] = {7, 12, 17, 22};
|
const uint32_t S1[4] = {7, 12, 17, 22};
|
||||||
const unsigned int S2[4] = {5, 9, 14, 20};
|
const uint32_t S2[4] = {5, 9, 14, 20};
|
||||||
const unsigned int S3[4] = {4, 11, 16, 23};
|
const uint32_t S3[4] = {4, 11, 16, 23};
|
||||||
const unsigned int S4[4] = {6, 10, 15, 21};
|
const uint32_t S4[4] = {6, 10, 15, 21};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Function to perform the cyclic left rotation of blocks of data
|
* Function to perform the cyclic left rotation of blocks of data
|
||||||
*/
|
*/
|
||||||
inline unsigned int cyclic_left_rotate(unsigned int data, unsigned int shift_bits) {
|
inline uint32_t cyclic_left_rotate(uint32_t data, uint32_t shift_bits) {
|
||||||
return (data << shift_bits) | (data >> (32 - shift_bits));
|
return (data << shift_bits) | (data >> (32 - shift_bits));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline unsigned int F(unsigned int x, unsigned int y, unsigned int z) {return (x & y) | (~x & z);};
|
inline uint32_t F(uint32_t x, uint32_t y, uint32_t z) {return (x & y) | (~x & z);};
|
||||||
inline unsigned int G(unsigned int x, unsigned int y, unsigned int z) {return (x & z) | (y & ~z);};
|
inline uint32_t G(uint32_t x, uint32_t y, uint32_t z) {return (x & z) | (y & ~z);};
|
||||||
inline unsigned int H(unsigned int x, unsigned int y, unsigned int z) {return x ^ y ^ z;};
|
inline uint32_t H(uint32_t x, uint32_t y, uint32_t z) {return x ^ y ^ z;};
|
||||||
inline unsigned int I(unsigned int x, unsigned int y, unsigned int z) {return y ^ (x | ~z);};
|
inline uint32_t I(uint32_t x, uint32_t y, uint32_t z) {return y ^ (x | ~z);};
|
||||||
|
|
||||||
inline void FF(unsigned int &a, unsigned int b, unsigned int c, unsigned int d, unsigned int Xk, unsigned int s, unsigned int i) {
|
inline void FF(uint32_t &a, uint32_t b, uint32_t c, uint32_t d, uint32_t Xk, uint32_t s, uint32_t i) {
|
||||||
#if MD5_DEBUG
|
#if MD5_DEBUG
|
||||||
std::cout << "\nA: " << a << "\nB: " << b << "\nC: " << c << "\nD: " << d << "\nX[" << i << "]: " << Xk << "\ns: " << S1[s] << "\nT: " << T[i] << "\n";
|
std::cout << "\nA: " << a << "\nB: " << b << "\nC: " << c << "\nD: " << d << "\nX[" << i << "]: " << Xk << "\ns: " << S1[s] << "\nT: " << T[i] << "\n";
|
||||||
#endif
|
#endif
|
||||||
@@ -54,7 +54,7 @@ namespace md5 {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void GG(unsigned int &a, unsigned int b, unsigned int c, unsigned int d, unsigned int Xk, unsigned int s, unsigned int i) {
|
inline void GG(uint32_t &a, uint32_t b, uint32_t c, uint32_t d, uint32_t Xk, uint32_t s, uint32_t i) {
|
||||||
#if MD5_DEBUG
|
#if MD5_DEBUG
|
||||||
std::cout << "\nA: " << a << "\nB: " << b << "\nC: " << c << "\nD: " << d << "\nX[" << i - 16 << "]: " << Xk << "\ns: " << S2[s] << "\nT: " << T[i] << "\n";
|
std::cout << "\nA: " << a << "\nB: " << b << "\nC: " << c << "\nD: " << d << "\nX[" << i - 16 << "]: " << Xk << "\ns: " << S2[s] << "\nT: " << T[i] << "\n";
|
||||||
#endif // MD5_DEBUG
|
#endif // MD5_DEBUG
|
||||||
@@ -68,7 +68,7 @@ namespace md5 {
|
|||||||
#endif // MD5_DEBUG
|
#endif // MD5_DEBUG
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void HH(unsigned int &a, unsigned int b, unsigned int c, unsigned int d, unsigned int Xk, unsigned int s, unsigned int i) {
|
inline void HH(uint32_t &a, uint32_t b, uint32_t c, uint32_t d, uint32_t Xk, uint32_t s, uint32_t i) {
|
||||||
#if MD5_DEBUG
|
#if MD5_DEBUG
|
||||||
std::cout << "\nA: " << a << "\nB: " << b << "\nC: " << c << "\nD: " << d << "\nX[" << i - 32 << "]: " << Xk << "\ns: " << S3[s] << "\nT: " << T[i] << "\n";
|
std::cout << "\nA: " << a << "\nB: " << b << "\nC: " << c << "\nD: " << d << "\nX[" << i - 32 << "]: " << Xk << "\ns: " << S3[s] << "\nT: " << T[i] << "\n";
|
||||||
#endif // MD5_DEBUG
|
#endif // MD5_DEBUG
|
||||||
@@ -81,7 +81,7 @@ namespace md5 {
|
|||||||
std::cout << "A = " << a << "\n";
|
std::cout << "A = " << a << "\n";
|
||||||
#endif // MD5_DEBUG
|
#endif // MD5_DEBUG
|
||||||
};
|
};
|
||||||
inline void II(unsigned int &a, unsigned int b, unsigned int c, unsigned int d, unsigned int Xk, unsigned int s, unsigned int i) {
|
inline void II(uint32_t &a, uint32_t b, uint32_t c, uint32_t d, uint32_t Xk, uint32_t s, uint32_t i) {
|
||||||
#if MD5_DEBUG
|
#if MD5_DEBUG
|
||||||
std::cout << "\nA: " << a << "\nB: " << b << "\nC: " << c << "\nD: " << d << "\nX[" << i - 48 << "]: " << Xk << "\ns: " << S4[s] << "\nT: " << T[i] << "\n";
|
std::cout << "\nA: " << a << "\nB: " << b << "\nC: " << c << "\nD: " << d << "\nX[" << i - 48 << "]: " << Xk << "\ns: " << S4[s] << "\nT: " << T[i] << "\n";
|
||||||
#endif // MD5_DEBUG
|
#endif // MD5_DEBUG
|
||||||
@@ -163,7 +163,7 @@ namespace md5 {
|
|||||||
*
|
*
|
||||||
* signature - A 16 byte buffer that will contain the MD5 signature.
|
* signature - A 16 byte buffer that will contain the MD5 signature.
|
||||||
*/
|
*/
|
||||||
md5_t::md5_t(const void* input, const unsigned int input_length, void* signature) {
|
md5_t::md5_t(const void* input, const uint32_t input_length, void* signature) {
|
||||||
/* initialize the computation context */
|
/* initialize the computation context */
|
||||||
initialise();
|
initialise();
|
||||||
|
|
||||||
@@ -192,9 +192,9 @@ namespace md5 {
|
|||||||
*
|
*
|
||||||
* input_length - The length of the buffer.
|
* input_length - The length of the buffer.
|
||||||
*/
|
*/
|
||||||
void md5_t::process(const void* input, const unsigned int input_length) {
|
void md5_t::process(const void* input, const uint32_t input_length) {
|
||||||
if (!finished) {
|
if (!finished) {
|
||||||
unsigned int processed = 0;
|
uint32_t processed = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we have any data stored from a previous call to process then we use these
|
* If we have any data stored from a previous call to process then we use these
|
||||||
@@ -257,7 +257,7 @@ namespace md5 {
|
|||||||
message_length[1]++;
|
message_length[1]++;
|
||||||
message_length[0] += stored_size;
|
message_length[0] += stored_size;
|
||||||
|
|
||||||
int pad = md5::BLOCK_SIZE - (sizeof(unsigned int) * 2) - stored_size;
|
int pad = md5::BLOCK_SIZE - (sizeof(uint32_t) * 2) - stored_size;
|
||||||
if (pad <= 0)
|
if (pad <= 0)
|
||||||
pad += md5::BLOCK_SIZE;
|
pad += md5::BLOCK_SIZE;
|
||||||
|
|
||||||
@@ -276,14 +276,14 @@ namespace md5 {
|
|||||||
* Put the 64-bit file length in _bits_ (i.e. *8) at the end of the
|
* Put the 64-bit file length in _bits_ (i.e. *8) at the end of the
|
||||||
* buffer. appears to be in beg-endian format in the buffer?
|
* buffer. appears to be in beg-endian format in the buffer?
|
||||||
*/
|
*/
|
||||||
unsigned int size_low = ((message_length[0] & 0x1FFFFFFF) << 3);
|
uint32_t size_low = ((message_length[0] & 0x1FFFFFFF) << 3);
|
||||||
memcpy(stored + stored_size, &size_low, sizeof(unsigned int));
|
memcpy(stored + stored_size, &size_low, sizeof(uint32_t));
|
||||||
stored_size += sizeof(unsigned int);
|
stored_size += sizeof(uint32_t);
|
||||||
|
|
||||||
/* shift the high word over by 3 and add in the top 3 bits from the low */
|
/* shift the high word over by 3 and add in the top 3 bits from the low */
|
||||||
unsigned int size_high = (message_length[1] << 3) | ((message_length[0] & 0xE0000000) >> 29);
|
uint32_t size_high = (message_length[1] << 3) | ((message_length[0] & 0xE0000000) >> 29);
|
||||||
memcpy(stored + stored_size, &size_high, sizeof(unsigned int));
|
memcpy(stored + stored_size, &size_high, sizeof(uint32_t));
|
||||||
stored_size += sizeof(unsigned int);
|
stored_size += sizeof(uint32_t);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* process the last block of data.
|
* process the last block of data.
|
||||||
@@ -391,6 +391,7 @@ namespace md5 {
|
|||||||
message_length[0] = 0;
|
message_length[0] = 0;
|
||||||
message_length[1] = 0;
|
message_length[1] = 0;
|
||||||
stored_size = 0;
|
stored_size = 0;
|
||||||
|
memset(&stored, 0, BLOCK_SIZE * 2);
|
||||||
|
|
||||||
finished = false;
|
finished = false;
|
||||||
}
|
}
|
||||||
@@ -425,13 +426,13 @@ namespace md5 {
|
|||||||
message_length[0] += BLOCK_SIZE;
|
message_length[0] += BLOCK_SIZE;
|
||||||
|
|
||||||
// Copy the block into X. */
|
// Copy the block into X. */
|
||||||
unsigned int X[16];
|
uint32_t X[16];
|
||||||
for (unsigned int i = 0; i < 16; i++) {
|
for (uint32_t i = 0; i < 16; i++) {
|
||||||
memcpy(X + i, block + 4 * i, 4);
|
memcpy(X + i, block + 4 * i, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save A as AA, B as BB, C as CC, and D as DD. */
|
/* Save A as AA, B as BB, C as CC, and D as DD. */
|
||||||
unsigned int AA = A, BB = B, CC = C, DD = D;
|
uint32_t AA = A, BB = B, CC = C, DD = D;
|
||||||
|
|
||||||
/* Round 1
|
/* Round 1
|
||||||
* Let [abcd k s i] denote the operation
|
* Let [abcd k s i] denote the operation
|
||||||
@@ -563,10 +564,10 @@ namespace md5 {
|
|||||||
* result - A 16 byte buffer that will contain the MD5 signature.
|
* result - A 16 byte buffer that will contain the MD5 signature.
|
||||||
*/
|
*/
|
||||||
void md5_t::get_result(void *result) {
|
void md5_t::get_result(void *result) {
|
||||||
memcpy((char*)result, &A, sizeof(unsigned int));
|
memcpy((char*)result, &A, sizeof(uint32_t));
|
||||||
memcpy((char*)result + sizeof(unsigned int), &B, sizeof(unsigned int));
|
memcpy((char*)result + sizeof(uint32_t), &B, sizeof(uint32_t));
|
||||||
memcpy((char*)result + 2 * sizeof(unsigned int), &C, sizeof(unsigned int));
|
memcpy((char*)result + 2 * sizeof(uint32_t), &C, sizeof(uint32_t));
|
||||||
memcpy((char*)result + 3 * sizeof(unsigned int), &D, sizeof(unsigned int));
|
memcpy((char*)result + 3 * sizeof(uint32_t), &D, sizeof(uint32_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************** Exported Functions ******************************/
|
/****************************** Exported Functions ******************************/
|
||||||
@@ -601,8 +602,8 @@ namespace md5 {
|
|||||||
max_p = str_ + str_len;
|
max_p = str_ + str_len;
|
||||||
|
|
||||||
for (sig_p = (unsigned char*)signature_; sig_p < (unsigned char*)signature_ + MD5_SIZE; sig_p++) {
|
for (sig_p = (unsigned char*)signature_; sig_p < (unsigned char*)signature_ + MD5_SIZE; sig_p++) {
|
||||||
unsigned int high = *sig_p / 16;
|
uint32_t high = *sig_p / 16;
|
||||||
unsigned int low = *sig_p % 16;
|
uint32_t low = *sig_p % 16;
|
||||||
/* account for 2 chars */
|
/* account for 2 chars */
|
||||||
if (str_p + 1 >= max_p) {
|
if (str_p + 1 >= max_p) {
|
||||||
break;
|
break;
|
||||||
@@ -644,9 +645,9 @@ namespace md5 {
|
|||||||
sig_p = static_cast<unsigned char*>(signature_);
|
sig_p = static_cast<unsigned char*>(signature_);
|
||||||
|
|
||||||
for (str_p = str_; str_p < str_ + MD5_SIZE * 2; str_p += 2) {
|
for (str_p = str_; str_p < str_ + MD5_SIZE * 2; str_p += 2) {
|
||||||
unsigned int high = strchr(hex, *str_p) - hex;
|
uint32_t high = strchr(hex, *str_p) - hex;
|
||||||
unsigned int low = strchr(hex, *(str_p + 1)) - hex;
|
uint32_t low = strchr(hex, *(str_p + 1)) - hex;
|
||||||
unsigned int val = high * 16 + low;
|
uint32_t val = high * 16 + low;
|
||||||
*sig_p++ = val;
|
*sig_p++ = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,15 +6,15 @@
|
|||||||
* external programs only. The MD5 routines themselves reference the
|
* external programs only. The MD5 routines themselves reference the
|
||||||
* signature as 4 unsigned 32-bit integers.
|
* signature as 4 unsigned 32-bit integers.
|
||||||
*/
|
*/
|
||||||
const unsigned int MD5_SIZE = (4 * sizeof(unsigned int)); /* 16 */
|
const uint32_t MD5_SIZE = (4 * sizeof(uint32_t)); /* 16 */
|
||||||
const unsigned int MD5_STRING_SIZE = 2 * MD5_SIZE + 1; /* 33 */
|
const uint32_t MD5_STRING_SIZE = 2 * MD5_SIZE + 1; /* 33 */
|
||||||
|
|
||||||
namespace md5 {
|
namespace md5 {
|
||||||
/*
|
/*
|
||||||
* The MD5 algorithm works on blocks of characters of 64 bytes. This
|
* The MD5 algorithm works on blocks of characters of 64 bytes. This
|
||||||
* is an internal value only and is not necessary for external use.
|
* is an internal value only and is not necessary for external use.
|
||||||
*/
|
*/
|
||||||
const unsigned int BLOCK_SIZE = 64;
|
const uint32_t BLOCK_SIZE = 64;
|
||||||
|
|
||||||
class md5_t {
|
class md5_t {
|
||||||
public:
|
public:
|
||||||
@@ -60,7 +60,7 @@ const unsigned int MD5_STRING_SIZE = 2 * MD5_SIZE + 1; /* 33 */
|
|||||||
*
|
*
|
||||||
* signature_ - A 16 byte buffer that will contain the MD5 signature.
|
* signature_ - A 16 byte buffer that will contain the MD5 signature.
|
||||||
*/
|
*/
|
||||||
md5_t(const void* input, const unsigned int input_length, void* signature_ = NULL);
|
md5_t(const void* input, const uint32_t input_length, void* signature_ = NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* process
|
* process
|
||||||
@@ -80,7 +80,7 @@ const unsigned int MD5_STRING_SIZE = 2 * MD5_SIZE + 1; /* 33 */
|
|||||||
*
|
*
|
||||||
* input_length - The length of the buffer.
|
* input_length - The length of the buffer.
|
||||||
*/
|
*/
|
||||||
void process(const void* input, const unsigned int input_length);
|
void process(const void* input, const uint32_t input_length);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* finish
|
* finish
|
||||||
@@ -144,13 +144,13 @@ const unsigned int MD5_STRING_SIZE = 2 * MD5_SIZE + 1; /* 33 */
|
|||||||
void process_block(const unsigned char*);
|
void process_block(const unsigned char*);
|
||||||
void get_result(void*);
|
void get_result(void*);
|
||||||
|
|
||||||
unsigned int A; /* accumulator 1 */
|
uint32_t A; /* accumulator 1 */
|
||||||
unsigned int B; /* accumulator 2 */
|
uint32_t B; /* accumulator 2 */
|
||||||
unsigned int C; /* accumulator 3 */
|
uint32_t C; /* accumulator 3 */
|
||||||
unsigned int D; /* accumulator 4 */
|
uint32_t D; /* accumulator 4 */
|
||||||
|
|
||||||
unsigned int message_length[2]; /* length of data */
|
uint32_t message_length[2]; /* length of data */
|
||||||
unsigned int stored_size; /* length of stored bytes */
|
uint32_t stored_size; /* length of stored bytes */
|
||||||
unsigned char stored[md5::BLOCK_SIZE * 2]; /* stored bytes */
|
unsigned char stored[md5::BLOCK_SIZE * 2]; /* stored bytes */
|
||||||
|
|
||||||
bool finished; /* object state */
|
bool finished; /* object state */
|
||||||
|
|||||||
+1
-1
@@ -113,7 +113,7 @@ int addNodes(std::string link, std::vector<nodeInfo> &allNodes, int groupID, con
|
|||||||
writeLog(LOG_TYPE_ERROR, "Invalid subscription!");
|
writeLog(LOG_TYPE_ERROR, "Invalid subscription!");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(strSub.find("ssd://") == 0)
|
if(startsWith(strSub, "ssd://"))
|
||||||
{
|
{
|
||||||
getSubInfoFromSSD(strSub, subInfo);
|
getSubInfoFromSSD(strSub, subInfo);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ std::string foldPathString(const std::string &path)
|
|||||||
pos_up = output.find("../", pos_unres);
|
pos_up = output.find("../", pos_unres);
|
||||||
if(pos_up == output.npos)
|
if(pos_up == output.npos)
|
||||||
break;
|
break;
|
||||||
else if(pos_up == 0)
|
if(pos_up == 0)
|
||||||
{
|
{
|
||||||
pos_unres = pos_up + 3;
|
pos_unres = pos_up + 3;
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
+2
-2
@@ -746,10 +746,10 @@ std::string rulesetToClashStr(YAML::Node &base_rule, std::vector<ruleset_content
|
|||||||
writeLog(0, "Failed to fetch ruleset or ruleset is empty: '" + x.rule_path + "'!", LOG_LEVEL_WARNING);
|
writeLog(0, "Failed to fetch ruleset or ruleset is empty: '" + x.rule_path + "'!", LOG_LEVEL_WARNING);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(retrieved_rules.find("[]") == 0)
|
if(startsWith(retrieved_rules, "[]"))
|
||||||
{
|
{
|
||||||
strLine = retrieved_rules.substr(2);
|
strLine = retrieved_rules.substr(2);
|
||||||
if(strLine.find("FINAL") == 0)
|
if(startsWith(strLine, "FINAL"))
|
||||||
strLine.replace(0, 5, "MATCH");
|
strLine.replace(0, 5, "MATCH");
|
||||||
strLine += "," + rule_group;
|
strLine += "," + rule_group;
|
||||||
if(count_least(strLine, ',', 3))
|
if(count_least(strLine, ',', 3))
|
||||||
|
|||||||
Reference in new issue
Block a user