]> git.ipfire.org Git - thirdparty/util-linux.git/blob - libfdisk/src/init.c
b25a876b3dbbdf1f275c897eb5b137d7d19ba6e7
[thirdparty/util-linux.git] / libfdisk / src / init.c
1
2 #include "fdiskP.h"
3
4
5 /**
6 * SECTION: init
7 * @title: Library initialization
8 * @short_description: initialize debug stuff
9 *
10 */
11
12 UL_DEBUG_DEFINE_MASK(libfdisk);
13 UL_DEBUG_DEFINE_MASKNAMES(libfdisk) =
14 {
15 { "all", LIBFDISK_DEBUG_ALL, "info about all subsystems" },
16 { "ask", LIBFDISK_DEBUG_ASK, "fdisk dialogs" },
17 { "help", LIBFDISK_DEBUG_HELP, "this help" },
18 { "cxt", LIBFDISK_DEBUG_CXT, "library context (handler)" },
19 { "label", LIBFDISK_DEBUG_LABEL, "disk label utils" },
20 { "part", LIBFDISK_DEBUG_PART, "partition utils" },
21 { "parttype", LIBFDISK_DEBUG_PARTTYPE,"partition type utils" },
22 { "script", LIBFDISK_DEBUG_SCRIPT, "sfdisk-like scripts" },
23 { "tab", LIBFDISK_DEBUG_TAB, "table utils"},
24 { "wipe", LIBFDISK_DEBUG_WIPE, "wipe area utils" },
25 { "item", LIBFDISK_DEBUG_WIPE, "disklabel items" },
26 { NULL, 0 }
27 };
28
29 /**
30 * fdisk_init_debug:
31 * @mask: debug mask (0xffff to enable full debugging)
32 *
33 * If the @mask is not specified then this function reads
34 * LIBFDISK_DEBUG environment variable to get the mask.
35 *
36 * Already initialized debugging stuff cannot be changed. It does not
37 * have effect to call this function twice.
38 *
39 * It's strongly recommended to use fdisk_init_debug(0) in your code.
40 */
41 void fdisk_init_debug(int mask)
42 {
43 if (libfdisk_debug_mask)
44 return;
45
46 __UL_INIT_DEBUG_FROM_ENV(libfdisk, LIBFDISK_DEBUG_, mask, LIBFDISK_DEBUG);
47
48
49 if (libfdisk_debug_mask != LIBFDISK_DEBUG_INIT
50 && libfdisk_debug_mask != (LIBFDISK_DEBUG_HELP|LIBFDISK_DEBUG_INIT)) {
51 const char *ver = NULL;
52
53 fdisk_get_library_version(&ver);
54
55 DBG(INIT, ul_debug("library debug mask: 0x%04x", libfdisk_debug_mask));
56 DBG(INIT, ul_debug("library version: %s", ver));
57 }
58
59 ON_DBG(HELP, ul_debug_print_masks("LIBFDISK_DEBUG",
60 UL_DEBUG_MASKNAMES(libfdisk)));
61 }