[luci] luci grammar

Jo-Philipp Wich xm at subsignal.org
Tue Jun 17 12:44:06 CEST 2014


On 17.06.2014 06:36, 子文 wrote:
> Dear
>    uci:foreach("network", "interface",
>         function (section)
>             local ifc = section[".name"]
>             if ifc ~= "loopback" then
>                 entry({"admin", "network", "network", ifc},
>                  true,
>                  ifc:upper())
>             end
>         end
>     )
>       Sorry  , I can't still understand the setence " local ifc =
> section[".name"]", why can it get the section name by using
> section[".name"]"?


For a uci section like:

config interface lan
  option ifname eth1
  option proto pppoe
  option username test
  option password test

The lua table looks like this:

{
   ".type" = "interface",
   ".name" = "lan",
   ".index" = 3,
   ".anonymous" = false,
   "ifname" = "eth1"
   "proto" = "pppoe",
   "username" = "test",
   "password" = "test"
}

The ".type", ".name", ".index" and ".anonymous" fields are added by the
UCI library and they're prefixed with a dot to not clash with any option
value. The field ".name" (not "name") refers to the name from the
"config type name" line in a UCI config.

~ Jow

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 263 bytes
Desc: OpenPGP digital signature
URL: <http://lists.subsignal.org/pipermail/luci/attachments/20140617/f1512cde/attachment.pgp>


More information about the luci mailing list