summaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
authorKatolaZ <katolaz@freaknet.org>2017-06-30 23:15:36 +0100
committerKatolaZ <katolaz@freaknet.org>2017-06-30 23:15:36 +0100
commitee3dc59322eb3a366f3594261491381db5084110 (patch)
treefa3a98639cf8c38f80c42fe00f1f8abb0562d200 /config.go
parentcfc67a824600be8d522c23c108d6333fca6b0359 (diff)
Added max_size in the configuration file
Diffstat (limited to 'config.go')
-rw-r--r--config.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/config.go b/config.go
index 729815f..afbaaf0 100644
--- a/config.go
+++ b/config.go
@@ -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])