From: Chris Hanson Date: Tue, 20 Jun 2000 19:48:46 +0000 (+0000) Subject: Define HEADER-FIELD-LENGTH. X-Git-Tag: 20090517-FFI~3467 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=5d4356f4203021cc3718ce8f020230d564c4b848;p=mit-scheme.git Define HEADER-FIELD-LENGTH. --- diff --git a/v7/src/imail/imail-core.scm b/v7/src/imail/imail-core.scm index 36fb31763..917c9bfd1 100644 --- a/v7/src/imail/imail-core.scm +++ b/v7/src/imail/imail-core.scm @@ -1,6 +1,6 @@ ;;; -*-Scheme-*- ;;; -;;; $Id: imail-core.scm,v 1.107 2000/06/20 19:45:37 cph Exp $ +;;; $Id: imail-core.scm,v 1.108 2000/06/20 19:48:42 cph Exp $ ;;; ;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology ;;; @@ -642,14 +642,13 @@ (guarantee-header-field-value value 'MAKE-HEADER-FIELD) (constructor name value)))) -(define (copy-header-field header) - (record-copy header)) +(define (guarantee-header-field-name object procedure) + (if (not (header-field-name? object)) + (error:wrong-type-argument object "header-field name" procedure))) -(define (->header-fields object) - (cond ((or (pair? object) (null? object)) object) - ((message? object) (message-header-fields object)) - ((string? object) (string->header-fields object)) - (else (error:wrong-type-argument object "header fields" #f)))) +(define (guarantee-header-field-value object procedure) + (if (not (header-field-value? object)) + (error:wrong-type-argument object "header-field value" procedure))) (define (header-field-name? object) (and (string? object) @@ -665,13 +664,19 @@ (char-lwsp? (string-ref object (fix:+ nl 1))) (loop (fix:+ nl 2))))))))) -(define (guarantee-header-field-name object procedure) - (if (not (header-field-name? object)) - (error:wrong-type-argument object "header-field name" procedure))) +(define (copy-header-field header) + (record-copy header)) -(define (guarantee-header-field-value object procedure) - (if (not (header-field-value? object)) - (error:wrong-type-argument object "header-field value" procedure))) +(define (->header-fields object) + (cond ((or (pair? object) (null? object)) object) + ((message? object) (message-header-fields object)) + ((string? object) (string->header-fields object)) + (else (error:wrong-type-argument object "header fields" #f)))) + +(define (header-field-length header) + (+ (string-length (header-field-name header)) + (string-length (header-field-value header)) + 2)) (define (get-first-header-field headers name error?) (let loop ((headers (->header-fields headers))) diff --git a/v7/src/imail/imail-file.scm b/v7/src/imail/imail-file.scm index b843c7d48..9cd89efd9 100644 --- a/v7/src/imail/imail-file.scm +++ b/v7/src/imail/imail-file.scm @@ -1,6 +1,6 @@ ;;; -*-Scheme-*- ;;; -;;; $Id: imail-file.scm,v 1.46 2000/06/20 19:47:05 cph Exp $ +;;; $Id: imail-file.scm,v 1.47 2000/06/20 19:48:46 cph Exp $ ;;; ;;; Copyright (c) 1999-2000 Massachusetts Institute of Technology ;;; @@ -284,16 +284,11 @@ (%set-message-flags! message flags)) (define-method message-length ((message )) - (+ (apply + - (map (lambda (header) - (+ (string-length (header-field-name header)) - (string-length (header-field-value header)) - 2)) - (message-header-fields message))) + (+ (apply + (map header-field-length (message-header-fields message))) 1 (string-length (file-message-body message)))) -(define-method message-internal-time ((message )) +(define-method message-internal-time ((message )) (let loop ((headers (get-all-header-fields message "received")) (winner #f)) (if (pair? headers) (loop (cdr headers)