0
0
mirror of https://codeberg.org/crimeflare/cloudflare-tor synced 2024-12-22 15:40:32 +00:00

Upload files to 'tool/PGListUtil/src/common'

This commit is contained in:
katze 2020-11-11 02:46:54 +01:00
parent b3a4f05d9f
commit 69595de83b
2 changed files with 104 additions and 0 deletions

View File

@ -0,0 +1,56 @@
#ifndef CIPLIST_H
#define CIPLIST_H
#include <boost/pool/pool.hpp>
#include <boost/xpressive/xpressive.hpp>
#include "common.h"
#include "CFilter.h"
namespace pglu {
namespace ip {
struct CIp {
char * caption;
union {
ulong ip64;
uint ip32[2];
uchar ip8[8];
};
CIp * next;
};
class CIpList {
private:
boost::pool<> m_poolIp;
CIp m_ipHead;
CIp * m_ipFoot;
filter::CFilter m_filter;
int m_count;
int m_countDisabled;
CIp * CreateIp(boost::xpressive::cmatch & match);
public:
CIpList();
~CIpList();
void Clear();
void SetFilter(const char *filter, const filter::EFilterMode mode, const bool del);
void UnSetFilter();
bool LoadListFile(const char *path);
bool SaveListFile(const char *path, const bool append);
void CheckAndSort(const bool sortCap, const bool sortIp, const bool delDupIp);
int Count();
int CountDisabled();
};
} // namespace ip
} // namespace pglu
#endif // CIPLIST_H

View File

@ -0,0 +1,48 @@
#ifndef COMMON_H
#define COMMON_H
#ifdef _MSC_VER
typedef unsigned __int8 uchar;
typedef unsigned __int32 uint;
typedef unsigned __int64 ulong;
# else
#include <boost/cstdint.hpp>
typedef uint8_t uchar;
typedef uint32_t uint;
typedef uint64_t ulong;
#endif
namespace pglu {
#define PGLU_LENGTH_FILELINE 1024
inline uint ParseDigit3(const char *begin, const char *end) {
switch(end - begin) {
case 3:
return ((*begin & 0xF) * 100) + ((*(begin + 1) & 0xF) * 10) + (*(begin + 2) & 0xF);
case 2:
return ((*begin & 0xF) * 10) + (*(begin + 1) & 0xF);
case 1:
return (*begin & 0xF);
default:
return 256;
}
}
#ifdef __MINGW32__
inline void ZeroString(char *str) {
while(*str != '\0')
*(str++) = '\0';
}
#endif
} // namespace pglu
#endif // COMMON_H