Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

defmacro -> define-syntax

  • Loading branch information...
commit db9fdaabe885db862525f3937e62f2fd42dfa95e 1 parent 9f1434a
nik gaffney authored

Showing 1 changed file with 30 additions and 29 deletions. Show diff stats Hide diff stats

  1. +30 29 xmpp.ss
59 xmpp.ss
@@ -67,15 +67,15 @@
67 67 (module xmpp scheme
68 68
69 69 (provide (all-defined-out)
70   - ;open-connection
71   - ;open-ssl-connection
72   - ;with-xmpp-session
  70 + ;; with-xmpp-session
  71 + ;; xmpp-stream xmpp-session xmpp-auth
  72 + ;; send message presence iq
  73 + ;; jid-user jid-host jid-resource
73 74 )
74 75
75 76 (require (planet lizorkin/sxml:2:1/sxml)) ;; encoding xml
76 77 (require (planet lizorkin/ssax:2:0/ssax)) ;; decoding xml
77 78 (require mzlib/os) ;; hostname
78   - (require mzlib/defmacro) ;; with-xmpp-session macro
79 79 (require scheme/tcp) ;; networking
80 80 (require openssl) ;; ssl/tls
81 81 (require srfi/13) ;; jid decoding
@@ -191,11 +191,11 @@
191 191 ;; - http://xmpp.org/rfcs/rfc3920.html#sasl
192 192 ;;
193 193 ;;;; ;;
194   -
  194 +
195 195 (define session->tls? #f) ;; changes state when a tls proceed is recived
196 196
197 197 ;; moved to xmpp-sasl until it 'works'
198   -
  198 +
199 199
200 200 ;;;;;;;;; ; ;; ; ; ;; ;; ; ;
201 201 ;;
@@ -300,28 +300,29 @@
300 300 (define (send str)
301 301 (printf "sending iO: ~a ~%~%" str)
302 302 (fprintf (xmpp-out-port) "~A~%" str) (flush-output (xmpp-out-port)))
303   -
304   - (defmacro with-xmpp-session (jid pass . body)
305   - `(let ((host (jid-host ,jid))
306   - (user (jid-user ,jid))
307   - (resource (jid-resource ,jid)))
308   - (let-values (((in out)
309   - (ssl-connect host ssl-port 'tls)))
310   - ;;(tcp-connect host port)))
311   - (parameterize ((xmpp-in-port in)
312   - (xmpp-out-port out))
313   - (file-stream-buffer-mode out 'line)
314   - (xmpp-response-handler in)
315   - (send (xmpp-stream host))
316   - (send (xmpp-session host))
317   - ;(starttls in out)
318   -
319   - (send (xmpp-auth user ,pass resource))
320   - (send (presence))
321   - (send (presence #:status "Available"))
322   - ,@body
323   - (close-output-port out)
324   - (close-input-port in)))))
  303 +
  304 + (define-syntax with-xmpp-session
  305 + (syntax-rules ()
  306 + ((_ jid pass . body)
  307 + (let ((host (jid-host jid))
  308 + (user (jid-user jid))
  309 + (resource (jid-resource jid)))
  310 + (let-values (((in out)
  311 + (ssl-connect host ssl-port 'tls)))
  312 + ;;(tcp-connect host port)))
  313 + (parameterize ((xmpp-in-port in)
  314 + (xmpp-out-port out))
  315 + (file-stream-buffer-mode out 'line)
  316 + (xmpp-response-handler in)
  317 + (send (xmpp-stream host))
  318 + (send (xmpp-session host))
  319 + ;(starttls in out)
  320 +
  321 + (send (xmpp-auth user pass resource))
  322 + (send (presence))
  323 + (send (presence #:status "Available"))
  324 + body
  325 + (close-output-port out)
  326 + (close-input-port in)))))))
325 327
326 328 ) ;; end module
327   -

0 comments on commit db9fdaa

Please sign in to comment.
Something went wrong with that request. Please try again.