summaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
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])