From 71a6579a6e5337f8148d0da83d40256639169e3c Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Thu, 14 Feb 2008 15:43:03 +0000 Subject: Added modified functionallity. git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@722 ab2d0c66-481e-0410-8bed-d214d4d58bed --- lib/getopts.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'lib') diff --git a/lib/getopts.lua b/lib/getopts.lua index 1c8b7bf..ef74b49 100644 --- a/lib/getopts.lua +++ b/lib/getopts.lua @@ -97,3 +97,27 @@ function opts_to_table ( optstring, filter ) end return optsparams end +function getoptsfromfile_onperline (file, search, filter) + local opts = nil + if not (fs.is_file(file)) then return nil end + local conf_file = fs.read_file_as_array ( file ) + for i=1,table.maxn(conf_file) do + local l = conf_file[i] + if not string.find ( l, "^[;#].*" ) then + local a = string.match ( l, "^%s*(%S*)=" ) + if (a) then + if not (search) or (search == a) then + local b = string.match ( l, '^%s*%S*%s*%=%s*%"?(.-)%s*%"?%s*$' ) +-- local optstable = getopts.opts_to_table(b,filter) + if not (filter) then + if not (opts) then + opts = {} + end + opts[a] = b + end + end + end + end + end + return opts +end -- cgit v1.2.3