Browse Source

Parse configuration file and get entries.

Probably should use match operator instead.
master
Pjotr Prins 5 months ago
parent
commit
5659f27bd7
2 changed files with 34 additions and 4 deletions
  1. 29
    4
      bin/sheepdog
  2. 5
    0
      etc/monitor.conf

+ 29
- 4
bin/sheepdog View File

@@ -2,7 +2,8 @@
!#

;; (use-modules (sjson) (sjson utils))
(use-modules (ice-9 getopt-long))
(use-modules (ice-9 getopt-long)
(ice-9 format))

(define (parse-args args)
;; some magic because both -H and --server work
@@ -41,6 +42,30 @@ sheepdog [options]
(let* [(op (parse-args (command-line)))
(config (option-ref op 'config #f))
]
(display config)
(display config)
)
(display (string-append "Reading " config))
(let* [(port (open-file config "r"))
(buf (read port))
(global (cdr buf))
(ishost (assoc 'host global))
(host (cond
[(list? ishost) (car (cdr ishost))]))
(ismail (assoc 'mailto global))
(mailto (cond
[(list? ismail) (car (cdr ismail))]))
(isunknown (assoc 'unknown global))
(unknown (cond
[(list? isunknown)]))
]
(begin
(display "BUFFER:")
(display buf)
(newline)
(display "HOST:")
(write host)
(display "Mail:")
(display mailto)
(newline)
(display (format #t "~s" port))
(write isunknown)
(write unknown)
)))

+ 5
- 0
etc/monitor.conf View File

@@ -0,0 +1,5 @@
(config
(host "localhost")
(port 7777)
(mailto "admin@myhost.eu")
)

Loading…
Cancel
Save