-
Notifications
You must be signed in to change notification settings - Fork 0
/
boilerplate.h
34 lines (27 loc) · 1.4 KB
/
boilerplate.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
#ifndef BOILERPLATE_H
#define BOILERPLATE_H
#include <signal.h>
#include <iostream>
using namespace std;
#define SANITY \
if (argc < 6) { \
cout << "usage: game-of-life <graphics-cell-width> <height> <width> <transitions> <period> [<fill>]" << endl; \
exit(1); \
} \
if (signal(SIGINT, sig_handler) == SIG_ERR) { \
cout << "\ncan't catch SIGINT" << endl; \
exit(1); \
}
#define ARGUMENTS \
S = atoi(argv[1]); \
H = atoi(argv[2]), W = atoi(argv[3]); \
T = atoi(argv[4]), P = atoi(argv[5]); \
F = argc == 7 ? atoi(argv[6]) : 10;
bool interrupted = false;
void sig_handler(int signo) {
interrupted = true;
(void)signo;
cout << "\n"
<< endl;
}
#endif