blob: 260e043920c58ab7e3a5c006b3f50f1f4f2799e1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
/*
* BIRD Client
*
* (c) 1999--2000 Martin Mares <mj@ucw.cz>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <readline/readline.h>
#include <readline/history.h>
#include "nest/bird.h"
#include "lib/resource.h"
#include "client/client.h"
static char *opt_list = "";
static void
usage(void)
{
fprintf(stderr, "Usage: birdc\n");
exit(1);
}
static void
parse_args(int argc, char **argv)
{
int c;
while ((c = getopt(argc, argv, opt_list)) >= 0)
switch (c)
{
default:
usage();
}
if (optind < argc)
usage();
}
static char *
get_command(void)
{
static char *cmd_buffer;
if (cmd_buffer)
free(cmd_buffer);
cmd_buffer = readline("bird> ");
if (!cmd_buffer)
exit(0);
if (cmd_buffer[0])
add_history(cmd_buffer);
return cmd_buffer;
}
int
main(int argc, char **argv)
{
#ifdef HAVE_LIBDMALLOC
if (!getenv("DMALLOC_OPTIONS"))
dmalloc_debug(0x2f03d00);
#endif
parse_args(argc, argv);
for(;;)
{
char *c = get_command();
puts(c);
}
}
|