From patchwork Wed Sep 2 23:44:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 513707 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (unknown [IPv6:2600:3c00::f03c:91ff:fe6e:bdf7]) by ozlabs.org (Postfix) with ESMTP id 618291401F0 for ; Thu, 3 Sep 2015 09:45:45 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 0B08010AAF; Wed, 2 Sep 2015 16:44:39 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e4.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id BD6C1106E3 for ; Wed, 2 Sep 2015 16:44:37 -0700 (PDT) Received: from bar2.cudamail.com (unknown [192.168.21.12]) by mx1e4.cudamail.com (Postfix) with ESMTPS id 3931E1E0442 for ; Wed, 2 Sep 2015 17:44:37 -0600 (MDT) X-ASG-Debug-ID: 1441237476-03dc53534198d30001-byXFYA Received: from mx1-pf2.cudamail.com ([192.168.24.2]) by bar2.cudamail.com with ESMTP id ja9mzEyTSpkUsvZX (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 02 Sep 2015 17:44:36 -0600 (MDT) X-Barracuda-Envelope-From: blp@nicira.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.2 Received: from unknown (HELO mail-pa0-f49.google.com) (209.85.220.49) by mx1-pf2.cudamail.com with ESMTPS (RC4-SHA encrypted); 2 Sep 2015 23:44:36 -0000 Received-SPF: unknown (mx1-pf2.cudamail.com: Multiple SPF records returned) X-Barracuda-RBL-Trusted-Forwarder: 209.85.220.49 Received: by pacwi10 with SMTP id wi10so26169018pac.3 for ; Wed, 02 Sep 2015 16:44:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=c2JBSXvSwJK8f9XoULlqISvwxqKlvth/RGQx2k2FHV4=; b=jO01HqAtwo7MLcvE5crtyD2ywYH9firfTqhtMoj2tlDM6kKGCCnl28bXMPZUwyvVeb CCFLE5GUg5kPrWtSYLNsezQ42hDs9pU/czvsiE5UqOHy2LfdLi/MidoeZXg1Ih5nzwlS y1esgR4Ot/IQKoELTPXmlbj1GjxpNthpqAs1HwEnufSE9PEHWuu2iPNwYpcHegH7fvc/ SulNtKE7ZgiXqKYf50M9EUyf7miMttaw83i1UJQ/b1RZ/rV+a6DVrlExl6Sv/BzQLB1v cXEbsmlH+BULd1i//jqs33CAjZ+Lg5GdupLWHkbSsICVK9viB+eicz5KHkKkYTqQugmv 3jSw== X-Gm-Message-State: ALoCoQmCTz7dc+GtLc5oOLHZ8m+0r3j7nTfaW6AhRMoCqX6gDSK5DIqxySARcUCMnETqbLTSvLJT X-Received: by 10.68.200.40 with SMTP id jp8mr62586361pbc.16.1441237476162; Wed, 02 Sep 2015 16:44:36 -0700 (PDT) Received: from sigabrt.benpfaff.org ([208.91.2.4]) by smtp.gmail.com with ESMTPSA id f5sm23046151pas.23.2015.09.02.16.44.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 Sep 2015 16:44:35 -0700 (PDT) X-CudaMail-Envelope-Sender: blp@nicira.com X-Barracuda-Apparent-Source-IP: 208.91.2.4 From: Ben Pfaff To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-E2-901094980 X-CudaMail-DTE: 090215 X-CudaMail-Originating-IP: 209.85.220.49 Date: Wed, 2 Sep 2015 16:44:09 -0700 X-ASG-Orig-Subj: [##CM-E2-901094980##][PATCH v2 12/14] db-ctl-base: Make 'cmd_show_tables' argument to ctl_init() optional. Message-Id: <1441237451-17940-12-git-send-email-blp@nicira.com> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1441237451-17940-1-git-send-email-blp@nicira.com> References: <1441237451-17940-1-git-send-email-blp@nicira.com> X-Barracuda-Connect: UNKNOWN[192.168.24.2] X-Barracuda-Start-Time: 1441237476 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Cc: Ben Pfaff Subject: [ovs-dev] [PATCH v2 12/14] db-ctl-base: Make 'cmd_show_tables' argument to ctl_init() optional. X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" This allows the client to omit the "show" command if it doesn't want it. This will be used in an upcoming commit. Signed-off-by: Ben Pfaff --- lib/db-ctl-base.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index b018bad..cf49ac0 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -2036,10 +2036,15 @@ static const struct ctl_command_syntax db_ctl_commands[] = { NULL, "--if-exists,--all", RW}, {"wait-until", 2, INT_MAX, "TABLE RECORD [COLUMN[:KEY]=VALUE]...", pre_cmd_wait_until, cmd_wait_until, NULL, "", RO}, - {"show", 0, 0, "", pre_cmd_show, cmd_show, NULL, "", RO}, {NULL, 0, 0, NULL, NULL, NULL, NULL, NULL, RO}, }; +static void +ctl_register_command(const struct ctl_command_syntax *command) +{ + shash_add_assert(&all_commands, command->name, command); +} + /* Registers commands represented by 'struct ctl_command_syntax's to * 'all_commands'. The last element of 'commands' must be an all-NULL * element. */ @@ -2049,7 +2054,7 @@ ctl_register_commands(const struct ctl_command_syntax *commands) const struct ctl_command_syntax *p; for (p = commands; p->name; p++) { - shash_add_assert(&all_commands, p->name, p); + ctl_register_command(p); } } @@ -2060,9 +2065,15 @@ ctl_init(const struct ctl_table_class tables_[], void (*ctl_exit_func_)(int status)) { tables = tables_; - cmd_show_tables = cmd_show_tables_; ctl_exit_func = ctl_exit_func_; ctl_register_commands(db_ctl_commands); + + cmd_show_tables = cmd_show_tables_; + if (cmd_show_tables) { + static const struct ctl_command_syntax show = + {"show", 0, 0, "", pre_cmd_show, cmd_show, NULL, "", RO}; + ctl_register_command(&show); + } } /* Returns the text for the database commands usage. */