diff --git a/include/nftables.h b/include/nftables.h index 3394e32..c3d3dbf 100644 --- a/include/nftables.h +++ b/include/nftables.h @@ -31,7 +31,14 @@ extern unsigned int debug_level; extern const char *include_paths[INCLUDE_PATHS_MAX]; struct parser_state; +#ifdef HAVE_LIBREADLINE extern int cli_init(struct parser_state *state); +#else +static inline int cli_init(struct parser_state *state) +{ + return -1; +} +#endif extern void cli_exit(void); extern void cli_display(const char *fmt, va_list ap) __fmtstring(1, 0); diff --git a/src/main.c b/src/main.c index de2efe6..8dc0768 100644 --- a/src/main.c +++ b/src/main.c @@ -335,14 +335,12 @@ int main(int argc, char * const *argv) if (scanner_read_file(scanner, filename, &internal_location) < 0) goto out; } else if (interactive) { -#ifdef HAVE_LIBREADLINE - cli_init(&state); + if (cli_init(&state) < 0) { + fprintf(stderr, "%s: CLI not supported in this build\n", + argv[0]); + exit(NFT_EXIT_FAILURE); + } return 0; -#else - fprintf(stderr, "%s: interactive CLI not supported in this build\n", - argv[0]); - exit(NFT_EXIT_FAILURE); -#endif } else { fprintf(stderr, "%s: no command specified\n", argv[0]); exit(NFT_EXIT_FAILURE);