/usr/share/guile/site/config/load.scm is in guile-library 0.2.2-0.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | ;; (config load) -- loading configuration files
;; Copyright (C) 2003,2004 Andreas Rottmann
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This module needs to be documented.
;;; Code:
(define-module (config load)
#:use-module (oop goops)
#:use-module (ice-9 safe)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-34)
#:use-module (srfi srfi-35)
#:export (<configuration>
load-config!
&config-error
config-error-arguments))
(define-class <configuration> ())
(define-condition-type &config-error &error
config-error?
(key config-error-key)
(arguments config-error-arguments))
;; conditions are not GOOPS objects; but perhaps we should allow this somehow
;; (define-method (write (self &config-error) port)
;; (display "#<" port)
;; (display (class-name (class-of self)) port)
;; (display #\space port)
;; (display (config-error-key self) port)
;; (display #\space port)
;; (display (config-error-arguments self) port)
;; (display ">" port))
(define-method (cfg-include (cfg <configuration>) (file-name <string>) env)
(let ((old-dir (getcwd)))
(dynamic-wind
(lambda () (chdir (dirname file-name)))
(lambda ()
(do-load-config cfg (open-input-file (basename file-name)) env))
(lambda () (chdir old-dir)))))
(define (do-load-config cfg port env)
;; Read one expression a time.
(let lp ((expr (read port)))
;; End of file? -> Return.
(if (eof-object? expr)
#t
(catch #t
(lambda ()
;; Evaluate the expression in the safe environment.
(eval expr env)
;; ... and read the next expression if no error occured.
(lp (read port)))
;; Handle exceptions. This procedure will be called when
;; an error occurs while evaluating the expression. If a
;; condition was signalled, it is re-raised, otherwise a
;; &config-error condition is raised with the original
;; exception key and arguments.
;;
(lambda (key . args)
(if (and (= (length args) 1) (condition? (car args)))
(raise (car args))
(raise (condition (&config-error (key key)
(arguments args))))))))))
(define (bind-first proc . bind-args)
(lambda args
(apply proc (append bind-args args))))
(define (bind-last proc . bind-args)
(lambda args
(apply proc (append args bind-args))))
(define-method (load-config! (cfg <configuration>)
(commands <list>)
(file-name <string>))
(let ((config-env (safe-environment 5)))
(for-each (lambda (entry)
(module-define! config-env
(first entry) (bind-first (second entry) cfg)))
(cons `(include ,(bind-last cfg-include config-env)) commands))
(cfg-include cfg file-name config-env)))
;;; arch-tag: 09ffbf0f-b7e1-4280-a21f-178226487634
|