Statistics
| Branch: | Revision:

iof-bird-daemon / client / client.c @ 7211be1c

History | View | Annotate | Download (1.11 KB)

1
/*
2
 *        BIRD Client
3
 *
4
 *        (c) 1999--2000 Martin Mares <mj@ucw.cz>
5
 *
6
 *        Can be freely distributed and used under the terms of the GNU GPL.
7
 */
8

    
9
#include <stdio.h>
10
#include <string.h>
11
#include <stdlib.h>
12
#include <unistd.h>
13
#include <readline/readline.h>
14
#include <readline/history.h>
15

    
16
#include "nest/bird.h"
17
#include "lib/resource.h"
18
#include "client/client.h"
19

    
20
static char *opt_list = "";
21

    
22
static void
23
usage(void)
24
{
25
  fprintf(stderr, "Usage: birdc\n");
26
  exit(1);
27
}
28

    
29
static void
30
parse_args(int argc, char **argv)
31
{
32
  int c;
33

    
34
  while ((c = getopt(argc, argv, opt_list)) >= 0)
35
    switch (c)
36
      {
37
      default:
38
        usage();
39
      }
40
  if (optind < argc)
41
    usage();
42
}
43

    
44
static char *
45
get_command(void)
46
{
47
  static char *cmd_buffer;
48

    
49
  if (cmd_buffer)
50
    free(cmd_buffer);
51
  cmd_buffer = readline("bird> ");
52
  if (!cmd_buffer)
53
    exit(0);
54
  if (cmd_buffer[0])
55
    add_history(cmd_buffer);
56
  return cmd_buffer;
57
}
58

    
59
int
60
main(int argc, char **argv)
61
{
62
#ifdef HAVE_LIBDMALLOC
63
  if (!getenv("DMALLOC_OPTIONS"))
64
    dmalloc_debug(0x2f03d00);
65
#endif
66

    
67
  parse_args(argc, argv);
68

    
69
  for(;;)
70
    {
71
      char *c = get_command();
72
      puts(c);
73
    }
74
}