17 |
17 |
18 /** |
18 /** |
19 * Callbacks for event-based actions |
19 * Callbacks for event-based actions |
20 */ |
20 */ |
21 struct console_callbacks { |
21 struct console_callbacks { |
22 /** A line was read from the console */ |
22 /** |
23 void (*on_line) (char *line, void *arg); |
23 * A line was read from the console. |
|
24 * |
|
25 * XXX: currently, line might be NULL on EOF, but this is probably a second callback |
|
26 */ |
|
27 void (*on_line) (const char *line, void *arg); |
24 }; |
28 }; |
25 |
29 |
26 /** |
30 /** |
27 * Configuration info for console operation |
31 * Configuration info for console operation |
28 */ |
32 */ |
47 /** Already initialized? */ |
53 /** Already initialized? */ |
48 bool initialized; |
54 bool initialized; |
49 }; |
55 }; |
50 |
56 |
51 /** |
57 /** |
52 * Initialize the console, setting up the TTY and input handler |
58 * Initialize the console, setting up the TTY and input handler. |
|
59 * |
|
60 * @param console_ptr returned new console struct |
|
61 * @param ev_base the libevent base to use |
|
62 * @param config configuration things for the console |
|
63 * @param callbacks optional callbacks, can be updated later |
|
64 * @param cb_arg option callback argument, can be updated later |
|
65 * @param err returned error info |
53 */ |
66 */ |
54 err_t console_init (struct console **console_ptr, struct event_base *ev_base, const struct console_config *config, |
67 err_t console_init (struct console **console_ptr, struct event_base *ev_base, const struct console_config *config, |
55 const struct console_callbacks *callbacks, void *cb_arg, struct error_info *err); |
68 const struct console_callbacks *callbacks, void *cb_arg, struct error_info *err); |
|
69 |
|
70 /** |
|
71 * Replace the current callbacks with the given new ones. |
|
72 */ |
|
73 void console_set_callbacks (struct console *console, const struct console_callbacks *callbacks, void *cb_arg); |
56 |
74 |
57 /** |
75 /** |
58 * Deinitialize the console, restoring the TTY and releasing resources |
76 * Deinitialize the console, restoring the TTY and releasing resources |
59 */ |
77 */ |
60 void console_destroy (struct console *console); |
78 void console_destroy (struct console *console); |