summaryrefslogtreecommitdiffstats
path: root/syslog-model.lua
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2008-09-29 18:01:28 +0000
committerTed Trask <ttrask01@yahoo.com>2008-09-29 18:01:28 +0000
commit9663a8b2e44d0b1647a7a530873adcf7ea577fed (patch)
tree94ac8e921530cc5d83cc7c6b0ca4209b9f1b8772 /syslog-model.lua
parent7da47eb7d53a0f88cad08542a7c81747b7990205 (diff)
downloadacf-alpine-baselayout-9663a8b2e44d0b1647a7a530873adcf7ea577fed.tar.bz2
acf-alpine-baselayout-9663a8b2e44d0b1647a7a530873adcf7ea577fed.tar.xz
Removed getopts library and added functionality to format library as opts_to_table, table_to_opts, parse_configfile2, update_configfile2, get_section, and set_section. New functions work on strings, not files. Modified all code using getopts to use format instead. Fixed nil string bugs in TCPProxy. Fixed forward only bug in DNSCache.
git-svn-id: svn://svn.alpinelinux.org/acf/alpine-baselayout/trunk@1535 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'syslog-model.lua')
-rw-r--r--syslog-model.lua12
1 files changed, 5 insertions, 7 deletions
diff --git a/syslog-model.lua b/syslog-model.lua
index 25969fe..2f5c4a0 100644
--- a/syslog-model.lua
+++ b/syslog-model.lua
@@ -2,7 +2,6 @@ module(..., package.seeall)
require("modelfunctions")
require("fs")
-require("getopts")
require("format")
require("validator")
@@ -50,9 +49,8 @@ local writeconfig = function (config)
configdata[entry] = nil
end
end
-
- local cmdresult, cmdmessage, cmderror = getopts.setoptsinfile(configfile,"",variable,'"' .. getopts.table_to_opts(configdata) .. '"')
- return cmdmessage, cmderror
+
+ fs.write_file(configfile, format.update_configfile2(fs.read_file(configfile) or "", "", variable, '"'..format.table_to_opts(configdata) .. '"'))
end
local makeconfig = function(configcontent)
@@ -177,7 +175,7 @@ end
function getconfig()
local config = {}
if (fs.is_file(configfile)) then
- local configcontent = getopts.getoptsfromfile(configfile, "", "SYSLOGD_OPTS", true) or {}
+ local configcontent = format.opts_to_table(string.sub((format.parse_configfile2(fs.read_file(configfile), "", "SYSLOGD_OPTS") or ""),2,-2))
config = makeconfig(configcontent)
else
config = makeconfig()
@@ -192,7 +190,7 @@ function updateconfig (config)
success, config = validateconfig(config)
if success == true then
- config.descr, config.errtxt = writeconfig(config)
+ writeconfig(config)
else
config.errtxt = "Failed to save config!"
end
@@ -203,7 +201,7 @@ end
function update_filedetails (filedetails)
-- Validation before writing
filedetails.value.filecontent.value = string.gsub(format.dostounix(filedetails.value.filecontent.value), "\n+$", "")
- local configcontent = getopts.getoptsfromfile(filedetails.value.filecontent.value, "", "SYSLOGD_OPTS", true) or {}
+ local configcontent = format.opts_to_table(string.sub((format.parse_configfile2(filedetails.value.filecontent.value, "", "SYSLOGD_OPTS") or ""),2,-2))
local config = makeconfig(configcontent)
local success, errtxt
success, config = validateconfig(config)