Magick++: SecurityPolicy.cpp Source File

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
15 #include "Magick++/SecurityPolicy.h"
16 #include "Magick++/Exception.h"
17
18 using namespace std;
19
20 bool Magick::SecurityPolicy::anonymousCacheMemoryMap()
21 {
22 return(setValue(CachePolicyDomain,"memory-map","anonymous"));
23 }
24
25 bool Magick::SecurityPolicy::anonymousSystemMemoryMap()
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
67 GetPPException;
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 }
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