-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutil.h
55 lines (33 loc) · 1.24 KB
/
util.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
48
49
50
51
52
53
54
55
/*
Utilities for the examples
Author: R. Koucha
Date: 25-Mar-2020
*/
#ifndef UTIL_H
#define UTIL_H
#include <sys/types.h>
#include <stdio.h>
extern int dbg_level;
#define DBG(level, fmt, ...) do { \
if (level <= dbg_level) { \
fprintf(stderr, \
"DEBUG_%d (%s#%d): "fmt, \
level, __FUNCTION__, __LINE__, ## __VA_ARGS__); \
} \
} while(0)
#define ERR(fmt, ...) do { \
fprintf(stderr, \
"ERROR@%s#%d: "fmt, \
__FUNCTION__, __LINE__, ## __VA_ARGS__); \
} while(0)
extern int is_pid(const char *str);
extern int is_integer(const char *str);
extern int is_ns_name(const char *ns);
#define is_unsigned_integer(i) is_pid(i)
#define prompt(fmt, ...) do { \
printf(fmt, ## __VA_ARGS__); \
fflush(stdout); \
} while(0)
extern int getanswer(void);
extern int cmp_ns(pid_t pid1, pid_t pid2, const char *ns_name);
#endif // UTIL_H