forked from martinpitt/umockdev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug.c
37 lines (34 loc) · 991 Bytes
/
debug.c
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
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "debug.h"
#include "utils.h"
unsigned debug_categories = 0;
void
init_debug(void)
{
const char *d = getenv("UMOCKDEV_DEBUG");
char *d_copy, *token;
if (d == NULL)
return;
d_copy = strdupx(d);
for (token = strtok(d_copy, " ,"); token; token = strtok(NULL, " ,")) {
if (strcmp (token, "all") == 0)
debug_categories = ~0;
else if (strcmp (token, "path") == 0)
debug_categories |= DBG_PATH;
else if (strcmp (token, "netlink") == 0)
debug_categories |= DBG_NETLINK;
else if (strcmp (token, "script") == 0)
debug_categories |= DBG_SCRIPT;
else if (strcmp (token, "ioctl") == 0)
debug_categories |= DBG_IOCTL;
else if (strcmp (token, "ioctl-tree") == 0)
debug_categories |= DBG_IOCTL_TREE;
else {
fprintf(stderr, "Invalid UMOCKDEV_DEBUG category %s. Valid values are: path netlink ioctl ioctl-tree script all\n", token);
abort();
}
}
free(d_copy);
}