From patchwork Fri Jan 12 14:58:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Herbrechtsmeier X-Patchwork-Id: 859998 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:400c:c0c::23e; helo=mail-wr0-x23e.google.com; envelope-from=swupdate+bncbdn7dbh5yqibby434pjakgqe3y5n52i@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="pJgftT3u"; dkim-atps=neutral Received: from mail-wr0-x23e.google.com (mail-wr0-x23e.google.com [IPv6:2a00:1450:400c:c0c::23e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zJ5Yy1XcXz9sNw for ; Sat, 13 Jan 2018 02:01:58 +1100 (AEDT) Received: by mail-wr0-x23e.google.com with SMTP id v18sf3530250wrf.21 for ; Fri, 12 Jan 2018 07:01:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1515769315; cv=pass; d=google.com; s=arc-20160816; b=LPNXUh0eV7f3q7BbaOP+x923DYcY14TejB9KUtrbGS/8tVbDDAdWsgLhbEXoyCWpoK GzB1SdE7W1x1xGMv0bjOSf95PdHfMCJmWMbfFWHD5KJip6znn4E3/SibhMcgmHxY9W3g qw2OGUyLp805M+T926uc+F97s3xQ/m2dD6BySkc1RNXuDLj+FHnzpeApJ7xBSxKX2aLH fwR3j90JTu1l3waCytK3RQLgyV8hiLiwGj0mAqVs8nwN0vqc5EGYMgiSyKuNbyWnIqxv PE22xKuYcKzkwQJ14fBy3fvq8mYKKftuSaWuFtfAawR1MgtsLr8+D1/6U9GF+BMa5Wwa RKBw== 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=K+xT1LcKwdnrGnoW/n3XRe0LVwz1twEOMA8VgGqEy40=; b=gDYIge4z/SUeiYh/RCfCB+Cxzq8T0gZAFEXepvQbpuFN8z1n6yJ8/YgXdKQUcZZjb0 XU23OX1YK5ftujfTsAlVfJfndAfdM1MoMUkiWdCGoVC4dIMxoMyKTRqZ5tZQnX6RLJ8T QmrEaBocr7pJk5jXZFkd5gFxdBpbZBbXTyAvro/gp4s6rnis1UwVkYDhUEiLXR76Ctsw KL8jmysQ9i5iZEE1jlsQV8C6AVcnQ/sVYMOPW1aXKJmQ5JUdMEetBIFS+cqIzOcq9g0Q 0dG/zrBESNrJbVz+9/Hs3bBiKrhaDAr3Yh6Y0NkDj8hyWca+UYwFw48jJUONT6tNtKTe +s/g== 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=K+xT1LcKwdnrGnoW/n3XRe0LVwz1twEOMA8VgGqEy40=; b=pJgftT3uMpbDIqQWceIQ0sMemcvLbcvMfacSdD7NYQeeiPtL+Jq6m5+MOcGRSrkdjC K4uYq/n3rLLOQQ/3GlRSVcb4KrEXmwHYN7SBgZ/PJ4jra4MXoE6j+jpvktd5QJXZfgt9 XheD0OF3QYFOn05YSEY9DLk+Mm76GtBMe7GB+rKqQFzETZ389qO1FIveoit49thm4zH3 rFcvzMvBsQupoy6Hcju+1A2Mn+Np399q9W8YatLuX7N1SLQJU1RZGv2+2E00M/ZV6+eM MU7CYKhOp37cZ2zCtM70NNr1PgBJGxgx50/CV1oQ1uaMvMjbFcRHOqk347tp4mW58joe 16+Q== 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=K+xT1LcKwdnrGnoW/n3XRe0LVwz1twEOMA8VgGqEy40=; b=cI4DKzGSa6LcT083tLbyptZgLRjwbgcjFBMzztJp1zOSFw8hqeNvrAr0DCzkSrNu9a x64+Vrgd4K9+m9FjocmkrPdjwbKEtInUNNabaX+3aZ5gN/zK7uPSsMQjD0Yy1zpJppvy 1Ni1AlTzyjIkvRsGbGqtA1Xj8754TuIRgxyoA/galiKEIqv9rOAYkPB7YCCXqGvT6AJM nDpq+yKqPKIrzWpvcgdPPpgJeokD3TzbOc6keguztnTghkbPtTH/Ul5MTOlrcjhqph7o jziQXBaeISBLjn4GsY+wYjyGHbILgLfRYUlmzbps42kjmyM3V3bsKBlDyAH4HrqdY8l8 tN/A== Sender: swupdate@googlegroups.com X-Gm-Message-State: AKwxyte0Of/mZh62u9EOT6Nrn+H4RCg+wh4bIPqp/RPIn2bQ6o0X4Yuk r/VFkRdfmwDzvwngG5tVQZQ= X-Google-Smtp-Source: ACJfBovZtCM92BSf1VJqvXi8G3tPCwgltZk+pnRb5WgIOzTW2+7i28hpJtgI33bh9SNexk52mgyzWg== X-Received: by 10.28.144.198 with SMTP id s189mr51528wmd.6.1515769315898; Fri, 12 Jan 2018 07:01:55 -0800 (PST) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 10.28.28.11 with SMTP id c11ls244909wmc.2.gmail; Fri, 12 Jan 2018 07:01:55 -0800 (PST) X-Received: by 10.28.122.17 with SMTP id v17mr476925wmc.7.1515769315416; Fri, 12 Jan 2018 07:01:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515769315; cv=none; d=google.com; s=arc-20160816; b=hDAz/kxHqMK5LfqR+DlxsYIHKtZckBhNcVTa+cykSef01p7wiYW8nTL0uUbjs2DZnW KO5Z6EOV76N8hYDpVYQroBhpN9/hPC8EM43gl4s2AtCXmm17vbOxf9kZsZS19wiMZFdt ge/F9XkZ8NZ4mFtHknPDsX76G3jthE2X4SvY7ACWmx8HkXGp8mXsaR9E4gXTbHapTtnB x+dnROoBxjw39AZahiVJu51REITzpk7Up5v+OtvsCh2K5xxKjRWVLI/Td0E6tSrlwhP7 KAkEfWf+T3SVqhCDU7azbed4IaEbDDgWWAfvoivmrDLwcilmEto2YrQ+m/RMufHMSqwk qWrg== 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=O4PVL7IQgNpiKRxXODzzPsc6wcNVOvOUxu4j/Fcfjxo=; b=pfgeUY1i/F63m8vMT94kdZQ1oD3EAGJfCXq2203bmbHALXBOmxWiKTwNxVYFXjjHsb u2NGMJZG+Allf7mDNNo8YjJ/hy/y7jI98TF7xV3/iV23uU7koK+X4P4Et9EN2sW3ZKIk 1YZ8ga67Urw1J73UqFVGZ1WxY8bCZ+GOfqd3aPNhYIsyp6ytgXQi7ez9HPp6W6c+1Hgp /fzck77ND8XC/2vLYK3gtRTAcYx7Ltqm3jVa0Ip+bKgzPc6iezN6+tKhNvN14HFZLK20 NKld/tj3z8b20t5IFmBZxiqrYdLlqk0PlOBc1H3yqfz71dseAiTWOISE0MdvOqgvrUe1 7GPw== 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 h76si381006wmd.1.2018.01.12.07.01.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Jan 2018 07:01:55 -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 1742411A0438; Fri, 12 Jan 2018 16:01:55 +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: Fri, 12 Jan 2018 15:58:48 +0100 Message-Id: <1515769128-29657-5-git-send-email-stefan@herbrechtsmeier.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515769128-29657-1-git-send-email-stefan@herbrechtsmeier.net> References: <1515769128-29657-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 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 872cb2f..28bb4f5 100644 --- a/corelib/lua_interface.c +++ b/corelib/lua_interface.c @@ -439,6 +439,10 @@ static int l_istream_read(lua_State* L) static void update_table(lua_State* L, struct img_type *img) { + struct dict_entry *property; + struct dict_list_elem *elem; + int i; + if (L && img) { luaL_checktype(L, -1, LUA_TTABLE); @@ -464,6 +468,26 @@ 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) { + lua_pushstring(L, dict_entry_get_key(property)); + elem = LIST_FIRST(&property->list); + if (LIST_NEXT(elem, next) == LIST_END(&property->list)) { + lua_pushstring(L, elem->value); + } else { + 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");