Magick++  7.1.0
SecurityPolicy.cpp
Go to the documentation of this file.
1 // This may look like C code, but it is really -*- C++ -*-
2 //
3 // Copyright @ 2018 ImageMagick Studio LLC, a non-profit organization
4 // dedicated to making software imaging solutions freely available.
5 //
6 // Implementation of the security policy.
7 //
8 
9 #define MAGICKCORE_IMPLEMENTATION 1
10 #define MAGICK_PLUSPLUS_IMPLEMENTATION 1
11 
12 #include <string>
13 #include <sstream>
14 
16 #include "Magick++/Exception.h"
17 
18 using namespace std;
19 
21 {
22  return(setValue(CachePolicyDomain,"memory-map","anonymous"));
23 }
24 
26 {
27  return(setValue(SystemPolicyDomain,"memory-map","anonymous"));
28 }
29 
30 bool Magick::SecurityPolicy::precision(const int precision_)
31 {
32  string
33  value;
34 
35  value=toString(precision_);
36  return(setValue(SystemPolicyDomain,"precision",value));
37 }
38 
39 bool Magick::SecurityPolicy::maxMemoryRequest(const MagickSizeType limit_)
40 {
41  string
42  value;
43 
44  value=toString(limit_);
45  return(setValue(SystemPolicyDomain,"max-memory-request",value));
46 }
47 
48 bool Magick::SecurityPolicy::shred(const int passes_)
49 {
50  string
51  value;
52 
53  value=toString(passes_);
54  return(setValue(SystemPolicyDomain,"shred",value));
55 }
56 
57 Magick::SecurityPolicy::SecurityPolicy()
58 {
59 }
60 
61 bool Magick::SecurityPolicy::setValue(const PolicyDomain domain_,
62  const std::string name_,const std::string value_)
63 {
64  MagickBooleanType
65  status;
66 
68  status=MagickCore::SetMagickSecurityPolicyValue(domain_,name_.c_str(),
69  value_.c_str(),exceptionInfo);
70  ThrowPPException(false);
71  return(status != MagickFalse);
72 }
73 
74 template <typename T>
75 std::string Magick::SecurityPolicy::toString(const T& value)
76 {
77  stringstream ss;
78  ss << value;
79  return ss.str();
80 }
static bool maxMemoryRequest(const MagickSizeType limit_)
static bool precision(const int precision_)
STL namespace.
static bool anonymousSystemMemoryMap()
static bool anonymousCacheMemoryMap()
static bool shred(const int passes_)
#define ThrowPPException(quiet)
Definition: Include.h:1580
#define GetPPException
Definition: Include.h:1561