]>
Commit | Line | Data |
---|---|---|
7d3aab1c MM |
1 | /* |
2 | * BIRD Internet Routing Daemon -- Command-Line Interface | |
3 | * | |
4 | * (c) 1999 Martin Mares <mj@ucw.cz> | |
5 | * | |
6 | * Can be freely distributed and used under the terms of the GNU GPL. | |
7 | */ | |
8 | ||
9 | #ifndef _BIRD_CLI_H_ | |
10 | #define _BIRD_CLI_H_ | |
11 | ||
12 | #include "lib/resource.h" | |
13 | #include "lib/event.h" | |
14 | ||
15 | #define CLI_RX_BUF_SIZE 4096 | |
16 | #define CLI_TX_BUF_SIZE 4096 | |
17 | ||
18 | struct cli_out { | |
19 | struct cli_out *next; | |
20 | byte *wpos, *outpos, *end; | |
21 | byte buf[0]; | |
22 | }; | |
23 | ||
24 | typedef struct cli { | |
25 | pool *pool; | |
26 | void *priv; /* Private to sysdep layer */ | |
7d3aab1c MM |
27 | byte rx_buf[CLI_RX_BUF_SIZE]; |
28 | byte *rx_pos, *rx_aux; /* sysdep */ | |
29 | struct cli_out *tx_buf, *tx_pos, *tx_write; | |
30 | event *event; | |
b9672a84 | 31 | void (*cont)(struct cli *c); |
ffb59d24 | 32 | void (*cleanup)(struct cli *c); |
b9672a84 MM |
33 | void *rover; /* Private to continuation routine */ |
34 | int last_reply; | |
bc2fb680 | 35 | struct linpool *parser_pool; /* Pool used during parsing */ |
7d3aab1c MM |
36 | } cli; |
37 | ||
38 | extern pool *cli_pool; | |
bc2fb680 | 39 | extern struct cli *this_cli; /* Used during parsing */ |
7d3aab1c | 40 | |
b9672a84 MM |
41 | /* Functions to be called by command handlers */ |
42 | ||
43 | void cli_printf(cli *, int, char *, ...); | |
35793769 | 44 | #define cli_msg(x...) cli_printf(this_cli, x) |
b9672a84 MM |
45 | |
46 | /* Functions provided to sysdep layer */ | |
47 | ||
7d3aab1c MM |
48 | cli *cli_new(void *); |
49 | void cli_init(void); | |
50 | void cli_free(cli *); | |
51 | void cli_kick(cli *); | |
52 | void cli_written(cli *); | |
7d3aab1c | 53 | |
b9672a84 | 54 | /* Functions provided by sysdep layer */ |
7d3aab1c MM |
55 | |
56 | int cli_write(cli *); | |
7d3aab1c MM |
57 | int cli_get_command(cli *); |
58 | ||
59 | #endif |