Magick++
7.1.2-29
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 <string>
15
#include <sstream>
16
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::maxProfileSize(
const
MagickSizeType limit_)
49
{
50
string
51
value;
52
53
value=toString(limit_);
54
return
(setValue(SystemPolicyDomain,
"max-profile-size"
,value));
55
}
56
57
bool
Magick::SecurityPolicy::shred(
const
int
passes_)
58
{
59
string
60
value;
61
62
value=toString(passes_);
63
return
(setValue(SystemPolicyDomain,
"shred"
,value));
64
}
65
66
Magick::SecurityPolicy::SecurityPolicy()
67
{
68
}
69
70
bool
Magick::SecurityPolicy::setValue(
const
PolicyDomain domain_,
71
const
std::string name_,
const
std::string value_)
72
{
73
MagickBooleanType
74
status;
75
76
GetPPException;
77
status=MagickCore::SetMagickSecurityPolicyValue(domain_,name_.c_str(),
78
value_.c_str(),exceptionInfo);
79
ThrowPPException(
false
);
80
return
(status != MagickFalse);
81
}
82
83
template
<
typename
T>
84
std::string Magick::SecurityPolicy::toString(
const
T& value)
85
{
86
stringstream ss;
87
ss << value;
88
return
ss.str();
89
}
Magick++
lib
SecurityPolicy.cpp
Generated by
1.17.0