]>
Commit | Line | Data |
---|---|---|
acddc0ed | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
af2567b6 DL |
2 | /* |
3 | * Testing shim and API examples for the new CLI backend. | |
4 | * | |
5 | * Minimal main() to run grammar_sandbox standalone. | |
6 | * [split off grammar_sandbox.c 2017-01-23] | |
7 | * -- | |
8 | * Copyright (C) 2016 Cumulus Networks, Inc. | |
9 | * Copyright (C) 2017 David Lamparter for NetDEF, Inc. | |
af2567b6 DL |
10 | */ |
11 | ||
b45ac5f5 DL |
12 | #ifdef HAVE_CONFIG_H |
13 | #include "config.h" | |
14 | #endif | |
15 | ||
af2567b6 | 16 | #include "command.h" |
1c0d8808 | 17 | #include "lib_vty.h" |
af2567b6 | 18 | |
154b9e8f | 19 | static void vty_do_exit(int isexit) |
af2567b6 | 20 | { |
d62a17ae | 21 | printf("\nend.\n"); |
154b9e8f DL |
22 | if (!isexit) |
23 | exit(0); | |
af2567b6 DL |
24 | } |
25 | ||
cd9d0537 | 26 | struct event_loop *master; |
af2567b6 DL |
27 | |
28 | int main(int argc, char **argv) | |
29 | { | |
e6685141 | 30 | struct event event; |
af2567b6 | 31 | |
ce50d11c | 32 | master = event_master_create(NULL); |
af2567b6 | 33 | |
0bdeb5e5 | 34 | zlog_aux_init("NONE: ", LOG_DEBUG); |
af2567b6 | 35 | |
d62a17ae | 36 | /* Library inits. */ |
37 | cmd_init(1); | |
8586a88a DS |
38 | cmd_hostname_set("test"); |
39 | cmd_domainname_set("testdomainname"); | |
af2567b6 | 40 | |
2950f5da | 41 | vty_init(master, true); |
1c0d8808 | 42 | lib_cmd_init(); |
390a8862 | 43 | nb_init(master, NULL, 0, false); |
af2567b6 | 44 | |
d62a17ae | 45 | vty_stdio(vty_do_exit); |
af2567b6 | 46 | |
d62a17ae | 47 | /* Fetch next active thread. */ |
de2754be DS |
48 | while (event_fetch(master, &event)) |
49 | event_call(&event); | |
af2567b6 | 50 | |
d62a17ae | 51 | /* Not reached. */ |
52 | exit(0); | |
af2567b6 | 53 | } |