summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/Makefile14
-rw-r--r--client/birdc.c21
-rw-r--r--client/commands.c2
3 files changed, 29 insertions, 8 deletions
diff --git a/client/Makefile b/client/Makefile
index a1578766..fccb8346 100644
--- a/client/Makefile
+++ b/client/Makefile
@@ -1,11 +1,11 @@
-source=commands.c util.c client.c
-root-rel=../
-dir-name=client
+src := commands.c util.c client.c
+obj := $(src-o-files)
-clients := $(client) birdcl
+$(all-client)
-source-dep := $(source) $(addsuffix .c,$(clients))
+$(o)commands.o: $(objdir)/conf/commands.h
-subdir: $(addsuffix .o,$(clients))
+$(exedir)/birdc: $(o)birdc.o
+$(exedir)/birdc: LIBS += $(CLIENT_LIBS)
-include ../Rules
+$(exedir)/birdcl: $(o)birdcl.o
diff --git a/client/birdc.c b/client/birdc.c
index 8aa01c17..f1aea2fe 100644
--- a/client/birdc.c
+++ b/client/birdc.c
@@ -29,6 +29,9 @@ static int prompt_active;
extern int _rl_vis_botlin;
extern void _rl_move_vert(int);
+#define HISTORY "/.birdc_history"
+static char *history_file;
+
static void
add_history_dedup(char *cmd)
{
@@ -138,8 +141,24 @@ input_help(int arg, int key UNUSED)
}
void
+history_init(void)
+{
+ const char *homedir = getenv("HOME");
+ if (!homedir)
+ homedir = ".";
+ history_file = malloc(strlen(homedir) + sizeof(HISTORY));
+ if (!history_file)
+ die("couldn't alloc enough memory for history file name");
+
+ sprintf(history_file, "%s%s", homedir, HISTORY);
+ read_history(history_file);
+}
+
+void
input_init(void)
{
+ if (interactive)
+ history_init();
rl_readline_name = "birdc";
rl_add_defun("bird-complete", input_complete, '\t');
rl_add_defun("bird-help", input_help, '?');
@@ -217,5 +236,7 @@ cleanup(void)
return;
input_hide();
+ if (interactive)
+ write_history(history_file);
rl_callback_handler_remove();
}
diff --git a/client/commands.c b/client/commands.c
index 0da7d835..fdf2652a 100644
--- a/client/commands.c
+++ b/client/commands.c
@@ -7,8 +7,8 @@
*/
#include <stdio.h>
-#include <ctype.h>
#include <stdlib.h>
+#include <ctype.h>
#include "nest/bird.h"
#include "lib/resource.h"