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