]>
Commit | Line | Data |
---|---|---|
2bb57c68 DL |
1 | /* |
2 | * generic CLI test helper functions | |
3 | * | |
4 | * Copyright (C) 2015 by David Lamparter, | |
5 | * for Open Source Routing / NetDEF, Inc. | |
6 | * | |
7 | * Quagga is free software; you can redistribute it and/or modify it | |
8 | * under the terms of the GNU General Public License as published by the | |
9 | * Free Software Foundation; either version 2, or (at your option) any | |
10 | * later version. | |
11 | * | |
12 | * Quagga is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with Quagga; see the file COPYING. If not, write to the Free | |
19 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
20 | * 02111-1307, USA. | |
21 | */ | |
22 | ||
23 | #include <zebra.h> | |
24 | ||
25 | #include "thread.h" | |
26 | #include "vty.h" | |
27 | #include "command.h" | |
28 | #include "memory.h" | |
fc7948fa | 29 | #include "memory_vty.h" |
2bb57c68 DL |
30 | #include "log.h" |
31 | ||
32 | #include "common-cli.h" | |
33 | ||
34 | struct thread_master *master; | |
35 | ||
36 | int dump_args(struct vty *vty, const char *descr, | |
6a23719c | 37 | int argc, struct cmd_token *argv[]) |
2bb57c68 DL |
38 | { |
39 | int i; | |
40 | vty_out (vty, "%s with %d args.%s", descr, argc, VTY_NEWLINE); | |
41 | for (i = 0; i < argc; i++) | |
42 | { | |
6a23719c | 43 | vty_out (vty, "[%02d]: %s%s", i, argv[i]->arg, VTY_NEWLINE); |
2bb57c68 DL |
44 | } |
45 | ||
46 | return CMD_SUCCESS; | |
47 | } | |
48 | ||
49 | static void vty_do_exit(void) | |
50 | { | |
51 | printf ("\nend.\n"); | |
52 | exit (0); | |
53 | } | |
54 | ||
55 | /* main routine. */ | |
56 | int | |
57 | main (int argc, char **argv) | |
58 | { | |
59 | struct thread thread; | |
60 | ||
61 | /* Set umask before anything for security */ | |
62 | umask (0027); | |
63 | ||
64 | /* master init. */ | |
65 | master = thread_master_create (); | |
66 | ||
34be9094 | 67 | zlog_default = openzlog ("common-cli", ZLOG_NONE, 0, |
2bb57c68 DL |
68 | LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON); |
69 | zlog_set_level (NULL, ZLOG_DEST_SYSLOG, ZLOG_DISABLED); | |
70 | zlog_set_level (NULL, ZLOG_DEST_STDOUT, ZLOG_DISABLED); | |
71 | zlog_set_level (NULL, ZLOG_DEST_MONITOR, LOG_DEBUG); | |
72 | ||
73 | /* Library inits. */ | |
74 | cmd_init (1); | |
75 | host.name = strdup ("test"); | |
76 | ||
77 | vty_init (master); | |
78 | memory_init (); | |
79 | ||
80 | test_init (); | |
81 | ||
82 | vty_stdio (vty_do_exit); | |
83 | ||
84 | /* Fetch next active thread. */ | |
85 | while (thread_fetch (master, &thread)) | |
86 | thread_call (&thread); | |
87 | ||
88 | /* Not reached. */ | |
89 | exit (0); | |
90 | } | |
91 |