summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2023-09-08 12:28:25 -0500
committerCase Duckworth2023-09-08 12:28:25 -0500
commitbc1ba43d2e23ff6674c92f4cd1ab5fb3b1a673ec (patch)
treebf7f82ceed01524e75474fc93e2f6e52eb083a15
downloadcock-main.tar.gz
cock-main.zip
first commit main
-rw-r--r--.dir-locals.el4
-rw-r--r--.gitignore10
-rwxr-xr-xcockbin0 -> 20192 bytes
-rw-r--r--cock.egg10
-rw-r--r--cock.mod.scm24
-rw-r--r--cock.scm21
6 files changed, 69 insertions, 0 deletions
diff --git a/.dir-locals.el b/.dir-locals.el new file mode 100644 index 0000000..9c78ce8 --- /dev/null +++ b/.dir-locals.el
@@ -0,0 +1,4 @@
1;;; Directory Local Variables -*- no-byte-compile: t -*-
2;;; For more information see (info "(emacs) Directory Variables")
3
4((scheme-mode . ((geiser-scheme-implementation . chicken))))
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b4aa44a --- /dev/null +++ b/.gitignore
@@ -0,0 +1,10 @@
1boudin
2*.inline
3*.link
4*.so
5*.o
6*.import.scm
7*.types
8*.build.sh
9*.install.sh
10test/out/ \ No newline at end of file
diff --git a/cock b/cock new file mode 100755 index 0000000..036900f --- /dev/null +++ b/cock
Binary files differ
diff --git a/cock.egg b/cock.egg new file mode 100644 index 0000000..ec1bcbe --- /dev/null +++ b/cock.egg
@@ -0,0 +1,10 @@
1((synopsis "cock server")
2 (author "Case Duckworth")
3 (license "God Willing")
4 (version 0.0.0)
5 (components
6 (program cock
7 (source cock.scm))
8 (extension cock-mod
9 (source cock.mod.scm)
10 (install-name cock))))
diff --git a/cock.mod.scm b/cock.mod.scm new file mode 100644 index 0000000..5fc9c79 --- /dev/null +++ b/cock.mod.scm
@@ -0,0 +1,24 @@
1(module cock (serve)
2
3 (import (scheme)
4 (chicken base)
5 (chicken process signal)
6 (spiffy)
7 (utf8))
8
9 (define (eprint . xs)
10 (for-each (lambda (x) (display x (current-error-port)))
11 xs)
12 (newline (current-error-port)))
13
14 (define (serve root port)
15 (set-signal-handler! signal/int
16 (lambda _
17 (eprint "stopping server")
18 (exit)))
19 (eprint "Starting web server in " root "...")
20 (eprint "Served at http://localhost:" port)
21 (eprint "[Ctrl-c to stop]")
22 (parameterize ((server-port port)
23 (root-path root))
24 (start-server))))
diff --git a/cock.scm b/cock.scm new file mode 100644 index 0000000..d01c7e9 --- /dev/null +++ b/cock.scm
@@ -0,0 +1,21 @@
1(import (cock)
2 (chicken process-context))
3
4(define (main args)
5 (define root (current-directory))
6 (define port 8000)
7 (let loop ((args args))
8 (cond
9 ((null? args) (serve root port))
10 ((equal? (car args) "-p")
11 (set! port (cadr args))
12 (loop (cddr args)))
13 (else
14 (set! root (car args))
15 ;; Stop processing arguments
16 (loop '())))))
17
18(cond-expand
19 ((or chicken-script compiling)
20 (main (command-line-arguments)))
21 (else))