aboutsummaryrefslogtreecommitdiff
path: root/ui.h
blob: 77a5bc93da66d63f949af37f1c097eda7c3a9515 (plain)
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
56
57
58
59
60
61
62
63
#ifndef UI_H
#define UI_H 1

#include <ncurses.h>
#include <stdint.h>

#define MAX_PASSWD_LEN	128

#define UICB_OK		0
#define UICB_ERR_UNDEF	1
#define UICB_ERR_CB	2
#define UICB_ERR_BUF	3

#define DOUI_OK		0
#define DOUI_ERR	1
#define DOUI_TMOUT	2
#define DOUI_PASSWD	3

#define UILOOP_TIMEOUT	1

#define UIKEY_ENTER	10
#define UIKEY_BACKSPACE	7
#define UIKEY_ESC	27
#define UIKEY_DOWN	2
#define UIKEY_UP	3
#define UIKEY_LEFT	4
#define UIKEY_RIGHT	5


typedef int (*ui_callback)(WINDOW *, void *, bool);

struct nask_ui {
  ui_callback ui_elt_cb;
  WINDOW *wnd;
  void *data;
  struct nask_ui *next;
};

void
register_ui_elt(ui_callback uicb, void *data, WINDOW *wnd);

void
unregister_ui_elt(void *data);

void
ui_thrd_force_update(void);

WINDOW *
init_ui(void);

void
free_ui(void);

int
do_ui(int fifo_fd);

void
stop_ui(void);

bool
is_passwd_from_ui(void);

#endif