File: debug.c

package info (click to toggle)
umockdev 0.15.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,984 kB
  • sloc: ansic: 4,683; sh: 190; python: 179; xml: 42; makefile: 10
file content (36 lines) | stat: -rw-r--r-- 971 bytes parent folder | download | duplicates (4)
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
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

#include "debug.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 = strdup(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);
}