X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;ds=sidebyside;f=command.lsp;h=8751fc3082e4c5de8571b94d06f5787d22e62c4d;hb=45a86f2b3e502e41dda26426e6e1e60ba088006f;hp=3e5094c45a002d2fb808a22a4eecd65735519f43;hpb=14d1288d271ae14678513d06a8602f1d3d929245;p=rrq%2Fhourglass.git diff --git a/command.lsp b/command.lsp index 3e5094c..8751fc3 100644 --- a/command.lsp +++ b/command.lsp @@ -2,6 +2,46 @@ # This script is intended as main script for packnl embedding, it # dispatches to the command of the first argument. +(context 'MAIN:SITE) + +(define (set-int K V) (set K (int V 0 10))) + +(define (set-ints K V) + (map (curry set-int K) (clean empty? (parse V "\\s*,?\\s*" 0)))) + +(define (set-list K V) + (map (curry set K) (clean empty? (parse V "\\s*,?\\s*" 0)))) + +(constant + 'FILE "hourglass.conf" + 'KEYS '( + ("libc" set) + ("listener.ports" set-ints) + ("listener.ip" set) + ("listener.activity.dir" set) + ("control.action" set) + ("control.dat" set) + ("control.net" set) + ("control.extra.dat" set) + ("control.usage.dat" set) + ("control.usage.tmp" set) + + ("wui.port" set-int) + ("wui.roles" set) + ("wui.passwd" set) + ) + ) + +(define (setting LINE) + (when (regex "^\\s([^;#][^=]*)=(.*)" LINE 0) + (let ((KV (map trim (list $1 $2)))) + (if (lookup (KV 0) KEYS) (apply $it (list (sym (KV 0)) (KV 1))))))) + +(map setting (parse (or (read-file FILE) "") "\n")) + +#################### +(context MAIN) + (if (exists file? (list (main-args 1) (string (main-args 1) ".lsp"))) (load $it)