整合UMDH结果的一个小工具

ua.exe使用方法:

1、将UMDH生成的logcompare.txt改名为1.txt,内容示例:

 // Debug library initialized ...
DBGHELP: moxia_d - private symbols & lines
E:\p06\run_client\Bin\moxia_d.pdb
DBGHELP: ntdll - export symbols
DBGHELP: kernel32 - export symbols
DBGHELP: KERNELBASE - export symbols
DBGHELP: dbghelp - public symbols
D:\Symbols\dbghelp.pdb\4BC9BC6DED254508BF3551E750E992643\dbghelp.pdb
DBGHELP: msvcrt - public symbols
D:\Symbols\msvcrt.pdb\F1D253F9555C46DF8076400A52B3A9292\msvcrt.pdb
DBGHELP: ADVAPI32 - export symbols
DBGHELP: sechost - public symbols
D:\Symbols\sechost.pdb\7AF14D02D41E4CD6942745FE0E6372B11\sechost.pdb
DBGHELP: RPCRT4 - export symbols
DBGHELP: WINMM - public symbols
D:\Symbols\winmm.pdb\7AFD98FCAAD34F6B8B31A4667C4E2BFC2\winmm.pdb
DBGHELP: USER32 - public symbols
D:\Symbols\user32.pdb\DD74D86F12624845A42A6A5BAAB4D7A82\user32.pdb
DBGHELP: GDI32 - export symbols
DBGHELP: LPK - export symbols
DBGHELP: USP10 - export symbols
DBGHELP: PSAPI - public symbols
D:\Symbols\psapi.pdb\A895A052F325481B9E2DA00A29E8D5DF2\psapi.pdb
DBGHELP: wke - private symbols & lines
E:\p06\run_client\Bin\wke.pdb
DBGHELP: ole32 - private symbols & lines
D:\Symbols\ole32.pdb\5061F11A9A57433595EA5EA75A156F4B2\ole32.pdb
DBGHELP: iphlpapi - public symbols
D:\Symbols\iphlpapi.pdb\F162D2E137ED42978BF38C99AEE2DAAB2\iphlpapi.pdb
DBGHELP: NSI - public symbols
D:\Symbols\nsi.pdb\D15A81679FAE4A7392344B6FD26867942\nsi.pdb
DBGHELP: WINNSI - public symbols
D:\Symbols\winnsi.pdb\F7A0C25B1B0E4FA6876494D3F6BFD1012\winnsi.pdb
DBGHELP: WS2_32 - public symbols
D:\Symbols\ws2_32.pdb\18C960B958404C4F80F686EE978A33D42\ws2_32.pdb
DBGHELP: SHELL32 - export symbols
DBGHELP: SHLWAPI - public symbols
D:\Symbols\shlwapi.pdb\E128B1CEE2EB438C8646E6967118F33E2\shlwapi.pdb
DBGHELP: VERSION - public symbols
D:\Symbols\version.pdb\52234E5C7EC44646B62D56357B2C94872\version.pdb
DBGHELP: MSIMG32 - public symbols
D:\Symbols\msimg32.pdb\13C89B70614E4E7FB1C677D443D15D182\msimg32.pdb
DBGHELP: ijl15 - export symbols
DBGHELP: MFC80D - private symbols & lines
D:\Symbols\MFC80D.i386.pdb\86AA8DF59ABF432D8650175ACAE12170e\MFC80D.i386.pdb
DBGHELP: MSVCR80D - private symbols & lines
D:\Symbols\msvcr80d.i386.pdb\5B7548CDAC834BBCB4600BC0177659C61\msvcr80d.i386.pdb
DBGHELP: COMCTL32 - export symbols
DBGHELP: OLEAUT32 - public symbols
D:\Symbols\oleaut32.pdb\68047829A4754E789AC1C8035BA168CD2\oleaut32.pdb
DBGHELP: MSVCP80D - private symbols & lines
D:\Symbols\msvcp80d.i386.pdb\C9DDCE5461B6402B8832D85B19A8B92F1\msvcp80d.i386.pdb
DBGHELP: d3d9 - public symbols
D:\Symbols\d3d9.pdb\F55AEB50462B473F9733515DC6532DAF2\d3d9.pdb
DBGHELP: d3d8thk - public symbols
D:\Symbols\d3d8thk.pdb\D9C3A335615F448EA0B012D76716E6B72\d3d8thk.pdb
DBGHELP: dwmapi - public symbols
D:\Symbols\dwmapi.pdb\D8D91B3F339A4FDC960FC7121D146DF42\dwmapi.pdb
DBGHELP: IMM32 - public symbols
D:\Symbols\imm32.pdb\91A0004474E24AA89F185029E31144892\imm32.pdb
DBGHELP: MSCTF - public symbols
D:\Symbols\msctf.pdb\173DAEF86B2548DBA6134EB74C4D2F232\msctf.pdb
DBGHELP: DSOUND - public symbols
D:\Symbols\dsound.pdb\F38F478065E247C68EDA699606F56EED2\dsound.pdb
DBGHELP: POWRPROF - public symbols
D:\Symbols\powrprof.pdb\B1F8F66CCBAD4869BADFD20C1F24AC832\powrprof.pdb
DBGHELP: SETUPAPI - public symbols
D:\Symbols\setupapi.pdb\C6B7CC380FCD42C29EDB1B61757DFD922\setupapi.pdb
DBGHELP: CFGMGR32 - public symbols
D:\Symbols\cfgmgr32.pdb\93B1A0A82F114743AF9AABB1A17382462\cfgmgr32.pdb
DBGHELP: DEVOBJ - public symbols
D:\Symbols\devobj.pdb\5EC40EC65C5045EB96F4CFDCFC6E19062\devobj.pdb
DBGHELP: MFC80CHS - no symbols loaded
DBGHELP: uxtheme - public symbols
D:\Symbols\UxTheme.pdb\5BECAB35E7714835A6BF3DADD891BB3A2\UxTheme.pdb
DBGHELP: CRYPTBASE - public symbols
D:\Symbols\cryptbase.pdb\E62FEAE559EE4CD995614215B01AC2102\cryptbase.pdb
DBGHELP: CLBCatQ - public symbols
D:\Symbols\CLBCatQ.pdb\00A720C79BAC402295B6EBDC147257182\CLBCatQ.pdb
DBGHELP: mlang - export symbols
DBGHELP: nvd3dum - export symbols
DBGHELP: MMDevApi - public symbols
D:\Symbols\MMDevAPI.pdb\941E45A63E8F457D90CE29CC508C34B92\MMDevAPI.pdb
DBGHELP: PROPSYS - public symbols
D:\Symbols\propsys.pdb\D0EDA507E53D4579A337F875012D7B482\propsys.pdb
DBGHELP: AUDIOSES - public symbols
D:\Symbols\AudioSes.pdb\A88FCF91944949A8A1863D1592BB2FD12\AudioSes.pdb
DBGHELP: quartz - public symbols
D:\Symbols\quartz.pdb\80E345FD1EE54FBAB8211528D99BC28C2\quartz.pdb
DBGHELP: dhcpcsvc6 - export symbols
DBGHELP: dhcpcsvc - public symbols
D:\Symbols\dhcpcsvc.pdb\D3E01A80603143AC83EA5801BEC674D82\dhcpcsvc.pdb
DBGHELP: devenum - public symbols
D:\Symbols\devenum.pdb\728AEF77CC244D8BADC3F6255CE396B31\devenum.pdb
DBGHELP: DShowRdpFilter - public symbols
D:\Symbols\DShowRdpFilter.pdb\4722ABE2B47D49B994FE311D5B2097BC1\DShowRdpFilter.pdb
DBGHELP: WTSAPI32 - public symbols
D:\Symbols\wtsapi32.pdb\1F1D3CBAE8A447E5BF304735F21CB4132\wtsapi32.pdb
DBGHELP: WINSTA - public symbols
D:\Symbols\winsta.pdb\2A3148024D094FFEB24C3996E47658312\winsta.pdb
DBGHELP: slc - export symbols
DBGHELP: LAVSplitter - export symbols
DBGHELP: COMCTL32 - public symbols
D:\Symbols\comctl32.pdb\B4CE90AAB95E4B89A22A7711DFD7E6EF2\comctl32.pdb
DBGHELP: avformat-lav- - export symbols
DBGHELP: avcodec-lav- - export symbols
DBGHELP: avutil-lav- - export symbols
DBGHELP: libbluray - export symbols
DBGHELP: VSFilter - export symbols
DBGHELP: COMDLG32 - public symbols
D:\Symbols\comdlg32.pdb\96BC483CDFF04D1AAFE462F093B954EC2\comdlg32.pdb
DBGHELP: WINSPOOL - public symbols
D:\Symbols\winspool.pdb\B165BBE7CD8C4F39BE373C0D9DFCD77B2\winspool.pdb
DBGHELP: WININET - export symbols
DBGHELP: urlmon - export symbols
DBGHELP: CRYPT32 - export symbols
DBGHELP: MSASN1 - public symbols
D:\Symbols\msasn1.pdb\003D5F0E24804B20953A7A021B52FC322\msasn1.pdb
DBGHELP: iertutil - export symbols
DBGHELP: AviSplitter - export symbols
DBGHELP: OggSplitter - export symbols
DBGHELP: MpegSplitter - export symbols
DBGHELP: MpaSplitter - export symbols
DBGHELP: ffdshow - export symbols
DBGHELP: DINPUT - public symbols
D:\Symbols\dinput.pdb\A355C027AC914C65A03AE2C06EBC117C1\dinput.pdb
DBGHELP: SspiCli - export symbols
DBGHELP: LAVAudio - export symbols
DBGHELP: msdmo - public symbols
D:\Symbols\msdmo.pdb\7E91458399E34CF99F0C993D9128BB301\msdmo.pdb
DBGHELP: qasf - public symbols
D:\Symbols\qasf.pdb\9BD26FFA3B5F4FDBA04379D9F92935DD1\qasf.pdb
DBGHELP: mp3dmod - public symbols
D:\Symbols\MP3DMOD.pdb\54618A168148428DADB4CE0B4628168F2\MP3DMOD.pdb
DBGHELP: mfplat - public symbols
D:\Symbols\MFPLAT.pdb\F512BAE9BAA14B87A898050CB20C0E3B2\MFPLAT.pdb
DBGHELP: AVRT - public symbols
D:\Symbols\avrt.pdb\A15E148ACFC74F88A0A6DAF71CC916472\avrt.pdb
DBGHELP: ac3filter - export symbols
DBGHELP: ac3filter_intl - export symbols
DBGHELP: wdmaud - public symbols
D:\Symbols\wdmaud.pdb\F232D0B492574D7992D5805BEF84A01E2\wdmaud.pdb
DBGHELP: ksuser - public symbols
D:\Symbols\ksuser.pdb\7AE6BFAC128C4C57BAAF1C0B79FA95B42\ksuser.pdb
DBGHELP: msacm32 - public symbols
D:\Symbols\msacm32.pdb\EB29395AE01743DB8C5DCB7F5A1350F91\msacm32.pdb
DBGHELP: MSACM32 - public symbols
D:\Symbols\msacm32.pdb\3D318D5E38C54502B64578F0710A510F2\msacm32.pdb
DBGHELP: midimap - public symbols
D:\Symbols\midimap.pdb\49F76FA53B854E54A748A2B4301471B62\midimap.pdb
DBGHELP: CRYPTSP - export symbols
DBGHELP: rsaenh - export symbols
//
// Each log entry has the following syntax:
//
// + BYTES_DELTA (NEW_BYTES - OLD_BYTES) NEW_COUNT allocs BackTrace TRACEID
// + COUNT_DELTA (NEW_COUNT - OLD_COUNT) BackTrace TRACEID allocations
// ... stack trace ...
//
// where:
//
// BYTES_DELTA - increase in bytes between before and after log
// NEW_BYTES - bytes in after log
// OLD_BYTES - bytes in before log
// COUNT_DELTA - increase in allocations between before and after log
// NEW_COUNT - number of allocations in after log
// OLD_COUNT - number of allocations in before log
// TRACEID - decimal index of the stack trace in the trace database
// (can be used to search for allocation instances in the original
// UMDH logs).
// + ( - ) allocs BackTrace1628EDB8
+ ( - ) BackTrace1628EDB8 allocations ntdll!EtwSetMark+000023ED
MSVCR80D!_heap_alloc_base+0000005C (f:\dd\vctools\crt_bld\self_x86\crt\src\malloc.c, )
MSVCR80D!_heap_alloc_dbg+000001F5 (f:\dd\vctools\crt_bld\self_x86\crt\src\dbgheap.c, )
MSVCR80D!_nh_malloc_dbg+ (f:\dd\vctools\crt_bld\self_x86\crt\src\dbgheap.c, )
MSVCR80D!malloc+ (f:\dd\vctools\crt_bld\self_x86\crt\src\dbgheap.c, )
moxia_d!stRleFrame::Read+0000012D (e:\p06\sources\cache\stframe.cpp, )
moxia_d!stRleGroup::Load+0000011E (e:\p06\sources\cache\stframe.cpp, )
moxia_d!cResourceRle::LoadAGroup+ (e:\p06\sources\cache\cresourcerle.cpp, )
moxia_d!Load+0000007A (e:\p06\sources\cache\cresource.cpp, )
moxia_d!PreloadRes+000000C9 (e:\p06\sources\cache\cresource.cpp, )
MFC80D!_AfxThreadEntry+000002DC (f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\thrdcore.cpp, )
MSVCR80D!_callthreadstartex+ (f:\dd\vctools\crt_bld\self_x86\crt\src\threadex.c, )
MSVCR80D!_threadstartex+ (f:\dd\vctools\crt_bld\self_x86\crt\src\threadex.c, )
kernel32!BaseThreadInitThunk+
ntdll!RtlInitializeExceptionChain+000000EF
ntdll!RtlInitializeExceptionChain+000000C2 + ( - ) allocs BackTrace849BAB0
+ ( - ) BackTrace849BAB0 allocations ntdll!EtwSetMark+000023ED
MSVCR80D!_heap_alloc_base+0000005C (f:\dd\vctools\crt_bld\self_x86\crt\src\malloc.c, )
MSVCR80D!_heap_alloc_dbg+000001F5 (f:\dd\vctools\crt_bld\self_x86\crt\src\dbgheap.c, )
MSVCR80D!_nh_malloc_dbg+ (f:\dd\vctools\crt_bld\self_x86\crt\src\dbgheap.c, )
MSVCR80D!malloc+ (f:\dd\vctools\crt_bld\self_x86\crt\src\dbgheap.c, )
MSVCR80D!operator new+0000000F (f:\dd\vctools\crt_bld\self_x86\crt\src\new.cpp, )
MSVCP80D!std::_Allocate<char>+ (f:\dd\vctools\crt_bld\self_x86\crt\src\xmemory, )
MSVCP80D!std::allocator<char>::allocate+ (f:\dd\vctools\crt_bld\self_x86\crt\src\xmemory, )
moxia_d!std::vector<char,std::allocator<char> >::_Insert_n+
moxia_d!std::vector<char,std::allocator<char> >::resize+
moxia_d!std::vector<char,std::allocator<char> >::resize+0000001C
moxia_d!cBmp::Load+ (e:\p06\sources\cache\cfont.cpp, )
moxia_d!cFont::Load+000001C0 (e:\p06\sources\cache\cfont.cpp, )
moxia_d!CMainWnd::OnCreate+000001DE (e:\p06\sources\client\mainwnd.cpp, )
MFC80D!CWnd::OnWndMsg+000007FE (f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp, )
MFC80D!CWnd::WindowProc+ (f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp, )
moxia_d!CMainWnd::WindowProc+000018C0 (e:\p06\sources\client\mainwndinput.cpp, )
MFC80D!AfxCallWndProc+000000EE (f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp, )
MFC80D!AfxWndProc+000000A4 (f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp, )
MFC80D!AfxWndProcBase+ (f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxstate.cpp, )
USER32!InternalCallWinProc+
USER32!UserCallWinProcCheckWow+000000E0
USER32!DispatchClientMessage+000000DA
USER32!__fnINLPCREATESTRUCT+0000008B
ntdll!KiUserCallbackDispatcher+0000002E
USER32!_CreateWindowEx+
USER32!CreateWindowExA+
MFC80D!AfxCtxCreateWindowExA+000000A1 (f:\dd\vctools\vc7libs\ship\atlmfc\include\afxcomctl32.h, )
MFC80D!CWnd::CreateEx+0000014A (f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp, )
MFC80D!CWnd::CreateEx+0000005B (f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp, )
moxia_d!CMainWnd::Create+000003B7 (e:\p06\sources\client\mainwnd.cpp, )
moxia_d!CGameClient::InitInstance+ (e:\p06\sources\client\client.cpp, ) /////////////////////////////////////////////////////////
// 后面还有很多 ............

2、使用脚本运行:

 ua.exe .txt -yes:ScriptMgr::LoadFile
ua.exe .txt -yes:cBmp::Load
ua.exe .txt -yes:cStatic::RestoreDeviceObjects
ua.exe .txt -yes:cBackground::LoadFile
ua.exe .txt -yes:cPropertyTable::Load
ua.exe .txt -yes:CD3DApplication::Create
ua.exe .txt -yes:PreloadRes
ua.exe .txt -yes:LeaderBoardCMgr::Init
ua.exe .txt -yes:Magic_CreateStatic
ua.exe .txt -yes:CMainWnd::CreateGui
ua.exe .txt -yes:cDevice::MDDrawPresent
ua.exe .txt -yes:cMp3::PlayNext
ua.exe .txt -yes:e:\p06\sources\tolua\lparser.c
ua.exe .txt -yes:cWorldClient::CreateTable
ua.exe .txt -yes:CMainWnd::CreateSoundManager
ua.exe .txt -yes:CMainWnd::OnCreate
ua.exe .txt -no:moxia_d!
ua.exe .txt -yes:CMainWnd::Draw
ua.exe .txt -whatever

3、生成结果示例:

整合UMDH结果的一个小工具

生成ua.exe的代码:

 #include <stdafx.h>
#include <windows.h>
#include <assert.h>
#include <string>
#include <vector>
#include <Psapi.h>
using namespace std; // void string_MakeSurePathExists2( string path )
// {
// assert(path.find('/') == string::npos);
//
// int index = path.find("\\", 0);
// while (index != string::npos)
// {
// CreateDirectoryA(path.substr(0, index).c_str(), NULL);
// index = path.find("\\", index + 1);
// }
// }
#define LINES 64
#define BUFS 1024 typedef char TBUFF[BUFS]; bool readline(FILE* fp, TBUFF buf)
{
int index = ;
while ()
{
char& ch = buf[index];
if ( == fread(&ch, , , fp))
{
if (index > )
{
buf[index + ] = ;
return true;
} return false;
}
if (ch == '\n')
{
buf[index + ] = ;
return true;
}
if (++index >= BUFS - )
return false;
}
return false;
} inline bool isemptychar(char ch)
{
return (ch == ' ' || ch == '\r' || ch == '\n' || ch == '\t');
} bool isemptyline(TBUFF buf)
{
int i = ;
char ch;
while (ch = buf[i++])
{
if (!isemptychar(ch))
return false;
}
return true;
} bool readblock(FILE* fp, TBUFF bufs[LINES], int& lines)
{
bool bPlus = false;
bool bGTH = false;
lines = ; while ()
{
TBUFF& pLine = bufs[lines];
if (!readline(fp, pLine))
{
return bPlus;
} bool bFirst = ((pLine[] == '+' || pLine[] == '-') && strstr(pLine, "allocs"));
if (!bPlus)
{
if (bFirst)
bPlus = true;
}
else
{
if (!bGTH)
{
if (strstr(pLine, "!"))
bGTH = true;
}
else
{
if (isemptyline(pLine))
{
++lines;
return true;
}
}
} if (bPlus)
++lines;
}
} int getbytesfromrow(TBUFF buf)
{
// int positive = (buf[0] == '+'); char nums[] = {};
int N = ; int B = ;
char ch; bool bFound = false; while (ch = buf[B++])
{
if (!bFound)
{
if (ch >= '' && ch <= '')
{
bFound = true;
nums[N++] = ch;
}
}
else
{
if (ch >= '' && ch <= '')
nums[N++] = ch;
else
break;
}
} if (N == )
return ;
return atoi(nums);
} void handleinvalidfilename(char* p)
{
static const char invalid_ch[] = { '/','\\',':','*','?','<','>','|' };
while (*p)
{
for (int i = ; i < sizeof(invalid_ch); i++)
{
if (*p == invalid_ch[i])
{
*p = '_';
break;
}
}
p++;
}
} struct ParamInfo
{
BOOL bWhatever; // 当这个为TRUE,下面2个无效
std::vector<std::string > vecKeyYes;
std::vector<std::string > vecKeyNo;
}; bool matchparam(TBUFF bufs[LINES], int lines, ParamInfo* param)
{
if (param->bWhatever)
return true; bool bHaveNo = param->vecKeyNo.size() > ;
bool bHaveYes = param->vecKeyYes.size() > ; if (bHaveNo)
{
for (int i = ; i < lines; i++)
{
TBUFF& buf = bufs[i];
for (int j = ; j < (int)param->vecKeyNo.size(); j++)
{
if (strstr(buf, param->vecKeyNo[j].c_str()))
return false;
}
}
} if (bHaveYes)
{
for (int i = ; i < lines; i++)
{
TBUFF& buf = bufs[i];
for (int j = ; j < (int)param->vecKeyYes.size(); j++)
{
if (strstr(buf, param->vecKeyYes[j].c_str()))
return true;
}
}
return false;
}
else
{
return true;
}
} #define KeyWhatever "-whatever" // 随便什么都算
#define KeyYes "-yes:" // 必须某一行包含这个
#define KeyNo "-no:" // 所有行不得包含这个 void parseparam(char* argv, ParamInfo* param)
{
param->bWhatever = FALSE;
char* p;
if (strstr(argv, KeyWhatever) == argv)
{
param->bWhatever = TRUE;
}
else if (strstr(argv, KeyYes) == argv)
{
p = argv + strlen(KeyYes);
param->vecKeyYes.push_back(p);
}
else if (strstr(argv, KeyNo) == argv)
{
p = argv + strlen(KeyNo);
param->vecKeyNo.push_back(p);
}
} // 检查参数
// 返回 true表示可以继续执行
bool checkparam(ParamInfo* param)
{
if (param->bWhatever)
{
if (param->vecKeyYes.size() > || param->vecKeyNo.size() > )
{
printf("警告:已指定%s,将忽略其它参数\n", KeyWhatever);
}
return true;
}
else
{
if (param->vecKeyYes.size() > || param->vecKeyNo.size() > )
{
return true;
}
else
{
printf("错误:没有指定任何有效参数\n");
return false;
}
}
} void printusage()
{
printf("用法: this.exe TARGETFILE [%s] | [[%sxxx] * N] [[%syyy] * N]"
"\nTARGETFILE 请从 1.txt 开始"
"\n%s表示所有都匹配"
"\n%s表示任何一行带有这个就行"
"\n%s表示任何一行都不得带这个"
"\n例如:this.exe 1.txt %s"
"\n例如:this.exe 1.txt %sScriptMgr::LoadFile %scBmp::Load"
"\n例如:this.exe 1.txt %smoxia_d!"
"\n",
KeyWhatever, KeyYes, KeyNo,
KeyWhatever,
KeyYes,
KeyNo,
KeyWhatever,
KeyYes, KeyYes,
KeyNo
); getchar();
} void main(int argc, char* argv[])
{
if (argc < )
{
printusage();
return;
} FILE* fpSrc = ;
FILE* fpDst = ;
std::string t1, t2;
FILE* fpT1 = ;
FILE* fpT2 = ; int bytesSum = ;
char outputFolderName[MAX_PATH];
char outputFolderNameR[MAX_PATH]; do
{
// src file
const char* fileName = argv[];
fpSrc = fopen(fileName, "r");
if (NULL == fpSrc)
{
printf("open %s error.\n", fileName);
break;
} // dst file
char RfileName[MAX_PATH];
sprintf(RfileName, "%d.txt", atoi(fileName) + );
fpDst = fopen(RfileName, "w");
if (NULL == fpDst)
{
printf("open %s error.\n", RfileName);
break;
} // parameters
ParamInfo param;
for (int i = ; i < argc; i++)
{
parseparam(argv[i], &param);
}
if (!checkparam(&param))
{
printusage();
break;
} // dst folder
memset(outputFolderName, , MAX_PATH);
if (param.bWhatever)
sprintf(outputFolderName, "%d %s", atoi(fileName), KeyWhatever);
else if (param.vecKeyYes.size() > )
sprintf(outputFolderName, "%d %s", atoi(fileName), param.vecKeyYes[].c_str());
else if (param.vecKeyNo.size() > )
sprintf(outputFolderName, "%d no %s", atoi(fileName), param.vecKeyNo[].c_str());
else
sprintf(outputFolderName, "%d", atoi(fileName));
handleinvalidfilename(outputFolderName);
if (!CreateDirectory(outputFolderName, NULL))
{
printf("CreateDirectory %s error.\n", outputFolderName);
break;
}
t1 = std::string(outputFolderName) + "\\1.txt";
t2 = std::string(outputFolderName) + "\\2.txt";
fpT1 = fopen(t1.c_str(), "w");
fpT2 = fopen(t2.c_str(), "w"); TBUFF bufs[LINES];
int lines;
while ()
{
if (!readblock(fpSrc, bufs, lines))
{
break;
} // 是否 match
bool bMatch = matchparam(bufs, lines, &param);
if (!bMatch)
{
// 不匹配就输出到下一个文本中
for (int i = ; i < lines; i++)
fprintf(fpDst, bufs[i]);
}
else
{
// 匹配就输出到对应的文件夹内
int bytes = getbytesfromrow(bufs[]);
if (bufs[][] == '-')
bytes = -bytes;
fprintf(fpT1, "%d\n", bytes);
bytesSum += bytes;
for (int i = ; i < lines; i++)
fprintf(fpT2, bufs[i]);
}
} fprintf(fpT1, "Total %d\n", bytesSum); } while(false); if (fpSrc) fclose(fpSrc);
if (fpDst) fclose(fpDst);
if (fpT1) fclose(fpT1);
if (fpT2) fclose(fpT2); if (abs(bytesSum) >= * )
sprintf(outputFolderNameR, "%s (%.1f MB)", outputFolderName, (float)bytesSum//);
else if (abs(bytesSum) >= )
sprintf(outputFolderNameR, "%s (%d KB)", outputFolderName, bytesSum/);
else
sprintf(outputFolderNameR, "%s (%d Bytes)", outputFolderName, bytesSum);
rename(outputFolderName, outputFolderNameR);
}
上一篇:【javascript】随机颜色


下一篇:Android利用Looper在子线程中改变UI