From eaa23ecefaef558b30d7c69b2bd900dd70abf589 Mon Sep 17 00:00:00 2001 From: Mika Havela Date: Thu, 10 Jan 2008 10:17:25 +0000 Subject: Another try to figure out how to present data git-svn-id: svn://svn.alpinelinux.org/acf/alpine-baselayout/trunk@524 ab2d0c66-481e-0410-8bed-d214d4d58bed --- syslog-model.lua | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'syslog-model.lua') diff --git a/syslog-model.lua b/syslog-model.lua index 59747d1..ac37572 100644 --- a/syslog-model.lua +++ b/syslog-model.lua @@ -25,29 +25,44 @@ local is_running = function( process ) return statusreport end --- ################################################################################ --- EXPERIMENTAL LOCAL FUNCTIONS - local function readopts(optname) local opts = {} local line local f = io.open("/etc/conf.d/syslog", "r") - if f == nil then + if (f == nil) then return nil end for line in f:lines() do - local optstr = string.match(line, "^" .. optname .. "=\"?(.*)\"?") + local optstr = string.match(line, "^" .. optname .. "=\"?(.*)%\"+") if optstr then - local t = {} - for k, v in string.gmatch(optstr, "(%C*)") do --- for k, v in string.gmatch(optstr, "(-%S+)%s+(%S+)") do - opts[k] = optstr + local option = "" + local optvalue = "" + opts["org"]=optstr + for j = 1, string.len(optstr) do + if (string.sub(optstr, j, j) == "-") then + option=string.sub(optstr, j, j+1) + for k = j+1, string.len(optstr) do + if (string.sub(optstr, k, k) == "-") then + opts[option] = string.match(string.sub(optstr, j+2, k-1),"^%s*(.*)%s?") + break + end + if (k == string.len(optstr)) then + opts[option] = string.match(string.sub(optstr, j+2, k),"^%s*(.*)%s?") + break + end + + end + end end end end return opts end +-- ################################################################################ +-- EXPERIMENTAL LOCAL FUNCTIONS + + -- ################################################################################ -- PUBLIC FUNCTIONS @@ -120,6 +135,7 @@ function priv.enable(opts) end --]] +--[[ -- this func does not need privileges local function readopts() local opts = {} @@ -137,3 +153,4 @@ local function readopts() end return opts end +--]] -- cgit v1.2.3