Browse code
Untabify imap.lisp
Orivej Desh authored on 10/02/2012 19:03:32
Showing 1 changed files
Showing 1 changed files
... | ... |
@@ -79,7 +79,7 @@ |
79 | 79 |
#:with-pop-connection |
80 | 80 |
#:noop |
81 | 81 |
#:parse-mail-header |
82 |
- #:top-lines ; pop only |
|
82 |
+ #:top-lines ; pop only |
|
83 | 83 |
#:unique-id ; pop only |
84 | 84 |
|
85 | 85 |
#:po-condition |
... | ... |
@@ -115,18 +115,18 @@ |
115 | 115 |
|
116 | 116 |
(defclass post-office () |
117 | 117 |
((socket :initarg :socket |
118 |
- :accessor post-office-socket) |
|
118 |
+ :accessor post-office-socket) |
|
119 | 119 |
|
120 | 120 |
(host :initarg :host |
121 |
- :accessor post-office-host |
|
122 |
- :initform nil) |
|
121 |
+ :accessor post-office-host |
|
122 |
+ :initform nil) |
|
123 | 123 |
(user :initarg :user |
124 |
- :accessor post-office-user |
|
125 |
- :initform nil) |
|
124 |
+ :accessor post-office-user |
|
125 |
+ :initform nil) |
|
126 | 126 |
|
127 | 127 |
(state :accessor post-office-state |
128 |
- :initarg :state |
|
129 |
- :initform :unconnected) |
|
128 |
+ :initarg :state |
|
129 |
+ :initform :unconnected) |
|
130 | 130 |
|
131 | 131 |
(timeout |
132 | 132 |
;; time to wait for network activity for actions that should |
... | ... |
@@ -164,7 +164,7 @@ |
164 | 164 |
:accessor mailbox-uidnext ;; predicted next uid |
165 | 165 |
:initform 0) |
166 | 166 |
|
167 |
- (flags ; list of flags that can be stored in a message |
|
167 |
+ (flags ; list of flags that can be stored in a message |
|
168 | 168 |
:accessor mailbox-flags |
169 | 169 |
:initform nil) |
170 | 170 |
|
... | ... |
@@ -228,7 +228,7 @@ |
228 | 228 |
name ;; often the person's full name |
229 | 229 |
additional |
230 | 230 |
mailbox ;; the login name |
231 |
- host ;; the name of the machine |
|
231 |
+ host ;; the name of the machine |
|
232 | 232 |
) |
233 | 233 |
|
234 | 234 |
|
... | ... |
@@ -253,36 +253,36 @@ |
253 | 253 |
;; identifiers used in conditions/errors |
254 | 254 |
|
255 | 255 |
; :problem condition |
256 |
-; the server responded with 'no' followed by an explanation. |
|
257 |
-; this mean that something unusual happend and doesn't necessarily |
|
258 |
-; mean that the command has completely failed (but it might). |
|
256 |
+; the server responded with 'no' followed by an explanation. |
|
257 |
+; this mean that something unusual happend and doesn't necessarily |
|
258 |
+; mean that the command has completely failed (but it might). |
|
259 | 259 |
; |
260 | 260 |
; :unknown-ok condition |
261 |
-; the server responded with an 'ok' followed by something |
|
262 |
-; we don't recognize. It's probably safe to ignore this. |
|
261 |
+; the server responded with an 'ok' followed by something |
|
262 |
+; we don't recognize. It's probably safe to ignore this. |
|
263 | 263 |
; |
264 | 264 |
; :unknown-untagged condition |
265 |
-; the server responded with some untagged command we don't |
|
266 |
-; recognize. it's probaby ok to ignore this. |
|
265 |
+; the server responded with some untagged command we don't |
|
266 |
+; recognize. it's probaby ok to ignore this. |
|
267 | 267 |
; |
268 | 268 |
; :error-response error |
269 |
-; the command failed. |
|
269 |
+; the command failed. |
|
270 | 270 |
; |
271 | 271 |
; :syntax-error error |
272 |
-; the data passed to a function in this interface was malformed |
|
272 |
+; the data passed to a function in this interface was malformed |
|
273 | 273 |
; |
274 | 274 |
; :unexpected error |
275 |
-; the server responded an unexpected way. |
|
275 |
+; the server responded an unexpected way. |
|
276 | 276 |
; |
277 | 277 |
; :server-shutdown-connection error |
278 |
-; the server has shut down the connection, don't attempt to |
|
278 |
+; the server has shut down the connection, don't attempt to |
|
279 | 279 |
; send any more commands to this connection, or even close it. |
280 | 280 |
; |
281 | 281 |
; :timeout error |
282 |
-; server failed to respond within the timeout period |
|
282 |
+; server failed to respond within the timeout period |
|
283 | 283 |
; |
284 | 284 |
; :response-too-large error |
285 |
-; contents of a response is too large to store in a Lisp array. |
|
285 |
+; contents of a response is too large to store in a Lisp array. |
|
286 | 286 |
|
287 | 287 |
|
288 | 288 |
;; conditions |
... | ... |
@@ -308,13 +308,13 @@ |
308 | 308 |
;; format-control string |
309 | 309 |
(format stream "Post Office condition: ~s~%" identifier) |
310 | 310 |
(if* (and (excl::simple-condition-format-control con)) |
311 |
- then (apply #'format stream |
|
312 |
- (excl::simple-condition-format-control con) |
|
313 |
- (excl::simple-condition-format-arguments con))) |
|
311 |
+ then (apply #'format stream |
|
312 |
+ (excl::simple-condition-format-control con) |
|
313 |
+ (excl::simple-condition-format-arguments con))) |
|
314 | 314 |
(if* server-string |
315 |
- then (format stream |
|
316 |
- "~&Message from server: ~s" |
|
317 |
- (string-left-trim " " server-string))))))) |
|
315 |
+ then (format stream |
|
316 |
+ "~&Message from server: ~s" |
|
317 |
+ (string-left-trim " " server-string))))))) |
|
318 | 318 |
|
319 | 319 |
|
320 | 320 |
|
... | ... |
@@ -327,21 +327,21 @@ |
327 | 327 |
;; aignalling the conditions |
328 | 328 |
|
329 | 329 |
(defun po-condition (identifier &key server-string format-control |
330 |
- format-arguments) |
|
330 |
+ format-arguments) |
|
331 | 331 |
(signal (make-instance 'po-condition |
332 |
- :identifier identifier |
|
333 |
- :server-string server-string |
|
334 |
- :format-control format-control |
|
335 |
- :format-arguments format-arguments |
|
336 |
- ))) |
|
332 |
+ :identifier identifier |
|
333 |
+ :server-string server-string |
|
334 |
+ :format-control format-control |
|
335 |
+ :format-arguments format-arguments |
|
336 |
+ ))) |
|
337 | 337 |
|
338 | 338 |
(defun po-error (identifier &key server-string |
339 |
- format-control format-arguments) |
|
339 |
+ format-control format-arguments) |
|
340 | 340 |
(error (make-instance 'po-error |
341 |
- :identifier identifier |
|
342 |
- :server-string server-string |
|
343 |
- :format-control format-control |
|
344 |
- :format-arguments format-arguments))) |
|
341 |
+ :identifier identifier |
|
342 |
+ :server-string server-string |
|
343 |
+ :format-control format-control |
|
344 |
+ :format-arguments format-arguments))) |
|
345 | 345 |
|
346 | 346 |
|
347 | 347 |
|
... | ... |
@@ -366,80 +366,80 @@ |
366 | 366 |
;; (server-name &key (port 25) (ssl nil) (starttls nil) ...ssl-client-keywords...) |
367 | 367 |
(defun connect-to-imap/pop-server (server-info server-type) |
368 | 368 |
(macrolet ((pop-keyword (k l) `(prog1 (getf ,l ,k) (remf ,l ,k))) |
369 |
- (server-port (ssl type) `(cond ((eq ,type :imap) (if ,ssl 993 143)) |
|
370 |
- ((eq ,type :pop) (if ,ssl 995 110))))) |
|
369 |
+ (server-port (ssl type) `(cond ((eq ,type :imap) (if ,ssl 993 143)) |
|
370 |
+ ((eq ,type :pop) (if ,ssl 995 110))))) |
|
371 | 371 |
(let* ((server (car server-info)) |
372 |
- (ssl-args (cdr server-info)) |
|
373 |
- ssl port starttls sock) |
|
372 |
+ (ssl-args (cdr server-info)) |
|
373 |
+ ssl port starttls sock) |
|
374 | 374 |
(setq ssl (pop-keyword :ssl ssl-args)) |
375 | 375 |
(setq port (or (pop-keyword :port ssl-args) (server-port ssl server-type))) |
376 | 376 |
(setq starttls (pop-keyword :starttls ssl-args)) |
377 | 377 |
(setq sock (socket:make-socket :remote-host server |
378 |
- :remote-port port)) |
|
378 |
+ :remote-port port)) |
|
379 | 379 |
(when ssl |
380 |
- (setq sock (apply #'socket:make-ssl-client-stream sock ssl-args))) |
|
380 |
+ (setq sock (apply #'socket:make-ssl-client-stream sock ssl-args))) |
|
381 | 381 |
|
382 | 382 |
(values sock starttls))) ) |
383 | 383 |
|
384 | 384 |
(defun make-imap-connection (host &key (port 143) |
385 |
- user |
|
386 |
- password |
|
387 |
- (timeout 30)) |
|
385 |
+ user |
|
386 |
+ password |
|
387 |
+ (timeout 30)) |
|
388 | 388 |
(multiple-value-bind (sock starttls) |
389 | 389 |
(if (consp host) |
390 |
- (connect-to-imap/pop-server host :imap) |
|
391 |
- (socket:make-socket :remote-host host :remote-port port)) |
|
390 |
+ (connect-to-imap/pop-server host :imap) |
|
391 |
+ (socket:make-socket :remote-host host :remote-port port)) |
|
392 | 392 |
(let ((imap (make-instance 'imap-mailbox |
393 |
- :socket sock |
|
394 |
- :host host |
|
395 |
- :timeout timeout |
|
396 |
- :state :unauthorized))) |
|
393 |
+ :socket sock |
|
394 |
+ :host host |
|
395 |
+ :timeout timeout |
|
396 |
+ :state :unauthorized))) |
|
397 | 397 |
|
398 | 398 |
(multiple-value-bind (tag cmd count extra comment) |
399 |
- (get-and-parse-from-imap-server imap) |
|
399 |
+ (get-and-parse-from-imap-server imap) |
|
400 | 400 |
(declare (ignorable cmd count extra)) |
401 | 401 |
(if* (not (eq :untagged tag)) |
402 |
- then (po-error :error-response |
|
403 |
- :server-string comment))) |
|
402 |
+ then (po-error :error-response |
|
403 |
+ :server-string comment))) |
|
404 | 404 |
|
405 | 405 |
; check for starttls negotiation |
406 | 406 |
(when starttls |
407 | 407 |
(let (capabilities) |
408 |
- (send-command-get-results |
|
409 |
- imap "CAPABILITY" |
|
410 |
- #'(lambda (mb cmd count extra comment) |
|
411 |
- (declare (ignorable mb cmd count extra)) |
|
412 |
- (setq capabilities comment)) |
|
413 |
- #'(lambda (mb cmd count extra comment) |
|
414 |
- (check-for-success mb cmd count extra comment |
|
415 |
- "CAPABILITY"))) |
|
416 |
- (when (and capabilities (match-re "STARTTLS" capabilities :case-fold t |
|
417 |
- :return nil)) |
|
418 |
- ;; negotiate starttls |
|
419 |
- (send-command-get-results imap "STARTTLS" |
|
420 |
- #'handle-untagged-response |
|
421 |
- #'(lambda (mb cmd count extra comment) |
|
422 |
- (check-for-success mb cmd count extra comment |
|
423 |
- "STARTTLS") |
|
424 |
- (setf (post-office-socket mb) |
|
425 |
- (socket:make-ssl-client-stream |
|
426 |
- (post-office-socket mb) :method :tlsv1))))))) |
|
408 |
+ (send-command-get-results |
|
409 |
+ imap "CAPABILITY" |
|
410 |
+ #'(lambda (mb cmd count extra comment) |
|
411 |
+ (declare (ignorable mb cmd count extra)) |
|
412 |
+ (setq capabilities comment)) |
|
413 |
+ #'(lambda (mb cmd count extra comment) |
|
414 |
+ (check-for-success mb cmd count extra comment |
|
415 |
+ "CAPABILITY"))) |
|
416 |
+ (when (and capabilities (match-re "STARTTLS" capabilities :case-fold t |
|
417 |
+ :return nil)) |
|
418 |
+ ;; negotiate starttls |
|
419 |
+ (send-command-get-results imap "STARTTLS" |
|
420 |
+ #'handle-untagged-response |
|
421 |
+ #'(lambda (mb cmd count extra comment) |
|
422 |
+ (check-for-success mb cmd count extra comment |
|
423 |
+ "STARTTLS") |
|
424 |
+ (setf (post-office-socket mb) |
|
425 |
+ (socket:make-ssl-client-stream |
|
426 |
+ (post-office-socket mb) :method :tlsv1))))))) |
|
427 | 427 |
|
428 | 428 |
; now login |
429 | 429 |
(send-command-get-results imap |
430 |
- (format nil "login ~a ~a" user password) |
|
431 |
- #'handle-untagged-response |
|
432 |
- #'(lambda (mb command count extra comment) |
|
433 |
- (check-for-success mb command count extra |
|
434 |
- comment |
|
435 |
- "login"))) |
|
430 |
+ (format nil "login ~a ~a" user password) |
|
431 |
+ #'handle-untagged-response |
|
432 |
+ #'(lambda (mb command count extra comment) |
|
433 |
+ (check-for-success mb command count extra |
|
434 |
+ comment |
|
435 |
+ "login"))) |
|
436 | 436 |
|
437 | 437 |
; find the separator character |
438 | 438 |
(let ((res (mailbox-list imap))) |
439 | 439 |
;; |
440 | 440 |
(let ((sep (cadr (car res)))) |
441 |
- (if* sep |
|
442 |
- then (setf (mailbox-separator imap) sep)))) |
|
441 |
+ (if* sep |
|
442 |
+ then (setf (mailbox-separator imap) sep)))) |
|
443 | 443 |
|
444 | 444 |
|
445 | 445 |
|
... | ... |
@@ -451,18 +451,18 @@ |
451 | 451 |
(let ((sock (post-office-socket mb))) |
452 | 452 |
(if* sock |
453 | 453 |
then (ignore-errors |
454 |
- (send-command-get-results |
|
455 |
- mb |
|
456 |
- "logout" |
|
457 |
- ; don't want to get confused by untagged |
|
458 |
- ; bye command, which is expected here |
|
459 |
- #'(lambda (mb command count extra) |
|
460 |
- (declare (ignore mb command count extra)) |
|
461 |
- nil) |
|
462 |
- #'(lambda (mb command count extra comment) |
|
463 |
- (check-for-success mb command count extra |
|
464 |
- comment |
|
465 |
- "logout"))))) |
|
454 |
+ (send-command-get-results |
|
455 |
+ mb |
|
456 |
+ "logout" |
|
457 |
+ ; don't want to get confused by untagged |
|
458 |
+ ; bye command, which is expected here |
|
459 |
+ #'(lambda (mb command count extra) |
|
460 |
+ (declare (ignore mb command count extra)) |
|
461 |
+ nil) |
|
462 |
+ #'(lambda (mb command count extra comment) |
|
463 |
+ (check-for-success mb command count extra |
|
464 |
+ comment |
|
465 |
+ "logout"))))) |
|
466 | 466 |
(setf (post-office-socket mb) nil) |
467 | 467 |
(if* sock then (ignore-errors (close sock))) |
468 | 468 |
t)) |
... | ... |
@@ -472,9 +472,9 @@ |
472 | 472 |
(let ((sock (post-office-socket pb))) |
473 | 473 |
(if* sock |
474 | 474 |
then (ignore-errors |
475 |
- (send-pop-command-get-results |
|
476 |
- pb |
|
477 |
- "QUIT"))) |
|
475 |
+ (send-pop-command-get-results |
|
476 |
+ pb |
|
477 |
+ "QUIT"))) |
|
478 | 478 |
(setf (post-office-socket pb) nil) |
479 | 479 |
(if* sock then (ignore-errors (close sock))) |
480 | 480 |
t)) |
... | ... |
@@ -482,34 +482,34 @@ |
482 | 482 |
|
483 | 483 |
|
484 | 484 |
(defun make-pop-connection (host &key (port 110) |
485 |
- user |
|
486 |
- password |
|
487 |
- (timeout 30)) |
|
485 |
+ user |
|
486 |
+ password |
|
487 |
+ (timeout 30)) |
|
488 | 488 |
(multiple-value-bind (sock starttls) |
489 | 489 |
(if (consp host) |
490 |
- (connect-to-imap/pop-server host :pop) |
|
491 |
- (socket:make-socket :remote-host host :remote-port port)) |
|
490 |
+ (connect-to-imap/pop-server host :pop) |
|
491 |
+ (socket:make-socket :remote-host host :remote-port port)) |
|
492 | 492 |
(let ((pop (make-instance 'pop-mailbox |
493 |
- :socket sock |
|
494 |
- :host host |
|
495 |
- :timeout timeout |
|
496 |
- :state :unauthorized))) |
|
493 |
+ :socket sock |
|
494 |
+ :host host |
|
495 |
+ :timeout timeout |
|
496 |
+ :state :unauthorized))) |
|
497 | 497 |
|
498 | 498 |
(multiple-value-bind (result) |
499 |
- (get-and-parse-from-pop-server pop) |
|
499 |
+ (get-and-parse-from-pop-server pop) |
|
500 | 500 |
(if* (not (eq :ok result)) |
501 |
- then (po-error :error-response |
|
502 |
- :format-control |
|
503 |
- "unexpected line from server after connect"))) |
|
501 |
+ then (po-error :error-response |
|
502 |
+ :format-control |
|
503 |
+ "unexpected line from server after connect"))) |
|
504 | 504 |
|
505 | 505 |
; check for starttls negotiation |
506 | 506 |
(when starttls |
507 | 507 |
(let ((capabilities (send-pop-command-get-results pop "capa" t))) |
508 |
- (when (and capabilities (match-re "STLS" capabilities :case-fold t |
|
509 |
- :return nil)) |
|
510 |
- (send-pop-command-get-results pop "STLS") |
|
511 |
- (setf (post-office-socket pop) (socket:make-ssl-client-stream |
|
512 |
- (post-office-socket pop) :method :tlsv1))))) |
|
508 |
+ (when (and capabilities (match-re "STLS" capabilities :case-fold t |
|
509 |
+ :return nil)) |
|
510 |
+ (send-pop-command-get-results pop "STLS") |
|
511 |
+ (setf (post-office-socket pop) (socket:make-ssl-client-stream |
|
512 |
+ (post-office-socket pop) :method :tlsv1))))) |
|
513 | 513 |
|
514 | 514 |
; now login |
515 | 515 |
(send-pop-command-get-results pop (format nil "user ~a" user)) |
... | ... |
@@ -524,31 +524,31 @@ |
524 | 524 |
|
525 | 525 |
|
526 | 526 |
(defmethod send-command-get-results ((mb imap-mailbox) |
527 |
- command untagged-handler tagged-handler) |
|
527 |
+ command untagged-handler tagged-handler) |
|
528 | 528 |
;; send a command and retrieve results until we get the tagged |
529 | 529 |
;; response for the command we sent |
530 | 530 |
;; |
531 | 531 |
(let ((tag (get-next-tag))) |
532 | 532 |
(format (post-office-socket mb) |
533 |
- "~a ~a~a" tag command *crlf*) |
|
533 |
+ "~a ~a~a" tag command *crlf*) |
|
534 | 534 |
(force-output (post-office-socket mb)) |
535 | 535 |
|
536 | 536 |
(if* *debug-imap* |
537 | 537 |
then (format t |
538 |
- "~a ~a~a" tag command *crlf*) |
|
539 |
- (force-output)) |
|
538 |
+ "~a ~a~a" tag command *crlf*) |
|
539 |
+ (force-output)) |
|
540 | 540 |
(loop |
541 | 541 |
(multiple-value-bind (got-tag cmd count extra comment) |
542 |
- (get-and-parse-from-imap-server mb) |
|
543 |
- (if* (eq got-tag :untagged) |
|
544 |
- then (funcall untagged-handler mb cmd count extra comment) |
|
545 |
- elseif (equal tag got-tag) |
|
546 |
- then (funcall tagged-handler mb cmd count extra comment) |
|
547 |
- (return) |
|
548 |
- else (po-error :error-response |
|
549 |
- :format-control "received tag ~s out of order" |
|
550 |
- :format-arguments (list got-tag) |
|
551 |
- :server-string comment)))))) |
|
542 |
+ (get-and-parse-from-imap-server mb) |
|
543 |
+ (if* (eq got-tag :untagged) |
|
544 |
+ then (funcall untagged-handler mb cmd count extra comment) |
|
545 |
+ elseif (equal tag got-tag) |
|
546 |
+ then (funcall tagged-handler mb cmd count extra comment) |
|
547 |
+ (return) |
|
548 |
+ else (po-error :error-response |
|
549 |
+ :format-control "received tag ~s out of order" |
|
550 |
+ :format-arguments (list got-tag) |
|
551 |
+ :server-string comment)))))) |
|
552 | 552 |
|
553 | 553 |
|
554 | 554 |
(defun get-next-tag () |
... | ... |
@@ -556,7 +556,7 @@ |
556 | 556 |
(if* tag |
557 | 557 |
thenret |
558 | 558 |
else (setq *cur-imap-tags* *imap-tags*) |
559 |
- (pop *cur-imap-tags*)))) |
|
559 |
+ (pop *cur-imap-tags*)))) |
|
560 | 560 |
|
561 | 561 |
(defun handle-untagged-response (mb command count extra comment) |
562 | 562 |
;; default function to handle untagged responses, which are |
... | ... |
@@ -569,21 +569,21 @@ |
569 | 569 |
(:bye ; occurs when connection times out or mailbox lock is stolen |
570 | 570 |
(ignore-errors (close (post-office-socket mb))) |
571 | 571 |
(po-error :server-shutdown-connection |
572 |
- :server-string "server shut down the connection")) |
|
572 |
+ :server-string "server shut down the connection")) |
|
573 | 573 |
(:no ; used when grabbing a lock from another process |
574 | 574 |
(po-condition :problem :server-string comment)) |
575 | 575 |
(:ok ; a whole variety of things |
576 | 576 |
(if* extra |
577 |
- then (if* (equalp (car extra) "unseen") |
|
578 |
- then (setf (first-unseen mb) (cadr extra)) |
|
579 |
- elseif (equalp (car extra) "uidvalidity") |
|
580 |
- then (setf (mailbox-uidvalidity mb) (cadr extra)) |
|
581 |
- elseif (equalp (car extra) "uidnext") |
|
582 |
- then (setf (mailbox-uidnext mb) (cadr extra)) |
|
583 |
- elseif (equalp (car extra) "permanentflags") |
|
584 |
- then (setf (mailbox-permanent-flags mb) |
|
585 |
- (kwd-intern-possible-list (cadr extra))) |
|
586 |
- else (po-condition :unknown-ok :server-string comment)))) |
|
577 |
+ then (if* (equalp (car extra) "unseen") |
|
578 |
+ then (setf (first-unseen mb) (cadr extra)) |
|
579 |
+ elseif (equalp (car extra) "uidvalidity") |
|
580 |
+ then (setf (mailbox-uidvalidity mb) (cadr extra)) |
|
581 |
+ elseif (equalp (car extra) "uidnext") |
|
582 |
+ then (setf (mailbox-uidnext mb) (cadr extra)) |
|
583 |
+ elseif (equalp (car extra) "permanentflags") |
|
584 |
+ then (setf (mailbox-permanent-flags mb) |
|
585 |
+ (kwd-intern-possible-list (cadr extra))) |
|
586 |
+ else (po-condition :unknown-ok :server-string comment)))) |
|
587 | 587 |
(t (po-condition :unknown-untagged :server-string comment))) |
588 | 588 |
|
589 | 589 |
) |
... | ... |
@@ -595,43 +595,43 @@ |
595 | 595 |
(defmethod get-extended-results-sequence ((mb pop-mailbox) buffer &key (start 0) (end (length buffer))) |
596 | 596 |
(declare (optimize (speed 3) (safety 1))) |
597 | 597 |
(let ((inpos start) |
598 |
- (outpos start) |
|
599 |
- (sock (post-office-socket mb)) |
|
600 |
- ch |
|
601 |
- stop) |
|
598 |
+ (outpos start) |
|
599 |
+ (sock (post-office-socket mb)) |
|
600 |
+ ch |
|
601 |
+ stop) |
|
602 | 602 |
(macrolet ((add-to-buffer () |
603 |
- `(progn |
|
604 |
- (setf (schar buffer outpos) ch) |
|
605 |
- (incf outpos)))) |
|
603 |
+ `(progn |
|
604 |
+ (setf (schar buffer outpos) ch) |
|
605 |
+ (incf outpos)))) |
|
606 | 606 |
(while (and (< inpos end) (/= (state mb) 4)) |
607 |
- (setf stop (read-sequence buffer sock :start inpos :end end :partial-fill t)) |
|
608 |
- (while (< inpos stop) |
|
609 |
- (setf ch (schar buffer inpos)) |
|
610 |
- (if* (eq ch #\return) |
|
611 |
- thenret ; ignore crs |
|
612 |
- else (ecase (state mb) |
|
613 |
- (1 (if* (eq ch #\.) ; at beginning of line |
|
614 |
- then (setf (state mb) 2) |
|
615 |
- elseif (eq ch #\linefeed) |
|
616 |
- then |
|
617 |
- (add-to-buffer) ; state stays at 1 |
|
618 |
- else |
|
619 |
- (setf (state mb) 3) |
|
620 |
- (add-to-buffer))) |
|
621 |
- (2 ; seen first dot |
|
622 |
- (if* (eq ch #\linefeed) |
|
623 |
- then ; end of results |
|
624 |
- (setf (state mb) 4) |
|
625 |
- (return) |
|
626 |
- else |
|
627 |
- (setf (state mb) 3) |
|
628 |
- (add-to-buffer))) ; normal reading |
|
629 |
- (3 ; middle of line |
|
630 |
- (if* (eq ch #\linefeed) |
|
631 |
- then (setf (state mb) 1)) |
|
632 |
- (add-to-buffer)))) |
|
633 |
- (incf inpos)) |
|
634 |
- (setf inpos outpos)) |
|
607 |
+ (setf stop (read-sequence buffer sock :start inpos :end end :partial-fill t)) |
|
608 |
+ (while (< inpos stop) |
|
609 |
+ (setf ch (schar buffer inpos)) |
|
610 |
+ (if* (eq ch #\return) |
|
611 |
+ thenret ; ignore crs |
|
612 |
+ else (ecase (state mb) |
|
613 |
+ (1 (if* (eq ch #\.) ; at beginning of line |
|
614 |
+ then (setf (state mb) 2) |
|
615 |
+ elseif (eq ch #\linefeed) |
|
616 |
+ then |
|
617 |
+ (add-to-buffer) ; state stays at 1 |
|
618 |
+ else |
|
619 |
+ (setf (state mb) 3) |
|
620 |
+ (add-to-buffer))) |
|
621 |
+ (2 ; seen first dot |
|
622 |
+ (if* (eq ch #\linefeed) |
|
623 |
+ then ; end of results |
|
624 |
+ (setf (state mb) 4) |
|
625 |
+ (return) |
|
626 |
+ else |
|
627 |
+ (setf (state mb) 3) |
|
628 |
+ (add-to-buffer))) ; normal reading |
|
629 |
+ (3 ; middle of line |
|
630 |
+ (if* (eq ch #\linefeed) |
|
631 |
+ then (setf (state mb) 1)) |
|
632 |
+ (add-to-buffer)))) |
|
633 |
+ (incf inpos)) |
|
634 |
+ (setf inpos outpos)) |
|
635 | 635 |
outpos))) |
636 | 636 |
|
637 | 637 |
(defmacro end-of-extended-results-p (mb) |
... | ... |
@@ -650,10 +650,10 @@ |
650 | 650 |
`(let ((,mb ,mailbox)) |
651 | 651 |
(begin-extended-results-sequence ,mb) |
652 | 652 |
(unwind-protect |
653 |
- (progn |
|
654 |
- ,@body) |
|
655 |
- ;; cleanup |
|
656 |
- (end-extended-results-sequence ,mb))))) |
|
653 |
+ (progn |
|
654 |
+ ,@body) |
|
655 |
+ ;; cleanup |
|
656 |
+ (end-extended-results-sequence ,mb))))) |
|
657 | 657 |
|
658 | 658 |
|
659 | 659 |
|
... | ... |
@@ -676,44 +676,44 @@ |
676 | 676 |
|
677 | 677 |
(if* *debug-imap* |
678 | 678 |
then (format t "~a~a" command *crlf*) |
679 |
- (force-output t)) |
|
679 |
+ (force-output t)) |
|
680 | 680 |
|
681 | 681 |
(multiple-value-bind (result parsed line) |
682 | 682 |
(get-and-parse-from-pop-server pop) |
683 | 683 |
(if* (not (eq result :ok)) |
684 | 684 |
then (po-error :error-response |
685 |
- :server-string line)) |
|
685 |
+ :server-string line)) |
|
686 | 686 |
|
687 | 687 |
(if* extrap |
688 | 688 |
then ;; get the rest of the data |
689 |
- ;; many but not all pop servers return the size of the data |
|
690 |
- ;; after the +ok, so we use that to initially size the |
|
691 |
- ;; retreival buffer. |
|
692 |
- (let* ((buf (get-line-buffer (+ (if* (fixnump (car parsed)) |
|
693 |
- then (car parsed) |
|
694 |
- else 2048 ; reasonable size |
|
695 |
- ) |
|
696 |
- 50))) |
|
697 |
- (buflen (length buf)) |
|
698 |
- (pos 0)) |
|
699 |
- (with-extended-results-sequence (pop) |
|
700 |
- (until (end-of-extended-results-p pop) |
|
701 |
- (if* (>= pos buflen) |
|
702 |
- then ;; grow buffer |
|
703 |
- (if* (>= buflen (1- array-total-size-limit)) |
|
704 |
- then ; can't grow it any further |
|
705 |
- (po-error |
|
706 |
- :response-too-large |
|
707 |
- :format-control |
|
708 |
- "response from mail server is too large to hold in a lisp array")) |
|
709 |
- (let ((new-buf (get-line-buffer (* buflen 2)))) |
|
710 |
- (init-line-buffer new-buf buf) |
|
711 |
- (free-line-buffer buf) |
|
712 |
- (setq buf new-buf) |
|
713 |
- (setq buflen (length buf)))) |
|
714 |
- (setf pos (get-extended-results-sequence pop buf :start pos :end buflen)))) |
|
715 |
- (prog1 (subseq buf 0 pos) |
|
716 |
- (free-line-buffer buf))) |
|
689 |
+ ;; many but not all pop servers return the size of the data |
|
690 |
+ ;; after the +ok, so we use that to initially size the |
|
691 |
+ ;; retreival buffer. |
|
692 |
+ (let* ((buf (get-line-buffer (+ (if* (fixnump (car parsed)) |
|
693 |
+ then (car parsed) |
|
694 |
+ else 2048 ; reasonable size |
|
695 |
+ ) |
|
696 |
+ 50))) |
|
697 |
+ (buflen (length buf)) |
|
698 |
+ (pos 0)) |
|
699 |
+ (with-extended-results-sequence (pop) |
|
700 |
+ (until (end-of-extended-results-p pop) |
|
701 |
+ (if* (>= pos buflen) |
|
702 |
+ then ;; grow buffer |
|
703 |
+ (if* (>= buflen (1- array-total-size-limit)) |
|
704 |
+ then ; can't grow it any further |
|
705 |
+ (po-error |
|
706 |
+ :response-too-large |
|
707 |
+ :format-control |
|
708 |
+ "response from mail server is too large to hold in a lisp array")) |
|
709 |
+ (let ((new-buf (get-line-buffer (* buflen 2)))) |
|
710 |
+ (init-line-buffer new-buf buf) |
|
711 |
+ (free-line-buffer buf) |
|
712 |
+ (setq buf new-buf) |
|
713 |
+ (setq buflen (length buf)))) |
|
714 |
+ (setf pos (get-extended-results-sequence pop buf :start pos :end buflen)))) |
|
715 |
+ (prog1 (subseq buf 0 pos) |
|
716 |
+ (free-line-buffer buf))) |
|
717 | 717 |
else parsed))) |
718 | 718 |
|
719 | 719 |
|
... | ... |
@@ -731,16 +731,16 @@ |
731 | 731 |
(defmethod select-mailbox ((mb imap-mailbox) name) |
732 | 732 |
;; select the given mailbox |
733 | 733 |
(send-command-get-results mb |
734 |
- (format nil "select ~a" name) |
|
735 |
- #'handle-untagged-response |
|
736 |
- #'(lambda (mb command count extra comment) |
|
737 |
- (declare (ignore mb count extra)) |
|
738 |
- (if* (not (eq command :ok)) |
|
739 |
- then (po-error |
|
740 |
- :problem |
|
741 |
- :format-control |
|
742 |
- "imap mailbox select failed" |
|
743 |
- :server-string comment)))) |
|
734 |
+ (format nil "select ~a" name) |
|
735 |
+ #'handle-untagged-response |
|
736 |
+ #'(lambda (mb command count extra comment) |
|
737 |
+ (declare (ignore mb count extra)) |
|
738 |
+ (if* (not (eq command :ok)) |
|
739 |
+ then (po-error |
|
740 |
+ :problem |
|
741 |
+ :format-control |
|
742 |
+ "imap mailbox select failed" |
|
743 |
+ :server-string comment)))) |
|
744 | 744 |
(setf (mailbox-name mb) name) |
745 | 745 |
t |
746 | 746 |
) |
... | ... |
@@ -749,16 +749,16 @@ |
749 | 749 |
(defmethod fetch-letter ((mb imap-mailbox) number &key uid) |
750 | 750 |
;; return the whole letter |
751 | 751 |
(fetch-field number "body[]" |
752 |
- (fetch-parts mb number "body[]" :uid uid) |
|
753 |
- :uid uid)) |
|
752 |
+ (fetch-parts mb number "body[]" :uid uid) |
|
753 |
+ :uid uid)) |
|
754 | 754 |
|
755 | 755 |
|
756 | 756 |
(defmethod fetch-letter ((pb pop-mailbox) number &key uid) |
757 | 757 |
(declare (ignore uid)) |
758 | 758 |
(send-pop-command-get-results pb |
759 |
- (format nil "RETR ~d" number) |
|
760 |
- t ; extra stuff |
|
761 |
- )) |
|
759 |
+ (format nil "RETR ~d" number) |
|
760 |
+ t ; extra stuff |
|
761 |
+ )) |
|
762 | 762 |
|
763 | 763 |
(defmethod begin-fetch-letter-sequence ((mb imap-mailbox) number &key uid) |
764 | 764 |
(setf (fetch-letter-offset mb) 0) |
... | ... |
@@ -773,17 +773,17 @@ |
773 | 773 |
(begin-extended-results-sequence mb)) |
774 | 774 |
|
775 | 775 |
(defmethod fetch-letter-sequence ((mb imap-mailbox) buffer |
776 |
- &key (start 0) (end (length buffer))) |
|
776 |
+ &key (start 0) (end (length buffer))) |
|
777 | 777 |
(let* ((num (fetch-letter-number mb)) |
778 |
- (offset (fetch-letter-offset mb)) |
|
779 |
- (uid (fetch-letter-uid mb)) |
|
780 |
- (buflen (- end start)) |
|
781 |
- (data (fetch-field num (format nil "body[]<~d>" offset) |
|
782 |
- (fetch-parts mb num |
|
783 |
- (format nil "body[]<~d.~d>" offset buflen) |
|
784 |
- :uid uid) |
|
785 |
- :uid uid)) |
|
786 |
- (datalen (length data))) |
|
778 |
+ (offset (fetch-letter-offset mb)) |
|
779 |
+ (uid (fetch-letter-uid mb)) |
|
780 |
+ (buflen (- end start)) |
|
781 |
+ (data (fetch-field num (format nil "body[]<~d>" offset) |
|
782 |
+ (fetch-parts mb num |
|
783 |
+ (format nil "body[]<~d.~d>" offset buflen) |
|
784 |
+ :uid uid) |
|
785 |
+ :uid uid)) |
|
786 |
+ (datalen (length data))) |
|
787 | 787 |
|
788 | 788 |
(setf (subseq buffer start end) data) |
789 | 789 |
|
... | ... |
@@ -815,31 +815,31 @@ |
815 | 815 |
`(let ((,mb ,mailbox)) |
816 | 816 |
(begin-fetch-letter-sequence ,mb ,@args) |
817 | 817 |
(unwind-protect |
818 |
- (progn |
|
819 |
- ,@body) |
|
820 |
- ;; cleanup |
|
821 |
- (end-fetch-letter-sequence ,mb))))) |
|
818 |
+ (progn |
|
819 |
+ ,@body) |
|
820 |
+ ;; cleanup |
|
821 |
+ (end-fetch-letter-sequence ,mb))))) |
|
822 | 822 |
|
823 | 823 |
(defmethod fetch-parts ((mb imap-mailbox) number parts &key uid) |
824 | 824 |
(let (res) |
825 | 825 |
(send-command-get-results |
826 | 826 |
mb |
827 | 827 |
(format nil "~afetch ~a ~a" |
828 |
- (if* uid then "uid " else "") |
|
829 |
- (message-set-string number) |
|
830 |
- (or parts "body[]") |
|
831 |
- ) |
|
828 |
+ (if* uid then "uid " else "") |
|
829 |
+ (message-set-string number) |
|
830 |
+ (or parts "body[]") |
|
831 |
+ ) |
|
832 | 832 |
#'(lambda (mb command count extra comment) |
833 |
- (if* (eq command :fetch) |
|
834 |
- then (push (list count (internalize-flags extra)) res) |
|
835 |
- else (handle-untagged-response |
|
836 |
- mb command count extra comment))) |
|
833 |
+ (if* (eq command :fetch) |
|
834 |
+ then (push (list count (internalize-flags extra)) res) |
|
835 |
+ else (handle-untagged-response |
|
836 |
+ mb command count extra comment))) |
|
837 | 837 |
#'(lambda (mb command count extra comment) |
838 |
- (declare (ignore mb count extra)) |
|
839 |
- (if* (not (eq command :ok)) |
|
840 |
- then (po-error :problem |
|
841 |
- :format-control "imap mailbox fetch failed" |
|
842 |
- :server-string comment)))) |
|
838 |
+ (declare (ignore mb count extra)) |
|
839 |
+ (if* (not (eq command :ok)) |
|
840 |
+ then (po-error :problem |
|
841 |
+ :format-control "imap mailbox fetch failed" |
|
842 |
+ :server-string comment)))) |
|
843 | 843 |
res)) |
844 | 844 |
|
845 | 845 |
|
... | ... |
@@ -855,22 +855,22 @@ |
855 | 855 |
;; the same messagenumber may appear in multiple items |
856 | 856 |
(let (use-this) |
857 | 857 |
(if* uid |
858 |
- then ; uid appears as a property in the value, not |
|
859 |
- ; as the top level message sequence number |
|
860 |
- (do ((xx (cadr item) (cddr xx))) |
|
861 |
- ((null xx)) |
|
862 |
- (if* (equalp "uid" (car xx)) |
|
863 |
- then (if* (eql letter-number (cadr xx)) |
|
864 |
- then (return (setq use-this t)) |
|
865 |
- else (return)))) |
|
866 |
- else ; just a message sequence number |
|
867 |
- (setq use-this (eql letter-number (car item)))) |
|
858 |
+ then ; uid appears as a property in the value, not |
|
859 |
+ ; as the top level message sequence number |
|
860 |
+ (do ((xx (cadr item) (cddr xx))) |
|
861 |
+ ((null xx)) |
|
862 |
+ (if* (equalp "uid" (car xx)) |
|
863 |
+ then (if* (eql letter-number (cadr xx)) |
|
864 |
+ then (return (setq use-this t)) |
|
865 |
+ else (return)))) |
|
866 |
+ else ; just a message sequence number |
|
867 |
+ (setq use-this (eql letter-number (car item)))) |
|
868 | 868 |
|
869 | 869 |
(if* use-this |
870 |
- then (do ((xx (cadr item) (cddr xx))) |
|
871 |
- ((null xx)) |
|
872 |
- (if* (equalp field-name (car xx)) |
|
873 |
- then (return-from fetch-field (cadr xx)))))))) |
|
870 |
+ then (do ((xx (cadr item) (cddr xx))) |
|
871 |
+ ((null xx)) |
|
872 |
+ (if* (equalp field-name (car xx)) |
|
873 |
+ then (return-from fetch-field (cadr xx)))))))) |
|
874 | 874 |
|
875 | 875 |
|
876 | 876 |
|
... | ... |
@@ -881,10 +881,10 @@ |
881 | 881 |
((null xx)) |
882 | 882 |
(if* (equalp (car xx) "flags") |
883 | 883 |
then ; we can end up with sublists of forms if we |
884 |
- ; do add-flags with a list of flags. this seems like |
|
885 |
- ; a bug in the imap server.. but we have to deal with it |
|
886 |
- (setf (cadr xx) (kwd-intern-possible-list (cadr xx))) |
|
887 |
- (return))) |
|
884 |
+ ; do add-flags with a list of flags. this seems like |
|
885 |
+ ; a bug in the imap server.. but we have to deal with it |
|
886 |
+ (setf (cadr xx) (kwd-intern-possible-list (cadr xx))) |
|
887 |
+ (return))) |
|
888 | 888 |
|
889 | 889 |
stuff) |
890 | 890 |
|
... | ... |
@@ -903,27 +903,27 @@ |
903 | 903 |
(declare (ignore expunge uid)) |
904 | 904 |
|
905 | 905 |
(if* (or (numberp messages) |
906 |
- (and (consp messages) (eq :seq (car messages)))) |
|
906 |
+ (and (consp messages) (eq :seq (car messages)))) |
|
907 | 907 |
then (setq messages (list messages))) |
908 | 908 |
|
909 | 909 |
(if* (not (consp messages)) |
910 | 910 |
then (po-error :syntax-error |
911 |
- :format-control "expect a mesage number or list of messages, not ~s" |
|
912 |
- :format-arguments (list messages))) |
|
911 |
+ :format-control "expect a mesage number or list of messages, not ~s" |
|
912 |
+ :format-arguments (list messages))) |
|
913 | 913 |
|
914 | 914 |
(dolist (message messages) |
915 | 915 |
(if* (numberp message) |
916 | 916 |
then (send-pop-command-get-results pb |
917 |
- (format nil "DELE ~d" message)) |
|
917 |
+ (format nil "DELE ~d" message)) |
|
918 | 918 |
elseif (and (consp message) (eq :seq (car message))) |
919 | 919 |
then (do ((start (cadr message) (1+ start)) |
920 |
- (end (caddr message))) |
|
921 |
- ((> start end)) |
|
922 |
- (send-pop-command-get-results pb |
|
923 |
- (format nil "DELE ~d" start))) |
|
920 |
+ (end (caddr message))) |
|
921 |
+ ((> start end)) |
|
922 |
+ (send-pop-command-get-results pb |
|
923 |
+ (format nil "DELE ~d" start))) |
|
924 | 924 |
else (po-error :syntax-error |
925 |
- :format-control "bad message number ~s" |
|
926 |
- :format-arguments (list message))))) |
|
925 |
+ :format-control "bad message number ~s" |
|
926 |
+ :format-arguments (list message))))) |
|
927 | 927 |
|
928 | 928 |
|
929 | 929 |
|
... | ... |
@@ -933,13 +933,13 @@ |
933 | 933 |
;; just poke the server... keeping it awake and checking for |
934 | 934 |
;; new letters |
935 | 935 |
(send-command-get-results mb |
936 |
- "noop" |
|
937 |
- #'handle-untagged-response |
|
938 |
- #'(lambda (mb command count extra comment) |
|
939 |
- (check-for-success |
|
940 |
- mb command count extra |
|
941 |
- comment |
|
942 |
- "noop")))) |
|
936 |
+ "noop" |
|
937 |
+ #'handle-untagged-response |
|
938 |
+ #'(lambda (mb command count extra comment) |
|
939 |
+ (check-for-success |
|
940 |
+ mb command count extra |
|
941 |
+ comment |
|
942 |
+ "noop")))) |
|
943 | 943 |
|
944 | 944 |
|
945 | 945 |
(defmethod noop ((pb pop-mailbox)) |
... | ... |
@@ -958,61 +958,61 @@ |
958 | 958 |
;; |
959 | 959 |
(if* message |
960 | 960 |
then (let ((res (send-pop-command-get-results pb |
961 |
- (format nil |
|
962 |
- "UIDL ~d" |
|
963 |
- message)))) |
|
964 |
- (cadr res)) |
|
961 |
+ (format nil |
|
962 |
+ "UIDL ~d" |
|
963 |
+ message)))) |
|
964 |
+ (cadr res)) |
|
965 | 965 |
else ; get all of them |
966 |
- (let* ((res (send-pop-command-get-results pb "UIDL" t)) |
|
967 |
- (end (length res)) |
|
968 |
- kind |
|
969 |
- mnum |
|
970 |
- mid |
|
971 |
- (next 0)) |
|
966 |
+ (let* ((res (send-pop-command-get-results pb "UIDL" t)) |
|
967 |
+ (end (length res)) |
|
968 |
+ kind |
|
969 |
+ mnum |
|
970 |
+ mid |
|
971 |
+ (next 0)) |
|
972 | 972 |
|
973 | 973 |
|
974 |
- (let ((coll)) |
|
975 |
- (loop |
|
976 |
- (multiple-value-setq (kind mnum next) |
|
977 |
- (get-next-token res next end)) |
|
974 |
+ (let ((coll)) |
|
975 |
+ (loop |
|
976 |
+ (multiple-value-setq (kind mnum next) |
|
977 |
+ (get-next-token res next end)) |
|
978 | 978 |
|
979 |
- (if* (eq :eof kind) then (return)) |
|
979 |
+ (if* (eq :eof kind) then (return)) |
|
980 | 980 |
|
981 |
- (if* (not (eq :number kind)) |
|
982 |
- then ; hmm. bogus |
|
983 |
- (po-error :unexpected |
|
984 |
- :format-control "uidl returned illegal message number in ~s" |
|
985 |
- :format-arguments (list res))) |
|
981 |
+ (if* (not (eq :number kind)) |
|
982 |
+ then ; hmm. bogus |
|
983 |
+ (po-error :unexpected |
|
984 |
+ :format-control "uidl returned illegal message number in ~s" |
|
985 |
+ :format-arguments (list res))) |
|
986 | 986 |
|
987 |
- ; now get message id |
|
987 |
+ ; now get message id |
|
988 | 988 |
|
989 |
- (multiple-value-setq (kind mid next) |
|
990 |
- (get-next-token res next end)) |
|
989 |
+ (multiple-value-setq (kind mid next) |
|
990 |
+ (get-next-token res next end)) |
|
991 | 991 |
|
992 |
- (if* (eq :number kind) |
|
993 |
- then ; looked like a number to the tokenizer, |
|
994 |
- ; make it a string to be consistent |
|
995 |
- (setq mid (format nil "~d" mid)) |
|
996 |
- elseif (not (eq :string kind)) |
|
997 |
- then ; didn't find the uid |
|
998 |
- (po-error :unexpected |
|
999 |
- :format-control "uidl returned illegal message id in ~s" |
|
1000 |
- :format-arguments (list res))) |
|
992 |
+ (if* (eq :number kind) |
|
993 |
+ then ; looked like a number to the tokenizer, |
|
994 |
+ ; make it a string to be consistent |
|
995 |
+ (setq mid (format nil "~d" mid)) |
|
996 |
+ elseif (not (eq :string kind)) |
|
997 |
+ then ; didn't find the uid |
|
998 |
+ (po-error :unexpected |
|
999 |
+ :format-control "uidl returned illegal message id in ~s" |
|
1000 |
+ :format-arguments (list res))) |
|
1001 | 1001 |
|
1002 |
- (push (list mnum mid) coll)) |
|
1002 |
+ (push (list mnum mid) coll)) |
|
1003 | 1003 |
|
1004 |
- (nreverse coll))))) |
|
1004 |
+ (nreverse coll))))) |
|
1005 | 1005 |
|
1006 | 1006 |
(defmethod top-lines ((pb pop-mailbox) message lines) |
1007 | 1007 |
;; return the header and the given number of top lines of the message |
1008 | 1008 |
|
1009 | 1009 |
(let ((res (send-pop-command-get-results pb |
1010 |
- (format nil |
|
1011 |
- "TOP ~d ~d" |
|
1012 |
- message |
|
1013 |
- lines) |
|
1014 |
- t ; extra |
|
1015 |
- ))) |
|
1010 |
+ (format nil |
|
1011 |
+ "TOP ~d ~d" |
|
1012 |
+ message |
|
1013 |
+ lines) |
|
1014 |
+ t ; extra |
|
1015 |
+ ))) |
|
1016 | 1016 |
res)) |
1017 | 1017 |
|
1018 | 1018 |
|
... | ... |
@@ -1029,9 +1029,9 @@ |
1029 | 1029 |
(declare (ignore mb count extra)) |
1030 | 1030 |
(if* (not (eq command :ok)) |
1031 | 1031 |
then (po-error :error-response |
1032 |
- :format-control "imap ~a failed" |
|
1033 |
- :format-arguments (list command-string) |
|
1034 |
- :server-string comment))) |
|
1032 |
+ :format-control "imap ~a failed" |
|
1033 |
+ :format-arguments (list command-string) |
|
1034 |
+ :server-string comment))) |
|
1035 | 1035 |
|
1036 | 1036 |
|
1037 | 1037 |
|
... | ... |
@@ -1041,17 +1041,17 @@ |
1041 | 1041 |
;; return a list of mailbox names with respect to a given |
1042 | 1042 |
(let (res) |
1043 | 1043 |
(send-command-get-results mb |
1044 |
- (format nil "list ~s ~s" reference pattern) |
|
1045 |
- #'(lambda (mb command count extra comment) |
|
1046 |
- (if* (eq command :list) |
|
1047 |
- then (push extra res) |
|
1048 |
- else (handle-untagged-response |
|
1049 |
- mb command count extra |
|
1050 |
- comment))) |
|
1051 |
- #'(lambda (mb command count extra comment) |
|
1052 |
- (check-for-success |
|
1053 |
- mb command count extra |
|
1054 |
- comment "list"))) |
|
1044 |
+ (format nil "list ~s ~s" reference pattern) |
|
1045 |
+ #'(lambda (mb command count extra comment) |
|
1046 |
+ (if* (eq command :list) |
|
1047 |
+ then (push extra res) |
|
1048 |
+ else (handle-untagged-response |
|
1049 |
+ mb command count extra |
|
1050 |
+ comment))) |
|
1051 |
+ #'(lambda (mb command count extra comment) |
|
1052 |
+ (check-for-success |
|
1053 |
+ mb command count extra |
|
1054 |
+ comment "list"))) |
|
1055 | 1055 |
|
1056 | 1056 |
;; the car of each list is a set of keywords, make that so |
1057 | 1057 |
(dolist (rr res) |
... | ... |
@@ -1067,12 +1067,12 @@ |
1067 | 1067 |
;; create a mailbox name of the given name. |
1068 | 1068 |
;; use mailbox-separator if you want to create a hierarchy |
1069 | 1069 |
(send-command-get-results mb |
1070 |
- (format nil "create ~s" mailbox-name) |
|
1071 |
- #'handle-untagged-response |
|
1072 |
- #'(lambda (mb command count extra comment) |
|
1073 |
- (check-for-success |
|
1074 |
- mb command count extra |
|
1075 |
- comment "create"))) |
|
1070 |
+ (format nil "create ~s" mailbox-name) |
|
1071 |
+ #'handle-untagged-response |
|
1072 |
+ #'(lambda (mb command count extra comment) |
|
1073 |
+ (check-for-success |
|
1074 |
+ mb command count extra |
|
1075 |
+ comment "create"))) |
|
1076 | 1076 |
t) |
1077 | 1077 |
|
1078 | 1078 |
|
... | ... |
@@ -1080,33 +1080,33 @@ |
1080 | 1080 |
;; create a mailbox name of the given name. |
1081 | 1081 |
;; use mailbox-separator if you want to create a hierarchy |
1082 | 1082 |
(send-command-get-results mb |
1083 |
- (format nil "delete ~s" mailbox-name) |
|
1084 |
- #'handle-untagged-response |
|
1085 |
- #'(lambda (mb command count extra comment) |
|
1086 |
- (check-for-success |
|
1087 |
- mb command count extra |
|
1088 |
- comment "delete")))) |
|
1083 |
+ (format nil "delete ~s" mailbox-name) |
|
1084 |
+ #'handle-untagged-response |
|
1085 |
+ #'(lambda (mb command count extra comment) |
|
1086 |
+ (check-for-success |
|
1087 |
+ mb command count extra |
|
1088 |
+ comment "delete")))) |
|
1089 | 1089 |
|
1090 | 1090 |
(defmethod rename-mailbox ((mb imap-mailbox) old-mailbox-name new-mailbox-name) |
1091 | 1091 |
;; create a mailbox name of the given name. |
1092 | 1092 |
;; use mailbox-separator if you want to create a hierarchy |
1093 | 1093 |
(send-command-get-results mb |
1094 |
- (format nil "rename ~s ~s" |
|
1095 |
- old-mailbox-name |
|
1096 |
- new-mailbox-name) |
|
1097 |
- #'handle-untagged-response |
|
1098 |
- #'(lambda (mb command count extra comment) |
|
1099 |
- (check-for-success |
|
1100 |
- mb command count extra |
|
1101 |
- comment |
|
1102 |
- "rename")))) |
|
1094 |
+ (format nil "rename ~s ~s" |
|
1095 |
+ old-mailbox-name |
|
1096 |
+ new-mailbox-name) |
|
1097 |
+ #'handle-untagged-response |
|
1098 |
+ #'(lambda (mb command count extra comment) |
|
1099 |
+ (check-for-success |
|
1100 |
+ mb command count extra |
|
1101 |
+ comment |
|
1102 |
+ "rename")))) |
|
1103 | 1103 |
|
1104 | 1104 |
|
1105 | 1105 |
|
1106 | 1106 |
(defmethod alter-flags ((mb imap-mailbox) |
1107 |
- messages &key (flags nil flags-p) |
|
1108 |
- add-flags remove-flags |
|
1109 |
- silent uid) |
|
1107 |
+ messages &key (flags nil flags-p) |
|
1108 |
+ add-flags remove-flags |
|
1109 |
+ silent uid) |
|
1110 | 1110 |
;; |
1111 | 1111 |
;; change the flags using the store command |
1112 | 1112 |
;; |
... | ... |
@@ -1122,30 +1122,30 @@ |
1122 | 1122 |
(if* (atom val) then (setq val (list val))) |
1123 | 1123 |
|
1124 | 1124 |
(send-command-get-results mb |
1125 |
- (format nil "~astore ~a ~a~a ~a" |
|
1126 |
- (if* uid then "uid " else "") |
|
1127 |
- (message-set-string messages) |
|
1128 |
- cmd |
|
1129 |
- (if* silent |
|
1130 |
- then ".silent" |
|
1131 |
- else "") |
|
1132 |
- (if* val |
|
1133 |
- thenret |
|
1134 |
- else "()")) |
|
1135 |
- #'(lambda (mb command count extra comment) |
|
1136 |
- (if* (eq command :fetch) |
|
1137 |
- then (push (list count |
|
1138 |
- (convert-flags-plist |
|
1139 |
- extra)) |
|
1140 |
- res) |
|
1141 |
- else (handle-untagged-response |
|
1142 |
- mb command count extra |
|
1143 |
- comment))) |
|
1144 |
- |
|
1145 |
- #'(lambda (mb command count extra comment) |
|
1146 |
- (check-for-success |
|
1147 |
- mb command count extra |
|
1148 |
- comment "store"))) |
|
1125 |
+ (format nil "~astore ~a ~a~a ~a" |
|
1126 |
+ (if* uid then "uid " else "") |
|
1127 |
+ (message-set-string messages) |
|
1128 |
+ cmd |
|
1129 |
+ (if* silent |
|
1130 |
+ then ".silent" |
|
1131 |
+ else "") |
|
1132 |
+ (if* val |
|
1133 |
+ thenret |
|
1134 |
+ else "()")) |
|
1135 |
+ #'(lambda (mb command count extra comment) |
|
1136 |
+ (if* (eq command :fetch) |
|
1137 |
+ then (push (list count |
|
1138 |
+ (convert-flags-plist |
|
1139 |
+ extra)) |
|
1140 |
+ res) |
|
1141 |
+ else (handle-untagged-response |
|
1142 |
+ mb command count extra |
|
1143 |
+ comment))) |
|
1144 |
+ |
|
1145 |
+ #'(lambda (mb command count extra comment) |
|
1146 |
+ (check-for-success |
|
1147 |
+ mb command count extra |
|
1148 |
+ comment "store"))) |
|
1149 | 1149 |
res)) |
1150 | 1150 |
|
1151 | 1151 |
|
... | ... |
@@ -1156,22 +1156,22 @@ |
1156 | 1156 |
(if* (atom messages) |
1157 | 1157 |
then (format nil "~a" messages) |
1158 | 1158 |
else (if* (and (consp messages) |
1159 |
- (eq :seq (car messages))) |
|
1160 |
- then (format nil "~a:~a" (cadr messages) (caddr messages)) |
|
1161 |
- else (let ((str (make-string-output-stream)) |
|
1162 |
- (precomma nil)) |
|
1163 |
- (dolist (msg messages) |
|
1164 |
- (if* precomma then (format str ",")) |
|
1165 |
- (if* (atom msg) |
|
1166 |
- then (format str "~a" msg) |
|
1167 |
- elseif (eq :seq (car msg)) |
|
1168 |
- then (format str |
|
1169 |
- "~a:~a" (cadr msg) (caddr msg)) |
|
1170 |
- else (po-error :syntax-error |
|
1171 |
- :format-control "bad message list ~s" |
|
1172 |
- :format-arguments (list msg))) |
|
1173 |
- (setq precomma t)) |
|
1174 |
- (get-output-stream-string str))))) |
|
1159 |
+ (eq :seq (car messages))) |
|
1160 |
+ then (format nil "~a:~a" (cadr messages) (caddr messages)) |
|
1161 |
+ else (let ((str (make-string-output-stream)) |
|
1162 |
+ (precomma nil)) |
|
1163 |
+ (dolist (msg messages) |
|
1164 |
+ (if* precomma then (format str ",")) |
|
1165 |
+ (if* (atom msg) |
|
1166 |
+ then (format str "~a" msg) |
|
1167 |
+ elseif (eq :seq (car msg)) |
|
1168 |
+ then (format str |
|
1169 |
+ "~a:~a" (cadr msg) (caddr msg)) |
|
1170 |
+ else (po-error :syntax-error |
|
1171 |
+ :format-control "bad message list ~s" |
|
1172 |
+ :format-arguments (list msg))) |
|
1173 |
+ (setq precomma t)) |
|
1174 |
+ (get-output-stream-string str))))) |
|
1175 | 1175 |
|
1176 | 1176 |
|
1177 | 1177 |
|
... | ... |
@@ -1182,18 +1182,18 @@ |
1182 | 1182 |
;; remove messages marked as deleted |
1183 | 1183 |
(let (res) |
1184 | 1184 |
(send-command-get-results mb |
1185 |
- "expunge" |
|
1186 |
- #'(lambda (mb command count extra |
|
1187 |
- comment) |
|
1188 |
- (if* (eq command :expunge) |
|
1189 |
- then (push count res) |
|
1190 |
- else (handle-untagged-response |
|
1191 |
- mb command count extra |
|
1192 |
- comment))) |
|
1193 |
- #'(lambda (mb command count extra comment) |
|
1194 |
- (check-for-success |
|
1195 |
- mb command count extra |
|
1196 |
- comment "expunge"))) |
|
1185 |
+ "expunge" |
|
1186 |
+ #'(lambda (mb command count extra |
|
1187 |
+ comment) |
|
1188 |
+ (if* (eq command :expunge) |
|
1189 |
+ then (push count res) |
|
1190 |
+ else (handle-untagged-response |
|
1191 |
+ mb command count extra |
|
1192 |
+ comment))) |
|
1193 |
+ #'(lambda (mb command count extra comment) |
|
1194 |
+ (check-for-success |
|
1195 |
+ mb command count extra |
|
1196 |
+ comment "expunge"))) |
|
1197 | 1197 |
(nreverse res))) |
1198 | 1198 |
|
1199 | 1199 |
|
... | ... |
@@ -1201,29 +1201,29 @@ |
1201 | 1201 |
(defmethod close-mailbox ((mb imap-mailbox)) |
1202 | 1202 |
;; remove messages marked as deleted |
1203 | 1203 |
(send-command-get-results mb |
1204 |
- "close" |
|
1205 |
- #'handle-untagged-response |
|
1204 |
+ "close" |
|
1205 |
+ #'handle-untagged-response |
|
1206 | 1206 |
|
1207 |
- #'(lambda (mb command count extra comment) |
|
1208 |
- (check-for-success |
|
1209 |
- mb command count extra |
|
1210 |
- comment "close"))) |
|
1207 |
+ #'(lambda (mb command count extra comment) |
|
1208 |
+ (check-for-success |
|
1209 |
+ mb command count extra |
|
1210 |
+ comment "close"))) |
|
1211 | 1211 |
t) |
1212 | 1212 |
|
1213 | 1213 |
|
1214 | 1214 |
|
1215 | 1215 |
(defmethod copy-to-mailbox ((mb imap-mailbox) message-list destination |
1216 |
- &key uid) |
|
1216 |
+ &key uid) |
|
1217 | 1217 |
(send-command-get-results mb |
1218 |
- (format nil "~acopy ~a ~s" |
|
1219 |
- (if* uid then "uid " else "") |
|
1220 |
- (message-set-string message-list) |
|
1221 |
- destination) |
|
1222 |
- #'handle-untagged-response |
|
1223 |
- #'(lambda (mb command count extra comment) |
|
1224 |
- (check-for-success |
|
1225 |
- mb command count extra |
|
1226 |
- comment "copy"))) |
|
1218 |
+ (format nil "~acopy ~a ~s" |
|
1219 |
+ (if* uid then "uid " else "") |
|
1220 |
+ (message-set-string message-list) |
|
1221 |
+ destination) |
|
1222 |
+ #'handle-untagged-response |
|
1223 |
+ #'(lambda (mb command count extra comment) |
|
1224 |
+ (check-for-success |
|
1225 |
+ mb command count extra |
|
1226 |
+ comment "copy"))) |
|
1227 | 1227 |
t) |
1228 | 1228 |
|
1229 | 1229 |
|
... | ... |
@@ -1232,19 +1232,19 @@ |
1232 | 1232 |
(defmethod search-mailbox ((mb imap-mailbox) search-expression &key uid) |
1233 | 1233 |
(let (res) |
1234 | 1234 |
(send-command-get-results mb |
1235 |
- (format nil "~asearch ~a" |
|
1236 |
- (if* uid then "uid " else "") |
|
1237 |
- (build-search-string search-expression)) |
|
1238 |
- #'(lambda (mb command count extra comment) |
|
1239 |
- (if* (eq command :search) |
|
1240 |
- then (setq res (append res extra)) |
|
1241 |
- else (handle-untagged-response |
|
1242 |
- mb command count extra |
|
1243 |
- comment))) |
|
1244 |
- #'(lambda (mb command count extra comment) |
|
1245 |
- (check-for-success |
|
1246 |
- mb command count extra |
|
1247 |
- comment "search"))) |
|
1235 |
+ (format nil "~asearch ~a" |
|
1236 |
+ (if* uid then "uid " else "") |
|
1237 |
+ (build-search-string search-expression)) |
|
1238 |
+ #'(lambda (mb command count extra comment) |
|
1239 |
+ (if* (eq command :search) |
|
1240 |
+ then (setq res (append res extra)) |
|
1241 |
+ else (handle-untagged-response |
|
1242 |
+ mb command count extra |
|
1243 |
+ comment))) |
|
1244 |
+ #'(lambda (mb command count extra comment) |
|
1245 |
+ (check-for-success |
|
1246 |
+ mb command count extra |
|
1247 |
+ comment "search"))) |
|
1248 | 1248 |
res)) |
1249 | 1249 |
|
1250 | 1250 |
|
... | ... |
@@ -1296,151 +1296,151 @@ |
1296 | 1296 |
(if* (null search) |
1297 | 1297 |
then "" |
1298 | 1298 |
else (let ((str (make-string-output-stream))) |
1299 |
- (bss-int search str) |
|
1300 |
- (get-output-stream-string str)))) |
|
1299 |
+ (bss-int search str) |
|
1300 |
+ (get-output-stream-string str)))) |
|
1301 | 1301 |
|
1302 | 1302 |
(defun bss-int (search str) |
1303 | 1303 |
;;* it turns out that imap (on linux) is very picky about spaces.... |
1304 | 1304 |
;; any extra whitespace will result in failed searches |
1305 | 1305 |
;; |
1306 | 1306 |
(labels ((and-ify (srch str) |
1307 |
- (let ((spaceout nil)) |
|
1308 |
- (dolist (xx srch) |
|
1309 |
- (if* spaceout then (format str " ")) |
|
1310 |
- (bss-int xx str) |
|
1311 |
- (setq spaceout t)))) |
|
1312 |
- (or-ify (srch str) |
|
1313 |
- ; only binary or allowed in imap but we support n-ary |
|
1314 |
- ; or in this interface |
|
1315 |
- (if* (null (cdr srch)) |
|
1316 |
- then (bss-int (car srch) str) |
|
1317 |
- elseif (cddr srch) |
|
1318 |
- then ; over two clauses |
|
1319 |
- (format str "or (") |
|
1320 |
- (bss-int (car srch) str) |
|
1321 |
- (format str ") (") |
|
1322 |
- (or-ify (cdr srch) str) |
|
1323 |
- (format str ")") |
|
1324 |
- else ; 2 args |
|
1325 |
- (format str "or (" ) |
|
1326 |
- (bss-int (car srch) str) |
|
1327 |
- (format str ") (") |
|
1328 |
- (bss-int (cadr srch) str) |
|
1329 |
- (format str ")"))) |
|
1330 |
- (set-ify (srch str) |
|
1331 |
- ;; a sequence of messages |
|
1332 |
- (do* ((xsrch srch (cdr xsrch)) |
|
1333 |
- (val (car xsrch) (car xsrch))) |
|
1334 |
- ((null xsrch)) |
|
1335 |
- (if* (integerp val) |
|
1336 |
- then (format str "~s" val) |
|
1337 |
- elseif (and (consp val) |
|
1338 |
- (eq :seq (car val)) |
|
1339 |
- (eq 3 (length val))) |
|
1340 |
- then (format str "~s:~s" (cadr val) (caddr val)) |
|
1341 |
- else (po-error :syntax-error |
|
1342 |
- :format-control "illegal set format ~s" |
|
1343 |
- :format-arguments (list val))) |
|
1344 |
- (if* (cdr xsrch) then (format str ",")))) |
|
1345 |
- (arg-process (str args arginfo) |
|
1346 |
- ;; process and print each arg to str |
|
1347 |
- ;; assert (length of args and arginfo are the same) |
|
1348 |
- (do* ((x-args args (cdr x-args)) |
|
1349 |
- (val (car x-args) (car x-args)) |
|
1350 |
- (x-arginfo arginfo (cdr x-arginfo))) |
|
1351 |
- ((null x-args)) |
|
1352 |
- (ecase (car x-arginfo) |
|
1353 |
- (:str |
|
1354 |
- ; print it as a string |
|
1355 |
- (format str " \"~a\"" (car x-args))) |
|
1356 |
- (:date |
|
1357 |
- |
|
1358 |
- (if* (integerp val) |
|
1359 |
- then (setq val (universal-time-to-rfc822-date |
|
1360 |
- val)) |
|
1361 |
- elseif (not (stringp val)) |
|
1362 |
- then (po-error :syntax-error |
|
1363 |
- :format-control "illegal value for date search ~s" |
|
1364 |
- :format-arguments (list val))) |
|
1365 |
- ;; val is now a string |
|
1366 |
- (format str " ~s" val)) |
|
1367 |
- (:number |
|
1368 |
- |
|
1369 |
- (if* (not (integerp val)) |
|
1370 |
- then (po-error :syntax-error |
|
1371 |
- :format-control "illegal value for number in search ~s" |
|
1372 |
- :format-arguments (list val))) |
|
1373 |
- (format str " ~s" val)) |
|
1374 |
- (:flag |
|
1375 |
- |
|
1376 |
- ;; should be a symbol in the kwd package |
|
1377 |
- (setq val (string val)) |
|
1378 |
- (format str " ~s" val)) |
|
1379 |
- (:messageset |
|
1380 |
- (if* (numberp val) |
|
1381 |
- then (format str " ~s" val) |
|
1382 |
- elseif (consp val) |
|
1383 |
- then (set-ify val str) |
|
1384 |
- else (po-error :syntax-error |
|
1385 |
- :format-control "illegal message set ~s" |
|
1386 |
- :format-arguments (list val)))) |
|
1387 |
- |
|
1388 |
- )))) |
|
1307 |
+ (let ((spaceout nil)) |
|
1308 |
+ (dolist (xx srch) |
|
1309 |
+ (if* spaceout then (format str " ")) |
|
1310 |
+ (bss-int xx str) |
|
1311 |
+ (setq spaceout t)))) |
|
1312 |
+ (or-ify (srch str) |
|
1313 |
+ ; only binary or allowed in imap but we support n-ary |
|
1314 |
+ ; or in this interface |
|
1315 |
+ (if* (null (cdr srch)) |
|
1316 |
+ then (bss-int (car srch) str) |
|
1317 |
+ elseif (cddr srch) |
|
1318 |
+ then ; over two clauses |
|
1319 |
+ (format str "or (") |
|
1320 |
+ (bss-int (car srch) str) |
|
1321 |
+ (format str ") (") |
|
1322 |
+ (or-ify (cdr srch) str) |
|
1323 |
+ (format str ")") |
|
1324 |
+ else ; 2 args |
|
1325 |
+ (format str "or (" ) |
|
1326 |
+ (bss-int (car srch) str) |
|
1327 |
+ (format str ") (") |
|
1328 |
+ (bss-int (cadr srch) str) |
|
1329 |
+ (format str ")"))) |
|
1330 |
+ (set-ify (srch str) |
|
1331 |
+ ;; a sequence of messages |
|
1332 |
+ (do* ((xsrch srch (cdr xsrch)) |
|
1333 |
+ (val (car xsrch) (car xsrch))) |
|
1334 |
+ ((null xsrch)) |
|
1335 |
+ (if* (integerp val) |
|
1336 |
+ then (format str "~s" val) |
|
1337 |
+ elseif (and (consp val) |
|
1338 |
+ (eq :seq (car val)) |
|
1339 |
+ (eq 3 (length val))) |
|
1340 |
+ then (format str "~s:~s" (cadr val) (caddr val)) |
|
1341 |
+ else (po-error :syntax-error |
|
1342 |
+ :format-control "illegal set format ~s" |
|
1343 |
+ :format-arguments (list val))) |
|
1344 |
+ (if* (cdr xsrch) then (format str ",")))) |
|
1345 |
+ (arg-process (str args arginfo) |
|
1346 |
+ ;; process and print each arg to str |
|
1347 |
+ ;; assert (length of args and arginfo are the same) |
|
1348 |
+ (do* ((x-args args (cdr x-args)) |
|
1349 |
+ (val (car x-args) (car x-args)) |
|
1350 |
+ (x-arginfo arginfo (cdr x-arginfo))) |
|
1351 |
+ ((null x-args)) |
|
1352 |
+ (ecase (car x-arginfo) |
|
1353 |
+ (:str |
|
1354 |
+ ; print it as a string |
|
1355 |
+ (format str " \"~a\"" (car x-args))) |
|
1356 |
+ (:date |
|
1357 |
+ |
|
1358 |
+ (if* (integerp val) |
|
1359 |
+ then (setq val (universal-time-to-rfc822-date |
|
1360 |
+ val)) |
|
1361 |
+ elseif (not (stringp val)) |
|
1362 |
+ then (po-error :syntax-error |
|
1363 |
+ :format-control "illegal value for date search ~s" |
|
1364 |
+ :format-arguments (list val))) |
|
1365 |
+ ;; val is now a string |
|
1366 |
+ (format str " ~s" val)) |
|
1367 |
+ (:number |
|
1368 |
+ |
|
1369 |
+ (if* (not (integerp val)) |
|
1370 |
+ then (po-error :syntax-error |
|
1371 |
+ :format-control "illegal value for number in search ~s" |
|
1372 |
+ :format-arguments (list val))) |
|
1373 |
+ (format str " ~s" val)) |
|
1374 |
+ (:flag |
|
1375 |
+ |
|
1376 |
+ ;; should be a symbol in the kwd package |
|
1377 |
+ (setq val (string val)) |
|
1378 |
+ (format str " ~s" val)) |
|
1379 |
+ (:messageset |
|
1380 |
+ (if* (numberp val) |
|
1381 |
+ then (format str " ~s" val) |
|
1382 |
+ elseif (consp val) |
|
1383 |
+ then (set-ify val str) |
|
1384 |
+ else (po-error :syntax-error |
|
1385 |
+ :format-control "illegal message set ~s" |
|
1386 |
+ :format-arguments (list val)))) |
|
1387 |
+ |
|
1388 |
+ )))) |
|
1389 | 1389 |
|
1390 | 1390 |
(if* (symbolp search) |
1391 | 1391 |
then (if* (get search 'imap-search-no-args) |
1392 |
- then (format str "~a" (string-upcase |
|
1393 |
- (string search))) |
|
1394 |
- else (po-error :syntax-error |
|
1395 |
- :format-control "illegal search word: ~s" |
|
1396 |
- :format-arguments (list search))) |
|
1392 |
+ then (format str "~a" (string-upcase |
|
1393 |
+ (string search))) |
|
1394 |
+ else (po-error :syntax-error |
|
1395 |
+ :format-control "illegal search word: ~s" |
|
1396 |
+ :format-arguments (list search))) |
|
1397 | 1397 |
elseif (consp search) |
1398 | 1398 |
then (case (car search) |
1399 |
- (and (if* (null (cdr search)) |
|
1400 |
- then (bss-int :all str) |
|
1401 |
- elseif (null (cddr search)) |
|
1402 |
- then (bss-int (cadr search) str) |
|
1403 |
- else (and-ify (cdr search) str))) |
|
1404 |
- (or (if* (null (cdr search)) |
|
1405 |
- then (bss-int :all str) |
|
1406 |
- elseif (null (cddr search)) |
|
1407 |
- then (bss-int (cadr search) str) |
|
1408 |
- else (or-ify (cdr search) str))) |
|
1409 |
- (not (if* (not (eql (length search) 2)) |
|
1410 |
- then (po-error :syntax-error |
|
1411 |
- :format-control "not takes one argument: ~s" |
|
1412 |
- :format-arguments (list search))) |
|
1413 |
- (format str "not (" ) |
|
1414 |
- (bss-int (cadr search) str) |
|
1415 |
- (format str ")")) |
|
1416 |
- (:seq |
|
1417 |
- (set-ify (list search) str)) |
|
1418 |
- (t (let (arginfo) |
|
1419 |
- (if* (and (symbolp (car search)) |
|
1420 |
- (setq arginfo (get (car search) |
|
1421 |
- 'imap-search-args))) |
|
1422 |
- then |
|
1423 |
- (format str "~a" (string-upcase |
|
1424 |
- (string (car search)))) |
|
1425 |
- (if* (not (equal (length (cdr search)) |
|
1426 |
- (length arginfo))) |
|
1427 |
- then (po-error :syntax-error |
|
1428 |
- :format-control "wrong number of arguments to ~s" |
|
1429 |
- :format-arguments search)) |
|
1430 |
- |
|
1431 |
- (arg-process str (cdr search) arginfo) |
|
1432 |
- |
|
1433 |
- elseif (integerp (car search)) |
|
1434 |
- then (set-ify search str) |
|
1435 |
- else (po-error :syntax-error |
|
1436 |
- :format-control "Illegal form ~s in search string" |
|
1437 |
- :format-arguments (list search)))))) |
|
1399 |
+ (and (if* (null (cdr search)) |
|
1400 |
+ then (bss-int :all str) |
|
1401 |
+ elseif (null (cddr search)) |
|
1402 |
+ then (bss-int (cadr search) str) |
|
1403 |
+ else (and-ify (cdr search) str))) |
|
1404 |
+ (or (if* (null (cdr search)) |
|
1405 |
+ then (bss-int :all str) |
|
1406 |
+ elseif (null (cddr search)) |
|
1407 |
+ then (bss-int (cadr search) str) |
|
1408 |
+ else (or-ify (cdr search) str))) |
|
1409 |
+ (not (if* (not (eql (length search) 2)) |
|
1410 |
+ then (po-error :syntax-error |
|
1411 |
+ :format-control "not takes one argument: ~s" |
|
1412 |
+ :format-arguments (list search))) |
|
1413 |
+ (format str "not (" ) |
|
1414 |
+ (bss-int (cadr search) str) |
|
1415 |
+ (format str ")")) |
|
1416 |
+ (:seq |
|
1417 |
+ (set-ify (list search) str)) |
|
1418 |
+ (t (let (arginfo) |
|
1419 |
+ (if* (and (symbolp (car search)) |
|
1420 |
+ (setq arginfo (get (car search) |
|
1421 |
+ 'imap-search-args))) |
|
1422 |
+ then |
|
1423 |
+ (format str "~a" (string-upcase |
|
1424 |
+ (string (car search)))) |
|
1425 |
+ (if* (not (equal (length (cdr search)) |
|
1426 |
+ (length arginfo))) |
|
1427 |
+ then (po-error :syntax-error |
|
1428 |
+ :format-control "wrong number of arguments to ~s" |
|
1429 |
+ :format-arguments search)) |
|
1430 |
+ |
|
1431 |
+ (arg-process str (cdr search) arginfo) |
|
1432 |
+ |
|
1433 |
+ elseif (integerp (car search)) |
|
1434 |
+ then (set-ify search str) |
|
1435 |
+ else (po-error :syntax-error |
|
1436 |
+ :format-control "Illegal form ~s in search string" |
|
1437 |
+ :format-arguments (list search)))))) |
|
1438 | 1438 |
elseif (integerp search) |
1439 | 1439 |
then ; a message number |
1440 |
- (format str "~s" search) |
|
1440 |
+ (format str "~s" search) |
|
1441 | 1441 |
else (po-error :syntax-error |
1442 |
- :format-control "Illegal form ~s in search string" |
|
1443 |
- :format-arguments (list search))))) |
|
1442 |
+ :format-control "Illegal form ~s in search string" |
|
1443 |
+ :format-arguments (list search))))) |
|
1444 | 1444 |
|
1445 | 1445 |
|
1446 | 1446 |
|
... | ... |
@@ -1453,107 +1453,107 @@ |
1453 | 1453 |
;; Note that the header is string with most likely mixed case names |
1454 | 1454 |
;; as it's conventional to capitalize header names. |
1455 | 1455 |
(let ((next 0) |
1456 |
- (end (length text)) |
|
1457 |
- header |
|
1458 |
- value |
|
1459 |
- kind |
|
1460 |
- headers) |
|
1456 |
+ (end (length text)) |
|
1457 |
+ header |
|
1458 |
+ value |
|
1459 |
+ kind |
|
1460 |
+ headers) |
|
1461 | 1461 |
(labels ((next-header-line () |
1462 |
- ;; find the next header line return |
|
1463 |
- ;; :eof - no more |
|
1464 |
- ;; :start - beginning of header value, header and |
|
1465 |
- ;; value set |
|
1466 |
- ;; :continue - continuation of previous header line |
|
1467 |
- |
|
1468 |
- |
|
1469 |
- (let ((state 1) |
|
1470 |
- beginv ; charpos beginning value |
|
1471 |
- beginh ; charpos beginning header |
|
1472 |
- ch |
|
1473 |
- ) |
|
1474 |
- (tagbody again |
|
1475 |
- |
|
1476 |
- (return-from next-header-line |
|
1477 |
- |
|
1478 |
- (loop ; for each character |
|
1479 |
- |
|
1480 |
- (if* (>= next end) |
|
1481 |
- then (return :eof)) |
|
1482 |
- |
|
1483 |
- (setq ch (char text next)) |
|
1484 |
- (if* (eq ch #\return) |
|
1485 |
- thenret ; ignore return, (handle following linefeed) |
|
1486 |
- else (case state |
|
1487 |
- (1 ; no characters seen |
|
1488 |
- (if* (eq ch #\linefeed) |
|
1489 |
- then (incf next) |
|
1490 |
- (return :eof) |
|
1491 |
- elseif (member ch |
|
1492 |
- '(#\space |
|
1493 |
- #\tab)) |
|
1494 |
- then ; continuation |
|
1495 |
- (setq state 2) |
|
1496 |
- else (setq beginh next) |
|
1497 |
- (setq state 3) |
|
1498 |
- )) |
|
1499 |
- (2 ; looking for first non blank in value |
|
1500 |
- (if* (eq ch #\linefeed) |
|
1501 |
- then ; empty continuation line, ignore |
|
1502 |
- (incf next) |
|
1503 |
- (if* header |
|
1504 |
- then ; header and no value |
|
1505 |
- (setq value "") |
|
1506 |
- (return :start)) |
|
1507 |
- (setq state 1) |
|
1508 |
- (go again) |
|
1509 |
- elseif (not (member ch |
|
1510 |
- (member ch |
|
1511 |
- '(#\space |
|
1512 |
- #\tab)))) |
|
1513 |
- then ; begin value part |
|
1514 |
- (setq beginv next) |
|
1515 |
- (setq state 4))) |
|
1516 |
- (3 ; reading the header |
|
1517 |
- (if* (eq ch #\linefeed) |
|
1518 |
- then ; bogus header line, ignore |
|
1519 |
- (setq state 1) |
|
1520 |
- (go again) |
|
1521 |
- elseif (eq ch #\:) |
|
1522 |
- then (setq header |
|
1523 |
- (subseq text beginh next)) |
|
1524 |
- (setq state 2))) |
|
1525 |
- (4 ; looking for the end of the value |
|
1526 |
- (if* (eq ch #\linefeed) |
|
1527 |
- then (setq value |
|
1528 |
- (subseq text beginv |
|
1529 |
- (if* (eq #\return |
|
1530 |
- (char text |
|
1531 |
- (1- next))) |
|
1532 |
- then (1- next) |
|
1533 |
- else next))) |
|
1534 |
- (incf next) |
|
1535 |
- (return (if* header |
|
1536 |
- then :start |
|
1537 |
- else :continue)))))) |
|
1538 |
- (incf next))))))) |
|
1462 |
+ ;; find the next header line return |
|
1463 |
+ ;; :eof - no more |
|
1464 |
+ ;; :start - beginning of header value, header and |
|
1465 |
+ ;; value set |
|
1466 |
+ ;; :continue - continuation of previous header line |
|
1467 |
+ |
|
1468 |
+ |
|
1469 |
+ (let ((state 1) |
|
1470 |
+ beginv ; charpos beginning value |
|
1471 |
+ beginh ; charpos beginning header |
|
1472 |
+ ch |
|
1473 |
+ ) |
|
1474 |
+ (tagbody again |
|
1475 |
+ |
|
1476 |
+ (return-from next-header-line |
|
1477 |
+ |
|
1478 |
+ (loop ; for each character |
|
1479 |
+ |
|
1480 |
+ (if* (>= next end) |
|
1481 |
+ then (return :eof)) |
|
1482 |
+ |
|
1483 |
+ (setq ch (char text next)) |
|
1484 |
+ (if* (eq ch #\return) |
|
1485 |
+ thenret ; ignore return, (handle following linefeed) |
|
1486 |
+ else (case state |
|
1487 |
+ (1 ; no characters seen |
|
1488 |
+ (if* (eq ch #\linefeed) |
|
1489 |
+ then (incf next) |
|
1490 |
+ (return :eof) |
|
1491 |
+ elseif (member ch |
|
1492 |
+ '(#\space |
|
1493 |
+ #\tab)) |
|
1494 |
+ then ; continuation |
|
1495 |
+ (setq state 2) |
|
1496 |
+ else (setq beginh next) |
|
1497 |
+ (setq state 3) |
|
1498 |
+ )) |
|
1499 |
+ (2 ; looking for first non blank in value |
|
1500 |
+ (if* (eq ch #\linefeed) |
|
1501 |
+ then ; empty continuation line, ignore |
|
1502 |
+ (incf next) |
|
1503 |
+ (if* header |
|
1504 |
+ then ; header and no value |
|
1505 |
+ (setq value "") |
|
1506 |
+ (return :start)) |
|
1507 |
+ (setq state 1) |
|
1508 |
+ (go again) |
|
1509 |
+ elseif (not (member ch |
|
1510 |
+ (member ch |
|
1511 |
+ '(#\space |
|
1512 |
+ #\tab)))) |
|
1513 |
+ then ; begin value part |
|
1514 |
+ (setq beginv next) |
|
1515 |
+ (setq state 4))) |
|
1516 |
+ (3 ; reading the header |
|
1517 |
+ (if* (eq ch #\linefeed) |
|
1518 |
+ then ; bogus header line, ignore |
|
1519 |
+ (setq state 1) |
|
1520 |
+ (go again) |
|
1521 |
+ elseif (eq ch #\:) |
|
1522 |
+ then (setq header |
|
1523 |
+ (subseq text beginh next)) |
|
1524 |
+ (setq state 2))) |
|
1525 |
+ (4 ; looking for the end of the value |
|
1526 |
+ (if* (eq ch #\linefeed) |
|
1527 |
+ then (setq value |
|
1528 |
+ (subseq text beginv |
|
1529 |
+ (if* (eq #\return |
|
1530 |
+ (char text |
|
1531 |
+ (1- next))) |
|
1532 |
+ then (1- next) |
|
1533 |
+ else next))) |
|
1534 |
+ (incf next) |
|
1535 |
+ (return (if* header |
|
1536 |
+ then :start |
|
1537 |
+ else :continue)))))) |
|
1538 |
+ (incf next))))))) |
|
1539 | 1539 |
|
1540 | 1540 |
|
1541 | 1541 |
|
1542 | 1542 |
(loop ; for each header line |
1543 |
- (setq header nil) |
|
1544 |
- (if* (eq :eof (setq kind (next-header-line))) |
|
1545 |
- then (return)) |
|
1546 |
- (case kind |
|
1547 |
- (:start (push (cons header value) headers)) |
|
1548 |
- (:continue |
|
1549 |
- (if* headers |
|
1550 |
- then ; append to previous one |
|
1551 |
- (setf (cdr (car headers)) |
|
1552 |
- (concatenate 'string (cdr (car headers)) |
|
1553 |
- " " |
|
1554 |
- value))))))) |
|
1543 |
+ (setq header nil) |
|
1544 |
+ (if* (eq :eof (setq kind (next-header-line))) |
|
1545 |
+ then (return)) |
|
1546 |
+ (case kind |
|
1547 |
+ (:start (push (cons header value) headers)) |
|
1548 |
+ (:continue |
|
1549 |
+ (if* headers |
|
1550 |
+ then ; append to previous one |
|
1551 |
+ (setf (cdr (car headers)) |
|
1552 |
+ (concatenate 'string (cdr (car headers)) |
|
1553 |
+ " " |
|
1554 |
+ value))))))) |
|
1555 | 1555 |
(values headers |
1556 |
- (subseq text next end)))) |
|
1556 |
+ (subseq text next end)))) |
|
1557 | 1557 |
|
1558 | 1558 |
|
1559 | 1559 |
(defun make-envelope-from-text (text) |
... | ... |
@@ -1594,9 +1594,9 @@ |
1594 | 1594 |
(get-line-from-server mb) |
1595 | 1595 |
(if* *debug-imap* |
1596 | 1596 |
then (format t "from server: ") |
1597 |
- (dotimes (i count)(write-char (schar line i))) |
|
1598 |
- (terpri) |
|
1599 |
- (force-output)) |
|
1597 |
+ (dotimes (i count)(write-char (schar line i))) |
|
1598 |
+ (terpri) |
|
1599 |
+ (force-output)) |
|
1600 | 1600 |
|
1601 | 1601 |
(parse-imap-response line count) |
1602 | 1602 |
)) |
... | ... |
@@ -1616,8 +1616,8 @@ |
1616 | 1616 |
|
1617 | 1617 |
(if* *debug-imap* |
1618 | 1618 |
then (format t "from server: ") |
1619 |
- (dotimes (i count)(write-char (schar line i))) |
|
1620 |
- (terpri)) |
|
1619 |
+ (dotimes (i count)(write-char (schar line i))) |
|
1620 |
+ (terpri)) |
|
1621 | 1621 |
|
1622 | 1622 |
(parse-pop-response line count))) |
1623 | 1623 |
|
... | ... |
@@ -1628,16 +1628,16 @@ |
1628 | 1628 |
;; tag -- either a string or the symbol :untagged |
1629 | 1629 |
;; command -- a keyword symbol naming the command, like :ok |
1630 | 1630 |
;; count -- a number which preceeded the command, or nil if |
1631 |
-;; there wasn't a command |
|
1631 |
+;; there wasn't a command |
|
1632 | 1632 |
;; bracketted - a list of objects found in []'s after the command |
1633 | 1633 |
;; or in ()'s after the command or sometimes just |
1634 |
-;; out in the open after the command (like the search) |
|
1634 |
+;; out in the open after the command (like the search) |
|
1635 | 1635 |
;; comment -- the whole of the part after the command |
1636 | 1636 |
;; |
1637 | 1637 |
(defun parse-imap-response (line end) |
1638 | 1638 |
(let (kind value next |
1639 |
- tag count command extra-data |
|
1640 |
- comment) |
|
1639 |
+ tag count command extra-data |
|
1640 |
+ comment) |
|
1641 | 1641 |
|
1642 | 1642 |
;; get tag |
1643 | 1643 |
(multiple-value-setq (kind value next) |
... | ... |
@@ -1645,13 +1645,13 @@ |
1645 | 1645 |
|
1646 | 1646 |
(case kind |
1647 | 1647 |
(:string (setq tag (if* (equal value "*") |
1648 |
- then :untagged |
|
1649 |
- else value))) |
|
1648 |
+ then :untagged |
|
1649 |
+ else value))) |
|
1650 | 1650 |
(t (po-error :unexpected |
1651 |
- :format-control "Illegal tag on response: ~s" |
|
1652 |
- :format-arguments (list (subseq line 0 count)) |
|
1653 |
- :server-string (subseq line 0 end) |
|
1654 |
- ))) |
|
1651 |
+ :format-control "Illegal tag on response: ~s" |
|
1652 |
+ :format-arguments (list (subseq line 0 count)) |
|
1653 |
+ :server-string (subseq line 0 end) |
|
1654 |
+ ))) |
|
1655 | 1655 |
|
1656 | 1656 |
;; get command |
1657 | 1657 |
(multiple-value-setq (kind value next) |
... | ... |
@@ -1659,39 +1659,39 @@ |
1659 | 1659 |
|
1660 | 1660 |
(tagbody again |
1661 | 1661 |
(case kind |
1662 |
- (:number (setq count value) |
|
1663 |
- (multiple-value-setq (kind value next) |
|
1664 |
- (get-next-token line next end)) |
|
1665 |
- (go again)) |
|
1666 |
- (:string (setq command (kwd-intern value))) |
|
1667 |
- (t (po-error :unexpected |
|
1668 |
- :format-control "Illegal command on response: ~s" |
|
1669 |
- :format-arguments (list (subseq line 0 count)) |
|
1670 |
- :server-string (subseq line 0 end))))) |
|
1662 |
+ (:number (setq count value) |
|
1663 |
+ (multiple-value-setq (kind value next) |
|
1664 |
+ (get-next-token line next end)) |
|
1665 |
+ (go again)) |
|
1666 |
+ (:string (setq command (kwd-intern value))) |
|
1667 |
+ (t (po-error :unexpected |
|
1668 |
+ :format-control "Illegal command on response: ~s" |
|
1669 |
+ :format-arguments (list (subseq line 0 count)) |
|
1670 |
+ :server-string (subseq line 0 end))))) |
|
1671 | 1671 |
|
1672 | 1672 |
(setq comment (subseq line next end)) |
1673 | 1673 |
|
1674 | 1674 |
;; now the part after the command... this gets tricky |
1675 | 1675 |
(loop |
1676 | 1676 |
(multiple-value-setq (kind value next) |
1677 |
- (get-next-token line next end)) |
|
1677 |
+ (get-next-token line next end)) |
|
1678 | 1678 |
|
1679 | 1679 |
(case kind |
1680 |
- ((:lbracket :lparen) |
|
1681 |
- (multiple-value-setq (kind value next) |
|
1682 |
- (get-next-sexpr line (1- next) end)) |
|
1683 |
- (case kind |
|
1684 |
- (:sexpr (push value extra-data)) |
|
1685 |
- (t (po-error :syntax-error :format-control "bad sexpr form")))) |
|
1686 |
- (:eof (return nil)) |
|
1687 |
- ((:number :string :nil) (push value extra-data)) |
|
1688 |
- (t ; should never happen |
|
1689 |
- (return))) |
|
1680 |
+ ((:lbracket :lparen) |
|
1681 |
+ (multiple-value-setq (kind value next) |
|
1682 |
+ (get-next-sexpr line (1- next) end)) |
|
1683 |
+ (case kind |
|
1684 |
+ (:sexpr (push value extra-data)) |
|
1685 |
+ (t (po-error :syntax-error :format-control "bad sexpr form")))) |
|
1686 |
+ (:eof (return nil)) |
|
1687 |
+ ((:number :string :nil) (push value extra-data)) |
|
1688 |
+ (t ; should never happen |
|
1689 |
+ (return))) |
|
1690 | 1690 |
|
1691 | 1691 |
(if* (not (member command '(:list :search) :test #'eq)) |
1692 |
- then ; only one item returned |
|
1693 |
- (setq extra-data (car extra-data)) |
|
1694 |
- (return))) |
|
1692 |
+ then ; only one item returned |
|
1693 |
+ (setq extra-data (car extra-data)) |
|
1694 |
+ (return))) |
|
1695 | 1695 |
|
1696 | 1696 |
(if* (member command '(:list :search) :test #'eq) |
1697 | 1697 |
then (setq extra-data (nreverse extra-data))) |
... | ... |
@@ -1715,52 +1715,52 @@ |
1715 | 1715 |
((:string :number :nil) |
1716 | 1716 |
(values :sexpr value next)) |
1717 | 1717 |
(:eof (po-error :syntax-error |
1718 |
- :format-control "eof inside sexpr")) |
|
1718 |
+ :format-control "eof inside sexpr")) |
|
1719 | 1719 |
((:lbracket :lparen) |
1720 | 1720 |
(let (res) |
1721 |
- (loop |
|
1722 |
- (multiple-value-setq (kind value next) |
|
1723 |
- (get-next-sexpr line next end)) |
|
1724 |
- (case kind |
|
1725 |
- (:sexpr (push value res)) |
|
1726 |
- ((:rparen :rbracket) |
|
1727 |
- (return (values :sexpr (nreverse res) next))) |
|
1728 |
- (t (po-error :syntax-error |
|
1729 |
- :format-control "bad sexpression")))))) |
|
1721 |
+ (loop |
|
1722 |
+ (multiple-value-setq (kind value next) |
|
1723 |
+ (get-next-sexpr line next end)) |
|
1724 |
+ (case kind |
|
1725 |
+ (:sexpr (push value res)) |
|
1726 |
+ ((:rparen :rbracket) |
|
1727 |
+ (return (values :sexpr (nreverse res) next))) |
|
1728 |
+ (t (po-error :syntax-error |
|
1729 |
+ :format-control "bad sexpression")))))) |
|
1730 | 1730 |
((:rbracket :rparen) |
1731 | 1731 |
(values kind nil next)) |
1732 | 1732 |
(t (po-error :syntax-error |
1733 |
- :format-control "bad sexpression"))))) |
|
1733 |
+ :format-control "bad sexpression"))))) |
|
1734 | 1734 |
|
1735 | 1735 |
|
1736 | 1736 |
(defun parse-pop-response (line end) |
1737 | 1737 |
;; return 3 values: |
1738 | 1738 |
;; :ok or :error |
1739 | 1739 |
;; a list of rest of the tokens on the line, the tokens |
1740 |
- ;; being either strings or integers |
|
1740 |
+ ;; being either strings or integers |
|
1741 | 1741 |
;; the whole line after the +ok or -err |
1742 | 1742 |
;; |
1743 | 1743 |
(let (res lineres result) |
1744 | 1744 |
(multiple-value-bind (kind value next) |
1745 |
- (get-next-token line 0 end) |
|
1745 |
+ (get-next-token line 0 end) |
|
1746 | 1746 |
|
1747 | 1747 |
(case kind |
1748 |
- (:string (setq result (if* (equal "+OK" value) |
|
1749 |
- then :ok |
|
1750 |
- else :error))) |
|
1751 |
- (t (po-error :unexpected |
|
1752 |
- :format-control "bad response from server" |
|
1753 |
- :server-string (subseq line 0 end)))) |
|
1748 |
+ (:string (setq result (if* (equal "+OK" value) |
|
1749 |
+ then :ok |
|
1750 |
+ else :error))) |
|
1751 |
+ (t (po-error :unexpected |
|
1752 |
+ :format-control "bad response from server" |
|
1753 |
+ :server-string (subseq line 0 end)))) |
|
1754 | 1754 |
|
1755 | 1755 |
(setq lineres (subseq line next end)) |
1756 | 1756 |
|
1757 | 1757 |
(loop |
1758 |
- (multiple-value-setq (kind value next) |
|
1759 |
- (get-next-token line next end)) |
|
1758 |
+ (multiple-value-setq (kind value next) |
|
1759 |
+ (get-next-token line next end)) |
|
1760 | 1760 |
|
1761 |
- (case kind |
|
1762 |
- (:eof (return)) |
|
1763 |
- ((:string :number) (push value res)))) |
|
1761 |
+ (case kind |
|
1762 |
+ (:eof (return)) |
|
1763 |
+ ((:string :number) (push value res)))) |
|
1764 | 1764 |
|
1765 | 1765 |
(values result (nreverse res) lineres)))) |
1766 | 1766 |
|
... | ... |
@@ -1777,8 +1777,8 @@ |
1777 | 1777 |
(let ((arr (make-array 256 :initial-element nil))) |
1778 | 1778 |
|
1779 | 1779 |
(do ((i #.(char-code #\0) (1+ i))) |
1780 |
- ((> i #.(char-code #\9))) |
|
1781 |
- (setf (aref arr i) :number)) |
|
1780 |
+ ((> i #.(char-code #\9))) |
|
1781 |
+ (setf (aref arr i) :number)) |
|
1782 | 1782 |
|
1783 | 1783 |
(setf (aref arr #.(char-code #\space)) :space) |
1784 | 1784 |
(setf (aref arr #.(char-code #\tab)) :space) |
... | ... |
@@ -1800,104 +1800,104 @@ |
1800 | 1800 |
;; scan past whitespace for the next token |
1801 | 1801 |
;; return three values: |
1802 | 1802 |
;; kind: :string , :number, :eof, :lbracket, :rbracket, |
1803 |
- ;; :lparen, :rparen |
|
1803 |
+ ;; :lparen, :rparen |
|
1804 | 1804 |
;; value: the value, either a string or number or nil |
1805 | 1805 |
;; next: the character pos to start scanning for the next token |
1806 | 1806 |
;; |
1807 | 1807 |
(let (ch chkind colstart (count 0) (state :looking) |
1808 |
- collector right-bracket-is-normal) |
|
1808 |
+ collector right-bracket-is-normal) |
|
1809 | 1809 |
(loop |
1810 | 1810 |
; pick up the next character |
1811 | 1811 |
(if* (>= start end) |
1812 |
- then (if* (eq state :looking) |
|
1813 |
- then (return (values :eof nil start)) |
|
1814 |
- else (setq ch #\space)) |
|
1815 |
- else (setq ch (schar line start))) |
|
1812 |
+ then (if* (eq state :looking) |
|
1813 |
+ then (return (values :eof nil start)) |
|
1814 |
+ else (setq ch #\space)) |
|
1815 |
+ else (setq ch (schar line start))) |
|
1816 | 1816 |
|
1817 | 1817 |
(setq chkind (aref *char-to-kind* (char-code ch))) |
1818 | 1818 |
|
1819 | 1819 |
(case state |
1820 |
- (:looking |
|
1821 |
- (case chkind |
|
1822 |
- (:space nil) |
|
1823 |
- (:number (setq state :number) |
|
1824 |
- (setq colstart start) |
|
1825 |
- (setq count (- (char-code ch) #.(char-code #\0)))) |
|
1826 |
- ((:lbracket :lparen :rbracket :rparen) |
|
1827 |
- (return (values chkind nil (1+ start)))) |
|
1828 |
- (:dquote |
|
1829 |
- (setq collector (make-array 10 |
|
1830 |
- :element-type 'character |
|
1831 |
- :adjustable t |
|
1832 |
- :fill-pointer 0)) |
|
1833 |
- (setq state :qstring)) |
|
1834 |
- (:big-string |
|
1835 |
- (setq colstart (1+ start)) |
|
1836 |
- (setq state :big-string)) |
|
1837 |
- (t (setq colstart start) |
|
1838 |
- (setq state :literal)))) |
|
1839 |
- (:number |
|
1840 |
- (case chkind |
|
1841 |
- ((:space :lbracket :lparen :rbracket :rparen |
|
1842 |
- :dquote) ; end of number |
|
1843 |
- (return (values :number count start))) |
|
1844 |
- (:number ; more number |
|
1845 |
- (setq count (+ (* count 10) |
|
1846 |
- (- (char-code ch) #.(char-code #\0))))) |
|
1847 |
- (t ; turn into an literal |
|
1848 |
- (setq state :literal)))) |
|
1849 |
- (:literal |
|
1850 |
- (case chkind |
|
1851 |
- ((:space :rbracket :lparen :rparen :dquote) ; end of literal |
|
1852 |
- (if* (and (eq chkind :rbracket) |
|
1853 |
- right-bracket-is-normal) |
|
1854 |
- then nil ; don't stop now |
|
1855 |
- else (let ((seq (subseq line colstart start))) |
|
1856 |
- (if* (equal "NIL" seq) |
|
1857 |
- then (return (values :nil |
|
1858 |
- nil |
|
1859 |
- start)) |
|
1860 |
- else (return (values :string |
|
1861 |
- seq |
|
1862 |
- start)))))) |
|
1863 |
- (t (if* (eq chkind :lbracket) |
|
1864 |
- then ; imbedded left bracket so right bracket isn't |
|
1865 |
- ; a break char |
|
1866 |
- (setq right-bracket-is-normal t)) |
|
1867 |
- nil))) |
|
1868 |
- (:qstring |
|
1869 |
- ;; quoted string |
|
1870 |
- ; (format t "start is ~s kind is ~s~%" start chkind) |
|
1871 |
- (case chkind |
|
1872 |
- (:dquote |
|
1873 |
- ;; end of string |
|
1874 |
- (return (values :string collector (1+ start)))) |
|
1875 |
- (t (if* (eq ch #\\) |
|
1876 |
- then ; escaping the next character |
|
1877 |
- (incf start) |
|
1878 |
- (if* (>= start end) |
|
1879 |
- then (po-error :unexpected |
|
1880 |
- :format-control "eof in string returned")) |
|
1881 |
- (setq ch (schar line start))) |
|
1882 |
- (vector-push-extend ch collector) |
|
1883 |
- |
|
1884 |
- (if* (>= start end) |
|
1885 |
- then ; we overran the end of the input |
|
1886 |
- (po-error :unexpected |
|
1887 |
- :format-control "eof in string returned"))))) |
|
1888 |
- (:big-string |
|
1889 |
- ;; super string... just a block of data |
|
1890 |
- ; (format t "start is ~s kind is ~s~%" start chkind) |
|
1891 |
- (case chkind |
|
1892 |
- (:big-string |
|
1893 |
- ;; end of string |
|
1894 |
- (return (values :string |
|
1895 |
- (subseq line colstart start) |
|
1896 |
- (1+ start)))) |
|
1897 |
- (t nil))) |
|
1898 |
- |
|
1899 |
- |
|
1900 |
- ) |
|
1820 |
+ (:looking |
|
1821 |
+ (case chkind |
|
1822 |
+ (:space nil) |
|
1823 |
+ (:number (setq state :number) |
|
1824 |
+ (setq colstart start) |
|
1825 |
+ (setq count (- (char-code ch) #.(char-code #\0)))) |
|
1826 |
+ ((:lbracket :lparen :rbracket :rparen) |
|
1827 |
+ (return (values chkind nil (1+ start)))) |
|
1828 |
+ (:dquote |
|
1829 |
+ (setq collector (make-array 10 |
|
1830 |
+ :element-type 'character |
|
1831 |
+ :adjustable t |
|
1832 |
+ :fill-pointer 0)) |
|
1833 |
+ (setq state :qstring)) |
|
1834 |
+ (:big-string |
|
1835 |
+ (setq colstart (1+ start)) |
|
1836 |
+ (setq state :big-string)) |
|
1837 |
+ (t (setq colstart start) |
|
1838 |
+ (setq state :literal)))) |
|
1839 |
+ (:number |
|
1840 |
+ (case chkind |
|
1841 |
+ ((:space :lbracket :lparen :rbracket :rparen |
|
1842 |
+ :dquote) ; end of number |
|
1843 |
+ (return (values :number count start))) |
|
1844 |
+ (:number ; more number |
|
1845 |
+ (setq count (+ (* count 10) |
|
1846 |
+ (- (char-code ch) #.(char-code #\0))))) |
|
1847 |
+ (t ; turn into an literal |
|
1848 |
+ (setq state :literal)))) |
|
1849 |
+ (:literal |
|
1850 |
+ (case chkind |
|
1851 |
+ ((:space :rbracket :lparen :rparen :dquote) ; end of literal |
|
1852 |
+ (if* (and (eq chkind :rbracket) |
|
1853 |
+ right-bracket-is-normal) |
|
1854 |
+ then nil ; don't stop now |
|
1855 |
+ else (let ((seq (subseq line colstart start))) |
|
1856 |
+ (if* (equal "NIL" seq) |
|
1857 |
+ then (return (values :nil |
|
1858 |
+ nil |
|
1859 |
+ start)) |
|
1860 |
+ else (return (values :string |
|
1861 |
+ seq |
|
1862 |
+ start)))))) |
|
1863 |
+ (t (if* (eq chkind :lbracket) |
|
1864 |
+ then ; imbedded left bracket so right bracket isn't |
|
1865 |
+ ; a break char |
|
1866 |
+ (setq right-bracket-is-normal t)) |
|
1867 |
+ nil))) |
|
1868 |
+ (:qstring |
|
1869 |
+ ;; quoted string |
|
1870 |
+ ; (format t "start is ~s kind is ~s~%" start chkind) |
|
1871 |
+ (case chkind |
|
1872 |
+ (:dquote |
|
1873 |
+ ;; end of string |
|
1874 |
+ (return (values :string collector (1+ start)))) |
|
1875 |
+ (t (if* (eq ch #\\) |
|
1876 |
+ then ; escaping the next character |
|
1877 |
+ (incf start) |
|
1878 |
+ (if* (>= start end) |
|
1879 |
+ then (po-error :unexpected |
|
1880 |
+ :format-control "eof in string returned")) |
|
1881 |
+ (setq ch (schar line start))) |
|
1882 |
+ (vector-push-extend ch collector) |
|
1883 |
+ |
|
1884 |
+ (if* (>= start end) |
|
1885 |
+ then ; we overran the end of the input |
|
1886 |
+ (po-error :unexpected |
|
1887 |
+ :format-control "eof in string returned"))))) |
|
1888 |
+ (:big-string |
|
1889 |
+ ;; super string... just a block of data |
|
1890 |
+ ; (format t "start is ~s kind is ~s~%" start chkind) |
|
1891 |
+ (case chkind |
|
1892 |
+ (:big-string |
|
1893 |
+ ;; end of string |
|
1894 |
+ (return (values :string |
|
1895 |
+ (subseq line colstart start) |
|
1896 |
+ (1+ start)))) |
|
1897 |
+ (t nil))) |
|
1898 |
+ |
|
1899 |
+ |
|
1900 |
+ ) |
|
1901 | 1901 |
|
1902 | 1902 |
(incf start)))) |
1903 | 1903 |
|
... | ... |
@@ -1919,10 +1919,10 @@ |
1919 | 1919 |
;; convert the string to the current preferred case |
1920 | 1920 |
;; and then intern |
1921 | 1921 |
(intern (case excl::*current-case-mode* |
1922 |
- ((:case-sensitive-lower |
|
1923 |
- :case-insensitive-lower) (string-downcase string)) |
|
1924 |
- (t (string-upcase string))) |
|
1925 |
- *keyword-package*)) |
|
1922 |
+ ((:case-sensitive-lower |
|
1923 |
+ :case-insensitive-lower) (string-downcase string)) |
|
1924 |
+ (t (string-upcase string))) |
|
1925 |
+ *keyword-package*)) |
|
1926 | 1926 |
|
1927 | 1927 |
|
1928 | 1928 |
|
... | ... |
@@ -1945,116 +1945,116 @@ |
1945 | 1945 |
;; was read from the socket. |
1946 | 1946 |
;; |
1947 | 1947 |
(let* ((buff (get-line-buffer 0)) |
1948 |
- (len (length buff)) |
|
1949 |
- (i 0) |
|
1950 |
- (p (post-office-socket mailbox)) |
|
1951 |
- (ch nil) |
|
1952 |
- (whole-count) |
|
1953 |
- ) |
|
1948 |
+ (len (length buff)) |
|
1949 |
+ (i 0) |
|
1950 |
+ (p (post-office-socket mailbox)) |
|
1951 |
+ (ch nil) |
|
1952 |
+ (whole-count) |
|
1953 |
+ ) |
|
1954 | 1954 |
|
1955 | 1955 |
(handler-case |
1956 |
- (flet ((grow-buffer (size) |
|
1957 |
- (let ((newbuff (get-line-buffer size))) |
|
1958 |
- (dotimes (j i) |
|
1959 |
- (setf (schar newbuff j) (schar buff j))) |
|
1960 |
- (free-line-buffer buff) |
|
1961 |
- (setq buff newbuff) |
|
1962 |
- (setq len (length buff))))) |
|
1963 |
- |
|
1964 |
- ;; increase the buffer to at least size |
|
1965 |
- ;; this is somewhat complex to ensure that we aren't doing |
|
1966 |
- ;; buffer allocation within the with-timeout form, since |
|
1967 |
- ;; that could trigger a gc which could then cause the |
|
1968 |
- ;; with-timeout form to expire. |
|
1969 |
- (loop |
|
1970 |
- |
|
1971 |
- (if* whole-count |
|
1972 |
- then ; we should now read in this may bytes and |
|
1973 |
- ; append it to this buffer |
|
1974 |
- (multiple-value-bind (ans this-count) |
|
1975 |
- (get-block-of-data-from-server mailbox whole-count) |
|
1976 |
- ; now put this data in the current buffer |
|
1977 |
- (if* (> (+ i whole-count 5) len) |
|
1978 |
- then ; grow the initial buffer |
|
1979 |
- (grow-buffer (+ i whole-count 100))) |
|
1980 |
- |
|
1981 |
- (dotimes (ind this-count) |
|
1982 |
- (setf (schar buff i) (schar ans ind)) |
|
1983 |
- (incf i)) |
|
1984 |
- (setf (schar buff i) #\^b) ; end of inset string |
|
1985 |
- (incf i) |
|
1986 |
- (free-line-buffer ans) |
|
1987 |
- (setq whole-count nil) |
|
1988 |
- ) |
|
1989 |
- elseif ch |
|
1990 |
- then ; we're growing the buffer holding the line data |
|
1991 |
- (grow-buffer (+ len 200)) |
|
1992 |
- (setf (schar buff i) ch) |
|
1993 |
- (incf i)) |
|
1994 |
- |
|
1995 |
- |
|
1996 |
- (block timeout |
|
1997 |
- (mp:with-timeout ((timeout mailbox) |
|
1998 |
- (po-error :timeout |
|
1999 |
- :format-control "imap server failed to respond")) |
|
2000 |
- ;; read up to lf (lf most likely preceeded by cr) |
|
2001 |
- (loop |
|
2002 |
- (setq ch (read-char p)) |
|
2003 |
- (if* (eq #\linefeed ch) |
|
2004 |
- then ; end of line. Don't save the return |
|
2005 |
- (if* (and (> i 0) |
|
2006 |
- (eq (schar buff (1- i)) #\return)) |
|
2007 |
- then ; remove #\return, replace with newline |
|
2008 |
- (decf i) |
|
2009 |
- (setf (schar buff i) #\newline) |
|
2010 |
- ) |
|
2011 |
- ;; must check for an extended return value which |
|
2012 |
- ;; is indicated by a {nnn} at the end of the line |
|
2013 |
- (block count-check |
|
2014 |
- (let ((ind (1- i))) |
|
2015 |
- (if* (and (>= i 0) (eq (schar buff ind) #\})) |
|
2016 |
- then (let ((count 0) |
|
2017 |
- (mult 1)) |
|
2018 |
- (loop |
|
2019 |
- (decf ind) |
|
2020 |
- (if* (< ind 0) |
|
2021 |
- then ; no of the form {nnn} |
|
2022 |
- (return-from count-check)) |
|
2023 |
- (setf ch (schar buff ind)) |
|
2024 |
- (if* (eq ch #\{) |
|
2025 |
- then ; must now read that many bytes |
|
2026 |
- (setf (schar buff ind) #\^b) |
|
2027 |
- (setq whole-count count) |
|
2028 |
- (setq i (1+ ind)) |
|
2029 |
- (return-from timeout) |
|
2030 |
- elseif (<= #.(char-code #\0) |
|
2031 |
- (char-code ch) |
|
2032 |
- #.(char-code #\9)) |
|
2033 |
- then ; is a digit |
|
2034 |
- (setq count |
|
2035 |
- (+ count |
|
2036 |
- (* mult |
|
2037 |
- (- (char-code ch) |
|
2038 |
- #.(char-code #\0))))) |
|
2039 |
- (setq mult (* 10 mult)) |
|
2040 |
- else ; invalid form, get out |
|
2041 |
- (return-from count-check))))))) |
|
2042 |
- |
|
2043 |
- |
|
2044 |
- (return-from get-line-from-server |
|
2045 |
- (values buff i)) |
|
2046 |
- else ; save character |
|
2047 |
- (if* (>= i len) |
|
2048 |
- then ; need bigger buffer |
|
2049 |
- (return)) |
|
2050 |
- (setf (schar buff i) ch) |
|
2051 |
- (incf i))))))) |
|
1956 |
+ (flet ((grow-buffer (size) |
|
1957 |
+ (let ((newbuff (get-line-buffer size))) |
|
1958 |
+ (dotimes (j i) |
|
1959 |
+ (setf (schar newbuff j) (schar buff j))) |
|
1960 |
+ (free-line-buffer buff) |
|
1961 |
+ (setq buff newbuff) |
|
1962 |
+ (setq len (length buff))))) |
|
1963 |
+ |
|
1964 |
+ ;; increase the buffer to at least size |
|
1965 |
+ ;; this is somewhat complex to ensure that we aren't doing |
|
1966 |
+ ;; buffer allocation within the with-timeout form, since |
|
1967 |
+ ;; that could trigger a gc which could then cause the |
|
1968 |
+ ;; with-timeout form to expire. |
|
1969 |
+ (loop |
|
1970 |
+ |
|
1971 |
+ (if* whole-count |
|
1972 |
+ then ; we should now read in this may bytes and |
|
1973 |
+ ; append it to this buffer |
|
1974 |
+ (multiple-value-bind (ans this-count) |
|
1975 |
+ (get-block-of-data-from-server mailbox whole-count) |
|
1976 |
+ ; now put this data in the current buffer |
|
1977 |
+ (if* (> (+ i whole-count 5) len) |
|
1978 |
+ then ; grow the initial buffer |
|
1979 |
+ (grow-buffer (+ i whole-count 100))) |
|
1980 |
+ |
|
1981 |
+ (dotimes (ind this-count) |
|
1982 |
+ (setf (schar buff i) (schar ans ind)) |
|
1983 |
+ (incf i)) |
|
1984 |
+ (setf (schar buff i) #\^b) ; end of inset string |
|
1985 |
+ (incf i) |
|
1986 |
+ (free-line-buffer ans) |
|
1987 |
+ (setq whole-count nil) |
|
1988 |
+ ) |
|
1989 |
+ elseif ch |
|
1990 |
+ then ; we're growing the buffer holding the line data |
|
1991 |
+ (grow-buffer (+ len 200)) |
|
1992 |
+ (setf (schar buff i) ch) |
|
1993 |
+ (incf i)) |
|
1994 |
+ |
|
1995 |
+ |
|
1996 |
+ (block timeout |
|
1997 |
+ (mp:with-timeout ((timeout mailbox) |
|
1998 |
+ (po-error :timeout |
|
1999 |
+ :format-control "imap server failed to respond")) |
|
2000 |
+ ;; read up to lf (lf most likely preceeded by cr) |
|
2001 |
+ (loop |
|
2002 |
+ (setq ch (read-char p)) |
|
2003 |
+ (if* (eq #\linefeed ch) |
|
2004 |
+ then ; end of line. Don't save the return |
|
2005 |
+ (if* (and (> i 0) |
|
2006 |
+ (eq (schar buff (1- i)) #\return)) |
|
2007 |
+ then ; remove #\return, replace with newline |
|
2008 |
+ (decf i) |
|
2009 |
+ (setf (schar buff i) #\newline) |
|
2010 |
+ ) |
|
2011 |
+ ;; must check for an extended return value which |
|
2012 |
+ ;; is indicated by a {nnn} at the end of the line |
|
2013 |
+ (block count-check |
|
2014 |
+ (let ((ind (1- i))) |
|
2015 |
+ (if* (and (>= i 0) (eq (schar buff ind) #\})) |
|
2016 |
+ then (let ((count 0) |
|
2017 |
+ (mult 1)) |
|
2018 |
+ (loop |
|
2019 |
+ (decf ind) |
|
2020 |
+ (if* (< ind 0) |
|
2021 |
+ then ; no of the form {nnn} |
|
2022 |
+ (return-from count-check)) |
|
2023 |
+ (setf ch (schar buff ind)) |
|
2024 |
+ (if* (eq ch #\{) |
|
2025 |
+ then ; must now read that many bytes |
|
2026 |
+ (setf (schar buff ind) #\^b) |
|
2027 |
+ (setq whole-count count) |
|
2028 |
+ (setq i (1+ ind)) |
|
2029 |
+ (return-from timeout) |
|
2030 |
+ elseif (<= #.(char-code #\0) |
|
2031 |
+ (char-code ch) |
|
2032 |
+ #.(char-code #\9)) |
|
2033 |
+ then ; is a digit |
|
2034 |
+ (setq count |
|
2035 |
+ (+ count |
|
2036 |
+ (* mult |
|
2037 |
+ (- (char-code ch) |
|
2038 |
+ #.(char-code #\0))))) |
|
2039 |
+ (setq mult (* 10 mult)) |
|
2040 |
+ else ; invalid form, get out |
|
2041 |
+ (return-from count-check))))))) |
|
2042 |
+ |
|
2043 |
+ |
|
2044 |
+ (return-from get-line-from-server |
|
2045 |
+ (values buff i)) |
|
2046 |
+ else ; save character |
|
2047 |
+ (if* (>= i len) |
|
2048 |
+ then ; need bigger buffer |
|
2049 |
+ (return)) |
|
2050 |
+ (setf (schar buff i) ch) |
|
2051 |
+ (incf i))))))) |
|
2052 | 2052 |
(error (con) |
2053 |
- ;; most likely error is that the server went away |
|
2054 |
- (ignore-errors (close p)) |
|
2055 |
- (po-error :server-shutdown-connection |
|
2056 |
- :format-control "condition signalled: ~a~%most likely server shut down the connection." |
|
2057 |
- :format-arguments (list con))) |
|
2053 |
+ ;; most likely error is that the server went away |
|
2054 |
+ (ignore-errors (close p)) |
|
2055 |
+ (po-error :server-shutdown-connection |
|
2056 |
+ :format-control "condition signalled: ~a~%most likely server shut down the connection." |
|
2057 |
+ :format-arguments (list con))) |
|
2058 | 2058 |
))) |
2059 | 2059 |
|
2060 | 2060 |
|
... | ... |
@@ -2065,16 +2065,16 @@ |
2065 | 2065 |
;; like lisp likes). |
2066 | 2066 |
;; |
2067 | 2067 |
(let ((buff (get-line-buffer count)) |
2068 |
- (p (post-office-socket mb)) |
|
2069 |
- (ind 0)) |
|
2068 |
+ (p (post-office-socket mb)) |
|
2069 |
+ (ind 0)) |
|
2070 | 2070 |
(mp:with-timeout ((timeout mb) |
2071 |
- (po-error :timeout |
|
2072 |
- :format-control "imap server timed out")) |
|
2071 |
+ (po-error :timeout |
|
2072 |
+ :format-control "imap server timed out")) |
|
2073 | 2073 |
|
2074 | 2074 |
(dotimes (i count) |
2075 |
- (if* (eq #\return (setf (schar buff ind) (read-char p))) |
|
2076 |
- then (if* save-returns then (incf ind)) ; drop #\returns |
|
2077 |
- else (incf ind))) |
|
2075 |
+ (if* (eq #\return (setf (schar buff ind) (read-char p))) |
|
2076 |
+ then (if* save-returns then (incf ind)) ; drop #\returns |
|
2077 |
+ else (incf ind))) |
|
2078 | 2078 |
|
2079 | 2079 |
|
2080 | 2080 |
(values buff ind)))) |
... | ... |
@@ -2090,7 +2090,7 @@ |
2090 | 2090 |
(defmacro with-locked-line-buffers (&rest body) |
2091 | 2091 |
;; #+(version>= 8 1) |
2092 | 2092 |
;; `(with-locked-structure (*line-buffers-lock* |
2093 |
-;; :non-smp :without-scheduling) |
|
2093 |
+;; :non-smp :without-scheduling) |
|
2094 | 2094 |
;; ,@body) |
2095 | 2095 |
;; #-(version>= 8 1) |
2096 | 2096 |
`(mp:without-scheduling ,@body) |
... | ... |
@@ -2100,12 +2100,12 @@ |
2100 | 2100 |
;; get a buffer of at least size bytes |
2101 | 2101 |
(setq size (min size (1- array-total-size-limit))) |
2102 | 2102 |
(let ((found |
2103 |
- (with-locked-line-buffers |
|
2104 |
- (dolist (buff *line-buffers*) |
|
2105 |
- (if* (>= (length buff) size) |
|
2106 |
- then ;; use this one |
|
2107 |
- (setq *line-buffers* (delete buff *line-buffers*)) |
|
2108 |
- (return buff)))))) |
|
2103 |
+ (with-locked-line-buffers |
|
2104 |
+ (dolist (buff *line-buffers*) |
|
2105 |
+ (if* (>= (length buff) size) |
|
2106 |
+ then ;; use this one |
|
2107 |
+ (setq *line-buffers* (delete buff *line-buffers*)) |
|
2108 |
+ (return buff)))))) |
|
2109 | 2109 |
(or found (make-string size)))) |
2110 | 2110 |
|
2111 | 2111 |
(defun free-line-buffer (buff) |
... | ... |
@@ -2133,13 +2133,13 @@ |
2133 | 2133 |
(decode-universal-time ut 0) |
2134 | 2134 |
(declare (ignore time-zone sec min hour day-of-week dsp time-zone)) |
2135 | 2135 |
(format nil "~d-~a-~d" |
2136 |
- date |
|
2137 |
- (svref |
|
2138 |
- '#(nil "Jan" "Feb" "Mar" "Apr" "May" "Jun" |
|
2139 |
- "Jul" "Aug" "Sep" "Oct" "Nov" "Dec") |
|
2140 |
- month |
|
2141 |
- ) |
|
2142 |
- year))) |
|
2136 |
+ date |
|
2137 |
+ (svref |
|
2138 |
+ '#(nil "Jan" "Feb" "Mar" "Apr" "May" "Jun" |
|
2139 |
+ "Jul" "Aug" "Sep" "Oct" "Nov" "Dec") |
|
2140 |
+ month |
|
2141 |
+ ) |
|
2142 |
+ year))) |
|
2143 | 2143 |
|
2144 | 2144 |
|
2145 | 2145 |
|
... | ... |
@@ -2149,14 +2149,14 @@ |
2149 | 2149 |
(defmacro with-imap-connection ((mb &rest options) &body body) |
2150 | 2150 |
`(let ((,mb (make-imap-connection ,@options))) |
2151 | 2151 |
(unwind-protect |
2152 |
- (progn |
|
2153 |
- ,@body) |
|
2152 |
+ (progn |
|
2153 |
+ ,@body) |
|
2154 | 2154 |
(close-connection ,mb)))) |
2155 | 2155 |
|
2156 | 2156 |
|
2157 | 2157 |
(defmacro with-pop-connection ((mb &rest options) &body body) |
2158 | 2158 |
`(let ((,mb (make-pop-connection ,@options))) |
2159 | 2159 |
(unwind-protect |
2160 |
- (progn |
|
2161 |
- ,@body) |
|
2160 |
+ (progn |
|
2161 |
+ ,@body) |
|
2162 | 2162 |
(close-connection ,mb)))) |