資源簡介
int main(int argc, char *argv[])
{
int i = 0;
bool bOnce = true;
char szPath[RH_MAX_PATH];
char szAbsPath[RH_MAX_PATH];
char szOrgPath[RH_MAX_PATH];
char szTemp[RH_MAX_BUFFER];
int iErrorCode = 0;
CHashManager hashmgr;
getcwd(szOrgPath, RH_MAX_PATH);
//No arguments?
if(argc == 1)
{
printInfo();
return(RH_NO_ARGS);
}
memset(szPath, 0, RH_MAX_PATH);
bOnce = true;
hashmgr.SelectAllAlgorithms(true);
for(i = 1; i = RH_MAX_BUFFER) continue; // Non-parsable option argument, ignore
fmtArgument(argv[i], szTemp); // Format the argument, i.e. remove all special chars
if(strcmp(szTemp, "help" ) == 0) printInfo();
if(strcmp(szTemp, "h" ) == 0) printInfo();
if(strcmp(szTemp, "?" ) == 0) printInfo();
if(strcmp(szTemp, "version" ) == 0) printInfo();
if(strcmp(szTemp, "v" ) == 0) printInfo();
if(strcmp(szTemp, "fullpath") == 0) hashmgr.SetOption(OPT_FULLPATH, true);
if(strcmp(szTemp, "f" ) == 0) hashmgr.SetOption(OPT_FULLPATH, true);
if(strcmp(szTemp, "nopath" ) == 0) hashmgr.SetOption(OPT_FULLPATH, false);
if(strcmp(szTemp, "rcrsv" ) == 0) hashmgr.SetOption(OPT_RECURSIVE, true);
if(strcmp(szTemp, "norcrsv" ) == 0) hashmgr.SetOption(OPT_RECURSIVE, false);
if(strcmp(szTemp, "recur" ) == 0) hashmgr.SetOption(OPT_RECURSIVE, true);
if(strcmp(szTemp, "norecur" ) == 0) hashmgr.SetOption(OPT_RECURSIVE, false);
if(strcmp(szTemp, "r" ) == 0) hashmgr.SetOption(OPT_RECURSIVE, true);
if(strcmp(szTemp, "all" ) == 0) hashmgr.SelectAllAlgorithms(true);
if(strcmp(szTemp, "a" ) == 0) hashmgr.SelectAllAlgorithms(true);
if(strcmp(szTemp, "none" ) == 0) hashmgr.SelectAllAlgorithms(false);
if(strcmp(s

代碼片段和文件信息
/*
---------------------------------------------------------------------------
Copyright?(c)?2003?Dominik?Reichl??Germany.
All?rights?reserved.
Distributed?under?the?terms?of?the?GNU?General?Public?License?v2.
This?software?is?provided?‘as?is‘?with?no?explicit?or?implied?warranties
in?respect?of?its?properties?including?but?not?limited?to?correctness?
and/or?fitness?for?purpose.
---------------------------------------------------------------------------
*/
#include?“clutil.h“
#include?“rehash.h“
bool?isArgument(char?*pszString)
{
if(pszString?==?NULL)?return?false;
if(pszString[0]?==?‘-‘)?return?true;
return?false;
}
void?fmtArgument(char?*pszArg?char?*pszDest)
{
unsigned?int?i?=?0;
int?pos?=?0;
if(pszArg?==?NULL)?return;
if(pszDest?==?NULL)?return;
pszDest[0]?=?0;
//?Filter?special?characters
for(i?=?0;?i? {
if(pszArg[i]?==?‘-‘)?continue;
if(pszArg[i]?==?‘#‘)?continue;
if(pszArg[i]?==?‘?‘)?continue;
if(pszArg[i]?==?‘<‘)?continue;
if(pszArg[i]?==?‘>‘)?continue;
if(pszArg[i]?==?‘(‘)?continue;
if(pszArg[i]?==?‘)‘)?continue;
if(pszArg[i]?==?‘[‘)?continue;
if(pszArg[i]?==?‘]‘)?continue;
if(pszArg[i]?==?‘/‘)?continue;
if(pszArg[i]?==?‘\\‘)?continue;
if(pszArg[i]?==?‘\“‘)?continue;
pszDest[pos]?=?pszArg[i];
pos++;
}
pszDest[pos]?=?0;
strlwr(pszDest);
}
void?fmtPath(char?*pszPath)
{
unsigned?int?i?=?0;
char?chFind?=?0;
char?chReplace?=?0;
if(pszPath?==?NULL)?return;
if(strlen(pszPath)?==?0)?return;
#if(RH_TARGET_SYSTEM?==?RH_TARGET_SYSTEM_WINDOWS)
chFind????=?‘/‘;
chReplace?=?‘\\‘;
#elif(RH_TARGET_SYSTEM?==?RH_TARGET_SYSTEM_LINUX)
chFind????=?‘\\‘;
chReplace?=?‘/‘;
#endif
for(i?=?0;?i? {
if(pszPath[i]?==?chFind)?pszPath[i]?=?chReplace;
}
}
void?catdirsep(char?*pszPath)
{
unsigned?int?i?=?0;
if(pszPath?==?NULL)?return;
i?=?strlen(pszPath);
if(pszPath[i-1]?==?SZ_DIR_CHAR)?return;?//?Nothing?to?do
strcat(pszPath?SZ_DIR_STR);
}
void?pathonly(char?*pszPath)
{
unsigned?int?i?=?0;
bool?bReplaced?=?false;
if(pszPath?==?NULL)?return;
i?=?strlen(pszPath)?-?1;
if(i?==?(unsigned?int)-1)?return;
while(1)
{
if(pszPath[i]?==?SZ_DIR_CHAR)
{
pszPath[i]?=?0;
bReplaced?=?true;
break;
}
i--;
if(i?==?(unsigned?int)-1)?break;
}
if(bReplaced?==?false)?pszPath[0]?=?0;
#if(RH_TARGET_SYSTEM?==?RH_TARGET_SYSTEM_WINDOWS)
if(strlen(pszPath)?==?2)?catdirsep(pszPath);
#endif
}
void?fileonly(char?*pszPath)
{
char?szTemp[RH_MAX_PATH];
unsigned?int?i?=?0;
unsigned?int?j?=?0;
if(pszPath?==?NULL)?return;
i?=?strlen(pszPath)?-?1;
if(i?==?(unsigned?int)-1)?return;
if(i?<=?1)?return;
while(1)?//?Reverse?scan?for?path?delimiter
{
if(pszPath[i]?==?SZ_DIR_CHAR)?break;
i--;
if(i?==?0)?break;
}
if(i?==?0)?return;
j?=?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????3634??2003-04-09?19:33??algo\crc16.cpp
?????文件?????????970??2003-04-09?19:33??algo\crc16.h
?????文件????????4531??2003-04-09?19:33??algo\crc32.cpp
?????文件?????????763??2003-04-09?19:33??algo\crc32.h
?????文件????????6811??2003-04-09?19:33??algo\fcs.cpp
?????文件?????????949??2003-04-09?19:33??algo\fcs.h
?????文件????????1478??2003-04-09?19:33??algo\ghash.cpp
?????文件?????????846??2003-04-09?19:33??algo\ghash.h
?????文件???????12235??2003-04-04?18:59??algo\gosthash.cpp
?????文件?????????931??2003-04-04?18:59??algo\gosthash.h
?????文件???????31432??2003-04-04?19:54??algo\haval.cpp
?????文件????????4455??2003-04-04?19:36??algo\haval.h
?????文件????????2807??2003-04-01?19:22??algo\md2.cpp
?????文件?????????475??2003-04-01?19:22??algo\md2.h
?????文件????????8367??2003-04-01?19:22??algo\md4.cpp
?????文件????????1767??2003-03-28?16:28??algo\md4.h
?????文件???????12112??2003-03-30?12:09??algo\md5.cpp
?????文件????????3889??2003-03-28?16:28??algo\md5.h
?????文件????????9278??2003-03-27?18:38??algo\sha1.cpp
?????文件????????2330??2003-03-27?18:38??algo\sha1.h
?????文件???????25610??2003-03-27?18:38??algo\sha2.cpp
?????文件????????4495??2003-03-27?18:38??algo\sha2.h
?????文件?????????776??2003-04-09?19:33??algo\sizehash.cpp
?????文件?????????772??2003-04-09?19:33??algo\sizehash.h
?????文件???????45894??2003-04-01?19:22??algo\tiger.cpp
?????文件?????????716??2003-03-28?18:34??algo\tiger.h
?????文件????????3734??2003-04-09?19:33??clutil.cpp
?????文件?????????921??2003-04-09?19:33??clutil.h
?????文件???????15411??1999-11-23?21:29??docs\gnugpl2.txt
?????文件???????10249??2003-04-12?11:39??docs\rehash.html
?????文件??????111716??2003-04-12?11:24??docs\rehash.jpg
............此處省略27個文件信息
評論
共有 條評論