Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

34 lines (33 sloc) 1.619 kb
#lang scheme
(provide reread-config config-file SERVER DAEMON SERVER-PORT DAEMON-PORT NAME FORMAT-STRING DATASTORE-TYPE)
(define config-file (string-append (path->string (find-system-path 'pref-dir)) "code-immersion.config"))
(define read-config (lambda ()
(if (file-exists? config-file)
(call-with-input-file config-file
(lambda (in) (read in))
#:mode 'text)
null)))
(define default '((SERVER "localhost")
(DAEMON "localhost")
(SERVER-PORT 2000)
(DAEMON-PORT 2005)
(NAME "Unconfigured Name")
(FORMAT-STRING "~a from ~a: ~a~n")
(DATASTORE-TYPE "hash-datastore")))
(define config (read-config))
(define reread-config
(lambda () (set! config (read-config))))
(define SERVER
(lambda () (second (or (assoc 'SERVER config) (assoc 'SERVER default)))))
(define DAEMON
(lambda () (second (or (assoc 'DAEMON config) (assoc 'DAEMON default)))))
(define SERVER-PORT
(lambda () (second (or (assoc 'SERVER-PORT config) (assoc 'SERVER-PORT default)))))
(define DAEMON-PORT
(lambda () (second (or (assoc 'DAEMON-PORT config) (assoc 'DAEMON-PORT default)))))
(define NAME
(lambda () (second (or (assoc 'NAME config) (assoc 'NAME default)))))
(define FORMAT-STRING
(lambda () (second (or (assoc 'FORMAT-STRING config) (assoc 'FORMAT-STRING default)))))
(define DATASTORE-TYPE
(lambda () (second (or (assoc 'DATASTORE-TYPE config) (assoc 'DATASTORE-TYPE default)))))
Jump to Line
Something went wrong with that request. Please try again.