Statistics
| Branch: | Revision:

iof-bird-daemon / nest / cli.h @ f3792601

History | View | Annotate | Download (1.29 KB)

1 7d3aab1c Martin Mares
/*
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 */
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;
31 b9672a84 Martin Mares
  void (*cont)(struct cli *c);
32 ffb59d24 Martin Mares
  void (*cleanup)(struct cli *c);
33 b9672a84 Martin Mares
  void *rover;                                /* Private to continuation routine */
34
  int last_reply;
35 bc2fb680 Martin Mares
  struct linpool *parser_pool;                /* Pool used during parsing */
36 7d3aab1c Martin Mares
} cli;
37
38
extern pool *cli_pool;
39 bc2fb680 Martin Mares
extern struct cli *this_cli;                /* Used during parsing */
40 7d3aab1c Martin Mares
41 b9672a84 Martin Mares
/* Functions to be called by command handlers */
42
43
void cli_printf(cli *, int, char *, ...);
44 35793769 Martin Mares
#define cli_msg(x...) cli_printf(this_cli, x)
45 b9672a84 Martin Mares
46
/* Functions provided to sysdep layer */
47
48 7d3aab1c Martin Mares
cli *cli_new(void *);
49
void cli_init(void);
50
void cli_free(cli *);
51
void cli_kick(cli *);
52
void cli_written(cli *);
53
54 b9672a84 Martin Mares
/* Functions provided by sysdep layer */
55 7d3aab1c Martin Mares
56
int cli_write(cli *);
57
int cli_get_command(cli *);
58
59
#endif