- Timestamp:
- 04/22/07 08:12:22 (18 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/protocol.lisp ¶
r188 r189 335 335 (loop while (read-message connection))) 336 336 337 (defun try-decode-line (line external-formats)338 (loop for external-format in external-formats339 for decoded = nil340 for error = nil341 do (multiple-value-setq (decoded error)342 (handler-case343 (flexi-streams:with-input-from-sequence (in line)344 (let* ((ex-fmt (external-format-fixup external-format))345 (flexi (flexi-streams:make-flexi-stream346 in347 ;; :element-type 'character348 :external-format ex-fmt)))349 (read-line flexi nil nil)))350 (flexi-streams:flexi-stream-encoding-error ()351 nil)))352 if decoded353 do (return decoded)))354 355 (defun read-protocol-line (connection)356 "Reads a line from the input network stream, returning a357 character array with the input read."358 (multiple-value-bind359 (buf buf-len)360 ;; Note: we cannot use read-line here (or any other361 ;; character based functions), since they may cause362 ;; (at this time unwanted) character conversion363 (read-sequence-until (network-stream connection)364 (make-array 1024365 :element-type '(unsigned-byte 8)366 :fill-pointer t)367 '(10))368 (when (< 0 buf-len)369 (setf (fill-pointer buf)370 ;; remove all trailing CR and LF characters371 ;; (This allows non-conforming clients to send CRCRLF372 ;; as a line separator too).373 (or (position-if #'(lambda (x) (member x '(10 13)))374 buf :from-end t :end buf-len)375 buf-len))376 (try-decode-line buf *default-incoming-external-formats*))))377 337 378 338 (defmethod read-irc-message ((connection connection)) -
TabularUnified trunk/utility.lisp ¶
r188 r189 106 106 (setf (getf (cdr new-format) :eol-style) :crlf) 107 107 new-format)) 108 109 (defun try-decode-line (line external-formats) 110 (loop for external-format in external-formats 111 for decoded = nil 112 for error = nil 113 do (multiple-value-setq (decoded error) 114 (handler-case 115 (flexi-streams:with-input-from-sequence (in line) 116 (let* ((ex-fmt (external-format-fixup external-format)) 117 (flexi (flexi-streams:make-flexi-stream 118 in 119 ;; :element-type 'character 120 :external-format ex-fmt))) 121 (read-line flexi nil nil))) 122 (flexi-streams:flexi-stream-encoding-error () 123 nil))) 124 if decoded 125 do (return decoded))) 108 126 109 127 (defun read-byte-no-hang (stream &optional eof-error-p eof-value) … … 140 158 (= limit-cur limit-max)) 141 159 do (return (values target (1+ targ-cur) nil))))) 160 161 (defun read-protocol-line (connection) 162 "Reads a line from the input network stream, returning a 163 character array with the input read." 164 (multiple-value-bind 165 (buf buf-len) 166 ;; Note: we cannot use read-line here (or any other 167 ;; character based functions), since they may cause 168 ;; (at this time unwanted) character conversion 169 (read-sequence-until (network-stream connection) 170 (make-array 1024 171 :element-type '(unsigned-byte 8) 172 :fill-pointer t) 173 '(10)) 174 (when (< 0 buf-len) 175 (setf (fill-pointer buf) 176 ;; remove all trailing CR and LF characters 177 ;; (This allows non-conforming clients to send CRCRLF 178 ;; as a line separator too). 179 (or (position-if #'(lambda (x) (member x '(10 13))) 180 buf :from-end t :end buf-len) 181 buf-len)) 182 (try-decode-line buf *default-incoming-external-formats*)))) 183 142 184 143 185 (defun substring (string start &optional end)
Note: See TracChangeset
for help on using the changeset viewer.