;; -*- mode: Scheme; -*- ;; ;; This file is part of WebGate for CHICKEN. ;; Copyright (c) 2011 by Thomas Chust. All rights reserved. ;; ;; Permission is hereby granted, free of charge, to any person ;; obtaining a copy of this software and associated documentation ;; files (the Software), to deal in the Software without restriction, ;; including without limitation the rights to use, copy, modify, ;; merge, publish, distribute, sublicense, and/or sell copies of the ;; Software, and to permit persons to whom the Software is furnished ;; to do so, subject to the following conditions: ;; ;; The above copyright notice and this permission notice shall be ;; included in all copies or substantial portions of the Software. ;; ;; THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, ;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS ;; BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ;; ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN ;; CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ;; SOFTWARE. (require-library srfi-1 srfi-4 srfi-13 srfi-14 srfi-18 srfi-69 srfi-99 data-structures ports extras lolevel irregex tcp) (module webgate-utils (make-uuid uuid? uuid-time write-netstring read-netstring make-at-reader make-at-read-table use-at-read-table uri-encode uri-decode write-html) (import scheme chicken foreign srfi-1 srfi-13 srfi-14 srfi-69 data-structures extras irregex) (include "webgate-utils.scm")) (module webgate-core (message make-message message? message-type message-headers message-body write-message max-request-size request-method-handler request-body-handler request-parameter-handler resource-context current-resource-context resource-context? resource-context-getenv resource-context-return response make-response response? collect-response make-html-response make-error-response response-status response-status-message write-response resource-handler define-resource resource-uri handle-query-parameters handle-request) (import scheme chicken srfi-1 srfi-4 srfi-13 srfi-18 srfi-69 srfi-99 data-structures ports extras lolevel irregex webgate-utils) (include "webgate-core.scm")) (module webgate-suspend (max-suspended-resources max-suspended-resources-load suspended-resource-handler suspended send/suspend) (import scheme chicken srfi-1 srfi-18 srfi-69 data-structures webgate-utils webgate-core) (include "webgate-suspend.scm")) (module webgate-cgi (cgi-main-loop) (import scheme chicken) (include "webgate-cgi.scm")) (module webgate-scgi (scgi-main-loop) (import scheme chicken srfi-13 srfi-18 srfi-69 data-structures irregex webgate-utils tcp) (include "webgate-scgi.scm")) (module webgate (message make-message message? message-type message-headers message-body max-request-size request-method-handler request-body-handler request-parameter-handler resource-context current-resource-context resource-context? resource-context-getenv resource-context-return response make-response response? collect-response make-html-response make-error-response response-status response-status-message resource-handler define-resource resource-uri max-suspended-resources max-suspended-resources-load suspended-resource-handler suspended send/suspend webgate-main) (import scheme chicken webgate-core webgate-suspend webgate-cgi webgate-scgi tcp) (define (webgate-main #!optional (arguments (command-line-arguments))) (let-optionals arguments ((port #f) (backlog "4") (host "localhost")) (if port (let ((port (or (string->number port) (error 'webgate-main "bad port number" port))) (backlog (or (string->number backlog) (error 'webgate-main "bad backlog number" backlog)))) (scgi-main-loop handle-request (tcp-listen port backlog host))) (cgi-main-loop handle-request)))) )