Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Slic3r::DnsName Struct Reference
+ Inheritance diagram for Slic3r::DnsName:
+ Collaboration diagram for Slic3r::DnsName:

Public Types

enum  { MAX_RECURSION = 10 }
 

Static Public Member Functions

static optional< DnsNamedecode (const std::vector< char > &buffer, size_t &offset, unsigned depth=0)
 

Detailed Description

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
MAX_RECURSION 
44 {
45 MAX_RECURSION = 10, // Keep this low
46 };
@ MAX_RECURSION
Definition Bonjour.cpp:45

Member Function Documentation

◆ decode()

static optional< DnsName > Slic3r::DnsName::decode ( const std::vector< char > &  buffer,
size_t &  offset,
unsigned  depth = 0 
)
inlinestatic
49 {
50 // Check offset sanity:
51 if (offset + 1 >= buffer.size()) {
52 return boost::none;
53 }
54
55 // Check for recursion depth to prevent parsing names that are nested too deeply or end up cyclic:
56 if (depth >= MAX_RECURSION) {
57 return boost::none;
58 }
59
60 DnsName res;
61 const size_t bsize = buffer.size();
62
63 while (true) {
64 const char* ptr = buffer.data() + offset;
65 unsigned len = static_cast<unsigned char>(*ptr);
66 if (len & 0xc0) {
67 // This is a recursive label
68 unsigned len_2 = static_cast<unsigned char>(ptr[1]);
69 size_t pointer = (len & 0x3f) << 8 | len_2;
70 const auto nested = decode(buffer, pointer, depth + 1);
71 if (!nested) {
72 return boost::none;
73 } else {
74 if (res.size() > 0) {
75 res.push_back('.');
76 }
77 res.append(*nested);
78 offset += 2;
79 return std::move(res);
80 }
81 } else if (len == 0) {
82 // This is a name terminator
83 offset++;
84 break;
85 } else {
86 // This is a regular label
87 len &= 0x3f;
88 if (len + offset + 1 >= bsize) {
89 return boost::none;
90 }
91
92 res.reserve(len);
93 if (res.size() > 0) {
94 res.push_back('.');
95 }
96
97 ptr++;
98 for (const auto end = ptr + len; ptr < end; ptr++) {
99 char c = *ptr;
100 if (c >= 0x20 && c <= 0x7f) {
101 res.push_back(c);
102 } else {
103 return boost::none;
104 }
105 }
106
107 offset += len + 1;
108 }
109 }
110
111 if (res.size() > 0) {
112 return std::move(res);
113 } else {
114 return boost::none;
115 }
116 }
Slic3r::Polygons offset(const Slic3r::Polygon &polygon, const float delta, ClipperLib::JoinType joinType, double miterLimit)
Definition ClipperUtils.cpp:416
S::iterator end(S &sh, const PathTag &)
Definition geometry_traits.hpp:620
static optional< DnsName > decode(const std::vector< char > &buffer, size_t &offset, unsigned depth=0)
Definition Bonjour.cpp:48

References decode(), MAX_RECURSION, and Slic3r::offset().

Referenced by Slic3r::DnsRR_SRV::decode(), Slic3r::DnsQuestion::decode(), Slic3r::DnsResource::decode(), and decode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

The documentation for this struct was generated from the following file: