From patchwork Thu Oct 9 16:33:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pablo Neira Ayuso X-Patchwork-Id: 398082 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 0712F140080 for ; Fri, 10 Oct 2014 03:31:51 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751372AbaJIQbu (ORCPT ); Thu, 9 Oct 2014 12:31:50 -0400 Received: from mail.us.es ([193.147.175.20]:41049 "EHLO mail.us.es" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751170AbaJIQbt (ORCPT ); Thu, 9 Oct 2014 12:31:49 -0400 Received: (qmail 22142 invoked from network); 9 Oct 2014 18:31:47 +0200 Received: from unknown (HELO us.es) (192.168.2.11) by us.es with SMTP; 9 Oct 2014 18:31:47 +0200 Received: (qmail 22759 invoked by uid 507); 9 Oct 2014 16:31:47 -0000 X-Qmail-Scanner-Diagnostics: from 127.0.0.1 by antivirus1 (envelope-from , uid 501) with qmail-scanner-2.10 (clamdscan: 0.98.4/19489. spamassassin: 3.3.2. Clear:RC:1(127.0.0.1):SA:0(-103.2/7.5):. Processed in 2.776704 secs); 09 Oct 2014 16:31:47 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on antivirus1 X-Spam-Level: X-Spam-Status: No, score=-103.2 required=7.5 tests=BAYES_50,SMTPAUTH_US, SPF_HELO_FAIL,USER_IN_WHITELIST autolearn=disabled version=3.3.2 X-Spam-ASN: AS12715 87.216.0.0/16 X-Envelope-From: pneira@us.es Received: from unknown (HELO antivirus1) (127.0.0.1) by us.es with SMTP; 9 Oct 2014 16:31:44 -0000 Received: from 192.168.1.13 (192.168.1.13) by antivirus1 (F-Secure/fsigk_smtp/412/antivirus1); Thu, 09 Oct 2014 18:31:44 +0200 (CEST) X-Virus-Status: clean(F-Secure/fsigk_smtp/412/antivirus1) Received: (qmail 18892 invoked from network); 9 Oct 2014 18:31:44 +0200 Received: from 129.166.216.87.static.jazztel.es (HELO us.es) (1984lsi@87.216.166.129) by mail.us.es with AES128-SHA encrypted SMTP; 9 Oct 2014 18:31:44 +0200 Date: Thu, 9 Oct 2014 18:33:10 +0200 From: Pablo Neira Ayuso To: Steven Barth Cc: netfilter-devel@vger.kernel.org Subject: Re: [nft PATCH] build: allow disabling libreadline-support Message-ID: <20141009163310.GA10706@salvia> References: <1412200742-5898-1-git-send-email-cyrus@openwrt.org> <20141009122648.GA17919@salvia> <1412866961.4287.1.camel@openwrt.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1412866961.4287.1.camel@openwrt.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org On Thu, Oct 09, 2014 at 05:02:41PM +0200, Steven Barth wrote: > > Please, add the: > > > > #ifdef HAVE_LIBREADLINE > > > > in cli_init() and cli_exit() in cli.c. It would be good if the cli_init() > > returns a negative value, so you spot the error message below. > > The problem I see here that this would basically mean enclosing most of > cli.c in #ifdef HAVE_LIBREADLINE to avoid depending on readline-headers > and having a rather awkward stub of cli_init in the no-readline case. > > My main point of excluding cli.c in the Makefile from the start is to > avoid this madness. I see, then I'd suggest something like the change (applies on top of your patch). Would you merge this to your patch, including the --without-cli option and resend? Thanks. 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);