Commit a185bea3 authored by Ted Trask's avatar Ted Trask
Browse files

Removed getopts library and added functionality to format library as...

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/dnscache/trunk@1535 ab2d0c66-481e-0410-8bed-d214d4d58bed
parent 3aa16eef
......@@ -3,7 +3,6 @@ module(..., package.seeall)
-- Load libraries
require("modelfunctions")
require("fs")
require("getopts")
require("format")
require("posix")
require("validator")
......@@ -69,7 +68,7 @@ function getstatus()
end
function getconfig()
local conf = getopts.getoptsfromfile(configfile, "") or {}
local conf = format.parse_configfile2(fs.read_file(configfile), "") or {}
local output = {}
output.IPSEND = cfe({ value = conf.IPSEND or "", label="IP address for requests",
descr="Use 0.0.0.0 for default address" })
......@@ -85,13 +84,13 @@ function setconfig(config)
if success then
local file = fs.read_file(configfile)
getopts.setoptsinfile(file,"","IPSEND",config.value.IPSEND.value)
getopts.setoptsinfile(file,"","CACHESIZE",config.value.CACHESIZE.value)
getopts.setoptsinfile(file,"","IP",config.value.IP.value)
if config.value.IPSEND.value then
getopts.setoptsinfile(file,"","FORWARDONLY",config.value.IPSEND.value)
file = format.update_configfile2(file,"","IPSEND",config.value.IPSEND.value)
file = format.update_configfile2(file,"","CACHESIZE",config.value.CACHESIZE.value)
file = format.update_configfile2(file,"","IP",config.value.IP.value)
if config.value.FORWARDONLY.value then
file = format.update_configfile2(file,"","FORWARDONLY","true")
else
getopts.setoptsinfile(file,"","FORWARDONLY","")
file = format.update_configfile2(file,"","FORWARDONLY","")
end
fs.write_file(configfile, file)
else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment