Use readline only if we have the header files
authorAlan T. DeKok <aland@freeradius.org>
Wed, 28 Apr 2010 09:01:14 +0000 (11:01 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 29 Apr 2010 08:19:18 +0000 (10:19 +0200)
Otherwise people install libreadline, and then the compile stage
fails because there's no header files

src/main/radmin.c

index daacf61..e86bdca 100644 (file)
@@ -47,29 +47,26 @@ RCSID("$Id$")
 #endif
 
 #ifdef HAVE_LIBREADLINE
+
 #if defined(HAVE_READLINE_READLINE_H)
 #include <readline/readline.h>
+#define USE_READLINE (1)
 #elif defined(HAVE_READLINE_H)
 #include <readline.h>
-#else /* !defined(HAVE_READLINE_H) */
-extern char *readline ();
+#define USE_READLINE (1)
 #endif /* !defined(HAVE_READLINE_H) */
-char *cmdline = NULL;
-#else /* !defined(HAVE_READLINE_READLINE_H) */
-  /* no readline */
+
 #endif /* HAVE_LIBREADLINE */
 
 #ifdef HAVE_READLINE_HISTORY
 #if defined(HAVE_READLINE_HISTORY_H)
 #include <readline/history.h>
+#define USE_READLINE_HISTORY (1)
 #elif defined(HAVE_HISTORY_H)
 #include <history.h>
-#else /* !defined(HAVE_HISTORY_H) */
-extern void add_history ();
-extern int write_history ();
-extern int read_history ();
+#define USE_READLINE_HISTORY (1)
 #endif /* defined(HAVE_READLINE_HISTORY_H) */
-  /* no history */
+
 #endif /* HAVE_READLINE_HISTORY */
 
 /*
@@ -431,9 +428,11 @@ int main(int argc, char **argv)
         */
        if (input_file && !quiet && !isatty(STDIN_FILENO)) quiet = 1;
 
-#ifdef HAVE_LIBREADLINE
+#ifdef USE_READLINE
        if (!quiet) {
+#ifdef USE_READLINE_HISTORY
                using_history();
+#endif
                rl_bind_key('\t', rl_insert);
        }
 #endif
@@ -510,7 +509,7 @@ int main(int argc, char **argv)
         */
 
        while (1) {
-#ifndef HAVE_LIBREADLINE
+#ifndef USE_READLINE
                if (!quiet) {
                        printf("radmin> ");
                        fflush(stdout);
@@ -526,7 +525,9 @@ int main(int argc, char **argv)
                                continue;
                        }
                        
+#ifdef USE_READLINE_HISTORY
                        add_history(line);
+#endif
                } else          /* quiet, or no readline */
 #endif
                {