9 #include <sys/socket.h>
15 using time_point = std::chrono::steady_clock::time_point;
18 return std::chrono::duration_cast<std::chrono::milliseconds>(now - program_start).count();
42 int SystemCall(
const char *attempt,
const int return_value,
const int errno_mask) {
43 if (return_value >= 0 || errno == errno_mask) {
54 int SystemCall(
const string &attempt,
const int return_value,
const int errno_mask) {
67 generate(seed_data.begin(), seed_data.end(), [&] { return rd(); });
68 seed_seq seed(seed_data.begin(), seed_data.end());
90 for (
size_t i = 0; i < data.size(); i++) {
103 while (ret > 0xffff) {
104 ret = (ret >> 16) + (ret & 0xffff);
114 const auto flags(
cout.flags());
115 const string indent_string(indent,
' ');
119 for (
unsigned i = 0; i <
len; ++i) {
120 if ((printed & 0xf) == 0) {
122 cout <<
" " << pchars.
str() <<
"\n";
125 cout << indent_string <<
setw(8) << printed <<
": ";
126 }
else if ((printed & 1) == 0) {
130 pchars << (static_cast<bool>(
isprint(data[i])) ?
static_cast<char>(data[i]) :
'.');
133 const int print_rem = (16 - (printed & 0xf)) % 16;
134 cout <<
string(2 * print_rem + print_rem / 2 + 4,
' ') << pchars.
str();
142 void hexdump(
const char *data,
const size_t len,
const size_t indent) {