#include <stdio.h>
#include <signal.h>
#include <unistd.h>
-#include <setjmp.h>
#include <getopt.h>
#ifdef HAVE_LIBREADLINE
+#include <setjmp.h>
#include <readline/readline.h>
#include <readline/history.h>
#endif
#ifdef HAVE_LIBREADLINE
static const struct TreeNode *compcur;
+static sigjmp_buf jmpbuf;
+static bool batch;
static char* my_generator (const char* text, int state)
int main_loop_continue;
static struct ngadmin *nga;
-static sigjmp_buf jmpbuf;
static struct termios orig_term;
struct termios current_term;
-static bool batch;
NORET static void handler (int sig)
case SIGINT:
printf("interrupt\n");
+#ifdef HAVE_LIBREADLINE
current_term.c_lflag |= ECHO;
tcsetattr(STDIN_FILENO, TCSANOW, ¤t_term);
if (!batch && main_loop_continue)
siglongjmp(jmpbuf, 1);
+#endif
default:
ngadmin_close(nga);
current_term = orig_term;
#ifdef HAVE_LIBREADLINE
batch = false;
-#else
- batch = true;
#endif
opterr = 0;
switch (n) {
case 'a':
+#ifdef HAVE_LIBREADLINE
batch = true;
+#endif
break;
case 'b':
if (ngadmin_useGlobalBroadcast(nga, global) != ERR_OK)
goto end;
+#ifdef HAVE_LIBREADLINE
/* non-TTY inputs are automatically set to batch mode */
if (!isatty(STDIN_FILENO))
batch = true;
+#endif
if (password != NULL)
ngadmin_setPassword(nga, password);
/* read user input */
line = NULL;
n = 0;
+#ifdef HAVE_LIBREADLINE
if (batch)
n = getline(&line, (size_t*)&i, stdin);
-#ifdef HAVE_LIBREADLINE
else
line = readline("> ");
+#else
+ n = getline(&line, (size_t*)&i, stdin);
#endif
if (n < 0 || line == NULL)
goto end;