summaryrefslogtreecommitdiffabout
path: root/guile
authorSergey Poznyakoff <gray@gnu.org.ua>2003-03-07 13:09:55 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2003-03-07 13:09:55 (GMT)
commit6dfe8daf02a86936fcbfad09048afe2533bd47bc (patch) (side-by-side diff)
tree928cf202be9936ed75be6374d08532c6d5ffdeeb /guile
parent7910549a2676dfb8d8efb88386e4f406fca2bd0e (diff)
downloadanubis-6dfe8daf02a86936fcbfad09048afe2533bd47bc.tar.gz
anubis-6dfe8daf02a86936fcbfad09048afe2533bd47bc.tar.bz2
(rot-13): A universal function for rotating the message body, its subject, or both.
Diffstat (limited to 'guile') (more/less context) (ignore whitespace changes)
-rw-r--r--guile/rot-13.scm20
1 files changed, 18 insertions, 2 deletions
diff --git a/guile/rot-13.scm b/guile/rot-13.scm
index 1a32e50..15c9405 100644
--- a/guile/rot-13.scm
+++ b/guile/rot-13.scm
@@ -18,9 +18,10 @@
;;;; GNU Anubis is released under the GPL with the additional exemption that
;;;; compiling, linking, and/or using OpenSSL is allowed.
-(define (rot-13 text)
+(define (rot-13-text input)
"Encode the text using ROT-13 method"
- (let ((length (string-length text)))
+ (let* ((text (string-append "" input))
+ (length (string-length text)))
(do ((i 0 (1+ i)))
((>= i length) text)
(let ((c (string-ref text i)))
@@ -34,3 +35,18 @@
(integer->char
(+ 65 (modulo (+ (- (char->integer c) 65) 13) 26))))))))))
+(define (rot-13 hdr body . rest)
+ (let ((rs (lambda (h)
+ (map (lambda (x)
+ (if (string-ci=? (car x) "subject")
+ (cons (car x) (rot-13-text (cdr x)))
+ x))
+ h))))
+ (if (null? rest)
+ (cons (rs hdr) (rot-13-text body))
+ (cons (if (member #:subject rest)
+ (rs hdr)
+ #t)
+ (if (member #:body rest)
+ (rot-13-text body)
+ #t)))))

Return to:

Send suggestions and report system problems to the System administrator.