Added newnews and generic message features

original commit: 9a1312f056848d2526f6cfec8cc13d3b8619937f
This commit is contained in:
Shriram Krishnamurthi 2002-06-20 14:52:20 +00:00
parent e67b821adb
commit be9849503f
2 changed files with 22 additions and 14 deletions

View File

@ -9,6 +9,7 @@
connect-to-server disconnect-from-server
open-news-group
head-of-message body-of-message
newnews-since generic-message-command
make-desired-header extract-desired-headers
(struct nntp ())

View File

@ -1,4 +1,3 @@
(module nntp-unit mzscheme
(require (lib "unitsig.ss")
(lib "etc.ss"))
@ -207,14 +206,16 @@
"unexpected group opening response: ~s" code)
code rest-of-line)))))))
;; head/body-of-message :
;; string x number -> communicator x number -> list (string)
;; generic-message-command :
;; string x number -> communicator x (number U string) -> list (string)
(define head/body-of-message
(define generic-message-command
(lambda (command ok-code)
(lambda (communicator message-number)
(lambda (communicator message-index)
(send-to-server communicator (string-append command " ~a")
(number->string message-number))
(if (number? message-index)
(number->string message-index)
message-index))
(let-values (((code response)
(get-single-line-response communicator)))
(if (= code ok-code)
@ -222,31 +223,37 @@
(case code
((423)
((signal-error make-article-not-in-group
"article number ~s not in group" message-number)
message-number))
"article id ~s not in group" message-index)
message-index))
((412)
((signal-error make-no-group-selected
"no group selected")))
((430)
((signal-error make-article-not-found
"no article number ~s found" message-number)
message-number))
"no article id ~s found" message-index)
message-index))
(else
((signal-error make-unexpected-response
"unexpected message access response: ~s" code)
code response))))))))
;; head-of-message :
;; communicator x number -> list (string)
;; communicator x (number U string) -> list (string)
(define head-of-message
(head/body-of-message "HEAD" 221))
(generic-message-command "HEAD" 221))
;; body-of-message :
;; communicator x number -> list (string)
;; communicator x (number U string) -> list (string)
(define body-of-message
(head/body-of-message "BODY" 222))
(generic-message-command "BODY" 222))
;; newnews-since :
;; communicator x (number U string) -> list (string)
(define newnews-since
(generic-message-command "NEWNEWS" 230))
;; make-desired-header :
;; string -> desired