From patchwork Thu Sep 29 15:39:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dirk Feytons X-Patchwork-Id: 676647 X-Patchwork-Delegate: nbd@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3slJkS3Ny7z9sBg for ; Fri, 30 Sep 2016 01:43:12 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=CXkOdGwg; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bpdS2-0005B2-1k; Thu, 29 Sep 2016 15:40:46 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bpdRy-000496-IA for lede-dev@lists.infradead.org; Thu, 29 Sep 2016 15:40:43 +0000 Received: by mail-wm0-x243.google.com with SMTP id b4so11365784wmb.2 for ; Thu, 29 Sep 2016 08:40:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=+NcGW/BWK6s41us17xW1i0StjQUv80d9p3zG4TKj6RI=; b=CXkOdGwg6fKhLvy7hAjg+Ao+LdBU4uAcmuQs7+/3+RsTrqBv66VzhgVA8seTMh0J1q lbxzM5ggK8QhmQmWkcf3+YwrZ9Z1dCDwlxNQqWNPRRgRlhVdEVe9++idtHoHIHKqYaSg xC9Tdfmpy1C7Oy767p19zb+15DXfLev2iEwEx1pMHgD27ztF0yiBWGdsycjs6mzGM+Z7 3qIE+yLDPqpK4935sJFNGECTLOdS7Mh3FoWvp0guUoZjp7jl0Anj4luz5IouqSTnjDAM d7zrz07YqowIPY4jiSzRPSSiwfES+hpisWUWMi+SFSLPmURKw6c79s4afkQ9AQ2dqUyE ai1A== 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; bh=+NcGW/BWK6s41us17xW1i0StjQUv80d9p3zG4TKj6RI=; b=a0rwaWOLCoVAQX4Yf1udAyqRRdQGO4o03HFb69BtC3uIDFsUe4f1AmcCClLWUyNSUP C+smRRZ/h2dSr7XmfYHySQbe+q3LVFBtfOxuGQYat+FCaR/RUhGsjQkig1tNYNKCtIba eNZ/LZf5VxGRGnQLw1S77C+YRdefHACEhsdOTCarnXMhByvPxnVwjubW81EvoWZQMdGb Qlz6jkkFkD4g8Ymzmk4ZoUs5kGne2+No53JT7mMlspxPZtfrO1r/DkLvrunZf934J60/ td4j2tPWnf9jIbHp1MjuKX2pJqYzlg93s1xyktyWuJhSJeTCCLHwUAQ7XP3beeMSysLR 0xfw== X-Gm-Message-State: AA6/9RmXpGneCBja6R1ms/QDEdmesOohcahGh0DW1b1xXMgCMh0qDe6D+Otm0PXH2SpzmQ== X-Received: by 10.28.166.196 with SMTP id p187mr3288302wme.121.1475163620447; Thu, 29 Sep 2016 08:40:20 -0700 (PDT) Received: from cplx1020.edegem.eu.thmulti.com ([141.11.62.7]) by smtp.gmail.com with ESMTPSA id w9sm14682229wjf.47.2016.09.29.08.40.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Sep 2016 08:40:19 -0700 (PDT) From: Dirk Feytons To: lede-dev@lists.infradead.org, nbd@nbd.name Date: Thu, 29 Sep 2016 17:39:56 +0200 Message-Id: <1475163597-11817-1-git-send-email-dirk.feytons@gmail.com> X-Mailer: git-send-email 1.7.9.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160929_084042_813205_5174F901 X-CRM114-Status: UNSURE ( 9.21 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (dirk.feytons[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Subject: [LEDE-DEV] [PATCH 1/2] uci/lua: add list_configs() function X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dirk Feytons MIME-Version: 1.0 Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Returns an array with all the available configs. Signed-off-by: Dirk Feytons --- lua/uci.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lua/uci.c b/lua/uci.c index 47d59c8..ddb9c5c 100644 --- a/lua/uci.c +++ b/lua/uci.c @@ -911,6 +911,26 @@ uci_lua_set_savedir(lua_State *L) } static int +uci_lua_list_configs(lua_State *L) +{ + struct uci_context *ctx; + char **configs = NULL; + char **ptr; + int i = 1; + + ctx = find_context(L, NULL); + if ((uci_list_configs(ctx, &configs) != UCI_OK) || !configs) + return uci_push_status(L, ctx, false); + lua_newtable(L); + for (ptr = configs; *ptr; ptr++) { + lua_pushstring(L, *ptr); + lua_rawseti(L, -2, i++); + } + free(configs); + return 1; +} + +static int uci_lua_gc(lua_State *L) { struct uci_context *ctx = find_context(L, NULL); @@ -971,6 +991,7 @@ static const luaL_Reg uci[] = { { "set_confdir", uci_lua_set_confdir }, { "get_savedir", uci_lua_get_savedir }, { "set_savedir", uci_lua_set_savedir }, + { "list_configs", uci_lua_list_configs }, { NULL, NULL }, };