-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.h
47 lines (39 loc) · 937 Bytes
/
common.h
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
#ifndef COMMON_H
#define COMMON_H
//Common headers and useful functions
//Standar C/C++ libraries
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <semaphore.h>
#include <iostream>
#include <time.h>
//Libconfig libraries to read configuration from file
#include <libconfig.h++>
//Named pipes libraries
#include <sys/stat.h>
#include <fcntl.h>
//Socket implementation libraries
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
//Read and write of files
#include <fstream>
#include <ostream>
using namespace std;
/**
* Outputs a readable error message and exits the program
*/
void error(const char *msg) {
perror(msg);
exit(1);
}
const int ACCEPTED = 0,
INVALID = -1;
//Return true if the specified file exist
bool fileExists(const char *fileName) {
struct stat fileExistTest;
return (stat(fileName, &fileExistTest) == 0);
}
#endif // COMMON_H