]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Testing shim and API examples for the new CLI backend. | |
3 | * | |
4 | * Minimal main() to run grammar_sandbox standalone. | |
5 | * [split off grammar_sandbox.c 2017-01-23] | |
6 | * -- | |
7 | * Copyright (C) 2016 Cumulus Networks, Inc. | |
8 | * Copyright (C) 2017 David Lamparter for NetDEF, Inc. | |
9 | * | |
10 | * This file is part of FreeRangeRouting (FRR). | |
11 | * | |
12 | * FRR is free software; you can redistribute it and/or modify it under the | |
13 | * terms of the GNU General Public License as published by the Free Software | |
14 | * Foundation; either version 2, or (at your option) any later version. | |
15 | * | |
16 | * FRR is distributed in the hope that it will be useful, but WITHOUT ANY | |
17 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
18 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
19 | * details. | |
20 | * | |
21 | * You should have received a copy of the GNU General Public License along | |
22 | * with this program; see the file COPYING; if not, write to the Free Software | |
23 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
24 | */ | |
25 | ||
26 | #include "command.h" | |
27 | #include "memory_vty.h" | |
28 | ||
29 | static void vty_do_exit(int isexit) | |
30 | { | |
31 | printf("\nend.\n"); | |
32 | if (!isexit) | |
33 | exit(0); | |
34 | } | |
35 | ||
36 | struct thread_master *master; | |
37 | ||
38 | int main(int argc, char **argv) | |
39 | { | |
40 | struct thread thread; | |
41 | ||
42 | master = thread_master_create(NULL); | |
43 | ||
44 | openzlog("grammar_sandbox", "NONE", 0, LOG_CONS | LOG_NDELAY | LOG_PID, | |
45 | LOG_DAEMON); | |
46 | zlog_set_level(ZLOG_DEST_SYSLOG, ZLOG_DISABLED); | |
47 | zlog_set_level(ZLOG_DEST_STDOUT, LOG_DEBUG); | |
48 | zlog_set_level(ZLOG_DEST_MONITOR, ZLOG_DISABLED); | |
49 | ||
50 | /* Library inits. */ | |
51 | cmd_init(1); | |
52 | host.name = strdup("test"); | |
53 | ||
54 | vty_init(master); | |
55 | memory_init(); | |
56 | ||
57 | vty_stdio(vty_do_exit); | |
58 | ||
59 | /* Fetch next active thread. */ | |
60 | while (thread_fetch(master, &thread)) | |
61 | thread_call(&thread); | |
62 | ||
63 | /* Not reached. */ | |
64 | exit(0); | |
65 | } |