summaryrefslogtreecommitdiff
path: root/lib/grammar_sandbox_main.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2016-12-16 08:11:37 +0100
committerDavid Lamparter <equinox@opensourcerouting.org>2017-01-23 21:52:44 +0100
commitaf2567b646a9bdf22c3f47caeedc8f2de1dac81c (patch)
tree776cfcdf2ed5be4069bec6bff51aa6f428c026d9 /lib/grammar_sandbox_main.c
parent818a5168a1c141beaa63fe887d195123a23a012e (diff)
grammar_sandbox: add into daemons if DEV_BUILD
Also adds "grammar access <node>" to test/dump an existing command node (e.g. BGP_NODE). Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'lib/grammar_sandbox_main.c')
-rw-r--r--lib/grammar_sandbox_main.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/lib/grammar_sandbox_main.c b/lib/grammar_sandbox_main.c
new file mode 100644
index 0000000000..5deef406c1
--- /dev/null
+++ b/lib/grammar_sandbox_main.c
@@ -0,0 +1,64 @@
+/*
+ * Testing shim and API examples for the new CLI backend.
+ *
+ * Minimal main() to run grammar_sandbox standalone.
+ * [split off grammar_sandbox.c 2017-01-23]
+ * --
+ * Copyright (C) 2016 Cumulus Networks, Inc.
+ * Copyright (C) 2017 David Lamparter for NetDEF, Inc.
+ *
+ * This file is part of FreeRangeRouting (FRR).
+ *
+ * FRR is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2, or (at your option) any later version.
+ *
+ * FRR is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FRR; see the file COPYING. If not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "command.h"
+#include "memory_vty.h"
+
+static void vty_do_exit(void)
+{
+ printf ("\nend.\n");
+ exit (0);
+}
+
+struct thread_master *master;
+
+int main(int argc, char **argv)
+{
+ struct thread thread;
+
+ master = thread_master_create ();
+
+ zlog_default = openzlog ("grammar_sandbox", ZLOG_NONE, 0,
+ LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
+ zlog_set_level (NULL, ZLOG_DEST_SYSLOG, ZLOG_DISABLED);
+ zlog_set_level (NULL, ZLOG_DEST_STDOUT, LOG_DEBUG);
+ zlog_set_level (NULL, ZLOG_DEST_MONITOR, ZLOG_DISABLED);
+
+ /* Library inits. */
+ cmd_init (1);
+ host.name = strdup ("test");
+
+ vty_init (master);
+ memory_init ();
+
+ vty_stdio (vty_do_exit);
+
+ /* Fetch next active thread. */
+ while (thread_fetch (master, &thread))
+ thread_call (&thread);
+
+ /* Not reached. */
+ exit (0);
+}