[ UP ] cgi
[archserver.git] / cgi / volumes / smb.lua
blobd4d9ce4ca9a6abc1762b5abf6e007c6f2e7a0a15
1 #!/usr/bin/lua
3 io.input("smb.conf")
4 t = io.read("*all")
5 t = string.gsub(t, "\n%s*#[^\n]+", "\n")
6 t = string.gsub(t, "\n%s*;[^\n]+", "\n")
7 t = string.gsub(t, "\n+", "\n") --remove multi lines to one line
8 t = string.gsub(t, "%[", "\n%[") -- make an tag "\n\n" at every end of a share
9 t = string.gsub(t, "$", "\n\n"); -- make sure there is a tag at end of file
12 tb={}
13 string.gsub(t, "%[(.-)%]%s*\n(.-\n)\n", function(sh, p)
14 tb[sh] = {}
15 string.gsub(p, "%s*(.-)%s*=%s*(.-)%s*\n", function(n,v)
16 tb[sh][n] = v
17 end)
18 end)
20 print("\n")
21 for i,k in pairs(tb) do
22 print("[-"..i.."-]")
23 for n, v in pairs(tb[i]) do
24 print("\t"..n.." = "..v)
25 end
26 end