From 70cffc589d8a79c36f8c6847f89b926d761b3f7a Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Mon, 29 Sep 2008 18:01:28 +0000 Subject: 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/openntpd/trunk@1535 ab2d0c66-481e-0410-8bed-d214d4d58bed --- openntpd-model.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'openntpd-model.lua') diff --git a/openntpd-model.lua b/openntpd-model.lua index 2c77e39..52bffd3 100644 --- a/openntpd-model.lua +++ b/openntpd-model.lua @@ -3,7 +3,7 @@ module (..., package.seeall) -- Load libraries require("modelfunctions") require("fs") -require("getopts") +require("format") -- Set variables local configfile = "/etc/ntpd.conf" @@ -83,7 +83,8 @@ function read_config () end end - if getopts.getoptsfromfile(confdfile, "", "NTPD_OPTS", true, "-s") then + local opts = string.sub(format.parse_configfile2(fs.read_file(confdfile), "", "NTPD_OPTS"), 2, -2) + if format.opts_to_table(opts, "-s") then config.setstimeonstartup.value = true end @@ -137,7 +138,7 @@ function update_config(config) -- Finally, handle setstimeonstartup local opts = {} if config.value.setstimeonstartup.value then opts["-s"] = "" end - getopts.setoptsinfile(confdfile, "", "NTPD_OPTS", '"'..getopts.table_to_opts(opts)..'"') + fs.write_file(confdfile, format.update_configfile2(fs.read_file(confdfile) or "", "", "NTPD_OPTS", '"'..format.table_to_opts(opts)..'"')) else config.errtxt = "Failed to save config" end -- cgit v1.2.3