diff --git a/app/master/tools/master_ctl/Makefile.in b/app/master/tools/master_ctl/Makefile.in index 2182fdb11..0f4d166e3 100644 --- a/app/master/tools/master_ctl/Makefile.in +++ b/app/master/tools/master_ctl/Makefile.in @@ -9,7 +9,7 @@ CFLAGS = -c -g -W -Wall -Wcast-qual -Wcast-align \ ########################################################### #Check system: # Linux, SunOS, Solaris, BSD variants, AIX, HP-UX -SYSLIB = -lreadline -lcurses -lpthread -lz +SYSLIB = -lpthread -lz CHECKSYSRES = @echo "Unknow system type!";exit 1 OSNAME = $(shell uname -s) OSTYPE = $(shell uname -m) @@ -20,20 +20,28 @@ endif ifeq ($(findstring on, $(HAS_READLINE)), on) CFLAGS += -DHAS_READLINE + SYSLIB += -lreadline -lcurses else ifeq ($(findstring ON, $(HAS_READLINE)), ON) CFLAGS += -DHAS_READLINE + SYSLIB += -lreadline -lcurses else ifeq ($(findstring yes, $(HAS_READLINE)), yes) CFLAGS += -DHAS_READLINE + SYSLIB += -lreadline -lcurses else ifeq ($(findstring YES, $(HAS_READLINE)), YES) CFLAGS += -DHAS_READLINE + SYSLIB += -lreadline -lcurses else ifeq ($(findstring on, $(has_readline)), on) CFLAGS += -DHAS_READLINE + SYSLIB += -lreadline -lcurses else ifeq ($(findstring ON, $(has_readline)), ON) CFLAGS += -DHAS_READLINE + SYSLIB += -lreadline -lcurses else ifeq ($(findstring yes, $(has_readline)), yes) CFLAGS += -DHAS_READLINE + SYSLIB += -lreadline -lcurses else ifeq ($(findstring YES, $(has_readline)), YES) CFLAGS += -DHAS_READLINE + SYSLIB += -lreadline -lcurses endif # For FreeBSD @@ -148,7 +156,7 @@ all: RM $(OBJ) @echo "" RM: rm -f $(PROG) -clean: +clean cl: rm -f $(PROG) rm -f $(OBJ) rebuild rb: clean all diff --git a/app/master/tools/master_ctl/main.cpp b/app/master/tools/master_ctl/main.cpp index e572314f2..ab57485d4 100644 --- a/app/master/tools/master_ctl/main.cpp +++ b/app/master/tools/master_ctl/main.cpp @@ -1,6 +1,10 @@ #include "stdafx.h" + +#ifdef HAS_READLINE #include #include +#endif + #include "http_request.h" static bool __verbose = false; @@ -508,7 +512,9 @@ static bool do_quit(const std::vector&, const char*, const char*) static bool do_clear(const std::vector&, const char*, const char*) { #if !defined(__APPLE__) +#ifdef HAS_READLINE rl_clear_screen(0, 0); +#endif #endif printf("\r\n"); return true; @@ -516,17 +522,27 @@ static bool do_clear(const std::vector&, const char*, const char*) static void getline(acl::string& out) { +#ifdef HAS_READLINE const char* prompt = "\033[1;34;40mmaster_ctl>\033[0m "; char* ptr = readline(prompt); - if (ptr == NULL) +#else + printf("master_ctl> "); + fflush(stdout); + char buf[1024]; + char* ptr = fgets(buf, (int) sizeof(buf), stdin); +#endif + if (ptr == NULL || *ptr == 0) { printf("Bye!\r\n"); exit(0); } out = ptr; out.trim_right_line(); + +#ifdef HAS_READLINE if (!out.empty() && !out.equal("y", false) && !out.equal("n", false)) add_history(out.c_str()); +#endif } static struct {