zero_start :1; /* ignore existing partition table */
};
+
+/*
+ * let's use include/debug.h stuff for cfdisk too
+ */
+UL_DEBUG_DEFINE_MASK(cfdisk);
+UL_DEBUG_DEFINE_MASKANEMS(cfdisk) = UL_DEBUG_EMPTY_MASKNAMES;
+
+#define CFDISK_DEBUG_INIT (1 << 1)
+#define CFDISK_DEBUG_UI (1 << 2)
+#define CFDISK_DEBUG_MENU (1 << 3)
+#define CFDISK_DEBUG_MISC (1 << 4)
+#define CFDISK_DEBUG_TABLE (1 << 5)
+#define CFDISK_DEBUG_ALL 0xFFFF
+
+#undef DBG /* temporary to avoid collision with fdiskP.h */
+#define DBG(m, x) __UL_DBG(cfdisk, CFDISK_DEBUG_, m, x)
+
+static void cfdisk_init_debug(void)
+{
+ __UL_INIT_DEBUG(cfdisk, CFDISK_DEBUG_, 0, CFDISK_DEBUG);
+}
+
/* Initialize output columns -- we follow libfdisk fields (usually specific
* to the label type.
*/
}
touchwin(stdscr);
- DBG(FRONTEND, ul_debug("ui: resize refresh COLS=%d, LINES=%d", COLS, LINES));
+ DBG(UI, ul_debug("ui: resize refresh COLS=%d, LINES=%d", COLS, LINES));
ui_resize = 0;
}
int tree = 0;
struct libscols_line *ln, *ln_cont = NULL;
- DBG(FRONTEND, ul_debug("table: convert to string"));
+ DBG(TABLE, ul_debug("convert to string"));
assert(cf);
assert(cf->cxt);
/* get container (e.g. extended partition) */
while (fdisk_table_next_partition(tb, itr, &pa) == 0) {
if (fdisk_partition_is_nested(pa)) {
- DBG(FRONTEND, ul_debug("table: nested detected, using tree"));
+ DBG(TABLE, ul_debug("nested detected, using tree"));
tree = SCOLS_FL_TREE;
break;
}
assert(cf);
- DBG(FRONTEND, ul_debug("refreshing buffer"));
+ DBG(TABLE, ul_debug("refreshing buffer"));
free(cf->linesbuf);
free(cf->lines);
static void die_on_signal(int dummy __attribute__((__unused__)))
{
- DBG(FRONTEND, ul_debug("die on signal."));
+ DBG(MISC, ul_debug("die on signal."));
ui_end();
exit(EXIT_FAILURE);
}
static void resize_on_signal(int dummy __attribute__((__unused__)))
{
- DBG(FRONTEND, ul_debug("resize on signal."));
+ DBG(MISC, ul_debug("resize on signal."));
ui_resize = 1;
}
m = cf->menu;
org = menu_get_menuitem(cf, m->idx);
- DBG(FRONTEND, ul_debug("menu: update menu ignored keys"));
+ DBG(MENU, ul_debug("update menu ignored keys"));
i = m->ignore_cb(cf, ignore, sizeof(ignore));
ignore[i] = '\0';
assert(cf);
- DBG(FRONTEND, ul_debug("menu: new menu"));
+ DBG(MENU, ul_debug("new menu"));
m->prev = cf->menu;
m->items = items;
assert(cf);
- DBG(FRONTEND, ul_debug("menu: rem menu"));
+ DBG(MENU, ul_debug("pop menu"));
if (cf->menu) {
m = cf->menu->prev;
{
struct sigaction sa;
- DBG(FRONTEND, ul_debug("ui: init"));
+ DBG(UI, ul_debug("init"));
/* setup SIGCHLD handler */
sigemptyset(&sa.sa_mask);
vert ? MBS_ALIGN_LEFT : MBS_ALIGN_CENTER,
0);
- DBG(FRONTEND, ul_debug("ui: menuitem: cl=%d, ln=%d, item='%s'",
+ DBG(MENU, ul_debug("menuitem: cl=%d, ln=%d, item='%s'",
cl, ln, buf));
if (vert) {
assert(cf);
assert(cf->menu);
- DBG(FRONTEND, ul_debug("ui: menu: draw start"));
+ DBG(MENU, ul_debug("draw start"));
ui_clean_menu(cf);
m = cf->menu;
mvaddch(ln + nlines, cl + m->width + 3, ACS_DARROW);
}
- DBG(FRONTEND, ul_debug("ui: menu: draw end."));
+ DBG(MENU, ul_debug("draw end."));
}
static void ui_menu_goto(struct cfdisk *cf, int where)
m = cf->menu;
- DBG(FRONTEND, ul_debug("ui: menu move key >%c<.", key));
+ DBG(MENU, ul_debug("menu move key >%c<.", key));
if (m->vertical)
{
curpg = cf->lines_idx / cf->page_sz;
}
- DBG(FRONTEND, ul_debug(
- "ui: draw partition %zu [page_sz=%zu, "
+ DBG(UI, ul_debug(
+ "draw partition %zu [page_sz=%zu, "
"line=%d, idx=%zu]",
i, cf->page_sz, ln, cf->lines_idx));
size_t i, nparts = fdisk_table_get_nents(cf->table);
size_t curpg = cf->page_sz ? cf->lines_idx / cf->page_sz : 0;
- DBG(FRONTEND, ul_debug("ui: draw table"));
+ DBG(UI, ul_debug("draw table"));
for (i = TABLE_START_LINE; i <= TABLE_START_LINE + cf->page_sz; i++) {
move(i, 0);
size_t old;
size_t nparts = fdisk_table_get_nents(cf->table);
- DBG(FRONTEND, ul_debug("ui: goto table %d", where));
+ DBG(UI, ul_debug("goto table %d", where));
if (where < 0)
where = 0;
ssize_t rc;
char *dflt = size_to_human_string(0, *res);
- DBG(FRONTEND, ul_debug("ui: get_size (default=%ju)", *res));
+ DBG(UI, ul_debug("get_size (default=%ju)", *res));
ui_clean_info();
}
if (rc == 0) {
- DBG(FRONTEND, ul_debug("ui: get_size user=%ju, power=%d, sectors=%s",
+ DBG(UI, ul_debug("get_size user=%ju, power=%d, sectors=%s",
user, pwr, insec ? "yes" : "no"));
if (insec)
user *= cf->cxt->sector_size;
*res = user;
free(dflt);
- DBG(FRONTEND, ul_debug("ui: get_size (result=%ju, rc=%zd)", *res, rc));
+ DBG(UI, ul_debug("get_size (result=%ju, rc=%zd)", *res, rc));
return rc;
}
struct fdisk_parttype *t = NULL;
int has_typestr = 0;
- DBG(FRONTEND, ul_debug("ui: asking for parttype."));
+ DBG(UI, ul_debug("asking for parttype."));
/* create cfdisk menu according to label types, note that the
* last cm[] item has to be empty -- so nitems + 1 */
free((char *) cm[i].name);
}
free(cm);
- DBG(FRONTEND, ul_debug("ui: get parrtype done [type=%s] ", t ? t->name : NULL));
+ DBG(UI, ul_debug("get parrtype done [type=%s] ", t ? t->name : NULL));
return t;
}
assert(cf);
- DBG(FRONTEND, ul_debug("ui: asking for new disklabe."));
+ DBG(UI, ul_debug("asking for new disklabe."));
/* create cfdisk menu according to libfdisk labels, note that the
* last cm[] item has to be empty -- so nitems + 1 */
done:
menu_pop(cf);
free(cm);
- DBG(FRONTEND, ul_debug("ui: create label done [rc=%d] ", rc));
+ DBG(UI, ul_debug("create label done [rc=%d] ", rc));
return rc;
}
} else if (key != 'w' && key != 'W')
key = tolower(key); /* case insensitive except 'W'rite */
- DBG(FRONTEND, ul_debug("ui: main menu action: key=%c", key));
+ DBG(MENU, ul_debug("main menu action: key=%c", key));
if (cf->menu->ignore && strchr(cf->menu->ignore, key)) {
- DBG(FRONTEND, ul_debug(" ignore '%c'", key));
+ DBG(MENU, ul_debug(" ignore '%c'", key));
return 0;
}
pa = get_current_partition(cf);
n = fdisk_partition_get_partno(pa);
- DBG(FRONTEND, ul_debug("menu action on %p", pa));
+ DBG(MENU, ul_debug("menu action on %p", pa));
ui_clean_hint();
ui_clean_info();
{
int rc = 0;
- DBG(FRONTEND, ul_debug("ui: start COLS=%d, LINES=%d", COLS, LINES));
+ DBG(UI, ul_debug("start COLS=%d, LINES=%d", COLS, LINES));
if (!fdisk_dev_has_disklabel(cf->cxt) || cf->zero_start) {
rc = ui_create_label(cf);
if (ui_menu_move(cf, key) == 0)
continue;
- DBG(FRONTEND, ul_debug("ui: main action key >%c<.", key));
+ DBG(UI, ul_debug("main action key >%c<.", key));
switch (key) {
case KEY_DOWN:
menu_pop(cf);
- DBG(FRONTEND, ul_debug("ui: end"));
+ DBG(UI, ul_debug("end"));
return 0;
}
fdisk_init_debug(0);
scols_init_debug(0);
-
+ cfdisk_init_debug();
cf->cxt = fdisk_new_context();
if (!cf->cxt)
err(EXIT_FAILURE, _("failed to allocate libfdisk context"));
rc = fdisk_context_deassign_device(cf->cxt, cf->nwrites == 0);
fdisk_free_context(cf->cxt);
- DBG(FRONTEND, ul_debug("bye! [rc=%d]", rc));
+ DBG(MISC, ul_debug("bye! [rc=%d]", rc));
return rc == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}