summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrekado <rekado@elephly.net>2014-12-16 18:35:29 +0100
committerrekado <rekado@elephly.net>2014-12-16 18:35:29 +0100
commit131d26ffeca06e98b50191703baf7683f8b47e30 (patch)
tree84bc5437f2cf542eee4976122324a98bcd9c9e1f
parentcb06d3d7fe9837e4e2708ba4e84fe9dd3f96660d (diff)
rewrite stanza-find-property with sxpath
-rw-r--r--xmpp.scm14
1 files changed, 6 insertions, 8 deletions
diff --git a/xmpp.scm b/xmpp.scm
index bade3c1..936013f 100644
--- a/xmpp.scm
+++ b/xmpp.scm
@@ -124,14 +124,12 @@ handlers."
(define (stanza-find-property property-name stanza)
- "Return the given property of a stanza or #f if there is none."
- (let ((properties (cadr stanza)))
- (if (equal? '@ (car properties))
- (let ((res (find (lambda (prop) (eq? property-name (car prop)))
- (cdr properties))))
- (if res
- (cadr res)
- #f)))))
+ "Return the value of a given stanza property or #f if there is
+none."
+ (let ((property ((sxpath `(* @ ,property-name)) stanza)))
+ (if (null? property)
+ #f
+ (cadar property))))
;; generate accessor functions for various stanza attributes
(for-each