+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <setjmp.h>
#include <getopt.h>
+#ifdef HAVE_LIBREADLINE
#include <readline/readline.h>
#include <readline/history.h>
+#endif
#include "common.h"
#include "commands.h"
#define MAXCOM 32
-int main_loop_continue = 1;
+int main_loop_continue;
static const struct TreeNode* getSubCom (char **com, int n, int *t)
}
+#ifdef HAVE_LIBREADLINE
static const struct TreeNode *compcur;
return matches;
}
+#endif /* HAVE_LIBREADLINE */
static struct ngadmin *nga;
tcgetattr(STDIN_FILENO, &orig_term);
current_term = orig_term;
+#ifdef HAVE_LIBREADLINE
batch = false;
+#else
+ batch = true;
+#endif
opterr = 0;
if (mac != NULL && pre_login(mac, retries) != 0)
goto end;
- if (batch) {
- /* in batch mode, we must be logged to continue */
- if (ngadmin_getCurrentSwitch(nga) == NULL) {
- printf("must be logged\n");
- goto end;
- }
- } else {
+ if (!batch) {
+#ifdef HAVE_LIBREADLINE
/* initialize readline functions */
rl_attempted_completion_function = my_completion;
rl_completion_entry_function = my_generator;
sigsetjmp(jmpbuf, 1);
+#endif
}
+ main_loop_continue = 1;
+
while (main_loop_continue) {
/* read user input */
line = NULL;
n = 0;
if (batch)
n = getline(&line, (size_t*)&i, stdin);
+#ifdef HAVE_LIBREADLINE
else
line = readline("> ");
+#endif
if (n < 0 || line == NULL)
goto end;
free(line);
continue;
} else {
+#ifdef HAVE_LIBREADLINE
if (!batch)
add_history(line);
+#endif
free(line);
}
AM_INIT_AUTOMAKE
-LT_PREREQ([2.4])
-LT_INIT
-
# Checks for programs
AC_PROG_CC
AM_PROG_CC_C_O
+AC_PROG_LIBTOOL
+AC_PROG_INSTALL
+
+LT_PREREQ([2.4])
+LT_INIT
+
+
+AC_ARG_WITH([readline],
+ [AS_HELP_STRING([--with-readline], [support fancy command line editing @<:@default=check@:>@])],
+ [with_readline="$withval"], [with_readline=check])
CFLAGS="-Wall -Wextra -Os"
# Checks for libraries
-AC_CHECK_LIB([readline], [readline])
+if test "x${with_readline}" != xno; then
+ AC_CHECK_LIB([readline], [readline], [], [
+ if test "x${with_readline}" = xyes; then
+ AC_MSG_ERROR([
+----------------------------------------
+Unable to find readline library
+----------------------------------------])
+ fi
+ ])
+fi
# Checks for header files
AC_CHECK_HEADERS([arpa/inet.h stdlib.h string.h sys/ioctl.h termios.h unistd.h])
AC_OUTPUT
+
+echo "
+${PACKAGE_NAME} version ${PACKAGE_VERSION}
+Prefix.............: ${prefix}
+Debug..............:
+Compiler...........: ${CC} ${CFLAGS} ${CPPFLAGS}
+"
+
+