Welcome to the CHICKEN Scheme pasting service

spiffy openssl support (v2) pasted by murphy on Sat Feb 4 16:44:24 2012

--- spiffy.scm	(revision 25859)
+++ spiffy.scm	(working copy)
@@ -536,12 +536,20 @@
         (mutex-unlock! m)
         (begin (mutex-unlock! m condition) (retry)))))
 
-;; From the openssl egg.  This is a way to support SSL without *requiring* it.
-(define (ssl-port? obj)
-  (and (port? obj) (eq? (##sys#slot obj 10) 'ssl-socket)))
+;; Imports from the openssl egg, if available
+(define (dynamic-import module symbol default)
+  (handle-exceptions _ default (eval `(let () (use ,module) ,symbol))))
 
+(define ssl-port?
+  (dynamic-import
+   'openssl 'ssl-port?
+   (lambda (v)
+     #f)))
+
 (define (ssl-port->tcp-port p)
-  (if (ssl-port? p) (##sys#slot p 11) (error "Expected an SSL port")))
+  (dynamic-import
+   'openssl 'ssl-port->tcp-port
+   (lambda (v) (error 'ssl-port->tcp-port "Expected an SSL port" v))))
 
 (define (ssl-or-tcp-addresses p)
   (tcp-addresses

spiffy openssl support (v3) added by mario-goulart on Sat Feb 4 17:47:22 2012

Index: spiffy.scm
===================================================================
--- spiffy.scm  (revision 25818)
+++ spiffy.scm  (working copy)
@@ -536,13 +536,21 @@
         (mutex-unlock! m)
         (begin (mutex-unlock! m condition) (retry)))))
 
-;; From the openssl egg.  This is a way to support SSL without *requiring* it.
-(define (ssl-port? obj)
-  (and (port? obj) (eq? (##sys#slot obj 10) 'ssl-socket)))
+;; Imports from the openssl egg, if available
+(define (dynamic-import module symbol default)
+  (handle-exceptions _ default (eval `(let () (use ,module) ,symbol))))
 
-(define (ssl-port->tcp-port p)
-  (if (ssl-port? p) (##sys#slot p 11) (error "Expected an SSL port")))
+(define ssl-port?
+  (dynamic-import
+   'openssl 'ssl-port?
+   (lambda (v)
+     #f)))
 
+(define ssl-port->tcp-port
+  (dynamic-import
+   'openssl 'ssl-port->tcp-port
+   (lambda (v) (error 'ssl-port->tcp-port "Expected an SSL port" v))))
+
 (define (ssl-or-tcp-addresses p)
   (tcp-addresses
    (if (ssl-port? p) (ssl-port->tcp-port p) p)))

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
Which one-argument R5RS procedure returns 1 when given `'(1 2 3)' as input?
Visually impaired? Let me spell it for you (wav file) download WAV