Magick++
7.1.2-32
Convert, Edit, Or Compose Bitmap Images
Toggle main menu visibility
Loading...
Searching...
No Matches
SecurityPolicy.cpp
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 "Magick++/SecurityPolicy.h"
13
#include "Magick++/Exception.h"
14
#include <sstream>
15
16
using namespace
std;
17
18
bool
Magick::SecurityPolicy::anonymousCacheMemoryMap()
19
{
20
return
(setValue(CachePolicyDomain,
"memory-map"
,
"anonymous"
));
21
}
22
23
bool
Magick::SecurityPolicy::anonymousSystemMemoryMap()
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::maxProfileSize(
const
MagickSizeType limit_)
47
{
48
string
49
value;
50
51
value=toString(limit_);
52
return
(setValue(SystemPolicyDomain,
"max-profile-size"
,value));
53
}
54
55
bool
Magick::SecurityPolicy::shred(
const
int
passes_)
56
{
57
string
58
value;
59
60
value=toString(passes_);
61
return
(setValue(SystemPolicyDomain,
"shred"
,value));
62
}
63
64
Magick::SecurityPolicy::SecurityPolicy()
65
{
66
}
67
68
bool
Magick::SecurityPolicy::setValue(
const
PolicyDomain domain_,
69
const
std::string name_,
const
std::string value_)
70
{
71
MagickBooleanType
72
status;
73
74
GetPPException;
75
status=MagickCore::SetMagickSecurityPolicyValue(domain_,name_.c_str(),
76
value_.c_str(),exceptionInfo);
77
ThrowPPException(
false
);
78
return
(status != MagickFalse);
79
}
80
81
template
<
typename
T>
82
std::string Magick::SecurityPolicy::toString(
const
T& value)
83
{
84
stringstream ss;
85
ss << value;
86
return
ss.str();
87
}
Magick++
lib
SecurityPolicy.cpp
Generated by
1.17.0