Add global parameters module.
This commit is contained in:
parent
8564056320
commit
49a638fa76
6 changed files with 74 additions and 22 deletions
27
Makefile
27
Makefile
|
@ -32,20 +32,23 @@ BRMSAPTOOL-DEPS=brmsaptool.scm testing.import.scm listing.import.scm \
|
|||
dictionary.import.scm month.import.scm period.import.scm \
|
||||
ansi.import.scm member-file.import.scm \
|
||||
command-line.import.scm members-base.import.scm \
|
||||
utils.import.scm primes.import.scm member-record.import.scm
|
||||
utils.import.scm primes.import.scm member-record.import.scm \
|
||||
configuration.import.scm
|
||||
|
||||
BRMSAPTOOL-SOURCES=brmsaptool.scm testing.scm listing.scm \
|
||||
dictionary.scm month.scm period.scm ansi.scm member-file.scm \
|
||||
command-line.scm members-base.scm utils.scm primes.scm \
|
||||
member-record.scm
|
||||
member-record.scm configuration.scm
|
||||
|
||||
BRMSAPTOOL-OBJS=testing.o listing.o month.o period.o ansi.o \
|
||||
member-file.o dictionary.o command-line.o \
|
||||
members-base.o utils.o primes.o member-record.o
|
||||
members-base.o utils.o primes.o member-record.o \
|
||||
configuration.o
|
||||
|
||||
BRMSAPTOOL-SHARED=testing.so listing.so month.so period.so ansi.so \
|
||||
member-file.so dictionary.so command-line.so \
|
||||
members-base.so utils.so primes.so member-record.so
|
||||
members-base.so utils.so primes.so member-record.so \
|
||||
configuration.so
|
||||
|
||||
brmsaptool: $(BRMSAPTOOL-DEPS)
|
||||
$(CSC) -o $@ $<
|
||||
|
@ -97,7 +100,7 @@ month.so: month.o
|
|||
month.o: month.import.scm
|
||||
month.import.scm: $(MONTH-SOURCES)
|
||||
|
||||
PERIOD-SOURCES=period.scm testing.import.scm month.import.scm
|
||||
PERIOD-SOURCES=period.scm testing.import.scm month.import.scm configuration.import.scm
|
||||
|
||||
period.so: period.o
|
||||
period.o: period.import.scm
|
||||
|
@ -111,7 +114,8 @@ ansi.import.scm: $(ANSI-SOURCES)
|
|||
|
||||
MEMBER-FILE-SOURCES=member-file.scm dictionary.import.scm \
|
||||
ansi.import.scm month.import.scm period.import.scm \
|
||||
listing.import.scm testing.import.scm
|
||||
listing.import.scm testing.import.scm \
|
||||
configuration.import.scm
|
||||
|
||||
member-file.so: member-file.o
|
||||
member-file.o: member-file.import.scm
|
||||
|
@ -126,7 +130,7 @@ command-line.import.scm: $(COMMAND-LINE-SOURCES)
|
|||
MEMBERS-BASE-SOURCES=members-base.scm testing.import.scm \
|
||||
utils.import.scm dictionary.import.scm member-file.import.scm \
|
||||
primes.import.scm member-record.import.scm ansi.import.scm \
|
||||
period.import.scm month.import.scm
|
||||
period.import.scm month.import.scm configuration.import.scm
|
||||
|
||||
members-base.so: members-base.o
|
||||
members-base.o: members-base.import.scm
|
||||
|
@ -146,8 +150,15 @@ primes.import.scm: $(PRIMES-SOURCES)
|
|||
|
||||
MEMBER-RECORD-SOURCES=member-record.scm dictionary.import.scm \
|
||||
period.import.scm testing.import.scm month.import.scm \
|
||||
member-file.import.scm listing.import.scm ansi.import.scm
|
||||
member-file.import.scm listing.import.scm ansi.import.scm \
|
||||
configuration.import.scm
|
||||
|
||||
member-record.so: member-record.o
|
||||
member-record.o: member-record.import.scm
|
||||
member-record.import.scm: $(MEMBER-RECORD-SOURCES)
|
||||
|
||||
CONFIGURATION-SOURCES=configuration.scm
|
||||
|
||||
configuration.so: configuration.o
|
||||
configuration.o: configuration.import.scm
|
||||
configuration.import.scm: $(CONFIGURATION-SOURCES)
|
||||
|
|
45
configuration.scm
Normal file
45
configuration.scm
Normal file
|
@ -0,0 +1,45 @@
|
|||
;;
|
||||
;; configuraiton.scm
|
||||
;;
|
||||
;; Configuration parameters used by various modules.
|
||||
;;
|
||||
;; ISC License
|
||||
;;
|
||||
;; Copyright 2023 Brmlab, z.s.
|
||||
;; Dominik Pantůček <dominik.pantucek@trustica.cz>
|
||||
;;
|
||||
;; Permission to use, copy, modify, and/or distribute this software
|
||||
;; for any purpose with or without fee is hereby granted, provided
|
||||
;; that the above copyright notice and this permission notice appear
|
||||
;; in all copies.
|
||||
;;
|
||||
;; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
;; WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
;; WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
||||
;; AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
|
||||
;; CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
;; OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
;; NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
;; CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
;;
|
||||
|
||||
(declare (unit configuration))
|
||||
|
||||
(module
|
||||
configuration
|
||||
(
|
||||
*current-month*
|
||||
)
|
||||
|
||||
(import scheme
|
||||
(chicken base)
|
||||
(chicken time)
|
||||
(chicken time posix))
|
||||
|
||||
(define *current-month*
|
||||
(make-parameter
|
||||
(let ((d (seconds->local-time (current-seconds))))
|
||||
(list (+ 1900 (vector-ref d 5))
|
||||
(vector-ref d 4)))))
|
||||
|
||||
)
|
|
@ -171,17 +171,17 @@
|
|||
;; under key k. Special handling for start/stop symbols means given
|
||||
;; value is prepended to given start/stop key (student/suspend) as
|
||||
;; parsed month for later processing of student/suspend periods.
|
||||
(define (process-member-line d k v)
|
||||
(define (process-member-line d k v line-number)
|
||||
(let ((ss (split-start/stop-symbol k)))
|
||||
(if ss
|
||||
(let ((pk (car ss))
|
||||
(pd (cadr ss))
|
||||
(vl (string-split v " ")))
|
||||
(if (null? vl)
|
||||
(if (null? vl) ; Should not happen - k/v parser already catches this
|
||||
(error 'process-member-line "Missing date for start/stop symbol" k)
|
||||
(let ((ds (car vl)))
|
||||
(dict-set d pk
|
||||
(cons (cons pd (string->month ds))
|
||||
(cons (list pd (string->month ds) line-number)
|
||||
(dict-ref d pk '()))))))
|
||||
(case k
|
||||
((card desfire credit) (dict-set d k (cons v (dict-ref d k '()))))
|
||||
|
@ -294,7 +294,7 @@
|
|||
(let ((p (split-member-line (car ls) file-name lines line-number)))
|
||||
(loop (cdr ls)
|
||||
(if p
|
||||
(apply process-member-line r p)
|
||||
(process-member-line r (car p) (cadr p) line-number)
|
||||
r)
|
||||
(+ line-number 1))))))
|
||||
|
||||
|
|
|
@ -55,7 +55,8 @@
|
|||
month
|
||||
member-file
|
||||
listing
|
||||
ansi)
|
||||
ansi
|
||||
configuration)
|
||||
|
||||
;; Prints human-readable information
|
||||
(define (print-member-record-info mr)
|
||||
|
|
|
@ -57,7 +57,8 @@
|
|||
member-record
|
||||
ansi
|
||||
period
|
||||
month)
|
||||
month
|
||||
configuration)
|
||||
|
||||
;; Gets all files and symbolic links from given directory. The
|
||||
;; symbolic links are represented by cons cells with car being the
|
||||
|
|
10
period.scm
10
period.scm
|
@ -28,7 +28,6 @@
|
|||
(module
|
||||
period
|
||||
(
|
||||
*current-month*
|
||||
sort-period-markers
|
||||
period-markers->periods
|
||||
period->duration
|
||||
|
@ -49,13 +48,8 @@
|
|||
(chicken format)
|
||||
(chicken string)
|
||||
month
|
||||
testing)
|
||||
|
||||
(define *current-month*
|
||||
(make-parameter
|
||||
(let ((d (seconds->local-time (current-seconds))))
|
||||
(list (+ 1900 (vector-ref d 5))
|
||||
(vector-ref d 4)))))
|
||||
testing
|
||||
configuration)
|
||||
|
||||
;; Sorts period markers (be it start or end) chronologically and
|
||||
;; returns the sorted list.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue