Commit a5d5ecde authored by Tollef Fog Heen's avatar Tollef Fog Heen

Require libedit/readline

Remove a bunch of ifdef code and fix up proper configure check for
libedit.

Fixes #1277
parent e4072d36
...@@ -32,25 +32,23 @@ ...@@ -32,25 +32,23 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#ifdef HAVE_LIBEDIT #include <stdio.h>
# include <stdio.h>
# ifdef HAVE_EDIT_READLINE_READLINE_H #ifdef HAVE_EDIT_READLINE_READLINE_H
# include <edit/readline/readline.h> # include <edit/readline/readline.h>
# elif HAVE_READLINE_READLINE_H #elif HAVE_READLINE_READLINE_H
# include <readline/readline.h> # include <readline/readline.h>
# ifdef HAVE_READLINE_HISTORY_H # ifdef HAVE_READLINE_HISTORY_H
# include <readline/history.h> # include <readline/history.h>
# endif
# else
# include <editline/readline.h>
# endif # endif
#else
# include <editline/readline.h>
#endif #endif
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <poll.h> #include <poll.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
...@@ -61,16 +59,12 @@ ...@@ -61,16 +59,12 @@
#include "vcli.h" #include "vcli.h"
#include "vss.h" #include "vss.h"
#ifdef HAVE_LIBEDIT
#define RL_EXIT(status) \ #define RL_EXIT(status) \
do { \ do { \
rl_callback_handler_remove(); \ rl_callback_handler_remove(); \
exit(status); \ exit(status); \
} while (0) } while (0)
#else
#define RL_EXIT(status) exit(status)
#endif
static double timeout = 5; static double timeout = 5;
...@@ -178,7 +172,6 @@ do_args(int sock, int argc, char * const *argv) ...@@ -178,7 +172,6 @@ do_args(int sock, int argc, char * const *argv)
exit(1); exit(1);
} }
#ifdef HAVE_LIBEDIT
/* Callback for readline, doesn't take a private pointer, so we need /* Callback for readline, doesn't take a private pointer, so we need
* to have a global variable. * to have a global variable.
*/ */
...@@ -228,7 +221,6 @@ varnishadm_completion (const char *text, int start, int end) ...@@ -228,7 +221,6 @@ varnishadm_completion (const char *text, int start, int end)
matches = rl_completion_matches(text, command_generator); matches = rl_completion_matches(text, command_generator);
return (matches); return (matches);
} }
#endif
/* /*
* No arguments given, simply pass bytes on stdin/stdout and CLI socket * No arguments given, simply pass bytes on stdin/stdout and CLI socket
...@@ -242,11 +234,6 @@ pass(int sock) ...@@ -242,11 +234,6 @@ pass(int sock)
int i; int i;
char *answer = NULL; char *answer = NULL;
unsigned u, status; unsigned u, status;
#ifndef HAVE_LIBEDIT
int n;
#endif
#ifdef HAVE_LIBEDIT
_line_sock = sock; _line_sock = sock;
rl_already_prompted = 1; rl_already_prompted = 1;
if (isatty(0)) { if (isatty(0)) {
...@@ -255,7 +242,6 @@ pass(int sock) ...@@ -255,7 +242,6 @@ pass(int sock)
rl_callback_handler_install("", send_line); rl_callback_handler_install("", send_line);
} }
rl_attempted_completion_function = varnishadm_completion; rl_attempted_completion_function = varnishadm_completion;
#endif
fds[0].fd = sock; fds[0].fd = sock;
fds[0].events = POLLIN; fds[0].events = POLLIN;
...@@ -317,25 +303,10 @@ pass(int sock) ...@@ -317,25 +303,10 @@ pass(int sock)
free(answer); free(answer);
answer = NULL; answer = NULL;
} }
#ifdef HAVE_LIBEDIT
rl_forced_update_display(); rl_forced_update_display();
#endif
} }
if (fds[1].revents & POLLIN) { if (fds[1].revents & POLLIN) {
#ifdef HAVE_LIBEDIT
rl_callback_read_char(); rl_callback_read_char();
#else
n = read(fds[1].fd, buf, sizeof buf);
if (n == 0) {
AZ(shutdown(sock, SHUT_WR));
fds[1].fd = -1;
} else if (n < 0) {
RL_EXIT(0);
} else {
buf[n] = '\0';
cli_write(sock, buf);
}
#endif
} }
} }
} }
......
...@@ -156,7 +156,7 @@ PKG_CHECK_MODULES([LIBEDIT], [libedit], ...@@ -156,7 +156,7 @@ PKG_CHECK_MODULES([LIBEDIT], [libedit],
LIBEDIT_CFLAGS="" LIBEDIT_CFLAGS=""
LIBEDIT_LIBS="-ledit ${CURSES_LIBS}" LIBEDIT_LIBS="-ledit ${CURSES_LIBS}"
], ],
[AC_MSG_WARN([libedit not found, disabling libedit support])], [AC_MSG_ERROR([libedit or readline not found])],
[${CURSES_LIBS}])]) [${CURSES_LIBS}])])
# Checks for header files. # Checks for header files.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment