-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.cpp
More file actions
51 lines (42 loc) · 903 Bytes
/
config.cpp
File metadata and controls
51 lines (42 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once
#include <stdio.h>
#include <iostream>
#include <mutex>
#include <sstream>
#include <errno.h>
#include <sys/utsname.h>
#ifndef SOCKET_PATH
#define SOCKET_PATH "127.0.0.1:8000"
#endif
#ifndef MESSEGE_LENGTH
#define MESSEGE_LENGTH 10
#endif
struct sending_data{
char msg[MESSEGE_LENGTH];
utsname required_info;
long info;
};
bool check(int val, const char* message){
if (val == -1) {
// ignore error of non-blocking "resource temporary unavailable"
if(errno != EAGAIN)
perror(message);
return true;
}
else {
return false;
}
}
class my_cout : public std::ostringstream
{
public:
my_cout() = default;
~my_cout()
{
std::lock_guard<std::mutex> guard(_mutexPrint);
std::cout << this->str();
}
private:
static std::mutex _mutexPrint;
};
std::mutex my_cout::_mutexPrint{};