diff options
author | KatolaZ <katolaz@freaknet.org> | 2017-06-30 23:15:36 +0100 |
---|---|---|
committer | KatolaZ <katolaz@freaknet.org> | 2017-06-30 23:15:36 +0100 |
commit | ee3dc59322eb3a366f3594261491381db5084110 (patch) | |
tree | fa3a98639cf8c38f80c42fe00f1f8abb0562d200 /config.go | |
parent | cfc67a824600be8d522c23c108d6333fca6b0359 (diff) |
Added max_size in the configuration file
Diffstat (limited to 'config.go')
-rw-r--r-- | config.go | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -7,7 +7,7 @@ import ( "bufio" "regexp" "strings" - "log" + "strconv" ) @@ -17,7 +17,7 @@ type Config struct { paste_dir string templ_dir string log_fname string - logger *log.Logger + max_size uint16 } @@ -29,6 +29,8 @@ func (c Config) String() string { s+= "Port: " + c.port + "\n" s+= "paste_dir: " + c.paste_dir + "\n" s+= "templ_dir: " + c.templ_dir + "\n" + s+= "log_fname: " + c.log_fname + "\n" + s+= "max_size: " + string(c.max_size) + "\n" return s @@ -66,6 +68,13 @@ func parse_config (fname string, c *Config) error { c.templ_dir = fields[1] case "log_fname": c.log_fname = fields[1] + case "max_size": + if m_size, err := strconv.ParseUint(fields[1], 10, 16); err == nil { + c.max_size = uint16(m_size) + } else { + fmt.Fprintf(os.Stderr, "Invalid max_size value %s at line %d (max: 65535)\n", + fields[1], line) + } default: fmt.Fprintf(os.Stderr, "Error reading config file %s at line %d: unknown variable '%s'\n", fname, line, fields[0]) |