summaryrefslogtreecommitdiffstats
path: root/Source/cmStringCommand.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmStringCommand.cxx')
-rw-r--r--Source/cmStringCommand.cxx32
1 files changed, 32 insertions, 0 deletions
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index d239c06..f2f2681 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -10,6 +10,8 @@
See the License for more information.
============================================================================*/
#include "cmStringCommand.h"
+#include "cmCryptoHash.h"
+
#include <cmsys/RegularExpression.hxx>
#include <cmsys/SystemTools.hxx>
@@ -36,6 +38,15 @@ bool cmStringCommand
{
return this->HandleReplaceCommand(args);
}
+ else if ( subCommand == "MD5" ||
+ subCommand == "SHA1" ||
+ subCommand == "SHA224" ||
+ subCommand == "SHA256" ||
+ subCommand == "SHA384" ||
+ subCommand == "SHA512" )
+ {
+ return this->HandleHashCommand(args);
+ }
else if(subCommand == "TOLOWER")
{
return this->HandleToUpperLowerCommand(args, false);
@@ -83,6 +94,27 @@ bool cmStringCommand
}
//----------------------------------------------------------------------------
+bool cmStringCommand::HandleHashCommand(std::vector<std::string> const& args)
+{
+ if(args.size() != 3)
+ {
+ cmOStringStream e;
+ e << args[0] << " requires an output variable and an input string";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+
+ cmsys::auto_ptr<cmCryptoHash> hash(cmCryptoHash::New(args[0].c_str()));
+ if(hash.get())
+ {
+ std::string out = hash->HashString(args[2].c_str());
+ this->Makefile->AddDefinition(args[1].c_str(), out.c_str());
+ return true;
+ }
+ return false;
+}
+
+//----------------------------------------------------------------------------
bool cmStringCommand::HandleToUpperLowerCommand(
std::vector<std::string> const& args, bool toUpper)
{