25createStreamName(
const std::istream& input_stream) {
27 ss <<
"stream-" << &input_stream;
32getStreamSize(std::istream&
is) {
34 is.seekg(0, std::ios_base::end);
39 "failed to seek end of input source");
40 }
else if (
is.fail() || errno != 0) {
56 const std::streampos len =
is.tellg();
58 if (len ==
static_cast<std::streampos
>(-1)) {
70 is.seekg(0, std::ios::beg);
73 "failed to seek beginning of input source");
91 name_(createStreamName(input_stream)),
93 input_size_(getStreamSize(input_)) {
100openFileStream(std::ifstream& file_stream,
const char* filename) {
102 file_stream.open(filename);
103 if (file_stream.fail()) {
104 std::string error_txt(
"Error opening the input source file: ");
105 error_txt += filename;
107 error_txt +=
"; possible cause: ";
108 error_txt += std::strerror(errno);
110 isc_throw(InputSource::OpenError, error_txt);
113 return (file_stream);
124 input_(openFileStream(file_stream_, filename)),
125 input_size_(getStreamSize(input_)) {
129 if (file_stream_.is_open()) {
130 file_stream_.close();
136 if (buffer_pos_ == buffer_.size()) {
144 const int c = input_.get();
156 "Error reading from the input stream: " <<
getName());
158 buffer_.push_back(c);
161 const int c = buffer_[buffer_pos_];
175 }
else if (buffer_pos_ == 0) {
177 "Cannot skip before the start of buffer");
181 if (buffer_[buffer_pos_] ==
'\n') {
190 total_pos_ -= buffer_pos_;
203 if (buffer_pos_ == buffer_.size()) {
206 buffer_.erase(buffer_.begin(), buffer_.begin() + buffer_pos_);
it forwards queries to a single upstream resolver and passes the answers back to the client It is constructed with the address of the forward server Queries are initiated with the question to ask the forward a buffer into which to write the and a pointer to the coroutine to be resumed when the answer has arrived In simplified the DNSQuery routine is
Exception thrown when we fail to read from the input stream or file.
static const size_t SOURCE_SIZE_UNKNOWN
Special value for input source size meaning "unknown".
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
#define isc_throw_assert(expr)
Replacement for assert() that throws if the expression is false.
Defines the logger used by the top-level component of kea-lfc.