From bc1ba43d2e23ff6674c92f4cd1ab5fb3b1a673ec Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 8 Sep 2023 12:28:25 -0500 Subject: first commit --- .dir-locals.el | 4 ++++ .gitignore | 10 ++++++++++ cock | Bin 0 -> 20192 bytes cock.egg | 10 ++++++++++ cock.mod.scm | 24 ++++++++++++++++++++++++ cock.scm | 21 +++++++++++++++++++++ 6 files changed, 69 insertions(+) create mode 100644 .dir-locals.el create mode 100644 .gitignore create mode 100755 cock create mode 100644 cock.egg create mode 100644 cock.mod.scm create mode 100644 cock.scm 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 @@ +;;; Directory Local Variables -*- no-byte-compile: t -*- +;;; For more information see (info "(emacs) Directory Variables") + +((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 @@ +boudin +*.inline +*.link +*.so +*.o +*.import.scm +*.types +*.build.sh +*.install.sh +test/out/ \ No newline at end of file diff --git a/cock b/cock new file mode 100755 index 0000000..036900f Binary files /dev/null and b/cock 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 @@ +((synopsis "cock server") + (author "Case Duckworth") + (license "God Willing") + (version 0.0.0) + (components + (program cock + (source cock.scm)) + (extension cock-mod + (source cock.mod.scm) + (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 @@ +(module cock (serve) + + (import (scheme) + (chicken base) + (chicken process signal) + (spiffy) + (utf8)) + + (define (eprint . xs) + (for-each (lambda (x) (display x (current-error-port))) + xs) + (newline (current-error-port))) + + (define (serve root port) + (set-signal-handler! signal/int + (lambda _ + (eprint "stopping server") + (exit))) + (eprint "Starting web server in " root "...") + (eprint "Served at http://localhost:" port) + (eprint "[Ctrl-c to stop]") + (parameterize ((server-port port) + (root-path root)) + (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 @@ +(import (cock) + (chicken process-context)) + +(define (main args) + (define root (current-directory)) + (define port 8000) + (let loop ((args args)) + (cond + ((null? args) (serve root port)) + ((equal? (car args) "-p") + (set! port (cadr args)) + (loop (cddr args))) + (else + (set! root (car args)) + ;; Stop processing arguments + (loop '()))))) + +(cond-expand + ((or chicken-script compiling) + (main (command-line-arguments))) + (else)) -- cgit 1.4.1-21-gabe81