Ejemplo n.º 1
0
void SymbolMap::SaveSymbolMap(const char *filename) const {
	lock_guard guard(lock_);

	// Don't bother writing a blank file.
	if (!File::Exists(filename) && functions.empty() && data.empty()) {
		return;
	}

#if defined(_WIN32) && defined(UNICODE)
	gzFile f = gzopen_w(ConvertUTF8ToWString(filename).c_str(), "w9");
#else
	gzFile f = gzopen(filename, "w9");
#endif

	if (f == Z_NULL)
		return;

	gzprintf(f, ".text\n");

	for (auto it = modules.begin(), end = modules.end(); it != end; ++it) {
		const ModuleEntry &mod = *it;
		gzprintf(f, ".module %x %08x %08x %s\n", mod.index, mod.start, mod.size, mod.name);
	}

	for (auto it = functions.begin(), end = functions.end(); it != end; ++it) {
		const FunctionEntry& e = it->second;
		gzprintf(f, "%08x %08x %x %i %s\n", e.start, e.size, e.module, ST_FUNCTION, GetLabelNameRel(e.start, e.module));
	}

	for (auto it = data.begin(), end = data.end(); it != end; ++it) {
		const DataEntry& e = it->second;
		gzprintf(f, "%08x %08x %x %i %s\n", e.start, e.size, e.module, ST_DATA, GetLabelNameRel(e.start, e.module));
	}
	gzclose(f);
}
Ejemplo n.º 2
0
void *BLI_gzopen(const char *filename, const char *mode)
{
	gzFile gzfile;

	if (!filename || !mode) {
		return 0;
	}
	else {
		/* xxx Creates file before transcribing the path */
		if (mode[0] == 'w')
			fclose(ufopen(filename, "a"));

		/* temporary #if until we update all libraries to 1.2.7
		 * for correct wide char path handling */
#if ZLIB_VERNUM >= 0x1270 && !defined(FREE_WINDOWS)
		UTF16_ENCODE(filename);

		gzfile = gzopen_w(filename_16, mode);

		UTF16_UN_ENCODE(filename);
#else
		{
			char short_name[256];
			BLI_get_short_name(short_name, filename);
			gzfile = gzopen(short_name, mode);
		}
#endif
	}

	return gzfile;
}
Ejemplo n.º 3
0
static BaseEngine *psgz2pdf(const WCHAR *fileName)
{
    ScopedMem<WCHAR> tmpFile(path::GetTempPath(L"PsE"));
    ScopedFile tmpFileScope(tmpFile);
    if (!tmpFile)
        return NULL;

    gzFile inFile = gzopen_w(fileName, "rb");
    if (!inFile)
        return NULL;
    FILE *outFile = NULL;
    errno_t err = _wfopen_s(&outFile, tmpFile, L"wb");
    if (err != 0 || !outFile) {
        gzclose(inFile);
        return NULL;
    }

    char buffer[12*1024];
    for (;;) {
        int len = gzread(inFile, buffer, sizeof(buffer));
        if (len <= 0)
            break;
        fwrite(buffer, 1, len, outFile);
    }
    fclose(outFile);
    gzclose(inFile);

    return ps2pdf(tmpFile);
}
Ejemplo n.º 4
0
// 应用对话框中的设置
void CSuperFunctionDlg::ApplyOptionsInDlg()
{
	gzFile f = gzopen_w(CURRENT_USER_PATH + _T("\\options2.tb"), "wb");
	if (f == NULL)
		return;

	// 头部
	gzwrite(f, "TB", 2);

	// 循环封
	int size;
	gzwrite(f, &(size = m_loopBanPage.m_list.GetCount()), sizeof(int)); // 长度
	CString strBuf;
	for (int i = 0; i < size; i++)
	{
		m_loopBanPage.m_list.GetText(i, strBuf);
		WriteText(f, strBuf);
		WriteText(f, m_loopBanPage.m_pid[i]);
	}

	BOOL boolBuf;
	gzwrite(f, &(boolBuf = m_loopBanPage.m_logCheck.GetCheck()), sizeof(BOOL));		// 输出日志
	gzwrite(f, &(boolBuf = m_loopBanPage.m_enableCheck.GetCheck()), sizeof(BOOL));	// 开启

	gzclose(f);

	if (m_clearScanCache)
		DeleteFile(CURRENT_USER_PATH + _T("\\LoopBanDate.tb"));
}
Ejemplo n.º 5
0
// 把对话框中的设置写入文件
void CSettingDlg::SaveOptionsInDlg(LPCTSTR path)
{
	gzFile f = gzopen_w(path, "wb");
	if (f == NULL)
		return;

	// 头部
	gzwrite(f, "TB", 2);

	// 违规内容
	WriteRegexTexts(f, m_keywordsPage.m_list);

	// 屏蔽用户
	WriteRegexTexts(f, m_blackListPage.m_list);

	// 信任用户
	int size;
	gzwrite(f, &(size = m_whiteListPage.m_list.GetCount()), sizeof(int)); // 长度
	CString strBuf;
	for (int i = 0; i < size; i++)
	{
		m_whiteListPage.m_list.GetText(i, strBuf);
		WriteText(f, strBuf);
	}

	// 信任内容
	WriteRegexTexts(f, m_whiteContentPage.m_list);

	int intBuf;
	BOOL boolBuf;
	float floatBuf;
	double doubleBuf;
	m_prefPage.m_scanIntervalEdit.GetWindowText(strBuf);
	gzwrite(f, &(intBuf = _ttoi(strBuf)), sizeof(int));								// 扫描间隔
	gzwrite(f, &(boolBuf = m_prefPage.m_banIDCheck.GetCheck()), sizeof(BOOL));		// 封ID
	intBuf = m_prefPage.m_banDurationCombo.GetCurSel();
	intBuf = intBuf == 0 ? 1 : (intBuf == 1 ? 3 : 10);
	gzwrite(f, &intBuf, sizeof(int));												// 封禁时长
	gzwrite(f, &(boolBuf = FALSE), sizeof(BOOL));									// 封IP
	m_prefPage.m_trigCountEdit.GetWindowText(strBuf);
	gzwrite(f, &(intBuf = _ttoi(strBuf)), sizeof(int));								// 封禁违规次数
	gzwrite(f, &(boolBuf = m_prefPage.m_onlyScanTitleCheck.GetCheck()), sizeof(BOOL)); // 只扫描标题
	m_prefPage.m_deleteIntervalEdit.GetWindowText(strBuf);
	gzwrite(f, &(floatBuf = (float)_ttof(strBuf)), sizeof(float));					// 删帖间隔
	gzwrite(f, &(boolBuf = m_prefPage.m_confirmCheck.GetCheck()), sizeof(BOOL));	// 操作前提示
	m_prefPage.m_scanPageCountEdit.GetWindowText(strBuf);
	gzwrite(f, &(intBuf = _ttoi(strBuf)), sizeof(int));								// 扫描最后页数
	gzwrite(f, &(boolBuf = m_prefPage.m_briefLogCheck.GetCheck()), sizeof(BOOL));	// 只输出删帖封号
	gzwrite(f, &(boolBuf = m_prefPage.m_deleteCheck.GetCheck()), sizeof(BOOL));		// 删帖
	m_prefPage.m_threadCountEdit.GetWindowText(strBuf);
	gzwrite(f, &(intBuf = _ttoi(strBuf)), sizeof(int));								// 线程数
	m_prefPage.m_banReasonEdit.GetWindowText(strBuf);
	WriteText(f, strBuf);															// 封禁原因
	m_imagePage.m_dirEdit.GetWindowText(strBuf);
	WriteText(f, strBuf);															// 违规图片目录
	m_imagePage.m_thresholdEdit.GetWindowText(strBuf);
	gzwrite(f, &(doubleBuf = _ttof(strBuf)), sizeof(double));						// 阈值

	gzclose(f);
}
Ejemplo n.º 6
0
// 保存当前账号配置
void SaveCurrentUserProfile()
{
	// 创建目录
	if (!PathFileExists(USERS_PATH))
		CreateDirectory(USERS_PATH, NULL);
	if (!PathFileExists(USERS_PATH + g_currentUser))
		CreateDirectory(USERS_PATH + g_currentUser, NULL);

	// 保存Cookie
	gzFile f = gzopen_w(COOKIE_PATH, "wb");
	if (f != NULL)
	{
		WriteText(f, g_cookie);
		gzclose(f);
	}

	// 保存历史回复、忽略ID等
	f = gzopen_w(CACHE_PATH, "wb");
	if (f != NULL)
	{
		int len;
		// 历史回复
		gzwrite(f, &(len = g_reply.size()), sizeof(int)); // 长度
		for (auto& i : g_reply)
		{
			gzwrite(f, &i.first, sizeof(__int64)); // 主题ID
			gzwrite(f, &i.second, sizeof(int)); // 回复数
		}
		// 忽略ID
		WriteIDSet(f, g_initIgnoredTID);
		WriteIDSet(f, g_initIgnoredPID);
		WriteIDSet(f, g_initIgnoredLZLID);
		// 违规次数
		gzwrite(f, &(len = g_userTrigCount.size()), sizeof(int)); // 长度
		for (auto& i : g_userTrigCount)
		{
			WriteText(f, i.first); // 用户名
			gzwrite(f, &i.second, sizeof(int)); // 违规次数
		}
		// 拉黑用户
		WriteTextSet(f, g_defriendedUser);
		gzclose(f);
	}
}
Ejemplo n.º 7
0
// 写方案
void WriteOptions(LPCTSTR path)
{
	gzFile f = gzopen_w(path, "wb");
	if (f == NULL)
		return;

	// 头部
	gzwrite(f, "TB", 2);

	int intBuf;

	// 违规内容
	WriteRegexTexts(f, g_keywords);

	// 屏蔽用户
	WriteRegexTexts(f, g_blackList);

	// 信任用户
	gzwrite(f, &(intBuf = g_whiteList.size()), sizeof(int)); // 长度
	for (const CString& i : g_whiteList)
		WriteText(f, i);

	// 信任内容
	WriteRegexTexts(f, g_whiteContent);

	gzwrite(f, &g_scanInterval, sizeof(int));		// 扫描间隔
	gzwrite(f, &g_banID, sizeof(BOOL));				// 封ID
	gzwrite(f, &g_banDuration, sizeof(int));		// 封禁时长
	BOOL banIP = FALSE;
	gzwrite(f, &banIP, sizeof(BOOL));				// 封IP
	gzwrite(f, &g_banTrigCount, sizeof(int));		// 封禁违规次数
	gzwrite(f, &g_onlyScanTitle, sizeof(BOOL));		// 只扫描标题
	gzwrite(f, &g_deleteInterval, sizeof(float));	// 删帖间隔
	gzwrite(f, &g_confirm, sizeof(BOOL));			// 操作前提示
	gzwrite(f, &g_scanPageCount, sizeof(int));		// 扫描最后页数
	gzwrite(f, &g_briefLog, sizeof(BOOL));			// 只输出删帖封号
	gzwrite(f, &g_delete, sizeof(BOOL));			// 删帖
	gzwrite(f, &g_threadCount, sizeof(int));		// 线程数
	WriteText(f, g_banReason);						// 封禁原因
	WriteText(f, g_imageDir);						// 违规图片目录
	gzwrite(f, &g_SSIMThreshold, sizeof(double));	// 阈值

	// 信任主题
	gzwrite(f, &(intBuf = g_trustedThread.size()), sizeof(int)); // 长度
	for (const CString& i : g_trustedThread)
		WriteText(f, i);

	gzwrite(f, &g_defriend, sizeof(BOOL));			// 拉黑
	gzwrite(f, &g_defriendTrigCount, sizeof(int));	// 拉黑违规次数
	gzwrite(f, &g_autoSaveLog, sizeof(BOOL));		// 自动保存日志

	gzclose(f);
}
Ejemplo n.º 8
0
// 显示当前设置
void CSuperFunctionDlg::ShowCurrentOptions()
{
	gzFile f = gzopen_w(CURRENT_USER_PATH + _T("\\options2.tb"), "rb");
	if (f == NULL)
		return;

	// 头部
	char header[2];
	gzread(f, header, sizeof(header));
	if (header[0] != 'T' || header[1] != 'B')
	{
		gzclose(f);
		return;
	}

	// 循环封
	int size;
	gzread(f, &size, sizeof(int)); // 长度
	m_loopBanPage.m_list.ResetContent();
	m_loopBanPage.m_pid.resize(size);
	CString strBuf;
	for (int i = 0; i < size; i++)
	{
		ReadText(f, strBuf);
		m_loopBanPage.m_list.AddString(strBuf);
		ReadText(f, m_loopBanPage.m_pid[i]);
	}

	BOOL boolBuf;
	if (gzread(f, &boolBuf, sizeof(BOOL)) == sizeof(BOOL))		// 输出日志
		m_loopBanPage.m_logCheck.SetCheck(boolBuf);
	else
		m_loopBanPage.m_logCheck.SetCheck(FALSE);
	if (gzread(f, &boolBuf, sizeof(BOOL)) == sizeof(BOOL))		// 开启
		m_loopBanPage.m_enableCheck.SetCheck(boolBuf);
	else
		m_loopBanPage.m_enableCheck.SetCheck(TRUE);

	gzclose(f);
}
Ejemplo n.º 9
0
gzstreambuf* gzstreambuf::open( const wchar_t* name, int open_mode) {
    if ( is_open())
        return (gzstreambuf*)0;
    mode = open_mode;
    // no append nor read/write mode
    if ((mode & std::ios::ate) || (mode & std::ios::app)
        || ((mode & std::ios::in) && (mode & std::ios::out)))
        return (gzstreambuf*)0;
    char  fmode[10];
    char* fmodeptr = fmode;
    if ( mode & std::ios::in)
        *fmodeptr++ = 'r';
    else if ( mode & std::ios::out)
        *fmodeptr++ = 'w';
    *fmodeptr++ = 'b';
    *fmodeptr = '\0';
    file = gzopen_w( name, fmode);
    if (file == 0)
        return (gzstreambuf*)0;
    opened = 1;
    return this;
}
Ejemplo n.º 10
0
bool SymbolMap::LoadSymbolMap(const char *filename) {
	Clear();  // let's not recurse the lock

	lock_guard guard(lock_);

#if defined(_WIN32) && defined(UNICODE)
	gzFile f = gzopen_w(ConvertUTF8ToWString(filename).c_str(), "r");
#else
	gzFile f = gzopen(filename, "r");
#endif

	if (f == Z_NULL)
		return false;

	//char temp[256];
	//fgets(temp,255,f); //.text section layout
	//fgets(temp,255,f); //  Starting        Virtual
	//fgets(temp,255,f); //  address  Size   address
	//fgets(temp,255,f); //  -----------------------

	bool started = false;
	bool hasModules = false;

	while (!gzeof(f)) {
		char line[512], temp[256] = {0};
		char *p = gzgets(f, line, 512);
		if (p == NULL)
			break;

		// Chop any newlines off.
		for (size_t i = strlen(line) - 1; i > 0; i--) {
			if (line[i] == '\r' || line[i] == '\n') {
				line[i] = '\0';
			}
		}

		if (strlen(line) < 4 || sscanf(line, "%s", temp) != 1)
			continue;

		if (strcmp(temp,"UNUSED")==0) continue;
		if (strcmp(temp,".text")==0)  {started=true;continue;};
		if (strcmp(temp,".init")==0)  {started=true;continue;};
		if (strcmp(temp,"Starting")==0) continue;
		if (strcmp(temp,"extab")==0) continue;
		if (strcmp(temp,".ctors")==0) break;
		if (strcmp(temp,".dtors")==0) break;
		if (strcmp(temp,".rodata")==0) continue;
		if (strcmp(temp,".data")==0) continue;
		if (strcmp(temp,".sbss")==0) continue;
		if (strcmp(temp,".sdata")==0) continue;
		if (strcmp(temp,".sdata2")==0) continue;
		if (strcmp(temp,"address")==0)  continue;
		if (strcmp(temp,"-----------------------")==0)  continue;
		if (strcmp(temp,".sbss2")==0) break;
		if (temp[1]==']') continue;

		if (!started) continue;

		u32 address = -1, size, vaddress = -1;
		int moduleIndex = 0;
		int typeInt;
		SymbolType type;
		char name[128] = {0};

		if (sscanf(line, ".module %x %08x %08x %127c", &moduleIndex, &address, &size, name) == 4) {
			// Found a module definition.
			ModuleEntry mod;
			mod.index = moduleIndex;
			strcpy(mod.name, name);
			mod.start = address;
			mod.size = size;
			modules.push_back(mod);
			hasModules = true;
			continue;
		}

		sscanf(line, "%08x %08x %x %i %127c", &address, &size, &vaddress, &typeInt, name);
		type = (SymbolType) typeInt;
		if (!hasModules) {
			if (!Memory::IsValidAddress(vaddress)) {
				ERROR_LOG(LOADER, "Invalid address in symbol file: %08x (%s)", vaddress, name);
				continue;
			}
		} else {
			// The 3rd field is now used for the module index.
			moduleIndex = vaddress;
			vaddress = GetModuleAbsoluteAddr(address, moduleIndex);
			if (!Memory::IsValidAddress(vaddress)) {
				ERROR_LOG(LOADER, "Invalid address in symbol file: %08x (%s)", vaddress, name);
				continue;
			}
		}

		if (type == ST_DATA && size == 0)
			size = 4;

		if (!strcmp(name, ".text") || !strcmp(name, ".init") || strlen(name) <= 1) {

		} else {
			switch (type)
			{
			case ST_FUNCTION:
				AddFunction(name, vaddress, size, moduleIndex);
				break;
			case ST_DATA:
				AddData(vaddress,size,DATATYPE_BYTE, moduleIndex);
				if (name[0] != 0)
					AddLabel(name, vaddress, moduleIndex);
				break;
			case ST_NONE:
			case ST_ALL:
				// Shouldn't be possible.
				break;
			}
		}
	}
	gzclose(f);
	SortSymbols();
	return started;
}
Ejemplo n.º 11
0
// 读方案
void ReadOptions(LPCTSTR path)
{
	CString strBuf;

	gzFile f = gzopen_w(path, "rb");
	if (f == NULL)
		goto UseDefaultOptions;

	// 头部
	char header[2];
	gzread(f, header, sizeof(header));
	if (header[0] != 'T' || header[1] != 'B')
	{
		gzclose(f);
		goto UseDefaultOptions;
	}

	g_optionsLock.Lock();

	// 违规内容
	ReadRegexTexts(f, g_keywords);

	// 屏蔽用户
	ReadRegexTexts(f, g_blackList);

	// 信任用户
	int intBuf;
	gzread(f, &intBuf, sizeof(int)); // 长度
	for (int i = 0; i < intBuf; i++)
	{
		ReadText(f, strBuf);
		g_whiteList.insert(strBuf);
	}

	// 信任内容
	ReadRegexTexts(f, g_whiteContent);

	gzread(f, &g_scanInterval, sizeof(int));	// 扫描间隔
	gzread(f, &g_banID, sizeof(BOOL));			// 封ID
	gzread(f, &g_banDuration, sizeof(int));		// 封禁时长
	BOOL banIP;
	gzread(f, &banIP, sizeof(BOOL));			// 封IP
	gzread(f, &g_banTrigCount, sizeof(int));	// 封禁违规次数
	gzread(f, &g_onlyScanTitle, sizeof(BOOL));	// 只扫描标题
	gzread(f, &g_deleteInterval, sizeof(float));// 删帖间隔
	gzread(f, &g_confirm, sizeof(BOOL));		// 操作前提示
	gzread(f, &g_scanPageCount, sizeof(int));	// 扫描最后页数
	gzread(f, &g_briefLog, sizeof(BOOL));		// 只输出删帖封号
	if (gzread(f, &g_delete, sizeof(BOOL)) != sizeof(BOOL))			// 删帖
		g_delete = TRUE;
	if (gzread(f, &g_threadCount, sizeof(int)) != sizeof(int))		// 线程数
		g_threadCount = 2;
	ReadText(f, g_banReason);										// 封禁原因
	if (!ReadText(f, g_imageDir))									// 违规图片目录
		g_images.clear();
	else
		ReadImages(g_imageDir);										// 违规图片
	if (gzread(f, &g_SSIMThreshold, sizeof(double)) != sizeof(double))	// 阈值
		g_SSIMThreshold = 2.43;

	// 信任主题
	g_trustedThread.clear();
	if (gzread(f, &intBuf, sizeof(int)) == sizeof(int)) // 长度
		for (int i = 0; i < intBuf; i++)
		{
			ReadText(f, strBuf);
			g_trustedThread.insert(strBuf);
		}

	if (gzread(f, &g_defriend, sizeof(BOOL)) != sizeof(BOOL))		// 拉黑
		g_defriend = FALSE;
	if (gzread(f, &g_defriendTrigCount, sizeof(int)) != sizeof(int)) // 拉黑违规次数
		g_defriendTrigCount = 5;
	if (gzread(f, &g_autoSaveLog, sizeof(BOOL)) != sizeof(BOOL))	// 自动保存日志
		g_autoSaveLog = FALSE;

	g_optionsLock.Unlock();

	gzclose(f);
	return;

UseDefaultOptions:
	g_optionsLock.Lock();
	g_keywords.clear();			// 违规内容
	g_blackList.clear();		// 屏蔽用户
	g_whiteList.clear();		// 信任用户
	g_whiteContent.clear();		// 信任内容
	g_scanInterval = 5;			// 扫描间隔
	g_banID = FALSE;			// 封ID
	g_banDuration = 1;			// 封禁时长
	g_banTrigCount = 1;			// 封禁违规次数
	g_onlyScanTitle = FALSE;	// 只扫描标题
	g_deleteInterval = 2.0f;	// 删帖间隔
	g_confirm = TRUE;			// 操作前提示
	g_scanPageCount = 1;		// 扫描最后页数
	g_briefLog = FALSE;			// 只输出删帖封号
	g_delete = TRUE;			// 删帖
	g_threadCount = 2;			// 线程数
	g_banReason = _T("");		// 封禁原因
	g_imageDir = _T("");		// 违规图片目录
	g_images.clear();			// 违规图片
	g_SSIMThreshold = 2.43;		// 阈值
	g_trustedThread.clear();	// 信任主题
	g_defriend = FALSE;			// 拉黑
	g_defriendTrigCount = 5;	// 拉黑违规次数
	g_autoSaveLog = FALSE;		// 自动保存日志
	g_optionsLock.Unlock();
}
Ejemplo n.º 12
0
// 设置当前账号
void SetCurrentUser(LPCTSTR userName)
{
	// 保存当前账号配置
	if (g_currentUser != _T(""))
		SaveCurrentUserProfile();

	// 设置配置路径
	g_currentUser = userName;
	CURRENT_USER_PATH = USERS_PATH + userName;
	USER_PROFILE_PATH = CURRENT_USER_PATH + _T("\\options.tb");
	COOKIE_PATH = CURRENT_USER_PATH + _T("\\ck.tb");
	CACHE_PATH = CURRENT_USER_PATH + _T("\\cache.tb");

	// 读取设置
	TCHAR buffer[260];
	// 方案
	GetPrivateProfileString(_T("Setting"), _T("Option"), _T("默认"), g_currentOption.GetBuffer(MAX_PATH), MAX_PATH, USER_PROFILE_PATH);
	g_currentOption.ReleaseBuffer();
	ReadOptions(OPTIONS_PATH + g_currentOption + _T(".tb"));
	// 贴吧名
	GetPrivateProfileString(_T("Setting"), _T("ForumName"), _T(""), buffer, _countof(buffer), USER_PROFILE_PATH);
	((CTiebaManagerDlg*)AfxGetApp()->m_pMainWnd)->m_forumNameEdit.SetWindowText(buffer);
	// Cookie
	gzFile f = gzopen_w(COOKIE_PATH, "rb");
	if (f != NULL)
	{
		ReadText(f, g_cookie);
		gzclose(f);
	}

	// 历史回复、忽略ID等
	f = gzopen_w(CACHE_PATH, "rb");
	if (f != NULL)
	{
		int size;
		// 历史回复
		if (gzread(f, &size, sizeof(int)) == sizeof(int) && 0 < size && size < 100000) // 长度
		{
			__int64 tid;
			int reply;
			for (int i = 0; i < size; i++)
			{
				gzread(f, &tid, sizeof(__int64));
				gzread(f, &reply, sizeof(int));
				g_reply[tid] = reply;
			}
		}
		// 忽略ID
		ReadIDSet(f, g_initIgnoredTID);
		g_ignoredTID = g_initIgnoredTID;
		ReadIDSet(f, g_initIgnoredPID);
		g_ignoredPID = g_initIgnoredPID;
		ReadIDSet(f, g_initIgnoredLZLID);
		g_ignoredLZLID = g_initIgnoredLZLID;
		// 违规次数
		if (gzread(f, &size, sizeof(int)) == sizeof(int) && 0 < size && size < 100000) // 长度
		{
			CString userName;
			int count;
			for (int i = 0; i < size; i++)
			{
				ReadText(f, userName);
				gzread(f, &count, sizeof(int));
				g_userTrigCount[userName] = count;
			}
		}
		// 拉黑用户
		ReadTextSet(f, g_defriendedUser);
		gzclose(f);
	}
}
Ejemplo n.º 13
0
// 显示文件中的设置
void CSettingDlg::ShowOptionsInFile(LPCTSTR path)
{
	CString strBuf;

	gzFile f = gzopen_w(path, "rb");
	if (f == NULL)
		goto UseDefaultOptions;

	// 头部
	char header[2];
	gzread(f, header, sizeof(header));
	if (header[0] != 'T' || header[1] != 'B')
	{
		gzclose(f);
		goto UseDefaultOptions;
	}

	// 违规内容
	ReadRegexTexts(f, m_keywordsPage.m_list);

	// 屏蔽用户
	ReadRegexTexts(f, m_blackListPage.m_list);

	// 信任用户
	int size;
	gzread(f, &size, sizeof(int)); // 长度
	m_whiteListPage.m_list.ResetContent();
	int intBuf;
	for (int i = 0; i < size; i++)
	{
		ReadText(f, strBuf);
		m_whiteListPage.m_list.AddString(strBuf);
	}

	// 信任内容
	ReadRegexTexts(f, m_whiteContentPage.m_list);

	// 违规图片
	m_imagePage.m_updateImage = TRUE;

	BOOL boolBuf;
	float floatBuf;
	double doubleBuf;
	gzread(f, &intBuf, sizeof(int));						// 扫描间隔
	strBuf.Format(_T("%d"), intBuf);
	m_prefPage.m_scanIntervalEdit.SetWindowText(strBuf);
	gzread(f, &boolBuf, sizeof(BOOL));						// 封ID
	m_prefPage.m_banIDCheck.SetCheck(boolBuf);
	gzread(f, &intBuf, sizeof(int));						// 封禁时长
	m_prefPage.m_banDurationCombo.SetCurSel(intBuf == 1 ? 0 : (intBuf == 3 ? 1 : 2));
	gzread(f, &boolBuf, sizeof(BOOL));						// 封IP
	gzread(f, &intBuf, sizeof(int));						// 封禁违规次数
	strBuf.Format(_T("%d"), intBuf);
	m_prefPage.m_trigCountEdit.SetWindowText(strBuf);
	gzread(f, &boolBuf, sizeof(BOOL));						// 只扫描标题
	m_prefPage.m_onlyScanTitleCheck.SetCheck(boolBuf);
	gzread(f, &floatBuf, sizeof(float));					// 删帖间隔
	strBuf.Format(_T("%g"), floatBuf);
	m_prefPage.m_deleteIntervalEdit.SetWindowText(strBuf);
	gzread(f, &boolBuf, sizeof(BOOL));						// 操作前提示
	m_prefPage.m_confirmCheck.SetCheck(boolBuf);
	gzread(f, &intBuf, sizeof(int));						// 扫描最后页数
	strBuf.Format(_T("%d"), intBuf);
	m_prefPage.m_scanPageCountEdit.SetWindowText(strBuf);
	gzread(f, &boolBuf, sizeof(BOOL));						// 只输出删帖封号
	m_prefPage.m_briefLogCheck.SetCheck(boolBuf);
	if (gzread(f, &boolBuf, sizeof(BOOL)) == sizeof(BOOL))	// 删帖
		m_prefPage.m_deleteCheck.SetCheck(boolBuf);
	else
		m_prefPage.m_deleteCheck.SetCheck(TRUE);
	if (gzread(f, &intBuf, sizeof(int)) == sizeof(int))		// 线程数
	{
		strBuf.Format(_T("%d"), intBuf);
		m_prefPage.m_threadCountEdit.SetWindowText(strBuf);
	}
	else
		m_prefPage.m_threadCountEdit.SetWindowText(_T("2"));
	ReadText(f, strBuf);									// 封禁原因
	m_prefPage.m_banReasonEdit.SetWindowText(strBuf);
	ReadText(f, strBuf);									// 违规图片目录
	m_imagePage.m_dirEdit.SetWindowText(strBuf);
	if (gzread(f, &doubleBuf, sizeof(double)) == sizeof(double))	// 阈值
	{
		strBuf.Format(_T("%lf"), doubleBuf);
		m_imagePage.m_thresholdEdit.SetWindowText(strBuf);
	}
	else
		m_imagePage.m_thresholdEdit.SetWindowText(_T("2.43"));

	gzclose(f);
	return;

UseDefaultOptions:
	m_keywordsPage.m_list.ResetContent();					// 违规内容
	m_blackListPage.m_list.ResetContent();					// 屏蔽用户
	m_whiteListPage.m_list.ResetContent();					// 信任用户
	m_whiteContentPage.m_list.ResetContent();				// 信任内容
	m_imagePage.m_updateImage = TRUE;						// 违规图片
	m_prefPage.m_scanIntervalEdit.SetWindowText(_T("5"));	// 扫描间隔
	m_prefPage.m_banIDCheck.SetCheck(FALSE);				// 封ID
	m_prefPage.m_banDurationCombo.SetCurSel(0);				// 封禁时长
	m_prefPage.m_trigCountEdit.SetWindowText(_T("1"));		// 封禁违规次数
	m_prefPage.m_onlyScanTitleCheck.SetCheck(FALSE);		// 只扫描标题
	m_prefPage.m_deleteIntervalEdit.SetWindowText(_T("2"));	// 删帖间隔
	m_prefPage.m_confirmCheck.SetCheck(TRUE);				// 操作前提示
	m_prefPage.m_scanPageCountEdit.SetWindowText(_T("1"));	// 扫描最后页数
	m_prefPage.m_briefLogCheck.SetCheck(FALSE);				// 只输出删帖封号
	m_prefPage.m_deleteCheck.SetCheck(TRUE);				// 删帖
	m_prefPage.m_threadCountEdit.SetWindowText(_T("2"));	// 线程数
	m_prefPage.m_banReasonEdit.SetWindowText(_T(""));		// 封禁原因
	m_imagePage.m_dirEdit.SetWindowText(_T(""));			// 违规图片目录
	m_imagePage.m_thresholdEdit.SetWindowText(_T("2.43"));	// 阈值
}