2003-01-19 11:57:27 -05:00
|
|
|
;; Structures and interfaces for surflets.
|
2002-09-19 07:16:29 -04:00
|
|
|
;; NOTE: SSAX/lib/packages.scm must be loaded before you can use this
|
|
|
|
;; downloadable from http://sourceforge.net/project/showfiles.php?group_id=30687
|
|
|
|
;; (take the r5rs compliant version (ssax-sr5rs-plt200-4.9.tar.gz))
|
2002-09-13 03:21:19 -04:00
|
|
|
|
|
|
|
(define-interface rt-module-language-interface
|
|
|
|
(export ((lambda-interface
|
|
|
|
with-names-from-rt-structure)
|
|
|
|
:syntax)
|
|
|
|
reify-structure
|
|
|
|
load-structure
|
|
|
|
load-config-file
|
|
|
|
rt-structure-binding))
|
|
|
|
|
|
|
|
(define-interface rt-modules-interface
|
|
|
|
(export interface-value-names
|
|
|
|
reify-structure
|
|
|
|
load-config-file
|
|
|
|
rt-structure-binding
|
|
|
|
load-structure))
|
|
|
|
|
|
|
|
(define-structure rt-module-language rt-module-language-interface
|
|
|
|
(open scheme
|
|
|
|
rt-modules)
|
|
|
|
(for-syntax (open scheme
|
|
|
|
rt-modules))
|
|
|
|
(begin
|
|
|
|
(define-syntax lambda-interface
|
|
|
|
(lambda (expr rename compare)
|
|
|
|
(let ((%lambda (rename 'lambda))
|
|
|
|
(interface-name (cadr expr))
|
|
|
|
(body (cddr expr)))
|
|
|
|
`(,%lambda ,(interface-value-names interface-name) ,@body))))
|
|
|
|
|
2003-01-19 11:57:27 -05:00
|
|
|
;(with-names-from-rt-structure surflet surflet-interface (main))
|
2002-09-13 03:21:19 -04:00
|
|
|
(define-syntax with-names-from-rt-structure
|
|
|
|
(lambda (expr rename compare)
|
|
|
|
(let ((%lambda (rename 'lambda))
|
|
|
|
(%let (rename 'let))
|
|
|
|
(%rt-structure-value (rename 'rt-structure-value))
|
|
|
|
(%rt-structure-binding (rename 'rt-structure-binding))
|
|
|
|
(rt-structure (cadr expr))
|
|
|
|
(interface-name (caddr expr))
|
|
|
|
(body (cdddr expr)))
|
|
|
|
(let ((ivn (interface-value-names interface-name)))
|
|
|
|
`(,%let ((,%rt-structure-value ,rt-structure))
|
|
|
|
((,%lambda ,ivn ,@body)
|
|
|
|
,@(map (lambda (name)
|
|
|
|
`(,%rt-structure-binding ,%rt-structure-value ',name))
|
|
|
|
ivn)))))))))
|
|
|
|
|
|
|
|
(define-structure rt-modules rt-modules-interface
|
|
|
|
(open scheme
|
|
|
|
meta-types ; syntax-type
|
|
|
|
interfaces ; for-each-declaration
|
|
|
|
define-record-types
|
|
|
|
records
|
|
|
|
signals
|
|
|
|
bindings
|
|
|
|
packages
|
|
|
|
packages-internal
|
|
|
|
locations
|
|
|
|
environments
|
|
|
|
ensures-loaded
|
|
|
|
package-commands-internal)
|
|
|
|
(files rt-module))
|
|
|
|
|
2003-01-19 11:57:27 -05:00
|
|
|
(define-interface surflet-handler-interface
|
|
|
|
(export surflet-handler))
|
2002-09-13 03:21:19 -04:00
|
|
|
|
2003-01-24 10:28:25 -05:00
|
|
|
(define-interface surflet-handler/surflets-interface
|
2002-09-24 05:12:58 -04:00
|
|
|
(export send/suspend ;send and suspend
|
|
|
|
send/finish ;send and finish
|
|
|
|
send ;just send (no finish, no suspend)
|
2003-01-24 11:02:29 -05:00
|
|
|
send-error ;send error response
|
2003-01-19 11:57:27 -05:00
|
|
|
set-surflet-data!
|
|
|
|
get-surflet-data
|
2002-12-07 17:26:40 -05:00
|
|
|
adjust-timeout ;adjusts timeout of current session
|
2002-10-21 04:42:09 -04:00
|
|
|
;Without `!' because PLT
|
|
|
|
;doesn't have it.
|
2002-09-24 04:19:41 -04:00
|
|
|
))
|
2002-09-13 03:21:19 -04:00
|
|
|
|
2003-01-19 11:57:27 -05:00
|
|
|
(define-interface surflet-handler/admin-interface
|
|
|
|
(export get-loaded-surflets
|
|
|
|
unload-surflet
|
2002-12-07 17:26:40 -05:00
|
|
|
set-options-session-lifetime
|
|
|
|
options-session-lifetime
|
2003-01-19 11:57:27 -05:00
|
|
|
set-options-cache-surflets?
|
|
|
|
options-cache-surflets?
|
|
|
|
options-surflet-path
|
2002-12-07 17:26:40 -05:00
|
|
|
get-sessions
|
2003-01-19 11:57:27 -05:00
|
|
|
session-surflet-name
|
2002-12-07 17:26:40 -05:00
|
|
|
session-memo
|
|
|
|
session-continuation-table
|
|
|
|
session-continuation-table-lock
|
|
|
|
session-continuation-counter
|
|
|
|
delete-session!
|
|
|
|
session-adjust-timeout!
|
2002-10-21 04:42:09 -04:00
|
|
|
adjust-timeout
|
2002-10-01 13:42:06 -04:00
|
|
|
get-continuations
|
|
|
|
delete-continuation!
|
2003-01-16 07:53:10 -05:00
|
|
|
instance-session-id
|
|
|
|
resume-url?
|
|
|
|
resume-url-ids
|
|
|
|
resume-url-session-id
|
|
|
|
resume-url-continuation-id))
|
2002-09-30 10:43:15 -04:00
|
|
|
|
2003-01-24 10:23:51 -05:00
|
|
|
(define-interface surflet-handler/responses-interface
|
|
|
|
(export make-surflet-response
|
|
|
|
surflet-response?
|
|
|
|
surflet-response-status
|
|
|
|
surflet-response-content-type
|
|
|
|
surflet-response-headers
|
|
|
|
surflet-response-data))
|
|
|
|
|
2002-09-13 03:21:19 -04:00
|
|
|
(define-structures
|
2003-01-19 11:57:27 -05:00
|
|
|
((surflet-handler surflet-handler-interface)
|
2003-01-24 10:28:25 -05:00
|
|
|
(surflet-handler/surflets surflet-handler/surflets-interface)
|
2003-01-24 10:23:51 -05:00
|
|
|
(surflet-handler/admin surflet-handler/admin-interface)
|
|
|
|
(surflet-handler/responses surflet-handler/responses-interface))
|
2003-02-17 05:09:24 -05:00
|
|
|
(open httpd-responses ;replies for httpd
|
|
|
|
httpd-requests ;requests from httpd
|
|
|
|
surflet-requests ;requests for surflets
|
|
|
|
httpd-errors ;errors for httpd
|
2002-09-18 11:32:41 -04:00
|
|
|
uri ;URI-PATH-LIST->PATH
|
|
|
|
tables ;HASH-TABLES
|
|
|
|
define-record-types ;DEFINE-RECORD-TYPE
|
2002-09-13 03:21:19 -04:00
|
|
|
rt-module-language ;get structures dynamically
|
2002-09-18 11:32:41 -04:00
|
|
|
; srfi-13 ;string
|
2002-09-13 03:21:19 -04:00
|
|
|
srfi-14 ;CHAR-SET:DIGIT
|
2003-01-25 11:09:03 -05:00
|
|
|
handle-fatal ;WITH-FATAL-ERROR-HANDLER* et al.
|
2002-09-18 11:32:41 -04:00
|
|
|
srfi-27 ;random numbers
|
|
|
|
locks ;MAKE-LOCK et al.
|
|
|
|
thread-cells ;THREAD-CELL et al.
|
|
|
|
profiling ;PROFILE-SPACE
|
|
|
|
httpd-logging ;HTTP-SYSLOG
|
|
|
|
shift-reset ;SHIFT and RESET
|
2002-09-29 11:20:36 -04:00
|
|
|
threads ;SLEEP
|
|
|
|
thread-fluids ;FORK-THREAD
|
2002-09-30 10:43:15 -04:00
|
|
|
sxml-to-html ;SXML->HTML
|
2003-01-25 11:09:03 -05:00
|
|
|
scheme-with-scsh ;regexp et al.
|
2003-01-14 06:27:42 -05:00
|
|
|
srfi-6 ;string-ports
|
2003-01-25 11:09:03 -05:00
|
|
|
thread-safe-counter
|
2003-02-19 04:43:29 -05:00
|
|
|
handle-fatal-error
|
2002-09-13 03:21:19 -04:00
|
|
|
)
|
2003-01-22 07:53:46 -05:00
|
|
|
(files surflet-handler))
|
2002-09-13 03:21:19 -04:00
|
|
|
|
2002-09-24 04:19:41 -04:00
|
|
|
|
2003-01-19 11:57:27 -05:00
|
|
|
(define-interface surflets-interface
|
2002-09-24 04:19:41 -04:00
|
|
|
(export send/suspend
|
|
|
|
send/finish
|
2002-10-03 07:20:05 -04:00
|
|
|
send
|
2003-01-24 11:02:29 -05:00
|
|
|
send-error
|
2002-09-24 04:19:41 -04:00
|
|
|
send-html/suspend
|
2002-09-19 07:16:29 -04:00
|
|
|
send-html/finish
|
2002-09-24 12:56:00 -04:00
|
|
|
send-html
|
2002-09-24 04:19:41 -04:00
|
|
|
form-query
|
2002-09-29 09:43:39 -04:00
|
|
|
get-bindings
|
2002-09-24 04:19:41 -04:00
|
|
|
extract-bindings
|
2002-09-24 12:56:00 -04:00
|
|
|
extract-single-binding
|
2002-10-01 08:10:58 -04:00
|
|
|
|
2002-10-21 04:42:09 -04:00
|
|
|
adjust-timeout
|
|
|
|
|
2002-10-01 08:10:58 -04:00
|
|
|
make-outdater
|
|
|
|
(if-outdated :syntax)
|
|
|
|
show-outdated
|
|
|
|
|
2002-09-27 11:19:42 -04:00
|
|
|
generate-input-field-name
|
|
|
|
make-input-field
|
2002-10-09 11:25:14 -04:00
|
|
|
make-higher-input-field
|
2002-09-24 12:56:00 -04:00
|
|
|
make-text-input-field
|
2002-09-30 10:43:15 -04:00
|
|
|
make-hidden-input-field
|
2002-09-24 12:56:00 -04:00
|
|
|
make-password-input-field
|
|
|
|
make-number-input-field
|
|
|
|
make-textarea-input-field
|
2002-10-02 09:37:41 -04:00
|
|
|
make-select-input-field
|
2002-09-27 13:29:31 -04:00
|
|
|
make-checkbox-input-field
|
2002-09-30 10:43:15 -04:00
|
|
|
make-radio-input-fields
|
2002-10-01 08:10:58 -04:00
|
|
|
|
2002-09-24 12:56:00 -04:00
|
|
|
make-submit-button
|
2002-09-30 10:43:15 -04:00
|
|
|
make-reset-button
|
|
|
|
make-image-button
|
2002-09-24 12:56:00 -04:00
|
|
|
input-field-value
|
2002-11-07 15:41:35 -05:00
|
|
|
raw-input-field-value
|
2002-10-02 14:22:01 -04:00
|
|
|
input-field-binding
|
2002-10-21 04:42:09 -04:00
|
|
|
|
2002-10-02 16:28:39 -04:00
|
|
|
make-address
|
2003-02-28 03:22:29 -05:00
|
|
|
make-annotated-address
|
2003-03-03 05:27:49 -05:00
|
|
|
returned-via
|
2002-10-02 16:28:39 -04:00
|
|
|
returned-via?
|
2003-03-03 05:27:49 -05:00
|
|
|
(case-returned-via :syntax)
|
2002-10-02 20:15:44 -04:00
|
|
|
make-callback
|
|
|
|
|
2003-01-19 11:57:27 -05:00
|
|
|
set-surflet-data!
|
|
|
|
get-surflet-data))
|
2002-10-01 08:10:58 -04:00
|
|
|
|
2003-01-19 11:57:27 -05:00
|
|
|
(define-structure surflets surflets-interface
|
2003-01-24 10:28:25 -05:00
|
|
|
(open surflet-handler/surflets
|
2003-01-24 10:23:51 -05:00
|
|
|
surflet-handler/responses
|
|
|
|
httpd-responses ; STATUS-CODE
|
2003-02-17 05:09:24 -05:00
|
|
|
surflet-requests ; HTTP-URL:SEARCH
|
2002-09-29 09:43:39 -04:00
|
|
|
url ; REQUEST:URL
|
2003-02-28 03:22:29 -05:00
|
|
|
(subset uri (escape-uri unescape-uri))
|
2002-09-24 04:19:41 -04:00
|
|
|
parse-html-forms
|
2002-09-29 09:43:39 -04:00
|
|
|
sxml-to-html ; SXML->HTML
|
|
|
|
srfi-1 ; FILTER
|
2002-10-02 20:15:44 -04:00
|
|
|
(subset srfi-13 (string-index))
|
2002-09-24 12:56:00 -04:00
|
|
|
sxml-tree-trans
|
|
|
|
define-record-types
|
2002-10-21 04:42:09 -04:00
|
|
|
weak ;MAKE-WEAK-POINTER
|
|
|
|
locks
|
2002-11-07 09:11:05 -05:00
|
|
|
let-opt ;:OPTIONAL
|
|
|
|
handle-fatal-error
|
2003-02-19 12:05:16 -05:00
|
|
|
(subset sunet-utilities (get-header)) ; GET-HEADER
|
2003-02-19 13:47:04 -05:00
|
|
|
scheme-with-scsh)
|
2003-01-22 07:53:46 -05:00
|
|
|
(files surflets))
|
2002-09-13 03:21:19 -04:00
|
|
|
|
2003-01-19 11:57:27 -05:00
|
|
|
(define-interface surflet-interface
|
2002-09-24 04:19:41 -04:00
|
|
|
(export main)) ; MAIN gets one parameter, the REQUEST
|
2002-09-14 12:48:59 -04:00
|
|
|
|
|
|
|
(define-interface shift-reset-interface
|
|
|
|
(export (reset :syntax)
|
|
|
|
(shift :syntax)))
|
|
|
|
|
|
|
|
(define-structure shift-reset shift-reset-interface
|
|
|
|
(open scheme
|
|
|
|
signals
|
|
|
|
escapes
|
|
|
|
thread-cells)
|
|
|
|
(files shift-reset))
|
|
|
|
|
|
|
|
(define-interface profiling-interface
|
|
|
|
(export profile-space
|
|
|
|
profile-result
|
|
|
|
profile-results
|
|
|
|
write-gnuplot-data-file
|
|
|
|
|
|
|
|
space-info-pair space-info-symbol
|
|
|
|
space-info-vector space-info-closure
|
|
|
|
space-info-location space-info-cell
|
|
|
|
space-info-channel space-info-port
|
|
|
|
space-info-ratnum space-info-record
|
|
|
|
space-info-continuation space-info-extended-number
|
|
|
|
space-info-template space-info-weak-pointer
|
|
|
|
space-info-shared-binding space-info-unused-d-header1
|
|
|
|
space-info-unused-d-header2 space-info-string
|
|
|
|
space-info-byte-vector space-info-double
|
|
|
|
space-info-bignum space-info-total
|
|
|
|
|
|
|
|
set-space-info-pair! set-space-info-symbol!
|
|
|
|
set-space-info-vector! set-space-info-closure!
|
|
|
|
set-space-info-location! set-space-info-cell!
|
|
|
|
set-space-info-channel! set-space-info-port!
|
|
|
|
set-space-info-ratnum! set-space-info-record!
|
|
|
|
set-space-info-continuation! set-space-info-extended-number!
|
|
|
|
set-space-info-template! set-space-info-weak-pointer!
|
|
|
|
set-space-info-shared-binding! set-space-info-unused-d-header1!
|
|
|
|
set-space-info-unused-d-header2! set-space-info-string!
|
|
|
|
set-space-info-byte-vector! set-space-info-double!
|
|
|
|
set-space-info-bignum! set-space-info-total!
|
|
|
|
|
|
|
|
pure-count pure-bytes
|
|
|
|
impure-count impure-bytes
|
|
|
|
total-count total-bytes
|
|
|
|
))
|
|
|
|
|
|
|
|
(define-structure profiling profiling-interface
|
|
|
|
(open let-opt
|
|
|
|
define-record-types
|
|
|
|
spatial
|
|
|
|
srfi-13
|
|
|
|
srfi-1
|
2002-09-18 11:32:41 -04:00
|
|
|
locks
|
2003-02-19 13:47:04 -05:00
|
|
|
scheme-with-scsh)
|
2002-09-21 16:20:29 -04:00
|
|
|
(files profile))
|
|
|
|
|
2003-01-19 11:57:27 -05:00
|
|
|
(define-interface simple-surflet-api-interface
|
2002-11-03 12:43:58 -05:00
|
|
|
(export single-query
|
|
|
|
queries
|
|
|
|
form-query
|
|
|
|
inform
|
|
|
|
final-page
|
|
|
|
make-password
|
|
|
|
make-number
|
|
|
|
make-boolean
|
|
|
|
make-radio
|
|
|
|
make-yes-no
|
|
|
|
extract/single
|
|
|
|
extract))
|
|
|
|
|
2003-01-19 11:57:27 -05:00
|
|
|
(define-structure simple-surflet-api simple-surflet-api-interface
|
2003-02-19 13:47:04 -05:00
|
|
|
(open scheme-with-scsh
|
2002-11-03 12:43:58 -05:00
|
|
|
define-record-types
|
|
|
|
let-opt
|
2003-01-19 11:57:27 -05:00
|
|
|
surflets
|
2002-11-09 12:17:14 -05:00
|
|
|
(subset srfi-1 (zip filter find make-list))
|
2002-11-03 12:43:58 -05:00
|
|
|
handle-fatal-error
|
|
|
|
)
|
2003-01-22 07:53:46 -05:00
|
|
|
(files simple-surflet-api))
|
2003-01-25 11:09:03 -05:00
|
|
|
|
|
|
|
(define-interface handle-fatal-interface
|
|
|
|
(export with-fatal-handler*
|
|
|
|
(with-fatal-handler :syntax)))
|
|
|
|
|
|
|
|
(define-structure handle-fatal handle-fatal-interface
|
|
|
|
(open scheme conditions handle)
|
|
|
|
(files handle-fatal))
|
|
|
|
|
|
|
|
|
|
|
|
(define-interface thread-safe-counter-interface
|
|
|
|
(export make-thread-safe-counter
|
|
|
|
thread-safe-counter-value
|
|
|
|
thread-safe-counter-next!
|
|
|
|
thread-safe-counter?))
|
|
|
|
|
|
|
|
(define-structure thread-safe-counter thread-safe-counter-interface
|
|
|
|
(open scheme
|
|
|
|
locks
|
|
|
|
define-record-types)
|
2003-02-17 05:09:24 -05:00
|
|
|
(files thread-safe-counter))
|
|
|
|
|
|
|
|
(define-interface surflet-requests-interface
|
|
|
|
(export make-surflet-request
|
|
|
|
surflet-request?
|
|
|
|
surflet-request-request
|
|
|
|
surflet-request-input-port
|
|
|
|
surflet-request-method
|
|
|
|
surflet-request-uri
|
|
|
|
surflet-request-url
|
|
|
|
surflet-request-version
|
|
|
|
surflet-request-headers
|
|
|
|
surflet-request-socket))
|
|
|
|
|
|
|
|
(define-structure surflet-requests surflet-requests-interface
|
|
|
|
(open scheme
|
|
|
|
define-record-types
|
|
|
|
httpd-requests)
|
|
|
|
(files surflet-request))
|
|
|
|
|