17#include <boost/lexical_cast.hpp>
34decimalToNumber(
const char* s,
const char* s_end) {
39 const std::string num_str(s, s + 3);
41 const int i = boost::lexical_cast<int>(num_str);
47 }
catch (
const boost::bad_lexical_cast&) {
49 "Invalid form for escaped digits: " << num_str);
61 const char* s = str_region.beg;
62 const char*
const s_end = str_region.beg + str_region.len;
64 for (
size_t n = str_region.len; n != 0; --n, ++s) {
66 if (escape && std::isdigit(c) != 0) {
67 c = decimalToNumber(s, s_end);
74 }
else if (!escape && c ==
'\\') {
86 (result.size() - 1) <<
"(+1) characters");
88 result[0] = result.size() - 1;
95 const char* s = str_region.beg;
96 const char*
const s_end = str_region.beg + str_region.len;
98 for (
size_t n = str_region.len; n != 0; --n, ++s) {
100 if (escape && std::isdigit(c) != 0) {
101 c = decimalToNumber(s, s_end);
108 }
else if (!escape && c ==
'\\') {
124 for (
auto const& it : char_string) {
129 const uint8_t ch = it;
130 if ((ch < 0x20) || (ch >= 0x7f)) {
133 s.push_back(
'0' + ((ch / 100) % 10));
134 s.push_back(
'0' + ((ch / 10) % 10));
135 s.push_back(
'0' + (ch % 10));
138 if ((ch ==
'"') || (ch ==
';') || (ch ==
'\\')) {
150 for (
auto const& it : char_string) {
151 const uint8_t ch = it;
152 if ((ch < 0x20) || (ch >= 0x7f)) {
155 s.push_back(
'0' + ((ch / 100) % 10));
156 s.push_back(
'0' + ((ch / 10) % 10));
157 s.push_back(
'0' + (ch % 10));
160 if ((ch ==
'"') || (ch ==
';') || (ch ==
'\\')) {
171 if (self.size() == 0 && other.size() == 0) {
174 if (self.size() == 0) {
177 if (other.size() == 0) {
180 const size_t self_len = self[0];
181 const size_t other_len = other[0];
182 const size_t cmp_len = std::min(self_len, other_len);
184 if (self_len < other_len) {
186 }
else if (self_len > other_len) {
192 const int cmp = std::memcmp(&self[1], &other[1], cmp_len);
195 }
else if (cmp > 0) {
197 }
else if (self_len < other_len) {
199 }
else if (self_len > other_len) {
208 if (self.size() == 0 && other.size() == 0) {
211 if (self.size() == 0) {
214 if (other.size() == 0) {
217 const size_t self_len = self.size();
218 const size_t other_len = other.size();
219 const size_t cmp_len = std::min(self_len, other_len);
220 const int cmp = std::memcmp(&self[0], &other[0], cmp_len);
223 }
else if (cmp > 0) {
225 }
else if (self_len < other_len) {
227 }
else if (self_len > other_len) {
237 if (rdata_len < 1 || buffer.getLength() - buffer.getPosition() < 1) {
239 "insufficient data to read character-string length");
241 const uint8_t len = buffer.readUint8();
242 if (rdata_len < len + 1) {
244 "character string length is too large: " <<
245 static_cast<int>(len));
247 if (buffer.getLength() - buffer.getPosition() < len) {
249 "not enough data in buffer to read character-string of len"
250 <<
static_cast<int>(len));
253 target.resize(len + 1);
255 buffer.readData(&target[0] + 1, len);
A standard DNS module exception that is thrown if RDATA parser fails to recognize a given textual rep...
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
std::string charStringToString(const CharString &char_string)
Convert a CharString into a textual DNS character-string.
int compareCharStrings(const detail::CharString &self, const detail::CharString &other)
Compare two CharString objects.
int compareCharStringDatas(const detail::CharStringData &self, const detail::CharStringData &other)
Compare two CharStringData objects.
void stringToCharString(const MasterToken::StringRegion &str_region, CharString &result)
Convert a DNS character-string into corresponding binary data.
std::vector< uint8_t > CharStringData
Type for DNS character string without the length prefix.
void stringToCharStringData(const MasterToken::StringRegion &str_region, CharStringData &result)
Convert a DNS character-string into corresponding binary data.
size_t bufferToCharString(isc::util::InputBuffer &buffer, size_t rdata_len, CharString &target)
Convert a buffer containing a character-string to CharString.
std::string charStringDataToString(const CharStringData &char_string)
Convert a CharStringData into a textual DNS character-string.
std::vector< uint8_t > CharString
Type for DNS character string.
const unsigned int MAX_CHARSTRING_LEN
The maximum allowable length of character-string containing in RDATA as defined in RFC1035,...
Defines the logger used by the top-level component of kea-lfc.
A simple representation of a range of a string.