--- a/analyzetool/commandlineengine/src/arguments.cpp Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/commandlineengine/src/arguments.cpp Wed Sep 15 13:53:27 2010 +0300
@@ -22,11 +22,13 @@
bool parseAnalyzeArguments( vector<string>& vArgs, ARGUMENTS& args );
bool parseParseArguments( vector<string>& vArgs, ARGUMENTS& args );
bool checkDataFileName( string& sFileName );
+bool checkDataFilePath( string& sFilePath );
bool parseSbsConfiguration( string& sConfiguration, ARGUMENTS& args );
// Constants for old "hooking" parameter parsing.
#define INVALID_PARAMETER "AnalyzeTool : Error, invalid parameter: "
-const char DATAFILENAME_INVALID_CHARS[] = " &^+-@$%*()|\\/[]{}<>?;:,\"'";
+const char DATAFILENAME_INVALID_CHARS[] = " &^+-@$*()|\\/[]{}<>?;:,\"'";
+const char DATAFILEPATH_INVALID_CHARS[] = " &^+-@$%*()|/[]{}<>?;,\"'";
/**
* Check datafile name for invalid characters.
@@ -44,6 +46,40 @@
}
/**
+* Check datafile path for invalid characters and correct format.
+* @return true if file path ok.
+*/
+bool checkDataFilePath( string& sFilePath )
+{
+ for ( size_t i = 0; i < sFilePath.length(); i++ )
+ {
+ char c = sFilePath.at( i );
+ if( strchr( DATAFILEPATH_INVALID_CHARS, c ) != 0 )
+ return false;
+ // first char must be drive letter a-z
+ if( i == 0 && ( c = tolower( c ) < 'a' || c > 'z' ) )
+ return false;
+ // if last char is not '\', add it
+ if( i == sFilePath.length()-1 && c != '\\' )
+ sFilePath.append( "\\" );
+ }
+
+ // ':\' after drive letter
+ if( sFilePath.find( ":\\" ) != 1 )
+ return false;
+
+ // there can be only one ':' on pos 1
+ if( sFilePath.find( ":", 2 ) != string::npos )
+ return false;
+
+ //check double slashes
+ if( sFilePath.find( "\\\\" ) != string::npos )
+ return false;
+
+ return true;
+}
+
+/**
* Parse base arguments from given vector of strings.
* Removes debug / help arguments from vector.
*/
@@ -178,16 +214,19 @@
args.eMainSwitch = SWITCH_HELP;
else if ( ! _stricmp( (*it).c_str(), "-me" ) )
{
- args.eMainSwitch = SWITCH_HOOK;
- args.eHookSwitch = HOOK_EXTERNAL;
+ cout << AT_MSG << "This feature is no longer supported. You can use -tr parameter for output to trace. \n" << endl;
}
- else if ( ! _stricmp( (*it).c_str(), "-e" ) )
+ else if ( ! _stricmp( (*it).c_str(), "-e" ) || ! _stricmp( (*it).c_str(), "-tr" ) )
{
args.eMainSwitch = SWITCH_HOOK;
args.eHookSwitch = HOOK_EXTERNAL_FAST;
}
else if ( ! _stricmp( (*it).c_str(), "-mi" ) )
{
+ cout << AT_MSG << "This feature is no longer supported. You can use -lf parameter for logging to file. \n" << endl;
+ }
+ else if ( ! _stricmp( (*it).c_str(), "-lf" ) )
+ {
args.eMainSwitch = SWITCH_HOOK;
args.eHookSwitch = HOOK_INTERNAL;
}
@@ -355,7 +394,8 @@
}
else if ( ! _stricmp( it->c_str(), "sbs" )
|| ! _stricmp( it->c_str(), "abld" )
- || ! _stricmp( it->c_str(), "-f" ) )
+ || ! _stricmp( it->c_str(), "-f" )
+ || ! _stricmp( it->c_str(), "-fp" ) )
{
bRet = false;
cout << AT_MSG << "Error, missing call stack size parameter." << endl;
@@ -407,13 +447,13 @@
if ( it == vArgs.end() )
{
bRet = false;
- cout << AT_MSG << "Error, missing internal data gathering file name." << endl;
+ cout << AT_MSG << "Error, missing log file name." << endl;
break;
}
else if ( ! _stricmp( it->c_str(), "sbs" ) || ! _stricmp( it->c_str(), "abld" ) )
{
bRet = false;
- cout << AT_MSG << "Error, missing internal data gathering file name." << endl;
+ cout << AT_MSG << "Error, missing log file name." << endl;
break;
}
else
@@ -427,7 +467,41 @@
else
{
bRet = false;
- cout << AT_MSG << "Error, specified internal data gathering file name contains invalid character(s)." << endl;
+ cout << AT_MSG << "Error, specified log file name contains invalid character(s)." << endl;
+ break;
+ }
+ }
+ }
+ // Data file path.
+ else if ( _stricmp( it->c_str(), "-fp" ) == 0 )
+ {
+ it++;
+ if ( it == vArgs.end() )
+ {
+ bRet = false;
+ cout << AT_MSG << "Error, missing path for log file." << endl;
+ break;
+ }
+ else if ( ! _stricmp( it->c_str(), "sbs" ) || ! _stricmp( it->c_str(), "abld" ) )
+ {
+ bRet = false;
+ cout << AT_MSG << "Error, missing path for log file." << endl;
+ break;
+ }
+ else
+ {
+ string sFormattedPath = string(*it);
+ if ( checkDataFilePath( sFormattedPath ) )
+ {
+ // Pickup filename.
+ args.HOOK.bDataFilePath = true;
+ args.HOOK.sDataFilePath = sFormattedPath;
+ }
+ else
+ {
+ bRet = false;
+ cout << AT_MSG << "Error, specified log file path contains invalid character(s) "
+ << "or is in wrong format. Please, check help for correct format," << endl;
break;
}
}