Merge pull request 'new-builds' (#3) from new-builds into main

Reviewed-on: https://codeberg.org/retropikzel/scheme-libraries/pulls/3
This commit is contained in:
retropikzel 2026-08-28 08:36:35 +02:00
commit 90d0cc3d27
92 changed files with 2672 additions and 4612 deletions

3
.gitignore vendored
View File

@ -5,7 +5,7 @@
*.log
.*
*.json
retropikzel/*/README.html
index.html
foreign
venv
tmp
@ -26,3 +26,4 @@ venv*
retropikzel/wasm/plus.sld
retropikzel/*.c
retropikzel/*.meta
test-program

926
Jenkinsfile vendored
View File

@ -1,80 +1,860 @@
pipeline {
agent {
dockerfile {
label 'docker-x86_64'
filename 'Dockerfile.jenkins'
args '-t --user=root --privileged -v /var/run/docker.sock:/var/run/docker.sock'
reuseNode true
agent {
label 'docker-x86_64'
}
options {
disableConcurrentBuilds()
buildDiscarder(logRotator(numToKeepStr: '10', artifactNumToKeepStr: '10'))
}
stages {
stage('capyscheme') {
agent {
docker {
image 'schemers/capyscheme:head'
reuseNode true
args '--user=root'
}
}
triggers {
GenericTrigger(
genericVariables: [[key: 'ref', value: '$.ref']],
causeString: 'Triggered on $ref',
printContributedVariables: true,
printPostContent: true,
silentResponse: false,
shouldNotFlatten: false,
regexpFilterText: '$ref',
regexpFilterExpression: 'refs/heads/' + BRANCH_NAME
)
}
options {
disableConcurrentBuilds()
buildDiscarder(logRotator(numToKeepStr: '10', artifactNumToKeepStr: '10'))
}
environment {
R6RS_SCHEMES='capyscheme chezscheme guile ikarus ironscheme loko mosh racket sagittarius ypsilon'
R7RS_SCHEMES='capyscheme chibi chicken cyclone foment gauche gambit kawa loko meevax mosh racket sagittarius skint stklos tr7 ypsilon'
LIBRARIES='tap junit debug lambda-utils ctrf mouth string url-encoding leb128 hardware-info'
}
stages {
stage('Parallel') {
parallel {
stage('R6RS tests') {
steps {
script {
env.LIBRARIES.split().each { LIBRARY ->
stage("${LIBRARY}") {
env.R6RS_SCHEMES.split().each { SCHEME ->
stage("${SCHEME}") {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "timeout 600 make SCHEME=${SCHEME} LIBRARY=${LIBRARY} RNRS=r6rs test-docker"
}
}
}
}
}
}
}
}
stage('R7RS tests') {
steps {
script {
env.LIBRARIES.split().each { LIBRARY ->
stage("${LIBRARY}") {
env.R7RS_SCHEMES.split().each { SCHEME ->
stage("${SCHEME}") {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "timeout 600 make SCHEME=${SCHEME} LIBRARY=${LIBRARY} RNRS=r7rs test-docker"
}
}
}
}
}
}
}
}
}
}
steps {
script {
get_capyscheme_stages()
}
}
}
post {
always {
cleanWs()
stage('chibi') {
agent {
docker {
image 'schemers/chibi:head'
reuseNode true
args '--user=root'
}
}
steps {
script {
get_chibi_stages()
}
}
}
stage('chicken') {
agent {
docker {
image 'schemers/chicken:head'
reuseNode true
args '--user=root'
}
}
steps {
script {
get_chicken_stages()
}
}
}
stage('foment') {
agent {
docker {
image 'schemers/foment:head'
reuseNode true
args '--user=root'
}
}
steps {
script {
get_foment_stages()
}
}
}
stage('gauche') {
agent {
docker {
image 'schemers/gauche:head'
reuseNode true
args '--user=root'
}
}
steps {
script {
get_gauche_stages()
}
}
}
stage('kawa') {
agent {
docker {
image 'schemers/kawa:head'
reuseNode true
args '--user=root'
}
}
steps {
script {
get_kawa_stages()
}
}
}
stage('loko') {
agent {
docker {
image 'schemers/loko:head'
reuseNode true
args '--user=root'
}
}
steps {
script {
get_loko_stages()
}
}
}
stage('meevax') {
agent {
docker {
image 'schemers/meevax:head'
reuseNode true
args '--user=root'
}
}
steps {
script {
get_meevax_stages()
}
}
}
stage('mit-scheme') {
agent {
docker {
image 'schemers/mit-scheme:head'
reuseNode true
args '--user=root'
}
}
steps {
script {
get_mit_scheme_stages()
}
}
}
stage('mosh') {
agent {
docker {
image 'schemers/mosh:head'
reuseNode true
args '--user=root'
}
}
steps {
script {
get_mosh_stages()
}
}
}
stage('racket') {
agent {
docker {
image 'schemers/racket:head'
reuseNode true
args '--user=root'
}
}
steps {
script {
get_racket_stages()
}
}
}
stage('sagittarius') {
agent {
docker {
image 'schemers/sagittarius:head'
reuseNode true
args '--user=root'
}
}
steps {
script {
get_sagittarius_stages()
}
}
}
stage('skint') {
agent {
docker {
image 'schemers/skint:head'
reuseNode true
args '--user=root'
}
}
steps {
script {
get_skint_stages()
}
}
}
stage('stklos') {
agent {
docker {
image 'schemers/stklos:head'
reuseNode true
args '--user=root'
}
}
steps {
script {
get_stklos_stages()
}
}
}
stage('tr7') {
agent {
docker {
image 'schemers/tr7:head'
reuseNode true
args '--user=root'
}
}
steps {
script {
get_tr7_stages()
}
}
}
stage('ypsilon') {
agent {
docker {
image 'schemers/ypsilon:head'
reuseNode true
args '--user=root'
}
}
steps {
script {
get_ypsilon_stages()
}
}
}
}
}
def get_capyscheme_stages() {
def stages = []
stages.plus(stage('init') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "apt-get update && apt-get install -y git ca-certificates gcc make libffi-dev"
sh "git clone https://github.com/ashinn/chibi-scheme.git --depth=1 || true"
sh "make -j8 -C chibi-scheme"
sh "make -j8 -C chibi-scheme install"
sh "snow-chibi install --always-yes retropikzel.compile-r7rs"
}
})
stages.plus(stage('tap') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=capyscheme LIBRARY=tap all install test"
}
})
stages.plus(stage('mouth') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=capyscheme LIBRARY=mouth all install test"
}
})
stages.plus(stage('debug') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=capyscheme LIBRARY=debug all install test"
}
})
stages.plus(stage('hardware-info') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=capyscheme LIBRARY=hardware-info all install test"
}
})
stages.plus(stage('lambda-utils') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=capyscheme LIBRARY=lambda-utils all install test"
}
})
return stages
}
def get_chibi_stages() {
def stages = []
stages.plus(stage('init') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "apt-get update && apt-get install -y git ca-certificates gcc make libffi-dev"
sh "git clone https://github.com/ashinn/chibi-scheme.git --depth=1 || true"
sh "make -j8 -C chibi-scheme"
sh "make -j8 -C chibi-scheme install"
sh "snow-chibi install --always-yes retropikzel.compile-r7rs"
}
})
stages.plus(stage('tap') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=chibi LIBRARY=tap all install test"
}
})
stages.plus(stage('mouth') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=chibi LIBRARY=mouth all install test"
}
})
stages.plus(stage('debug') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=chibi LIBRARY=debug all install test"
}
})
stages.plus(stage('hardware-info') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=chibi LIBRARY=hardware-info all install test"
}
})
stages.plus(stage('lambda-utils') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=chibi LIBRARY=lambda-utils all install test"
}
})
return stages
}
def get_chicken_stages() {
def stages = []
stages.plus(stage('init') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "apt-get update && apt-get install -y git ca-certificates gcc make libffi-dev"
sh "git clone https://github.com/ashinn/chibi-scheme.git --depth=1 || true"
sh "make -j8 -C chibi-scheme"
sh "make -j8 -C chibi-scheme install"
sh "snow-chibi install --always-yes retropikzel.compile-r7rs"
}
})
stages.plus(stage('tap') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=chicken LIBRARY=tap all install test"
}
})
stages.plus(stage('mouth') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=chicken LIBRARY=mouth all install test"
}
})
stages.plus(stage('debug') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=chicken LIBRARY=debug all install test"
}
})
stages.plus(stage('hardware-info') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=chicken LIBRARY=hardware-info all install test"
}
})
stages.plus(stage('lambda-utils') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=chicken LIBRARY=lambda-utils all install test"
}
})
return stages
}
def get_foment_stages() {
def stages = []
stages.plus(stage('init') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "apt-get update && apt-get install -y git ca-certificates gcc make libffi-dev"
sh "git clone https://github.com/ashinn/chibi-scheme.git --depth=1 || true"
sh "make -j8 -C chibi-scheme"
sh "make -j8 -C chibi-scheme install"
sh "snow-chibi install --always-yes retropikzel.compile-r7rs"
}
})
stages.plus(stage('tap') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=foment LIBRARY=tap all install test"
}
})
stages.plus(stage('mouth') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=foment LIBRARY=mouth all install test"
}
})
stages.plus(stage('debug') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=foment LIBRARY=debug all install test"
}
})
stages.plus(stage('hardware-info') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=foment LIBRARY=hardware-info all install test"
}
})
stages.plus(stage('lambda-utils') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=foment LIBRARY=lambda-utils all install test"
}
})
return stages
}
def get_gauche_stages() {
def stages = []
stages.plus(stage('init') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "apt-get update && apt-get install -y git ca-certificates gcc make libffi-dev"
sh "git clone https://github.com/ashinn/chibi-scheme.git --depth=1 || true"
sh "make -j8 -C chibi-scheme"
sh "make -j8 -C chibi-scheme install"
sh "snow-chibi install --always-yes retropikzel.compile-r7rs"
}
})
stages.plus(stage('tap') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=gauche LIBRARY=tap all install test"
}
})
stages.plus(stage('mouth') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=gauche LIBRARY=mouth all install test"
}
})
stages.plus(stage('debug') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=gauche LIBRARY=debug all install test"
}
})
stages.plus(stage('hardware-info') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=gauche LIBRARY=hardware-info all install test"
}
})
stages.plus(stage('lambda-utils') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=gauche LIBRARY=lambda-utils all install test"
}
})
return stages
}
def get_kawa_stages() {
def stages = []
stages.plus(stage('init') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "apt-get update && apt-get install -y git ca-certificates gcc make libffi-dev"
sh "git clone https://github.com/ashinn/chibi-scheme.git --depth=1 || true"
sh "make -j8 -C chibi-scheme"
sh "make -j8 -C chibi-scheme install"
sh "snow-chibi install --always-yes retropikzel.compile-r7rs"
}
})
stages.plus(stage('tap') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=kawa LIBRARY=tap all install test"
}
})
stages.plus(stage('mouth') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=kawa LIBRARY=mouth all install test"
}
})
stages.plus(stage('debug') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=kawa LIBRARY=debug all install test"
}
})
stages.plus(stage('hardware-info') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=kawa LIBRARY=hardware-info all install test"
}
})
stages.plus(stage('lambda-utils') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=kawa LIBRARY=lambda-utils all install test"
}
})
return stages
}
def get_loko_stages() {
def stages = []
stages.plus(stage('init') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "apt-get update && apt-get install -y git ca-certificates gcc make libffi-dev"
sh "git clone https://github.com/ashinn/chibi-scheme.git --depth=1 || true"
sh "make -j8 -C chibi-scheme"
sh "make -j8 -C chibi-scheme install"
sh "snow-chibi install --always-yes retropikzel.compile-r7rs"
}
})
stages.plus(stage('tap') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=loko LIBRARY=tap all install test"
}
})
stages.plus(stage('mouth') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=loko LIBRARY=mouth all install test"
}
})
stages.plus(stage('debug') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=loko LIBRARY=debug all install test"
}
})
stages.plus(stage('hardware-info') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=loko LIBRARY=hardware-info all install test"
}
})
stages.plus(stage('lambda-utils') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=loko LIBRARY=lambda-utils all install test"
}
})
return stages
}
def get_meevax_stages() {
def stages = []
stages.plus(stage('init') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "apt-get update && apt-get install -y git ca-certificates gcc make libffi-dev"
sh "git clone https://github.com/ashinn/chibi-scheme.git --depth=1 || true"
sh "make -j8 -C chibi-scheme"
sh "make -j8 -C chibi-scheme install"
sh "snow-chibi install --always-yes retropikzel.compile-r7rs"
}
})
stages.plus(stage('tap') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=meevax LIBRARY=tap all install test"
}
})
stages.plus(stage('mouth') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=meevax LIBRARY=mouth all install test"
}
})
stages.plus(stage('debug') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=meevax LIBRARY=debug all install test"
}
})
stages.plus(stage('hardware-info') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=meevax LIBRARY=hardware-info all install test"
}
})
stages.plus(stage('lambda-utils') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=meevax LIBRARY=lambda-utils all install test"
}
})
return stages
}
def get_mit_scheme_stages() {
def stages = []
stages.plus(stage('init') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "apt-get update && apt-get install -y git ca-certificates gcc make libffi-dev"
sh "git clone https://github.com/ashinn/chibi-scheme.git --depth=1 || true"
sh "make -j8 -C chibi-scheme"
sh "make -j8 -C chibi-scheme install"
sh "snow-chibi install --always-yes retropikzel.compile-r7rs"
}
})
stages.plus(stage('tap') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=mit-scheme LIBRARY=tap all install test"
}
})
stages.plus(stage('mouth') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=mit-scheme LIBRARY=mouth all install test"
}
})
stages.plus(stage('debug') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=mit-scheme LIBRARY=debug all install test"
}
})
stages.plus(stage('hardware-info') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=mit-scheme LIBRARY=hardware-info all install test"
}
})
stages.plus(stage('lambda-utils') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=mit-scheme LIBRARY=lambda-utils all install test"
}
})
return stages
}
def get_mosh_stages() {
def stages = []
stages.plus(stage('init') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "apt-get update && apt-get install -y git ca-certificates gcc make libffi-dev"
sh "git clone https://github.com/ashinn/chibi-scheme.git --depth=1 || true"
sh "make -j8 -C chibi-scheme"
sh "make -j8 -C chibi-scheme install"
sh "snow-chibi install --always-yes retropikzel.compile-r7rs"
}
})
stages.plus(stage('tap') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=mosh LIBRARY=tap all install test"
}
})
stages.plus(stage('mouth') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=mosh LIBRARY=mouth all install test"
}
})
stages.plus(stage('debug') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=mosh LIBRARY=debug all install test"
}
})
stages.plus(stage('hardware-info') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=mosh LIBRARY=hardware-info all install test"
}
})
stages.plus(stage('lambda-utils') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=mosh LIBRARY=lambda-utils all install test"
}
})
return stages
}
def get_racket_stages() {
def stages = []
stages.plus(stage('init') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "apt-get update && apt-get install -y git ca-certificates gcc make libffi-dev"
sh "git clone https://github.com/ashinn/chibi-scheme.git --depth=1 || true"
sh "make -j8 -C chibi-scheme"
sh "make -j8 -C chibi-scheme install"
sh "snow-chibi install --always-yes retropikzel.compile-r7rs"
}
})
stages.plus(stage('tap') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=racket LIBRARY=tap all install test"
}
})
stages.plus(stage('mouth') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=racket LIBRARY=mouth all install test"
}
})
stages.plus(stage('debug') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=racket LIBRARY=debug all install test"
}
})
stages.plus(stage('hardware-info') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=racket LIBRARY=hardware-info all install test"
}
})
stages.plus(stage('lambda-utils') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=racket LIBRARY=lambda-utils all install test"
}
})
return stages
}
def get_sagittarius_stages() {
def stages = []
stages.plus(stage('init') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "apt-get update && apt-get install -y git ca-certificates gcc make libffi-dev"
sh "git clone https://github.com/ashinn/chibi-scheme.git --depth=1 || true"
sh "make -j8 -C chibi-scheme"
sh "make -j8 -C chibi-scheme install"
sh "snow-chibi install --always-yes retropikzel.compile-r7rs"
}
})
stages.plus(stage('tap') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=sagittarius LIBRARY=tap all install test"
}
})
stages.plus(stage('mouth') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=sagittarius LIBRARY=mouth all install test"
}
})
stages.plus(stage('debug') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=sagittarius LIBRARY=debug all install test"
}
})
stages.plus(stage('hardware-info') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=sagittarius LIBRARY=hardware-info all install test"
}
})
stages.plus(stage('lambda-utils') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=sagittarius LIBRARY=lambda-utils all install test"
}
})
return stages
}
def get_skint_stages() {
def stages = []
stages.plus(stage('init') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "apt-get update && apt-get install -y git ca-certificates gcc make libffi-dev"
sh "git clone https://github.com/ashinn/chibi-scheme.git --depth=1 || true"
sh "make -j8 -C chibi-scheme"
sh "make -j8 -C chibi-scheme install"
sh "snow-chibi install --always-yes retropikzel.compile-r7rs"
}
})
stages.plus(stage('tap') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=skint LIBRARY=tap all install test"
}
})
stages.plus(stage('mouth') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=skint LIBRARY=mouth all install test"
}
})
stages.plus(stage('debug') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=skint LIBRARY=debug all install test"
}
})
stages.plus(stage('hardware-info') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=skint LIBRARY=hardware-info all install test"
}
})
stages.plus(stage('lambda-utils') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=skint LIBRARY=lambda-utils all install test"
}
})
return stages
}
def get_stklos_stages() {
def stages = []
stages.plus(stage('init') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "apt-get update && apt-get install -y git ca-certificates gcc make libffi-dev"
sh "git clone https://github.com/ashinn/chibi-scheme.git --depth=1 || true"
sh "make -j8 -C chibi-scheme"
sh "make -j8 -C chibi-scheme install"
sh "snow-chibi install --always-yes retropikzel.compile-r7rs"
}
})
stages.plus(stage('tap') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=stklos LIBRARY=tap all install test"
}
})
stages.plus(stage('mouth') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=stklos LIBRARY=mouth all install test"
}
})
stages.plus(stage('debug') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=stklos LIBRARY=debug all install test"
}
})
stages.plus(stage('hardware-info') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=stklos LIBRARY=hardware-info all install test"
}
})
stages.plus(stage('lambda-utils') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=stklos LIBRARY=lambda-utils all install test"
}
})
return stages
}
def get_tr7_stages() {
def stages = []
stages.plus(stage('init') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "apt-get update && apt-get install -y git ca-certificates gcc make libffi-dev"
sh "git clone https://github.com/ashinn/chibi-scheme.git --depth=1 || true"
sh "make -j8 -C chibi-scheme"
sh "make -j8 -C chibi-scheme install"
sh "snow-chibi install --always-yes retropikzel.compile-r7rs"
}
})
stages.plus(stage('tap') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=tr7 LIBRARY=tap all install test"
}
})
stages.plus(stage('mouth') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=tr7 LIBRARY=mouth all install test"
}
})
stages.plus(stage('debug') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=tr7 LIBRARY=debug all install test"
}
})
stages.plus(stage('hardware-info') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=tr7 LIBRARY=hardware-info all install test"
}
})
stages.plus(stage('lambda-utils') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=tr7 LIBRARY=lambda-utils all install test"
}
})
return stages
}
def get_ypsilon_stages() {
def stages = []
stages.plus(stage('init') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "apt-get update && apt-get install -y git ca-certificates gcc make libffi-dev"
sh "git clone https://github.com/ashinn/chibi-scheme.git --depth=1 || true"
sh "make -j8 -C chibi-scheme"
sh "make -j8 -C chibi-scheme install"
sh "snow-chibi install --always-yes retropikzel.compile-r7rs"
}
})
stages.plus(stage('tap') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=ypsilon LIBRARY=tap all install test"
}
})
stages.plus(stage('mouth') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=ypsilon LIBRARY=mouth all install test"
}
})
stages.plus(stage('debug') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=ypsilon LIBRARY=debug all install test"
}
})
stages.plus(stage('hardware-info') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=ypsilon LIBRARY=hardware-info all install test"
}
})
stages.plus(stage('lambda-utils') {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
sh "make SCHEME=ypsilon LIBRARY=lambda-utils all install test"
}
})
return stages
}

View File

@ -1,81 +1,49 @@
.SILENT:
.POSIX:
SCHEME=chibi
RNRS=r7rs
LIBRARY=ctrf
DOCKER_TAG=latest
AUTHOR=retropikzel
PKG=${AUTHOR}-${LIBRARY}-${VERSION}.tgz
tmpdir=.tmp/${SCHEME}/${LIBRARY}
LIBRARY_FILE=retropikzel/${LIBRARY}.sld
LIBRARY=tap
AUTHORS=Retropikzel
MAINTAINER=Retropikzel
VERSION=$$(cat retropikzel/${LIBRARY}/VERSION)
PKG=retropikzel-${LIBRARY}-${VERSION}.tgz
TESTFILE=retropikzel/${LIBRARY}/test.scm
VERSION != cat retropikzel/${LIBRARY}/VERSION
DESCRIPTION != head -n1 retropikzel/${LIBRARY}/README.md
README=retropikzel/${LIBRARY}/README.html
AKKU_PACKAGES=""
SFX=scm
ifeq "${RNRS}" "r6rs"
SFX=sps
AKKU_PACKAGES="akku-r7rs"
endif
ifeq "${SCHEME}" "capyscheme"
DOCKER_TAG=head
endif
ifeq "${SCHEME}" "chibi"
DOCKER_TAG=head
endif
ifeq "${SCHEME}" "chicken"
DOCKER_TAG=head
endif
ifeq "${SCHEME}" "gauche"
DOCKER_TAG=head
endif
DOCKER_TAG=latest
all: package
package: retropikzel/${LIBRARY}/LICENSE retropikzel/${LIBRARY}/VERSION retropikzel/${LIBRARY}/README.md
echo "<pre>$$(cat retropikzel/${LIBRARY}/README.md)</pre>" > ${README}
package: retropikzel/${LIBRARY}/LICENSE retropikzel/${LIBRARY}/VERSION retropikzel/${LIBRARY}/DESCRIPTION
snow-chibi package \
--always-yes \
--version=${VERSION} \
--authors=${AUTHOR} \
--doc=${README} \
--description="${DESCRIPTION}" \
${LIBRARY_FILE}
${PKG}: package
--authors=${AUTHORS} \
--maintainers=${MAINTAINER} \
--license="$$(cat retropikzel/${LIBRARY}/LICENSE)" \
--doc-from-scribble=1 \
--test=${TESTFILE} \
--description="$$(head -n1 retropikzel/${LIBRARY}/DESCRIPTION)" \
retropikzel/${LIBRARY}.sld
install:
snow-chibi install --impls=${SCHEME} ${PKG}
snow-chibi install --impls=${SCHEME} --always-yes --verbose?=1 --skip-tests?=1 ${PKG}
testfiles: ${PKG} ${TESTFILE}
rm -rf ${tmpdir}
mkdir -p ${tmpdir}
cp ${PKG} ${tmpdir}
cat test-headers.${SFX} | sed 's/LIBRARY/${LIBRARY}/' > ${tmpdir}/test.${SFX}
cat ${TESTFILE} >> ${tmpdir}/test.${SFX}
test: package
snow-chibi --impls=${SCHEME} test-package ${PKG}
test: testfiles
cd ${tmpdir} && COMPILE_R7RS=${SCHEME} CSC_OPIONS="-L -lcurl" compile-r7rs -o test-program test.${SFX}
cd ${tmpdir} && ./test-program
test-compile-r7rs:
COMPILE_R7RS=${SCHEME} compile-r7rs -o test-program ${TESTFILE}
./test-program
test-docker: testfiles
SNOW_PACKAGES="srfi.19 srfi.64 srfi.180 ${PKG}" \
APT_PACKAGES="libcurl4-openssl-dev" \
AKKU_PACKAGES="${AKKU_PACKAGES}" \
test-docker:
DOCKER_TAG=${DOCKER_TAG} \
SNOW_PACKAGES="retropikzel.tap ${PKG}" \
COMPILE_R7RS=${SCHEME} \
CSC_OPIONS="-L -lcurl" \
test-r7rs -o ${tmpdir}/test-program ${tmpdir}/test.${SFX}
test-r7rs -o test-program ${TESTFILE}
retropikzel/wasm/plus.wat: retropikzel/wasm/plus.c
emcc -o retropikzel/wasm/plus.js retropikzel/wasm/plus.c
wasm-dis retropikzel/wasm/plus.wasm > retropikzel/wasm/plus.wat
jenkinsfile: makings.scm
makings --jenkinsfile > Jenkinsfile
clean:
git clean -X -f

11
builds.yaml Normal file
View File

@ -0,0 +1,11 @@
- image: schemers/chibi
stages:
- name: init
cmd: |
apt-get update && apt-get install -y git ca-certificates gcc make libffi-dev
git clone https://github.com/ashinn/chibi-scheme.git --depth=1
make -j8 -C chibi-scheme
make -j8 -C chibi-scheme install
snow-chibi install retropikzel.compile-r7rs
- name: tap
cmd: make SCHEME=chibi LIBRARY=tap all install test

35
makings.scm Normal file
View File

@ -0,0 +1,35 @@
(let ((schemes
'("capyscheme" "chibi" "chicken" "foment" "gauche" "kawa"
"loko" "meevax" "mit-scheme" "mosh" "racket" "sagittarius" "skint"
"stklos" "tr7" "ypsilon"))
(libraries
'("tap" "mouth" "debug" "hardware-info" "lambda-utils"))
(init
'("apt-get update && apt-get install -y git ca-certificates gcc make libffi-dev"
"git clone https://github.com/ashinn/chibi-scheme.git --depth=1 || true"
"make -j8 -C chibi-scheme"
"make -j8 -C chibi-scheme install"
"snow-chibi install --always-yes retropikzel.compile-r7rs"))
(library-stage
(lambda (scheme library-name)
(list (string->symbol library-name)
(string-append "timeout 60 make SCHEME="
scheme
" LIBRARY="
library-name
" all install test")))))
`((jenkinsfile
(agent "label 'docker-x86_64'")
(options "disableConcurrentBuilds()"
"buildDiscarder(logRotator(numToKeepStr: '10', artifactNumToKeepStr: '10'))"))
(makings ,@(map (lambda (scheme)
`((name ,scheme)
(image ,(string-append "schemers/" scheme ":head"))
(stages
(init ,@init)
,@(map
(lambda (library-name)
(library-stage scheme library-name))
libraries))))
schemes))))

7
retropikzel/asn1.sld Normal file
View File

@ -0,0 +1,7 @@
(define-library
(retropikzel asn1)
(import (scheme base)
(scheme write))
(export read-asn1-sequence-length
read-asn1-sequence)
(include "asni1.scm"))

15
retropikzel/assert.scm Normal file
View File

@ -0,0 +1,15 @@
(define-syntax assert
(syntax-rules ()
((_ check body)
(let ((result body))
(when (not (check result))
(error "assertion error: " check body result))
result))))
(define-syntax asserts
(syntax-rules ()
((_ (check ...) body)
(let ((result body))
(when (not (check result)) (error "assertion error: " check body result)) ...
result))))

7
retropikzel/assert.sld Normal file
View File

@ -0,0 +1,7 @@
(define-library
(retropikzel assert)
(import (scheme base)
(scheme write))
(export assert
asserts)
(include "assert.scm"))

View File

@ -0,0 +1 @@
0.1.0

View File

@ -0,0 +1,21 @@
(import (scheme base)
(scheme write)
(scheme read)
(retropikzel tap)
(retropikzel debug)
(retropikzel assert)
(srfi 64))
(test-runner-current (tap-runner))
(test-begin "assert")
(test-equal 1 (assert number? 1))
(test-equal 'error
(guard (condition (else 'error))
(assert number? "string")))
(test-equal 1 (asserts (number? (lambda (i) (= i 1))) 1))
(test-end "assert")

View File

@ -1,6 +1,18 @@
(define stdin (open-binary-input-file "/dev/fd/0"))
(define stdin (current-input-port))
(define buffer-size 4000)
(define (make-temp-filename filename)
(let* ((tmpdir (or (get-environment-variable "SCM_CGI_TMPDIR")
(cond-expand (windows (get-environment-variable "TMP"))
(else "/tmp"))))
(tmpfile (string-append tmpdir
filename
"_"
(number->string (random-integer 1000000)))))
(if (file-exists? tmpfile)
(make-temp-filename filename)
tmpfile)))
(define string-split
(lambda (str mark)
(let* ((str-l (string->list str))
@ -33,7 +45,6 @@
(string-split (list->string bodylist)
#\&))))))))
(define read-until-eof
(lambda (port result)
(let ((c (read-bytevector buffer-size port)))
@ -179,8 +190,7 @@
(looper (+ index 1))))))))
(looper 0)))
(else (let ((raw-body (if (string=? request-method "POST")
(read-until-eof stdin (bytevector))
"")))
(read-until-eof stdin (bytevector)) "")))
(set! parameters (split-http-parameters (if (string=? request-method "POST")
raw-body
query-string)))
@ -193,11 +203,6 @@
(cons 'body body)
(cons 'files files)))
(define (write-to-string str)
(let ((port (open-output-string)))
(write str port)
(get-output-string port)))
(define (handle-request options thunk)
(let* ((request (cgi)))
(with-exception-handler

View File

@ -7,6 +7,7 @@
(scheme file)
(scheme char)
(scheme process-context)
(retropikzel net))
(retropikzel net)
(srfi 27))
(export handle-request)
(include "cgi.scm"))

View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -1,50 +1,41 @@
<pre>R7RS Scheme library for Common Gateway Interface
If you dont know what CGI is, in short server runs your Scheme script and
displays it's output as a webpage. Also checkout
[https://git.sr.ht/~retropikzel/scheme-php](https://git.sr.ht/~retropikzel/scheme-php).
displays it's output as a webpage.
[Project](https://sr.ht/~retropikzel/scheme-cgi/)
## Installation
[Repository](https://git.sr.ht/~retropikzel/scheme-cgi)
snow-chibi --impls=$SCHEME retropikzel.cgi
[Issue tracker](https://todo.sr.ht/~retropikzel/scheme-cgi)
## Caveats
- Works only on unix as it reads from /dev/fd/0 and /dev/random.
## Buggy on implementations
- Does not work with mit-scheme
- For some reason mit-scheme exits when it reads eof-object from standard
input
- STklos
- No output for some reason
## How to use
Example using Gauche in Docker.
## Usage example
lighttpd.conf:
server.document-root = "/workdir"
var.basedir = env.PWD
server.document-root = basedir
server.port = 3000
server.modules += ("mod_cgi", "mod_dirlisting")
cgi.assign = (".scm" => "/usr/bin/scheme-script")
cgi.assign = (".scm" => basedir + "/scheme-script")
dir-listing.activate = "enable"
Dockerfile:
scheme-script:
FROM schemers/gauche
RUN apt-get update && apt-get install -y --no-install-recommends lighttpd
WORKDIR /workdir
EXPOSE 3000
COPY lighttpd.conf /lighttpd.conf
RUN echo "#!/bin/sh" > /usr/bin/scheme-script
RUN echo "exec gosh -r7 -I ./snow \$@" >> /usr/bin/scheme-script
RUN chmod +x /usr/bin/scheme-script
ENTRYPOINT ["/usr/sbin/lighttpd", "-D", "-f", "/lighttpd.conf"]
#!/bin/sh
#exec capy --r7rs --script "$@"
#exec chibi-scheme "$@"
#exec csi -quiet -batch "$@"
#exec icyc -s "$@"
#exec gsi /home/youruser/.gambit_userlib/ "$@"
exec gosh "$@"
#exec kawa --r7rs -Dkawa.import.path=/usr/local/share/kawa/lib/*.sld "$@"
#exec loko --program "$@"
#exec mit-scheme --batch-mode --load "$@"
#exec racket -I r7rs --script "$@"
#exec sash -r7 "$@"
#exec skint "$@"
#exec stklos "$@"
#exec tr7i "$@"
hello.scm:
@ -55,80 +46,45 @@ hello.scm:
(handle-request
'()
(lambda (request headers parameters cookies body files)
(display "Content-type: text/html")
(display "
(display "Content-type: text/html
")
(display "
")
(display "Hello")))
(display "Hello</br>")
(write request)))
Run:
run:
docker build . --tag=scheme-cgi
docker run -it -v ${PWD}:/workdir -p 3000:3000 scheme-cgi
chmod +x scheme-cript
lighttpd -D -f lighttpd.conf
Then navigate with your browser to http://127.0.0.1:3000/hello.scm
Then navigate with your browser to http://127.0.0.1:3000
## Documentation
### Reference
(**handle-request** options thunk)
**get-request**
Options must be association list. Thunk must be procedure taking arguments:
Returns the whole request as association list.
- request
- Full request
- headers
- Request headers
- parameters
- Request parameters
- The ?foo=bar&baz=1 part parsed
- cookies
- Request cookies
- body
- Request body
- files
- Request files
**get-header** _name_
Name can be symbol or a string. Returns the value of given header or #f.
**get-headers**
Returns association list of all headers.
**get-parameter** _name_
Name can be symbol or a string. Returns the value of given parameter or #f.
**get-parameters**
Returns association list of all parameters.
**get-cookie** _name_
Returns the value of given cookie or #f if.
**get-cookies**
Returns association list of all cookies.
**get-file** _filename_
Filename is a symbol or a string. Returns the path of given file from files or #f.
Uploaded files are stored in /tmp, with randomly generated prefix on their
name. They are not deleted unless cgi-exit is called. Use **move-file** to move
them into preferred location.
**get-files**
Returns association list of all files.
**move-file** _from_ _to_
Moves a file from _from_ path to _to_ path.
**get-body**
Returns the request body.
**cgi-exit**</br>
**cgi-exit** _code_
Does necessary cleanup and exits the script. Code is a number, if it is given
then that is used as exit code.
Whatever thunk writes to (current-output-port) is sent back as response.
### Environment variables
**SCHEME\_CGI\_TMP\_PATH**
**SCM_CGI_TMPDIR**
Path to where uploaded files are stored. Default is /tmp.</pre>

View File

@ -1,50 +1,66 @@
R7RS Scheme library for Common Gateway Interface
If you dont know what CGI is, in short server runs your Scheme script and
displays it's output as a webpage. Also checkout
[https://git.sr.ht/~retropikzel/scheme-php](https://git.sr.ht/~retropikzel/scheme-php).
displays it's output as a webpage.
[Project](https://sr.ht/~retropikzel/scheme-cgi/)
## Installation
[Repository](https://git.sr.ht/~retropikzel/scheme-cgi)
snow-chibi --impls=$SCHEME retropikzel.cgi
[Issue tracker](https://todo.sr.ht/~retropikzel/scheme-cgi)
## Caveats
## Documentation
- Works only on unix as it reads from /dev/fd/0 and /dev/random.
(**handle-request** options thunk)
## Buggy on implementations
Options must be association list. Thunk must be procedure taking arguments:
- Does not work with mit-scheme
- For some reason mit-scheme exits when it reads eof-object from standard
input
- STklos
- No output for some reason
- request
- Full request
- headers
- Request headers
- parameters
- Request parameters
- The ?foo=bar&baz=1 part parsed
- cookies
- Request cookies
- body
- Request body
- files
- Request files
## How to use
Whatever thunk writes to (current-output-port) is sent back as response.
Example using Gauche in Docker.
lighttpd.conf:
### Environment variables
server.document-root = "/workdir"
server.port = 3000
server.modules += ("mod_cgi", "mod_dirlisting")
cgi.assign = (".scm" => "/usr/bin/scheme-script")
dir-listing.activate = "enable"
**SCM_CGI_TMPDIR**
Dockerfile:
Path to where uploaded files are stored. Default is /tmp.
FROM schemers/gauche
RUN apt-get update && apt-get install -y --no-install-recommends lighttpd
WORKDIR /workdir
EXPOSE 3000
COPY lighttpd.conf /lighttpd.conf
RUN echo "#!/bin/sh" > /usr/bin/scheme-script
RUN echo "exec gosh -r7 -I ./snow \$@" >> /usr/bin/scheme-script
RUN chmod +x /usr/bin/scheme-script
ENTRYPOINT ["/usr/sbin/lighttpd", "-D", "-f", "/lighttpd.conf"]
## Usage examples
These files are shared among all examples. We will be usign Gauche for examples,
but you can comment out your preferred implementation or copy just that exec
line from scheme-script. (Without the #)
scheme-script:
#!/bin/sh
#exec capy --r7rs --script "$@"
#exec chibi-scheme "$@"
#exec csi -quiet -batch "$@"
#exec icyc -s "$@"
#exec gsi /home/youruser/.gambit_userlib/ "$@"
exec gosh "$@"
#exec kawa --r7rs -Dkawa.import.path=/usr/local/share/kawa/lib/*.sld "$@"
#exec loko --program "$@"
#exec mit-scheme --batch-mode --load "$@"
#exec racket -I r7rs --script "$@"
#exec sash -r7 "$@"
#exec skint "$@"
#exec stklos "$@"
#exec tr7i "$@"
hello.scm:
@ -55,78 +71,68 @@ hello.scm:
(handle-request
'()
(lambda (request headers parameters cookies body files)
(display "Content-type: text/html")
(display "Content-type: text/html\r\n")
(display "\r\n")
(display "\r\n")
(display "Hello")))
(display "Hello</br>")
(write request)))
Run:
docker build . --tag=scheme-cgi
docker run -it -v ${PWD}:/workdir -p 3000:3000 scheme-cgi
### Usage lighttpd example
Then navigate with your browser to http://127.0.0.1:3000
Debian/Ubuntu/Mint:
## Documentation
apt-get install lighttpd
### Reference
Files in any (same) directory.
**get-request**
lighttpd.conf:
Returns the whole request as association list.
var.basedir = env.PWD
server.document-root = basedir
server.port = 3000
server.modules += ("mod_cgi", "mod_dirlisting")
cgi.assign = (".scm" => basedir + "/scheme-script")
dir-listing.activate = "enable"
**get-header** _name_
run:
Name can be symbol or a string. Returns the value of given header or #f.
chmod +x scheme-cript
lighttpd -D -f lighttpd.conf
**get-headers**
Then navigate with your browser to http://127.0.0.1:3000/hello.scm
Returns association list of all headers.
**get-parameter** _name_
### Usage apache2 example
Name can be symbol or a string. Returns the value of given parameter or #f.
Debian/Ubuntu/Mint:
**get-parameters**
apt-get install apache2
a2enmod cgi
systemctl restart apache
Returns association list of all parameters.
Only hello.scm in /var/lib/cgi-bin/
**get-cookie** _name_
Add shebang line as first line of hello.scm, for example:
Returns the value of given cookie or #f if.
#!/usr/local/bin/gosh
**get-cookies**
run:
Returns association list of all cookies.
chmod +x /var/lib/cgi-bin/hello.scm
**get-file** _filename_
Then navigate with your browser to http://127.0.0.1/cgi-bin/hello.scm
Filename is a symbol or a string. Returns the path of given file from files or #f.
If your server does not have cgi-bin directory you can try adding it
Uploaded files are stored in /tmp, with randomly generated prefix on their
name. They are not deleted unless cgi-exit is called. Use **move-file** to move
them into preferred location.
mkdir cgi-bin
**get-files**
cgi-bin/.htaccess:
Returns association list of all files.
Options +ExecCGI
SetHandler cgi-script
**move-file** _from_ _to_
Moves a file from _from_ path to _to_ path.
That should work in any other dir too, but you propably want to make it treat
only .scm files as cgi scripts.
**get-body**
Returns the request body.
**cgi-exit**</br>
**cgi-exit** _code_
Does necessary cleanup and exits the script. Code is a number, if it is given
then that is used as exit code.
### Environment variables
**SCHEME\_CGI\_TMP\_PATH**
Path to where uploaded files are stored. Default is /tmp.
SetHandler cgi-script "scm"

11
retropikzel/cgi/hello.scm Normal file
View File

@ -0,0 +1,11 @@
(import (scheme base)
(scheme write)
(retropikzel cgi))
(handle-request
'()
(lambda (request headers parameters cookies body files)
(display "Content-type: text/html\r\n")
(display "\r\n")
(display "Hello</br>")
(write request)))

View File

@ -0,0 +1,6 @@
var.basedir = env.PWD
server.document-root = basedir
server.port = 3000
server.modules += ("mod_cgi", "mod_dirlisting")
cgi.assign = (".scm" => basedir + "/scheme-script")
dir-listing.activate = "enable"

14
retropikzel/cgi/scheme-script Executable file
View File

@ -0,0 +1,14 @@
#!/bin/sh
#exec capy --r7rs --script "$@"
exec chibi-scheme "$@"
#exec csi -quiet -batch "$@"
#exec gsi /home/retropikzel/.gambit_userlib/ "$@"
#exec gosh "$@"
#exec kawa --r7rs -Dkawa.import.path=/usr/local/share/kawa/lib/*.sld "$@"
#exec loko --program "$@"
#exec mit-scheme --batch-mode --load "$@"
#exec racket -I r7rs --script "$@"
#exec sash -r7 "$@"
#exec skint "$@"
#exec stklos "$@"
#exec tr7i "$@"

View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -1,3 +1,7 @@
(define debug?
(and (get-environment-variable "SCM_DEBUG")
(equal? (get-environment-variable "SCM_DEBUG") "1")))
(define print
(lambda args
(map (lambda (item) (display item (current-error-port))) args)))
@ -6,22 +10,21 @@
(syntax-rules ()
((_ obj)
(begin
(print "[DEBUG] " 'obj ": " obj #\newline)
(when debug? (print "[DEBUG] " 'obj ": " obj #\newline))
obj))))
(define-syntax debug
(syntax-rules ()
((_ obj)
(begin
(print "[DEBUG] " 'obj ": " obj #\newline)
(when debug? (print "[DEBUG] " 'obj ": " obj #\newline))
obj))))
(define-syntax debug-proc
(syntax-rules ()
((_ proc arg ...)
(begin
(print "[DEBUG] Calling: " 'proc ", arguments: " '(arg ...))
(when debug? (print "[DEBUG] Calling: " 'proc ", arguments: " '(arg ...)))
(let ((result (apply proc (list arg ...))))
(print ", returned: " result #\newline)
(when debug? (print ", returned: " result #\newline))
result)))))

View File

@ -1,7 +1,8 @@
(define-library
(retropikzel debug)
(import (scheme base)
(scheme write))
(scheme write)
(scheme process-context))
(export debug
debug-display
debug-proc)

View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -1,3 +1,11 @@
(import (scheme base)
(scheme write)
(retropikzel tap)
(retropikzel debug)
(srfi 64))
(test-runner-current (tap-runner))
(test-begin "debug")
(debug 'lol)

116
retropikzel/dirt-db.scm Normal file
View File

@ -0,0 +1,116 @@
(define current-db (make-parameter #f (lambda (value) value)))
(define (err msg . irritants)
(apply error (cons (string-append "dirt-db error: " msg) irritants)))
(define (write-file file value)
(when (file-exists? file) (delete-file file))
(with-output-to-file file (lambda () (write value))))
(define (read-file file)
(guard (ex (else (err (string-append "value read error of: "
(error-object-message ex)
" in file "
file)
file)))
(with-input-from-file file (lambda () (read)))))
(define (file-path path key) (string-append path "/" key ".scm"))
(define (bak-path path key) (string-append path "/" key ".scm.bak"))
(define (strings-ends-with? str end)
(and (> (string-length str) (string-length end))
(string=? (string-copy str (- (string-length str) (string-length end)))
end)))
(define (db-keys path . values?)
(let ((results '()))
(for-each
(lambda (file)
(when (strings-ends-with? file ".scm")
(let ((key (string-copy file 0 (- (string-length file) 4))))
(set! results
(cons
(if (null? values?)
key
(cons key (parameterize ((current-db path)) (read-db key))))
results)))))
(if (directory-exists? path) (directory-files path) '()))
(reverse results)))
(define (directory-exists? path)
(or (file-exists? path)
(guard (condition (else #f))
(file-info-directory? (file-info path #f)))))
(define (ensure-directory-exists path)
(letrec*
((port (open-input-string path))
(looper (lambda (c path)
(let ((full-path (if (eof-object? c)
path
(string-append path (string c)))))
(when (and (or (eof-object? c) (char=? c #\/))
(not (directory-exists? full-path)))
(create-directory full-path)))
(when (not (eof-object? c))
(looper (read-char port) (string-append path (string c)))))))
(looper (read-char port) "")))
(define (read-db key)
(when (not (current-db))
(error "dirt-db error: read-db must be used inside with-db"))
(let ((path (current-db)))
(let* ((file (file-path path key))
(bak-file (bak-path path key)))
(cond ((file-exists? bak-file) (read-file bak-file))
((file-exists? file) (read-file file))
(else #f)))))
(define (write-db key value)
(for-each
(lambda (c)
(if (or (char-alphabetic? c) (char-numeric? c))
#t ;; Do nothing
(err "key can only contain char-alphabetic? and char-numeric?")))
(string->list key))
(when (not (current-db))
(err "write-db must be used inside with-db"))
(let ((path (current-db)))
(when (not (directory-exists? path)) (ensure-directory-exists path))
(let* ((file (file-path path key))
(bak-file (bak-path path key))
(old-value (if (file-exists? file) (read-file file) #f)))
(obtain-dot-lock file)
(guard
(ex (else (release-dot-lock file)
(err "[bak1] Could not write" path key value)))
(write-file bak-file old-value))
(when (not (equal? old-value (read-file bak-file)))
(guard (ex (else #f)) (delete-file bak-file))
(release-dot-lock file)
(err "[bak2] Could not write" path key value))
(guard
(ex (else (release-dot-lock file)
(err "[del] Could not write" path key value)))
(when (file-exists? file) (delete-file file)))
(guard
(ex (else (guard (ex (else #f)) (delete-file file))
(release-dot-lock file)
(err "[write] Could not write" path key value)))
(write-file file value))
(when (not (equal? value (read-file file)))
(guard (ex (else #f)) (delete-file file))
(release-dot-lock file)
(err "[equal] Could not write" path key value))
(guard
(ex (else (release-dot-lock file)
(err "[clean]Could not write" path key value)))
(delete-file bak-file))
(release-dot-lock file))))
(define (with-db path thunk)
(parameterize ((current-db path)) (thunk)))
(define (with-db-keys path thunk)
(parameterize ((current-db path)) (thunk (db-keys path))))
(define (with-db-values path thunk)
(parameterize ((current-db path)) (thunk (db-keys path #t))))

15
retropikzel/dirt-db.sld Normal file
View File

@ -0,0 +1,15 @@
(define-library
(retropikzel dirt-db)
(import (scheme base)
(scheme char)
(scheme read)
(scheme write)
(scheme file)
(retropikzel dot-locking)
(srfi 170))
(export with-db
with-db-keys
with-db-values
read-db
write-db)
(include "dirt-db.scm"))

View File

@ -0,0 +1,3 @@
DIRectories Thanks DataBase
"Database" built on top of directories and files.

View File

@ -0,0 +1 @@
1.0.0

View File

@ -0,0 +1,32 @@
(import (scheme base)
(scheme write)
(retropikzel tap)
(retropikzel dirt-db)
(srfi 64))
(test-runner-current (tap-runner))
(test-begin "dirt-db")
(define db "/tmp/testdb")
(with-db
db
(lambda ()
(write-db "hello" "foobar")))
(with-db
db
(lambda ()
(test-equal "foobar" (read-db "hello"))))
(with-db-keys
db
(lambda (keys)
(test-equal '("hello") keys)))
(with-db-values
db
(lambda (vals)
(test-equal '(("hello" . "foobar")) vals)))
(test-end "dirt-db")

102
retropikzel/dot-locking.scm Normal file
View File

@ -0,0 +1,102 @@
(define (make-lock-file-name file-name) (string-append file-name ".lock"))
(define (sleep time)
(letrec*
((end-time (+ (current-second) time))
(looper (lambda () (when (> (current-second) end-time) (looper)))))
(looper)))
(define (obtain-dot-lock file-name . args)
(let* ((interval
(* (if (>= (length args) 1)
(let ((interval (list-ref args 0)))
(when (not (integer? interval))
(error (string-append "obtain-dot-lock error: interval must"
" be integer"
interval)))
interval)
1000)))
(retry-number
(if (>= (length args) 2)
(let ((retry-number (list-ref args 1)))
(when (and (not (integer? retry-number))
(not (equal? retry-number #f)))
(error (string-append "obtain-dot-lock error: retry-number must"
" be integer or #f")
retry-number))
retry-number)
#f))
(stale-time-seconds
(if (>= (length args) 3)
(let ((stale-time (list-ref args 2)))
(when (and (not (integer? stale-time))
(not (equal? stale-time #f)))
(error (string-append "obtain-dot-lock error: stale time must"
" be integer or #f")
stale-time))
stale-time)
300))
(stale-time (if stale-time-seconds
(+ (current-second) stale-time-seconds)
#f))
(lock-file-name (make-lock-file-name file-name))
(lock-time (lambda ()
(if (file-exists? lock-file-name)
(guard (condition (else 0))
(string->number
(with-input-from-file
lock-file-name
(lambda () (read)))))
0)))
(write-lock-file
(lambda ()
(with-output-to-file
lock-file-name
(lambda ()
(write (current-second)))))))
(letrec
((locker
(lambda (try-count)
(cond ((not (file-exists? lock-file-name))
(guard (condition (else (locker (+ try-count 1))))
(write-lock-file)
#t))
((and retry-number (> try-count retry-number)) #f)
((and stale-time (> (lock-time) stale-time))
(break-dot-lock file-name)
(write-lock-file)
(guard (condition (else #f))
(write-lock-file)
'broken))
((or (not retry-number)
(<= try-count retry-number))
(sleep interval)
(locker (+ try-count)))))))
(locker 0))))
(define (break-dot-lock file-name)
(let ((lock-file-name (make-lock-file-name file-name)))
(when (file-exists? lock-file-name) (delete-file lock-file-name))))
(define (release-dot-lock file-name)
(let ((lock-file-name (make-lock-file-name file-name)))
(guard (condition (else #f))
(when (file-exists? lock-file-name) (delete-file lock-file-name))
#t)))
(define-syntax with-dot-lock*
(syntax-rules ()
((_ file-name thunk)
(letrec* ((locked? (obtain-dot-lock file-name))
(unlock (lambda ()
(when locked? (break-dot-lock file-name))
(set! locked? #f))))
(when locked?
(dynamic-wind (lambda () #t)
(lambda () (guard (condition (else (unlock))) (thunk)))
unlock))
(unlock)))))
(define-syntax with-dot-lock
(syntax-rules ()
((_ file-name body ...)
(with-dot-lock* file-name (lambda () body ...)))))

View File

@ -0,0 +1,13 @@
(define-library
(retropikzel dot-locking)
(import (scheme base)
(scheme read)
(scheme write)
(scheme file)
(scheme time))
(export obtain-dot-lock
break-dot-lock
release-dot-lock
with-dot-lock*
with-dot-lock)
(include "dot-locking.scm"))

View File

@ -0,0 +1,55 @@
Dot locking for files
This is an implementation of dot-locking from [scsh](https://scsh.net/).
## Documentation
From [https://scsh.net/docu/html/man-Z-H-11.html#node_sec_10.3](https://scsh.net/docu/html/man-Z-H-11.html#node_sec_10.3)
Copied here for convenience.
(__obtain-dot-lock__ file-name)
Tries to obtain the lock for file-name. If the file is already locked, the thread
sleeps for interval seconds (default is 1) before it retries. If the lock cannot
be obtained after retry-number attempts, the procedure returns #f, other-
wise #t. The default value of retry-number is #f which corresponds to an
infinite number of retires.
If stale-time is non-#f, it specifies the minimum age a lock may have
(in seconds) before it is considered stale. Obtain-dot-lock attempts to
delete stale locks. If it was succcessful obtaining a lock after breaking
it, obtain-dot-lock returns broken. If stale-time is #f, obtain-dot-lock
never considers a lock stale. The default for stale-time is 300.
Note that it is possible that obtain-dot-lock breaks a lock but never-
theless fails to obtain it otherwise. If it is necessary to handle this case
specially, use break-dot-lock directly (see below) rather than specifying
a non-#f stale-time
(__break-dot-lock__ file-name)
Breaks the lock for file-name if one exists. Note that breaking a lock
does not imply a subsequent obtain-dot-lock will succeed, as an-
other party may have acquired the lock between break-dot-lock and
obtain-dot-lock.
(__release-dot-lock__ file-name)
Releases the lock for file-name. On success, release-dot-lock returns #t,
otherwise #f. Note that this procedure can also be used to break the lock
for file-name.
(__with-dot-lock*__ file-name thunk)
(__with-dot-lock__ file-name body ...)
The procedure with-dot-lock* obtains the requested lock, and then calls
(thunk). When thunk returns, the lock is released. A non-local exit (e.g.,
throwing to a saved continuation or raising an exception) also causes the
lock to be released.
After a normal return from thunk, its return values are returned by
with-dot-lock*. The with-dot-lock special form is equivalent syntac-
tic sugar.

View File

@ -0,0 +1 @@
1.1.0

View File

@ -0,0 +1,73 @@
(import (scheme base)
(scheme write)
(scheme read)
(scheme char)
(scheme file)
(scheme process-context)
(retropikzel tap)
(retropikzel dot-locking)
(srfi 64))
(test-runner-current (tap-runner))
(test-begin "dot-locking")
(test-begin "obtain-dot-lock")
(let* ((testfile "/tmp/scshtestfile.txt")
(lockfile (string-append testfile ".lock")))
(when (file-exists? testfile) (delete-file testfile))
(when (file-exists? lockfile) (delete-file lockfile))
(with-output-to-file testfile (lambda () (display 1)))
(obtain-dot-lock testfile)
(test-assert (file-exists? lockfile)))
(test-end "obtain-dot-lock")
(test-begin "break-dot-lock")
(let* ((testfile "/tmp/scshtestfile.txt")
(lockfile (string-append testfile ".lock")))
(when (file-exists? testfile) (delete-file testfile))
(when (file-exists? lockfile) (delete-file lockfile))
(with-output-to-file testfile (lambda () (display 1)))
(obtain-dot-lock testfile)
(break-dot-lock testfile)
(test-assert (not (file-exists? lockfile))))
(test-end "break-dot-lock")
(test-begin "release-dot-lock")
(let* ((testfile "/tmp/scshtestfile.txt")
(lockfile (string-append testfile ".lock")))
(when (file-exists? testfile) (delete-file testfile))
(when (file-exists? lockfile) (delete-file lockfile))
(with-output-to-file testfile (lambda () (display 1)))
(obtain-dot-lock testfile)
(test-assert (release-dot-lock testfile)))
(test-end "release-dot-lock")
(test-begin "with-dot-lock*")
(let* ((testfile "/tmp/scshtestfile.txt")
(lockfile (string-append testfile ".lock")))
(when (file-exists? testfile) (delete-file testfile))
(when (file-exists? lockfile) (delete-file lockfile))
(with-output-to-file testfile (lambda () (display 1)))
(with-dot-lock*
testfile
(lambda ()
(test-assert (file-exists? lockfile)))))
(test-end "with-dot-lock*")
(test-begin "with-dot-lock")
(let* ((testfile "/tmp/scshtestfile.txt")
(lockfile (string-append testfile ".lock")))
(when (file-exists? testfile) (delete-file testfile))
(when (file-exists? lockfile) (delete-file lockfile))
(with-output-to-file testfile (lambda () (display 1)))
(with-dot-lock testfile (test-assert (file-exists? lockfile))))
(test-end "with-dot-lock")
(test-end "dot-locking")

View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -1,4 +1,4 @@
Scheme library implementing [FastCGI](https://en.wikipedia.org/wiki/FastCGI)
R7RS Scheme library implementing FastCGI
## Simple example
### Scheme Server

View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

4
retropikzel/match.scm Normal file
View File

@ -0,0 +1,4 @@
(define-syntax match
(syntax-rules (or)
((_ val compare-with (compare-to body ...) ...)
(cond ((compare-with val compare-to) body ...) ...))))

6
retropikzel/match.sld Normal file
View File

@ -0,0 +1,6 @@
(define-library
(retropikzel match)
(import (scheme base)
(scheme write))
(export match)
(include "match.scm"))

View File

@ -0,0 +1 @@
WIP

View File

@ -0,0 +1 @@
0.1.0

View File

@ -0,0 +1,17 @@
(import (scheme base)
(scheme write)
(retropikzel tap)
(retropikzel match)
(retropikzel debug)
(srfi 64))
(test-runner-current (tap-runner))
(test-begin "match")
(define val "Hello")
(test-equal 1 (debug (match val equal? ("world" 0) ("Hello" 1))))
(test-equal 1 (debug (match 2 = (1 0) (2 1))))
(test-end "match")

View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -1,3 +1,8 @@
(import (scheme base)
(scheme write)
(retropikzel mouth)
(srfi 64))
(test-begin "mouth")

View File

@ -1,8 +1,3 @@
(define temporary-directory
(if (get-environment-variable "NET_TMP_PATH")
(get-environment-variable "NET_TMP_PATH")
"/tmp"))
(define encode-replacements
(list (list " " "%20")
(list " " "+")
@ -70,26 +65,3 @@
(lambda (str)
(cond ((string? str) (endecode "decode" str))
(else str))))
(define make-temp-filename
(lambda (filename)
(letrec* ((dev-random (open-binary-input-file "/dev/random"))
(min-byte (char->integer #\a))
(max-byte (char->integer #\z))
(max-length 10)
(looper (lambda (result count)
(if (>= count max-length)
result
(let ((byte (read-u8 dev-random)))
(if (and (> byte min-byte) (< byte max-byte))
(looper (bytevector-append result
(bytevector byte))
(+ count 1))
(looper result count))))))
(result (string-append (utf8->string (looper (bytevector) 0))
"_"
(utf8->string (looper (bytevector) 0))
"_"
filename)))
(close-port dev-random)
result)))

View File

@ -4,6 +4,5 @@
(scheme file)
(scheme process-context))
(export url-encode
url-decode
make-temp-filename)
url-decode)
(include "net.scm"))

View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -1,19 +1,100 @@
(define thread-proc (lambda (x) #t))
(define (new-thread)
(make-thread
(lambda ()
(thread-specific-set!
(current-thread)
(thread-proc (thread-specific (current-thread)))))))
(define (new-thread name)
(let
((thread
(make-thread
(lambda ()
(letrec*
((runner
(lambda ()
(when (list? (thread-specific (current-thread)))
(for-each
(lambda (job)
(let ((lst (list-ref job 0))
(index (list-ref job 1))
(proc (list-ref job 2))
(result (list-ref job 3))
(getter (list-ref job 4))
(setter (list-ref job 5)))
(guard (condition
(else
(display "Error in thread: ")
(write (thread-name (current-thread)))
(display ", error: ")
(write condition)
(newline)
(list-set! threads
(string->number (thread-name (current-thread)))
(new-thread (thread-name (current-thread))))))
(setter result
index
(apply proc
(list (getter lst index)))))))
(thread-specific (current-thread)))
(thread-specific-set! (current-thread) #f))
(runner))))
(runner)))
name)))
(thread-specific-set! thread #f)
(thread-start! thread)
thread))
(define threads (make-list thread-count (new-thread)))
(define threads
(letrec*
((looper
(lambda (count result)
(if (>= count thread-count)
result
(looper (+ count 1)
(append result (list (new-thread (number->string count)))))))))
(looper 0 '())))
(define-syntax parallel-map
(syntax-rules ()
((_ env (l args body ...) lst)
(let* ((lst-length (length lst))
(thread-proc (eval `(lambda args body ...)
(apply environment 'env))))
(map thread-proc lst)
))))
(letrec*
((result (make-list (length lst) #f))
(lst-length (length lst))
(loop-length (- (length lst) 2))
(proc (eval `(lambda args body ...) (apply environment env)))
(job-queues (make-vector thread-count '()))
(index 0)
(waited? #f)
(waiter (lambda ()
(for-each
(lambda (thread)
(if (not (thread-specific thread))
(set! waited? #t)
(set! waited? #f)))
threads)
(if (not waited?) (waiter))))
(queu-builder
(lambda (index)
(when (< index lst-length)
(for-each
(lambda (thread)
(when (< index lst-length)
(let ((thread-index (string->number (thread-name thread))))
(vector-set! job-queues
thread-index
(append (vector-ref job-queues thread-index)
(list (list lst
index
proc
result
list-ref
list-set!)))))
(set! index (+ index 1))))
threads)
(queu-builder index)))))
(queu-builder 0)
(for-each
(lambda (thread)
(thread-specific-set!
thread
(vector-ref job-queues
(string->number (thread-name thread)))))
threads)
(waiter)
result))))

View File

@ -1,6 +1,4 @@
(define-syntax parallel-map
(syntax-rules ()
((_ env (l args body ...) lst)
(let* ((lst-length (length lst))
(proc (eval `(lambda args body ...) (apply environment 'env))))
(map proc lst)))))
(map (eval '(lambda args body ...) (apply environment env)) lst))))

View File

@ -3,14 +3,12 @@
(import (scheme base)
(scheme write)
(scheme eval)
(retropikzel hardware-info)
(retropikzel purer))
(retropikzel hardware-info))
(include "parallel/shared.scm")
(cond-expand
((library (srfi 18))
(import (srfi 18))
(include "parallel-srfi-18.scm"))
(else
(import (scheme base))
(include "parallel.scm")))
(else (include "parallel.scm"))
)
(export parallel-map))

View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -1 +1 @@
WIP
Utilities to process things in parallel easily

View File

@ -1,9 +1,23 @@
(import (scheme base)
(scheme write)
(retropikzel tap)
(retropikzel debug)
(retropikzel parallel)
(srfi 19)
(srfi 64))
(write (parallel-map
((scheme base))
(lambda (i)
(+ i 1))
'(1 2 3 4 5 6 7 8 9 10)))
(test-runner-current (tap-runner))
(define lst '(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16))
(write (parallel-map '((scheme base)) (lambda (i) (+ i 1)) lst))
(newline)
(newline)
(write (parallel-map '((scheme base)) (lambda (i) (+ i 1)) lst))
(newline)
(newline)
(write (parallel-map '((scheme base)) (lambda (i) (+ i 1)) lst))
(newline)
(newline)

View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -1,99 +1,184 @@
(define tap-output-port (current-output-port))
(define (set-tap-runner-output-port! port) (set! tap-output-port port))
;;> \pre{
;;> TAP output for SRFI-64
;;>
;;> [Test Anything Protocol](https://testanything.org/)
;;>
;;>}
(define-syntax tap-runner
(syntax-rules ()
((_)
(letrec* ((any->string
(lambda (any)
(let ((port (open-output-string)))
(display any port)
(get-output-string port))))
(indentation '())
(increase-indentation
(lambda ()
(set! indentation (append indentation '(#\space #\space)))))
(decrease-indentation
(lambda ()
(when (not (null? indentation))
(set! indentation (list-tail indentation 2)))))
(print
(lambda args
(map (lambda (item)
(display item tap-output-port))
(append indentation args))))
(println
(lambda args
(map (lambda (item)
(display item tap-output-port))
(append indentation args))
(display "\n" tap-output-port)))
(runner (test-runner-null))
(started? #f)
(current-test-groups (vector))
(current-test-group-count 0)
(current-suite-name #f))
;;> \section{Usage}
;;> \pre{
;;> (import (scheme base)
;;> (srfi 64)
;;> (retropikzel tap))
;;>
;;> (test-runner-current (tap-runner))
;;>
;;> (test-begin "My Cool Library")
;;> (test-equal 1 1)
;;> (test-end "My Cool Library")
;;>}
(test-runner-on-group-begin!
runner
(lambda (runner suite-name count)
(set! current-test-group-count 0)
(when current-suite-name
(println "# Subtest: " suite-name)
(increase-indentation))
(set! current-suite-name suite-name)
(set! current-test-groups (vector-append current-test-groups (vector suite-name)))))
;;> \section{Reference}
(test-runner-on-group-end!
runner
(lambda (runner)
(when (> current-test-group-count 0)
(println "1.." current-test-group-count))
(decrease-indentation)
(set! current-test-groups
(list->vector
(reverse
(list-tail
(reverse (vector->list current-test-groups))
1))))))
(define group-test-counts '())
(define (increase-group-test-count name)
(set! group-test-counts
(cons (cons name
(+ (cdr (or (assoc name group-test-counts) (cons 0 0))) 1))
group-test-counts)))
(test-runner-on-test-begin!
runner
(lambda (runner)
(when (not started?)
(println "TAP version 14")
(set! started? #t))
(set! current-test-group-count (+ current-test-group-count 1))))
(define group-fail-counts '())
(define (increase-group-fail-count name)
(set! group-fail-counts
(cons (cons name
(+ (cdr (or (assoc name group-fail-counts) (cons 0 0))) 1))
group-fail-counts)))
(test-runner-on-test-end!
runner
(lambda (runner)
(let* ((name (test-runner-test-name runner))
(result (test-result-kind runner))
(status (cond ((equal? result 'pass) "passed")
((equal? result 'xpass) "passed")
((equal? result 'fail) "failed")
((equal? result 'xfail) "failed")
((equal? result 'skipped) "skipped")
(else "other")))
(result-ref
(lambda (runner key)
(let ((value (test-result-ref runner key)))
(if value (any->string value) "")))))
(let* ((failed? (or (equal? result 'fail) (equal? result 'xfail))))
(when failed? (print "not "))
(print "ok " current-test-group-count)
(if (and (string? name) (not (string=? name "")))
(println " - " name)
(println ""))
(when failed?
(println " ---")
(println " severity: fail")
(println " data:")
(println " source: " (result-ref runner 'source-form))
(println " got: " (result-ref runner 'actual-value))
(println " expect: " (result-ref runner 'expected-value))
(println " at: ")
(println " file: " (result-ref runner 'source-file))
(println " line: " (result-ref runner 'source-line)))))))
runner))))
(define (display-map runner . args)
;; Indentation
(for-each
(lambda (group)
(display " "))
(if (> (length (test-runner-group-stack runner)) 1)
(cdr (test-runner-group-stack runner))
'()))
(map (lambda (item) (display item)) args))
(define (display-map-1 runner . args)
;; Indentation, -1
(for-each
(lambda (group)
(display " "))
(if (> (length (test-runner-group-stack runner)) 2)
(cdr (cdr (test-runner-group-stack runner)))
'()))
(map (lambda (item) (display item)) args))
;;>Get the TAP test runner.
(define (tap-runner)
(let ((runner (test-runner-null)))
(test-runner-reset runner)
(test-runner-on-group-begin! runner test-on-group-begin-tap)
(test-runner-on-group-end! runner test-on-group-end-tap)
(test-runner-on-final! runner test-on-final-tap)
(test-runner-on-test-begin! runner test-on-test-begin-tap)
(test-runner-on-test-end! runner test-on-test-end-tap)
(test-runner-on-bad-count! runner test-on-bad-count-tap)
(test-runner-on-bad-end-name! runner test-on-bad-end-name-tap)
runner))
(define (test-on-group-begin-tap runner name count)
(cond ((null? (test-runner-group-stack runner))
(display-map runner "TAP version 14" #\newline)
(display-map runner "# %%%% Starting test srfi-64" #\newline)
(when (implementation-name)
(display-map runner "# scheme: " (implementation-name) #\newline))
(when (implementation-version)
(display-map runner "# scheme version: " (implementation-version) #\newline))
(display-map runner "# scheme features: " (features) #\newline)
(when (cpu-architecture)
(display-map runner "# cpu-architecture: " (cpu-architecture) #\newline))
(when (machine-name)
(display-map runner "# machine-name: " (machine-name) #\newline)))
(else
(increase-group-test-count (car (test-runner-group-stack runner)))
(display-map runner "# Subtest: " name #\newline))))
(define (test-on-group-end-tap runner)
(let ((count (cdr (or (assoc (car (test-runner-group-stack runner))
group-test-counts)
(cons 0 0)))))
(display-map runner "1.." (if (= count 0) "0 # skip" count) #\newline))
(when (> (length (test-runner-group-stack runner)) 1)
(let ((previous-count (cdr (or (assoc (cadr (test-runner-group-stack runner))
group-test-counts)
(cons 0 0)))))
(cond ((assoc (car (test-runner-group-stack runner)) group-fail-counts)
(display-map-1 runner "not ok " previous-count #\newline))
(else (display-map-1 runner "ok " previous-count #\newline))))))
(define (test-on-final-tap runner)
(display-map runner
"# of total tests "
(+ (test-runner-pass-count runner)
(test-runner-xfail-count runner)
(test-runner-xpass-count runner)
(test-runner-fail-count runner)
(test-runner-skip-count runner))
#\newline)
(when (> (test-runner-pass-count runner) 0)
(display-map runner
"# of expected passes "
(test-runner-pass-count runner)
#\newline))
(when (> (test-runner-xfail-count runner) 0)
(display-map runner
"# of expected failures "
(test-runner-xfail-count runner)
#\newline))
(when (> (test-runner-xpass-count runner) 0)
(display-map runner
"# of unexpected successes "
(test-runner-xpass-count runner)
#\newline))
(when (> (test-runner-fail-count runner) 0)
(display-map runner
"# of failures "
(test-runner-fail-count runner)
#\newline))
(when (> (test-runner-skip-count runner) 0)
(display-map runner
"# of skipped test "
(test-runner-skip-count runner)
#\newline))
(when (and (not (get-environment-variable "SCM_TAP_NO_EXIT_FAIL"))
(> (test-runner-fail-count runner) 0))
(exit 1)))
(define (test-on-test-begin-tap runner)
(when (null? (test-runner-group-stack runner))
(error "Running tests without test-begin"))
(values))
(define (test-on-test-end-tap runner)
(increase-group-test-count (car (test-runner-group-stack runner)))
(let* ((result-kind-name (case (test-result-kind runner)
((pass) "pass")
((fail) "fail")
((xpass) "xpass")
((xfail) "xfail")
((skip) "skip")
(else "other")))
(count (cdr (assoc (car (test-runner-group-stack runner))
group-test-counts)))
(name
(cond ((not (string? (test-runner-test-name runner))) "")
((string=? (test-runner-test-name runner) "") "")
(else (string-append " - " (test-runner-test-name runner))))))
(cond ((equal? result-kind-name "fail")
(increase-group-fail-count (car (test-runner-group-stack runner)))
(display-map runner "not ok " count name #\newline)
(display-map runner " ---" #\newline)
(display-map runner " severity: fail" #\newline)
(when (test-result-ref runner 'source-form)
(display-map runner " source: " (test-result-ref runner 'source-form) #\newline))
(when (test-result-ref runner 'actual-value)
(display-map runner " got: " (test-result-ref runner 'actual-value) #\newline))
(when (test-result-ref runner 'expected-value)
(display-map runner " expect: " (test-result-ref runner 'expected-value) #\newline))
(when (test-result-ref runner 'source-file)
(display-map runner " file: " (test-result-ref runner 'source-file) #\newline))
(when (test-result-ref runner 'source-line)
(display-map runner " line: " (test-result-ref runner 'source-line) #\newline)))
((equal? result-kind-name "skip")
(display-map runner "ok " count name " # skip " #\newline))
(else (display-map runner "ok " count name #\newline)))))
(define (test-on-bad-count-tap runner count expected-count) #t)
(define (test-on-bad-end-name-tap runner begin-name end-name)
(error (string-append "Test-end \""
end-name
"\" does not match test-begin \""
begin-name
"\".")))

View File

@ -2,8 +2,10 @@
(retropikzel tap)
(import (scheme base)
(scheme write)
(srfi 64))
(export tap-runner
set-tap-runner-output-port!)
(scheme file)
(scheme process-context)
(srfi 64)
(srfi 112))
(export tap-runner)
(include "tap.scm"))

View File

@ -0,0 +1 @@
Test Anything Protocol output for SRFI-64

View File

@ -1,165 +1 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
LGPL-3.0-or-later

View File

@ -1,9 +1,8 @@
TAP output for SRFI-64
Test Anything Protocol output for SRFI-64
[Test Anything Protocol](https://testanything.org/)
## Usage
(import (scheme base)
@ -13,8 +12,7 @@ TAP output for SRFI-64
(test-runner-current (tap-runner))
## Reference
## Documentation
(**tap-runner**)
@ -27,3 +25,11 @@ Set the output port of the test runner. To output to file you can do:
(define tap-file "tap-result.txt")
(when (file-exists? tap-file) (delete-file tap-file))
(set-tap-runner-output-port! (open-output-file tap-file))
### Environment variables
**SCM_TAP_EXIT_FAIL**
If you want the test runner to exit on end with fail (1) if any of the tests
fail, set this environment variable.

View File

@ -1 +1 @@
0.2.1
1.2.0

View File

@ -1,24 +1,56 @@
(import (scheme base)
(scheme write)
(retropikzel tap)
(srfi 64))
(test-runner-current (tap-runner))
(test-begin "tap")
(test-assert #t)
(test-assert #t)
(test-equal 1 1)
(test-equal 1 1)
(test-begin "tap 1")
(test-assert #t)
(test-assert #t)
(test-assert #f)
(test-equal '(1 2 3) '(4 5 6))
(test-equal 1 1)
(test-equal 1 1)
(test-end "tap 1")
(test-begin "tap 2")
(test-equal '(1 2 3) '(1 2 3))
(test-assert #t)
(test-equal 1 1)
(test-assert "I have a name" #t)
(test-begin "tap 2.1")
(test-equal 1 1)
(test-begin "tap 2.1.1")
(test-skip 1)
(test-equal 1 1)
(test-end "tap 2.1.1")
(test-end "tap 2.1")
(test-end "tap 2")
(test-assert #t)
(test-equal '(4 5 6) '(7 8 9))
(test-equal 1 1)
;(test-equal '(4 5 6) '(7 8 9))
(test-skip (lambda (runner)
(string=? (car (test-runner-group-stack runner)) "tap 3")))
(test-begin "tap 3")
(test-equal 1 1)
(test-equal 1 1)
(test-equal 1 1)
(test-end "tap 3")
(test-group
"tap 4"
(test-assert (= 1 1))
(test-assert (= 1 1))
(test-assert (= 1 1))
(test-assert (= 1 1))
(test-assert (= 1 1))
(test-assert (= 1 1)))
(test-end "tap")

View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

185
retropikzel/tls-new.scm Normal file
View File

@ -0,0 +1,185 @@
;; If you hacking on this you best read the spec
;; https://datatracker.ietf.org/doc/html/rfc5246
(define versions '((tls-1.0 . #u8(3 1)) (tls-1.2 . #u8(3 3))))
(define cipher-suites
;; First is the default
'((TLS_RSA_WITH_AES_256_CBC_SHA . #u8(0 #x35))))
(define (make-tls-record version content-type fragment-bytes)
(let ((length-bytes (bytevector 0 0)))
(bytevector-uint-set! length-bytes 0 (bytevector-length fragment-bytes) 'big 2)
(bytevector-append
(bytevector (cdr (assoc content-type content-types)))
(cdr (assoc version versions))
length-bytes
fragment-bytes)))
(define (make-client-hello version random-bytes session-id cipher-suites)
;; https://datatracker.ietf.org/doc/html/rfc5246#section-7.4.1.2
(let* ((cipher-suites-length-bytes
(integer->bytevector (bytevector-length cipher-suites) 'big 2))
(content-bytes
(bytevector-append (cdr (assoc version versions))
random-bytes
session-id
cipher-suites-length-bytes
cipher-suites
(bytevector 1 0)
(bytevector 0 0)))
(content-length-bytes
(let ((bytes (bytevector 0 0 0)))
(bytevector-uint-set!
bytes 0 (bytevector-length content-bytes) 'big 3)
bytes)))
;; https://tls12.xargs.org/#client-hello
;; Interestingly the version is 3.1 (TLS 1.0) instead of the expected "3,3"
;; (TLS 1.2). Looking through the golang crypto/tls library we find the following comment:
;; // Some TLS servers fail if the record version is
;; // greater than TLS 1.0 for the initial ClientHello.
(make-tls-record 'tls-1.0
'handshake
(bytevector-append
(bytevector (cdr (assoc 'client_hello handshake-types)))
content-length-bytes
content-bytes))))
(define (read-tls-record receiver)
(let* ((type-byte (receiver 1))
(type (cdr (assoc (bytevector-u8-ref type-byte 0) types-content)))
(version (receiver 2))
(len-bytes (receiver 2))
(len (bytevector-uint-ref len-bytes 0 'big 2))
(bytes (receiver len)))
(display "HERE: type-byte ")
(write type-byte)
(newline)
(display "HERE: type ")
(write type)
(newline)
(display "HERE: version ")
(write version)
(newline)
(display "HERE: len-bytes ")
(write len-bytes)
(newline)
(display "HERE: len ")
(write len)
(newline)
;(display "HERE: bytes ")
;(write bytes)
;(newline)
(cond
;; https://datatracker.ietf.org/doc/html/rfc5246#section-7.2
((equal? type 'alert)
(if (= (bytevector-u8-ref bytes 0) 2) ;; Fatal
(error "TLS Alert: " (cdr (assoc (bytevector-u8-ref bytes 1) types-alert)))
(warn (cdr (assoc (bytevector-u8-ref bytes 1) types-alert)))))
((equal? type 'handshake)
(let ((type (cdr (assoc (bytevector-u8-ref bytes 0) types-handshake))))
(cond
;; https://datatracker.ietf.org/doc/html/rfc5246#section-7.4.1.3
((equal? type 'server_hello)
(let ((session-id-length (bytevector-u8-ref bytes 38)))
`(server_hello
(type . ,(bytevector-copy bytes 0 1))
(size . ,(bytevector-uint-ref bytes 1 'big 3))
(version . ,(bytevector-copy bytes 4 6))
(server-random . ,(bytevector-copy bytes 6 38))
(session-id-length ,session-id-length)
(session-id . ,(if (= session-id-length 0)
(bytevector)
(bytevector-copy bytes 39 (+ 39 session-id-length))))
(cipher-suite .
,(bytevector-copy bytes
(+ 39 session-id-length)
(+ 39 session-id-length 2)))
(compression . ,(bytevector-copy bytes
(+ 39 session-id-length 2)
(+ 39 session-id-length 3))))))
;; https://datatracker.ietf.org/doc/html/rfc5246#section-7.4.2
;; https://tls12.xargs.org/certificate.html#server-certificate-detail/annotated
((equal? type 'certificate)
(let* ((one 1)
(ASN.1-length1 (bytevector-u8-ref bytes 11))
(ASN.1-length2 (bytevector-u8-ref bytes (+ 14 ASN.1-length1)))
(certificate-length (bytevector-uint-ref bytes 7 'big 3))
)
`(certificate
(handshake-message-len . ,(bytevector-copy bytes 1 4))
(handshake-message-len . ,(bytevector-uint-ref bytes 1 'big 3))
(certificates-len . ,(bytevector-copy bytes 4 7))
(certificates-len . ,(bytevector-uint-ref bytes 4 'big 3))
(certificate-len . ,(bytevector-copy bytes 7 10))
(certificate-len . ,(bytevector-uint-ref bytes 7 'big 3))
(certificate ,(read-certificates bytes 10))
#;(test ,(bytevector-copy bytes
10
64
))
;(certificate-length . ,(bytevector-copy bytes 7 10))
;(certificate-length . ,(bytevector-uint-ref bytes 7 'big 3))
;(certificates-sequence-tag . ,(bytevector-u8-ref bytes 10))
;(certificates-sequence-len . ,(bytevector-uint-ref bytes 11 'big 3))
;(certificates ,(read-certificates bytes 10 (bytevector-length bytes) '()))
#;(test ,(bytevector-copy bytes
(+ 10 2 130 2 21)
(+ 10 2 130 2 21 512)
))
;(ASN.1-tag1 . ,(bytevector-u8-ref bytes 10))
;(ASN.1-length1 . ,(bytevector-u8-ref bytes 11))
;(ASN.1-length . ,(bytevector-uint-ref bytes 11 'big 3))
;(ASN.1-length2 . ,ASN.1-length2)
;(certificate-bytes1 . ,(bytevector-copy bytes 12 (+ 12 ASN.1-length1 1)))
#;(certificate-bytes2 . ,(bytevector-copy bytes
(+ 12 ASN.1-length1 1)
(+ 12 ASN.1-length1 1 ASN.1-length2)))
#;(test . ,(bytevector-copy bytes
(+ 12 ASN.1-length1 1 ASN.1-length2)
(+ 12 ASN.1-length1 1 ASN.1-length2 64)))
;(bytes-len ,(bytevector-length bytes))
#;(certificates . ,(read-certificates bytes
10
(bytevector-length bytes)
'()))
;(version . ,(bytevector-u8-ref bytes 4))
;; https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.2
;(serial-number . ,(bytevector-u8-ref bytes 5))
;; https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.3
;(signature . ,(bytevector-u8-ref bytes 6))
))
)))))))
(define (tls-client-handshake sender receiver . options)
(let* ((version 'tls-1.2) ;; Default, and currently only one
;; No unix time as first four bytes of random-bytes
;; https://datatracker.ietf.org/doc/html/draft-mathewson-no-gmtunixtime-00
(random-bytes (get-random-bytes 32))
(session-id (bytevector 0))
(client-hello (make-client-hello version
random-bytes
session-id
(cdr (car cipher-suites)))))
(display "HERE: client-hello ")
(write client-hello)
(newline)
(sender client-hello)
(let ((server-hello (read-tls-record receiver)))
(when (not (equal? (car server-hello) 'server_hello))
(error "tls error: Unexpected response from server, expected server_hello"
server-hello))
(let ((server-version-bytes (cdr (assoc 'version (cdr server-hello))))
(client-version-bytes (cdr (assoc version versions))))
(when (not (equal? client-version-bytes server-version-bytes))
(error "tls error: Client server version mismatch"
client-version-bytes
server-version-bytes))
(write server-hello)
(newline)
(let ((certificate (read-tls-record receiver)))
(write certificate)
(newline)
)))))

159
retropikzel/tls.scm Normal file
View File

@ -0,0 +1,159 @@
;; Context
(define-record-type <tls-context>
(internal-make-tls-context version
random-bytes
session-id
hello-cipher-suite
compression-method)
tls-context?
(version tls-context-version)
(random-bytes tls-context-random-bytes)
(session-id tls-context-session-id)
(hello-cipher-suite tls-context-hello-cipher-suite)
(compression-method tls-context-compression-method))
(define make-tls-context
(lambda options
(when (not (null? options))
(error "make-tls-context error: No options are currently supported" options))
(internal-make-tls-context (tls-version-bytes *tls-1.2*)
(get-random-bytes 28)
(make-bytevector 32 0)
(get-hello-cipher-suite-bytes 'TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384)
(bytevector 0))))
;; Version
;; https://datatracker.ietf.org/doc/html/rfc5246#section-6.2
(define-record-type <tls-version>
(make-tls-version name major minor bytes)
tls-version?
(name tls-version-name)
(major tls-version-major)
(minor tls-version-minor)
(bytes tls-version-bytes))
(define *tls-1.2* (make-tls-version "tls-1.2" 3 3 (bytevector 3 3)))
;; Hello Cipher Suites
(define (get-hello-cipher-suite-bytes name)
(cond ((equal? name 'TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) (bytevector 0 61))
(else (error "get-hello-cipher-suite-bytes error: Unsupported name" name))))
;; ContentType
(define (get-content-type-bytes name)
(cond ((equal? name 'ChangeChipherSpec) (bytevector 20))
((equal? name 'Alert) (bytevector 21))
((equal? name 'Handshake) (bytevector 22))
((equal? name 'Application) (bytevector 23))
((equal? name 'HeartBeat (bytevector 24)))
(else (error "get-content-type-bytes error: Unknown name" name))))
(define (get-content-type-name byte)
(cond ((= byte 20) 'ChangeChipherSpec)
((= byte 21) 'Alert)
((= byte 22) 'Handshake)
((= byte 23) 'Application)
((= byte 24) 'HeartBeat)
(else (error "get-content-type-name error: Unknown byte" byte))))
;; HandshakeType
(define (get-handshake-type-bytes name)
(cond ((equal? name 'Hellorequest) (bytevector 0))
((equal? name 'ClientHello) (bytevector 1))
((equal? name 'ServerHello) (bytevector 2))
((equal? name 'NewSessionTicket) (bytevector 4))
((equal? name 'EncryptedExtensions) (bytevector 8)) ;; TLS 1.3 Only
((equal? name 'Certificate) (bytevector 11))
((equal? name 'ServerKeyExhange) (bytevector 12))
((equal? name 'CertificateRequest) (bytevector 13))
((equal? name 'ServerHelloDone) (bytevector 14))
((equal? name 'CertificateVerify) (bytevector 15))
((equal? name 'ClientKeyExchange) (bytevector 16))
((equal? name 'Finished) (bytevector 20))
(else (error "get-handshake-type-bytes error: Unknown name" name))))
(define-record-type <tls-record>
(internal-make-tls-record type version length bytes)
tls-record?
(type tls-record-type)
(version tls-record-version)
(length tls-record-length)
(bytes tls-record-bytes))
(define (bytes->tls-record bytes)
(let ((type (get-content-type-name (bytevector-u8-ref bytes 0)))
(version (bytevector (bytevector-u8-ref bytes 1)
(bytevector-u8-ref bytes 2)))
)
(internal-make-tls-record type version #f #f)
))
(define (make-tls-record context content-type fragment-bytes)
(bytevector-append
(get-content-type-bytes content-type)
(tls-context-version context)
(integer->uint16-bytevector (bytevector-length fragment-bytes))
fragment-bytes))
;; Handshake
(define (make-tls-handshake-client-hello context)
(make-tls-record context
'Handshake
(bytevector-append
(tls-context-version context)
(integer->uint32-bytevector (current-second-integer))
(tls-context-random-bytes context)
(tls-context-session-id context)
(tls-context-hello-cipher-suite context)
(tls-context-compression-method context)
)))
#;(define (make-tls-record type version message-bytes data)
(when (not (tls-content-type? type))
(error "make-tls-record error: type must be be <tls-content-type>" type))
(when (not (tls-version? version))
(error "make-tls-record error: version must be <tls-version>" version))
(when (not (bytevector? message-bytes))
(error "make-tls-record error: message-bytes must be bytevector" message-bytes))
(when (> (bytevector-length message-bytes) 16384) ;; length MUST NOT exceed 2^14
(error "make-tls-record error: message-byte length too big"))
(let* ((len (bytevector-length message-bytes))
(bytes (bytevector-append
(tls-content-type-bytes type)
(tls-version-bytes version)
(integer->uint16-bytevector len)
;; TODO: Add MAC (optional)
;; TODO: Add padding (block chiphers only)
message-bytes)))
(internal-make-tls-record type version bytes data)))
#;(define (make-tls-handshake-record type version)
(when (not (tls-handshake-type? type))
(error "make-tls-handshake-record error: type must be <tls-handshake-type>" type))
(when (not (tls-version? version))
(error "make-tls-handshake-record error: version must be <tls-version>" version))
(cond
;; https://datatracker.ietf.org/doc/html/rfc5246#section-7.4.1.2
((equal? type *client-hello*)
(let* ((message-bytes (bytevector))
(message-bytes-length (bytevector-length message-bytes))
(header-bytes (bytevector-append
(tls-content-type-bytes *handshake*)
(integer->uint24-bytevector message-bytes-length)
(integer->uint32-bytevector (current-second-integer))
)))
(make-tls-record *handshake*
version
message-bytes
)))
(else (error "make-tls-handshake-type error: type not yet supported" type))))
#;(define (tls-handshake reader writer)
#t)

18
retropikzel/tls.sld Normal file
View File

@ -0,0 +1,18 @@
(define-library
(retropikzel tls)
(import (scheme base)
(scheme write)
(scheme time)
(scheme process-context)
(srfi 27)
(srfi 60))
(export tls-client-handshake
tls-send
tls-receive)
(include "tls/ext-util.scm")
(include "tls/types.scm")
(include "tls/util.scm")
(include "tls/certificate.scm")
;(include "tls.scm")
(include "tls-new.scm")
)

View File

@ -0,0 +1 @@
WIP

1
retropikzel/tls/VERSION Normal file
View File

@ -0,0 +1 @@
0.1.0

View File

@ -0,0 +1,59 @@
;; https://www.oss.com/asn1/resources/asn1-made-simple/introduction.html
;; https://www.oss.com/asn1/resources/asn1-made-simple/asn1-quick-reference/basic-encoding-rules.html
;; https://www.oss.com/asn1/resources/asn1-made-simple/asn1-quick-reference.html
;; https://letsencrypt.org/docs/a-warm-welcome-to-asn1-and-der/#length
(define (read-sequence-length bytes start-index)
(let ((bits (integer->list (bytevector-u8-ref bytes start-index))))
bits))
(define (read-asn.1-sequence bytes start-index result)
(when (not (= (bytevector-u8-ref bytes start-index) 48))
(error "read-asn.1-sequence error: start index is not sequence tag (48)"
bytes
start-index))
(if (or (> start-index (bytevector-length bytes))
(not (= (bytevector-u8-ref bytes start-index) 48)))
result
(let ((sequence-length+length-bytes-length
(bytevector-u8-ref bytes (+ start-index 1)))
)
(read-asn.1-sequence-items
bytes
(+ start-index sequence-length)
(append
result
(list
(bytevector-copy bytes
start-index
(+ start-index (- sequence-length 1)))))))))
(define (read-asn.1-integer bytes start-index)
(when (not (= (bytevector-u8-ref bytes start-index) 2))
(error "read-asn.1-integer error: bytes start index is not integer type tag"
bytes
start-index))
(bytevector-uint-ref bytes
(+ start-index
1 ;; ASN.1-type
1 ;; ASN.1-length
)
'big
(bytevector-u8-ref bytes (+ start-index 1)) ;; ASN.1-length
))
(define (bytes->certificate bytes)
(let ((asn.1-sequence-length (bytevector-u8-ref bytes 1)))
`(certificate
(asn.1-sequence-tag . ,(bytevector-u8-ref bytes 0))
(asn.1-sequence-length . ,asn.1-sequence-length)
(tbs-certificate . ,(read-asn.1-sequence bytes 0 '()))
(bytes ,bytes)
;(version . ,(bytevector-u8-ref bytes 2))
;(serial-number . , (read-asn.1-integer bytes 3))
)
))
(define (read-certificates bytes start-index)
;; https://datatracker.ietf.org/doc/html/rfc5280#section-4.1
(map bytes->certificate (read-asn.1-sequence bytes start-index)))

View File

@ -0,0 +1,61 @@
;;;;;;;;; From (r6rs bytevectores) begin ;;;;;;;;;;
;;; Copyright 2015 William D Clinger.
;;;
;;; Permission to copy this software, in whole or in part, to use this
;;; software for any lawful purpose, and to redistribute this software
;;; is granted subject to the restriction that all copies made of this
;;; software must include this copyright and permission notice in full.
;;;
;;; I also request that you send me a copy of any improvements that you
;;; make to this software so that they may be incorporated within it to
;;; the benefit of the Scheme community.
;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define-syntax bytevector:div
(syntax-rules ()
((_ x y) (quotient x y))))
(define-syntax bytevector:mod
(syntax-rules ()
((_ x y) (remainder x y))))
(define-syntax unspecified
(syntax-rules ()
((_) (if #f #f))))
(define (bytevector-uint-ref bytevector index endness size)
(case endness
((big)
(do ((i 0 (+ i 1))
(result 0 (+ (* 256 result)
(bytevector-u8-ref bytevector (+ index i)))))
((>= i size)
result)))
((little)
(do ((i (- size 1) (- i 1))
(result 0 (+ (* 256 result)
(bytevector-u8-ref bytevector (+ index i)))))
((< i 0)
result)))
(else (error "bytevector-uint-ref error: Unknown endianness" endness))))
(define (bytevector-uint-set! bytevector index val endness size)
(case endness
((little)
(do ((i 0 (+ i 1))
(val val (bytevector:div val 256)))
((>= i size)
(unspecified))
(bytevector-u8-set! bytevector (+ index i) (bytevector:mod val 256))))
((big)
(do ((i (- size 1) (- i 1))
(val val (bytevector:div val 256)))
((< i 0)
(unspecified))
(bytevector-u8-set! bytevector (+ index i) (bytevector:mod val 256))))
(else
(bytevector-uint-set! bytevector index val (native-endianness) size))))
;;;;;;;;; From (r6rs bytevectores) end ;;;;;;;;;;

44
retropikzel/tls/test.scm Normal file
View File

@ -0,0 +1,44 @@
(import (scheme base)
(scheme write)
(retropikzel tap)
(retropikzel tls)
(chibi crypto rsa)
(srfi 64)
(srfi 106))
;; tcpbin.com is an TCP echo server service
;;
;; - TCP echo server (port 4242)
;; - TCP echo server with TLS support (port 4243)
;; - TCP echo server with client authentication or mTLS (port 4244)
(test-runner-current (tap-runner))
(test-begin "TLS")
(test-group
"Ensuring TCP Socket works without TLS..."
(let ((client-socket (make-client-socket "tcpbin.com" "4242"))
(msg "Hello world!\n"))
(socket-send client-socket (string->utf8 msg))
(let ((response (utf8->string (socket-recv client-socket (string-length msg)))))
(test-assert (string=? response msg))
(when (not (string=? response msg))
(error "Stopping tests, TCP socket does not work even without TLS"
response)
(exit 1)))))
(let* ((client-socket (make-client-socket "tcpbin.com" "4243"))
(tls-connection
(tls-client-handshake (lambda (bytes)
(socket-send client-socket bytes))
(lambda (count)
(socket-recv client-socket count)))))
(display "HERE: ")
(write tls-connection)
(newline))
(test-end "TLS")

51
retropikzel/tls/types.scm Normal file
View File

@ -0,0 +1,51 @@
(define content-types
'((change_chipher_spec . 20)
(alert . 21)
(handshake . 22)
(application . 23)
(heart_beat . 24)))
(define types-content
(map (lambda (item) (cons (cdr item) (car item))) content-types))
(define alert-types
'((close_notify . 0)
(unexpected_message . 10)
(bad_record_mac . 20)
(decryption_failed_RESERVED . 21)
(record_overflow . 22)
(decompression_failure . 30)
(handshake_failure . 40)
(no_certificate_RESERVED . 41)
(bad_certificate . 42)
(unsupported_certificate . 43)
(certificate_revoked . 44)
(qertificate_expired . 45)
(certificate_unknown . 46)
(illegal_parameter . 47)
(unknown_ca . 48)
(access_denied . 49)
(decode_error . 50)
(decrypt_error . 51)
(export_restriction_RESERVED . 60)
(protocol_version . 70)
(insufficient_security . 71)
(internal_error . 80)
(user_canceled . 90)
(no_renegotiation . 100)
(unsupported_extension . 110)))
(define types-alert
(map (lambda (item) (cons (cdr item) (car item))) alert-types))
(define handshake-types
'((hello_request . 0)
(client_hello . 1)
(server_hello . 2)
(certificate . 11)
(server_key_exchange . 12)
(certificate_request . 13)
(server_hello_done . 14)
(certificate_verify . 15)
(client_key_exchange . 16)
(finished . 20)))
(define types-handshake
(map (lambda (item) (cons (cdr item) (car item))) handshake-types))

22
retropikzel/tls/util.scm Normal file
View File

@ -0,0 +1,22 @@
(define (warn msg)
(map
(lambda (item)
(display item (current-error-port)))
`("WARNING: " msg #\newline)))
(define (integer->bytevector value endness size)
(let ((bytes (make-bytevector size 0)))
(bytevector-uint-set! bytes 0 value endness size)
bytes))
(define (get-random-bytes count)
(letrec*
((looper (lambda (result)
(if (>= (bytevector-length result) count)
result
(looper
(bytevector-append result
(bytevector (random-integer 255))))))))
(looper (make-bytevector 0))))

View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@ -0,0 +1,49 @@
;;>\pre{
;;> vector-keys - Utilities to accessing vector indexes
;;>
;;> Macros that make it easy to access vector indexes using "keys".
;;>
;;>}
;;>\section{Usage}
;;>\pre{
;;> (define player (make-vector 10 0))
;;> (vector-keys player
;;> (player.x 0)
;;> (player.y 1))
;;>
;;> (player.x) ;; Returns 0
;;> (player.x 10)
;;> (player.x) ;; Returns 10
;;>
;;> (let ((enemy (make-vector 10 0)))
;;> (let-vector-keys enemy
;;> ((enemy.x 0)
;;> (enemy.y 1))
;;> (enemy.x) ;; Returns 0
;;> (enemy.x 100)
;;> (enemy.x) ;; Returns 100
;;> ))
;;>}
;;>\section{Reference}
;;> Define set of keys to access vector indexes
(define-syntax vector-keys
(syntax-rules ()
((_ vec (key index) ...)
(begin
(define-syntax key
(syntax-rules ()
((_) (vector-ref vec index))
((_ new-value) (vector-set! vec index new-value))))
...))))
;;> Define set of keys to access vector indexes inside let body
(define-syntax let-vector-keys
(syntax-rules ()
((_ vec ((key index) ...) body ...)
(let-syntax ((key (syntax-rules ()
((_) (vector-ref vec index))
((_ new-value) (vector-set! vec index new-value))))
...)
body ...))))

View File

@ -0,0 +1,6 @@
(define-library
(retropikzel vector-keys)
(import (scheme base))
(export vector-keys
let-vector-keys)
(include "vector-keys.scm"))

View File

@ -0,0 +1 @@
Utilities to accessing vector indexes

View File

@ -0,0 +1 @@
LGPL-3.0-or-later

View File

@ -0,0 +1 @@
1.0.0

View File

@ -0,0 +1,35 @@
(import (scheme base)
(scheme write)
(retropikzel tap)
(retropikzel vector-keys)
(srfi 64))
(test-runner-current (tap-runner))
(test-begin "vector-keys")
(test-begin "vector-keys")
(define player (make-vector 10 0))
(vector-keys player
(player.x 0)
(player.y 1))
(test-equal 0 (player.x))
(player.x 10)
(test-equal 10 (player.x))
(test-end "vector-keys")
(test-begin "let-vector-keys")
(let ((enemy (make-vector 10 0)))
(let-vector-keys enemy
((enemy.x 0)
(enemy.y 1))
(enemy.x 100)
(test-equal 100 (enemy.x))))
(test-end "let-vector-keys")
(test-end "vector-keys")

View File

@ -1,165 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.