diff --git a/scsh/thttpd/AUTHORS b/scsh/thttpd/AUTHORS new file mode 100644 index 0000000..c2430eb --- /dev/null +++ b/scsh/thttpd/AUTHORS @@ -0,0 +1 @@ +Copyright (C) 2011-2012 Johan Ceuppens diff --git a/scsh/thttpd/BLURB b/scsh/thttpd/BLURB new file mode 100644 index 0000000..9acccc6 --- /dev/null +++ b/scsh/thttpd/BLURB @@ -0,0 +1 @@ +thttpd : a client-server web system diff --git a/scsh/thttpd/NEWS b/scsh/thttpd/NEWS new file mode 100644 index 0000000..bb09772 --- /dev/null +++ b/scsh/thttpd/NEWS @@ -0,0 +1,12 @@ +version 0.1 +* working connection with a few commands (telnet localhost 1025 and +* type in MAIL\r\n or QUIT\r\n +* tdaemon.scm script which can be run in scsh to (run-daemon-child staterecord) +* "rc" alike tforks.scm, tserver.scm tclient.scm which contain tell-client and ask-server methods. +* tforks.scm contains record and daemon to be spawned by e.g. init or daemontools +* and uses fork-and-forget with 10 commands per session. +* old/ code directory +* daemon state record (port, host, etc.) +* telnetable daemon +* daemon state record +* dispatch object second executable file diff --git a/scsh/thttpd/README b/scsh/thttpd/README new file mode 100644 index 0000000..34c1a92 --- /dev/null +++ b/scsh/thttpd/README @@ -0,0 +1,7 @@ +- This is a http daemon +Basically run scsh, ',open records sockets' +telnet localhost 8080 +for asking the server. + +mailer daemon command history: +GET diff --git a/scsh/thttpd/load.scm b/scsh/thttpd/load.scm new file mode 100644 index 0000000..b86dcbe --- /dev/null +++ b/scsh/thttpd/load.scm @@ -0,0 +1,39 @@ +;;; load.scm - a scheme web daemon script +;;; +;;; Copyright (c) 2011-2012 Johan Ceuppens +;;; +;;; All rights reserved. +;;; +;;; Redistribution and use in source and binary forms, with or without +;;; modification, are permitted provided that the following conditions +;;; are met: +;;; 1. Redistributions of source code must retain the above copyright +;;; notice, this list of conditions and the following disclaimer. +;;; 2. Redistributions in binary form must reproduce the above copyright +;;; notice, this list of conditions and the following disclaimer in the +;;; documentation and/or other materials provided with the distribution. +;;; 3. The name of the authors may not be used to endorse or promote products +;;; derived from this software without specific prior written permission. +;;; +;;; THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR +;;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +;;; OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +;;; IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, +;;; INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +;;; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +;;; THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +(load "thttpdaemon.scm") + +(define rc (make-thttpd-daemon-record + "localhost" ;; virtual host + 8080 + #f)) + +(run-daemon-child-http rc) + +(display "http-daemon ends.") +(newline) diff --git a/scsh/thttpd/packages.scm b/scsh/thttpd/packages.scm new file mode 100644 index 0000000..b2bc7ac --- /dev/null +++ b/scsh/thttpd/packages.scm @@ -0,0 +1,8 @@ +(define-interface thttpd-interface + (export + run-daemon-child-http)) + +(define-structure thttpd + tmail-interface + (open scheme) + (files thttpdaemon load)) diff --git a/scsh/thttpd/pkg-def.scm b/scsh/thttpd/pkg-def.scm new file mode 100644 index 0000000..76826a2 --- /dev/null +++ b/scsh/thttpd/pkg-def.scm @@ -0,0 +1,12 @@ +(define-package "thttpd" + (0 1) + ((install-lib-version (1 3 0))) + (write-to-load-script + `((config) + (load ,(absolute-file-name "packages.scm" + (get-directory 'scheme #f))))) + (install-file "README" 'doc) + (install-file "NEWS" 'doc) + (install-string (COPYING) "COPYING" 'doc) + (install-file "packages.scm" 'scheme) + (install-file "tserver.scm" 'scheme)) diff --git a/scsh/thttpd/thttpdaemon.scm b/scsh/thttpd/thttpdaemon.scm new file mode 100644 index 0000000..ea6d6fa --- /dev/null +++ b/scsh/thttpd/thttpdaemon.scm @@ -0,0 +1,80 @@ +;;; thttpdaemon.scm - a scheme web daemon +;;; +;;; Copyright (c) 2011-2012 Johan Ceuppens +;;; +;;; All rights reserved. +;;; +;;; Redistribution and use in source and binary forms, with or without +;;; modification, are permitted provided that the following conditions +;;; are met: +;;; 1. Redistributions of source code must retain the above copyright +;;; notice, this list of conditions and the following disclaimer. +;;; 2. Redistributions in binary form must reproduce the above copyright +;;; notice, this list of conditions and the following disclaimer in the +;;; documentation and/or other materials provided with the distribution. +;;; 3. The name of the authors may not be used to endorse or promote products +;;; derived from this software without specific prior written permission. +;;; +;;; THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR +;;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +;;; OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +;;; IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, +;;; INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +;;; NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +;;; THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +(define (eoln) (string #\newline)) +(define (servermsg) (string "::thttpd-msg::")) +(define (errormsg) (string "::thttpd-error::")) +(define aspect-content "Content-Type: text/plain;charset=utf-8");; (string #\newline))) +(define :thttpd-daemon-record + (make-record-type 'thttpd-daemon-record + '(hostname port sock))) +(define make-thttpd-daemon-record + (record-constructor :thttpd-daemon-record + '(hostname port sock))) + +(define thttpd-hostname (record-accessor :thttpd-daemon-record 'hostname)) +(define thttpd-port (record-accessor :thttpd-daemon-record 'port)) +(define thttpd-sock (record-accessor :thttpd-daemon-record 'sock)) + + +(define (run-daemon-child-http rec) + (let ((*hostname (thttpd-hostname rec)) + (*port (thttpd-port rec)) + (*socket (thttpd-sock rec)) + ) + + (set! *socket (open-socket *port)) + + (for-each display '("Opening listening socket on host : " + *hostname + " port : " + *port + (eoln))) + ((lambda () + (call-with-values + (lambda () + (socket-accept *socket)) + (lambda (in out) + ;;(let ((in (make-string-input-port in))) + (let ((answer (read in))) + ;;(let ((answer2 (read in))) + ;;(let ((answer3 (read in))) + (for-each display '((servermsg) (symbol->string answer))) + (if (symbol? answer) + (cond ((eq? 'GET answer) + (write aspect-content out) + (write (string #\newline)) + (write "Hello World" out) + ;;(close-input-port in) + ;;(close-socket *socket) + ;;(close-output-port out) + ) + (else ;; + keep-alive + (write (errormsg) out)) + )))))))));;);;) + diff --git a/scsh/tmail/tforks.scm b/scsh/tmail/tforks.scm index a6cd4bb..8d65239 100644 --- a/scsh/tmail/tforks.scm +++ b/scsh/tmail/tforks.scm @@ -29,7 +29,7 @@ (load "util.scm") (load "trecords.scm") (load "tmailbox-load.scm") - +;; You can use e.g. daemontools to restart it everytime (define (run-daemon-child-mail rec) (let ((*hostname (hostname rec)) (*port (port rec))