SecurityPolicy.cpp
Go to the documentation of this file.
// This may look like C code, but it is really -*- C++ -*-
//
// Copyright @ 2018 ImageMagick Studio LLC, a non-profit organization
// dedicated to making software imaging solutions freely available.
//
// Implementation of the security policy.
//
#define MAGICKCORE_IMPLEMENTATION 1
#define MAGICK_PLUSPLUS_IMPLEMENTATION 1
#include <string>
#include <sstream>
#include "Magick++/SecurityPolicy.h"
#include "Magick++/Exception.h"
using namespace std;
bool Magick::SecurityPolicy::anonymousCacheMemoryMap()
{
return(setValue(CachePolicyDomain,"memory-map","anonymous"));
}
bool Magick::SecurityPolicy::anonymousSystemMemoryMap()
{
return(setValue(SystemPolicyDomain,"memory-map","anonymous"));
}
bool Magick::SecurityPolicy::precision(const int precision_)
{
string
value;
value=toString(precision_);
return(setValue(SystemPolicyDomain,"precision",value));
}
bool Magick::SecurityPolicy::maxMemoryRequest(const MagickSizeType limit_)
{
string
value;
value=toString(limit_);
return(setValue(SystemPolicyDomain,"max-memory-request",value));
}
bool Magick::SecurityPolicy::shred(const int passes_)
{
string
value;
value=toString(passes_);
return(setValue(SystemPolicyDomain,"shred",value));
}
Magick::SecurityPolicy::SecurityPolicy()
{
}
bool Magick::SecurityPolicy::setValue(const PolicyDomain domain_,
const std::string name_,const std::string value_)
{
MagickBooleanType
status;
GetPPException;
status=MagickCore::SetMagickSecurityPolicyValue(domain_,name_.c_str(),
value_.c_str(),exceptionInfo);
ThrowPPException(false);
return(status != MagickFalse);
}
template <typename T>
std::string Magick::SecurityPolicy::toString(const T& value)
{
stringstream ss;
ss << value;
return ss.str();
}
Magick::SecurityPolicy::maxMemoryRequest
static bool maxMemoryRequest(const MagickSizeType limit_)
Definition: SecurityPolicy.cpp:39
Magick::SecurityPolicy::precision
static bool precision(const int precision_)
Definition: SecurityPolicy.cpp:30
std
STL namespace.
Magick::SecurityPolicy::anonymousSystemMemoryMap
static bool anonymousSystemMemoryMap()
Definition: SecurityPolicy.cpp:25
Magick::SecurityPolicy::anonymousCacheMemoryMap
static bool anonymousCacheMemoryMap()
Definition: SecurityPolicy.cpp:20
Magick::SecurityPolicy::shred
static bool shred(const int passes_)
Definition: SecurityPolicy.cpp:48
ThrowPPException
#define ThrowPPException(quiet)
Definition: Include.h:1580
GetPPException
#define GetPPException
Definition: Include.h:1561
Exception.h
SecurityPolicy.h