From patchwork Wed Jan 17 14:34:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Herbrechtsmeier X-Patchwork-Id: 862294 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4010:c07::239; helo=mail-lf0-x239.google.com; envelope-from=swupdate+bncbdn7dbh5yqibbzv67xjakgqerb2b4cq@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="RIVb57/X"; dkim-atps=neutral Received: from mail-lf0-x239.google.com (mail-lf0-x239.google.com [IPv6:2a00:1450:4010:c07::239]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zM8m93R1zz9s7f for ; Thu, 18 Jan 2018 01:36:25 +1100 (AEDT) Received: by mail-lf0-x239.google.com with SMTP id j185sf2517820lfe.13 for ; Wed, 17 Jan 2018 06:36:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1516199782; cv=pass; d=google.com; s=arc-20160816; b=kEswHgorucd3Nnyy8KebKlWUOJVqjtiWlQN17akYf2P7CFbR5AgPiZxlo/SBJrqagE JQo/7AXeLg3p4hZ/ibrPQzmUdjmDyoOLgF1o14YuIe0XS2gWpyq5IdzbNS4B/zsZbneK BUWrVVFZVbyxjtQL6Uh19FZX3evSBR7QSNulI7ZQyxIcTxSDlcrv9+T3l3FJq74iF24I uBDTtlHu58VkH0F30wlnQ9wki28H8J05eFA8dpzjcqWK6gR7bPMK+LApcDRXSZ712/b2 29tsllgxvsFyLhH3TGzeg4xWlJEKmMdjZMqwoc6+IRiy4chgvM/fN9IapuNOgB/ySOKe g3Ig== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:arc-authentication-results :arc-message-signature:mime-version:sender:dkim-signature :arc-authentication-results; bh=UoaZ5rw5mQEhi0pfjCVQ5MLSQwkzOhDX6UD2+llpos4=; b=CGgekmbpYi1DMIO6lULNVu+9DVFUb41C0HgUln/DxWan9nrsM4RLkLviepyunzA6Tu 4i88ATn1lQXsmN8YGX/9tCTT1wQuRLNhhEVJIK2FAauVdC/7PxZfPe4uxyRGag4SPl28 fRucLi0voQcBKI+fRlaxDDZOLxo619dRgTqy+13bFHs3bVift7QBkiNq2IZU2kCXZe02 qflAsvB8JueN4g0Vm93avgOPAgv9YaMUCfyCvV31YFr43v5NdWc0ZAfMBJnEIH/jFq/W bfaK7CEnNM7iqUwjFq4MO7SqIh3I8juU5b3+OrXVkkIzeqWxmOD4G0CMQELg0+4frE/R ulxw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 85.13.157.12 is neither permitted nor denied by best guess record for domain of stefan@herbrechtsmeier.net) smtp.mailfrom=stefan@herbrechtsmeier.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=UoaZ5rw5mQEhi0pfjCVQ5MLSQwkzOhDX6UD2+llpos4=; b=RIVb57/X8oUMIi8cqcO15VZZJBxTGqvF9gzfmzBSmLzld7k/fctRvBBkK7kSxPF/hz ldpjperD+MFNhlLJi2tVm3k3BeW/BmnaLnBhZv3weNDfFEGN2tut0zwvMstW/CEDFoJd ABuWOPwR2gckawa1a/6BWYEVbMVlAlcZI2awkpt8qXkm47S+LbUjv4I/No8AaDQwUQZK se8MCfUReargBze+sBlmFAolORl0uMvcnkTIjOPef3EKKtlMxz9qOq8SrBB7hJBaW2q/ vqruUUcGN9+fPXh/UjD51tZPoKRzwmDfhgPy5UcguP2d8ho7DvfHv0493gHX5c0EOMso puvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=UoaZ5rw5mQEhi0pfjCVQ5MLSQwkzOhDX6UD2+llpos4=; b=A2PrjgiovfapTKrWAfcr7YCS14aW/y8Ajyb2Crtb4f8Jv/Z6TqT/N1/dnPhiUuZ5gU rUZgDBzgKr8kqffBh4cN7NMz8a7Gd6WPL51ADj5wUQtGCUq6mN86DzJTbUZnu72hLqtc hzxBZdkU4Q2YpP9oIlgxRdG2NyaHmUhqc5W+wV/QFWld+oKRSBbMGhDOtwVu4i5GQC77 H7HAFgs8ntU7xP6NJEmA8n8NQFIt2JVeCTfBhd1VHznbqo6milLM70kDASh3X9wXBaHH 3WqwOwoxYjI8Kxre7aEWn3WpGOl252r17o/vGMueqj56C903QzrcPKeMkmp8JYWdVZQA nBtg== Sender: swupdate@googlegroups.com X-Gm-Message-State: AKwxytfi3wKikIoKpUibu3L2g5j6mRvWLiT59D20t4fQQXSEvbFJ16O7 QMug3C2/nJCEpOKTTCb0TQ4= X-Google-Smtp-Source: ACJfBotBK8KFVOB0Dds+czXS8Gu6h4a4H65947lwW2Y53/gPHBofRLG2f1OFj2EyJshmpRfJSd+7Dg== X-Received: by 10.25.190.68 with SMTP id o65mr22281lff.13.1516199782636; Wed, 17 Jan 2018 06:36:22 -0800 (PST) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.46.108.8 with SMTP id h8ls723623ljc.2.gmail; Wed, 17 Jan 2018 06:36:22 -0800 (PST) X-Received: by 10.25.225.213 with SMTP id l82mr912778lfk.3.1516199782055; Wed, 17 Jan 2018 06:36:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516199782; cv=none; d=google.com; s=arc-20160816; b=K1bicEO5A0bd8r0/Az3AiK9CjM7vy0VqLydp8wqyqZYxape8s9duqyHAFTSgvH8Bg3 4sOyygF3ayrBCD8NnYnXNu+1vwSYp3ED6A2Df0T3sDs+u19x9YJrbPU7d/Z6771v3Eou 4Fi+WOpVLwCn7rfWULmcMJ1kcrMaSG0N6gtutdGy2n9DI99oTnTjn5/Tp4+6M/jl/DD6 UbnGsxv0zzzT7Pi/tKHabeOXESr7+k898heRFQTkuN6aD3ImktxSFL5MX5f1LSSlOWmu Ruj20esqHXcI/fK3pwrX3N+Zy7aVgyRHD482OoOnPpvxf51eSxFfEtfPmwdQMCjJW4QX OL0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=biambvGSpsMnodQaVwdVWotTOzzHDnQudQG8gTXQKbI=; b=XGj41AGIRfubIDjbLOwNgyrVFaRFYYd/o+YZXnapddQvWvPyMpgFz27NN61LGq1+aM lnwz9CThKFQv9g7H2Kg7FZxYqsf0P71weqYnWFERlTOug0eI76zTGtFnZHA7V0r7G+IR W5RXPklV7JcpJiTopj5AZJ3tV0J2S5axTGFj/JkZgZolZDZFIDjvTAzX275r6IoWtOi/ +AIjkVYpjVeBtDLU0PcBLoxykv1gwAUzkUfMJZeXzLyytFafV8bJ7uDDx5jX2DFqvhW0 w+PLBXGQHCmrqEIyGXv7EkhfwFrcnd/0nV82kbledgaHZ76LXgE/Sc3i/k/2GdlRfkW5 iEeA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 85.13.157.12 is neither permitted nor denied by best guess record for domain of stefan@herbrechtsmeier.net) smtp.mailfrom=stefan@herbrechtsmeier.net Received: from dd41138.kasserver.com (dd41138.kasserver.com. [85.13.157.12]) by gmr-mx.google.com with ESMTPS id y16si556524lje.2.2018.01.17.06.36.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jan 2018 06:36:22 -0800 (PST) Received-SPF: neutral (google.com: 85.13.157.12 is neither permitted nor denied by best guess record for domain of stefan@herbrechtsmeier.net) client-ip=85.13.157.12; Received: from WS08941.weidmueller.com (unknown [217.244.7.16]) by dd41138.kasserver.com (Postfix) with ESMTPSA id 5F68711A0698; Wed, 17 Jan 2018 15:36:21 +0100 (CET) From: stefan@herbrechtsmeier.net To: swupdate@googlegroups.com Cc: Stefan Herbrechtsmeier Subject: [swupdate] [PATCH v2 5/5] Lua: Forward image properties via table to scripts Date: Wed, 17 Jan 2018 15:34:06 +0100 Message-Id: <1516199646-5607-5-git-send-email-stefan@herbrechtsmeier.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516199646-5607-1-git-send-email-stefan@herbrechtsmeier.net> References: <1516199646-5607-1-git-send-email-stefan@herbrechtsmeier.net> X-Original-Sender: stefan@herbrechtsmeier.net X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 85.13.157.12 is neither permitted nor denied by best guess record for domain of stefan@herbrechtsmeier.net) smtp.mailfrom=stefan@herbrechtsmeier.net Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , From: Stefan Herbrechtsmeier Signed-off-by: Stefan Herbrechtsmeier --- Changes in v3: - Move declarations into the required group Changes in v2: None corelib/lua_interface.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c index 6b92cf0..25d84e6 100644 --- a/corelib/lua_interface.c +++ b/corelib/lua_interface.c @@ -429,6 +429,8 @@ static int l_istream_read(lua_State* L) static void update_table(lua_State* L, struct img_type *img) { if (L && img) { + struct dict_entry *property; + luaL_checktype(L, -1, LUA_TTABLE); LUA_PUSH_IMG_STRING(img, "name", id.name); @@ -453,6 +455,28 @@ static void update_table(lua_State* L, struct img_type *img) LUA_PUSH_IMG_NUMBER(img, "size", size); LUA_PUSH_IMG_NUMBER(img, "checksum", checksum); + lua_pushstring(L, "properties"); + lua_newtable (L); + LIST_FOREACH(property, &img->properties, next) { + struct dict_list_elem *elem = LIST_FIRST(&property->list); + + lua_pushstring(L, dict_entry_get_key(property)); + if (LIST_NEXT(elem, next) == LIST_END(&property->list)) { + lua_pushstring(L, elem->value); + } else { + int i = 1; + + lua_newtable (L); + LIST_FOREACH(elem, &property->list, next) { + lua_pushnumber(L, i++); + lua_pushstring(L, elem->value); + lua_settable(L, -3); + } + } + lua_settable(L, -3); + } + lua_settable(L, -3); + #ifdef CONFIG_HANDLER_IN_LUA if (is_type(L, LUA_TYPE_HANDLER)) { lua_pushstring(L, "copy2file");