Skip to content

Commit 58dd9d1

Browse files
committed
replace tabs with spaces
1 parent 74314d8 commit 58dd9d1

File tree

7 files changed

+420
-420
lines changed

7 files changed

+420
-420
lines changed

bio.lisp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@
4545
(defun make-bio-lisp-method ()
4646
(let ((m (cffi:foreign-alloc '(:struct bio-method))))
4747
(setf (cffi:foreign-slot-value m '(:struct bio-method) 'type)
48-
;; fixme: this is wrong, but presumably still better than some
49-
;; random value here.
50-
+bio-type-socket+)
48+
;; fixme: this is wrong, but presumably still better than some
49+
;; random value here.
50+
+bio-type-socket+)
5151
(macrolet ((slot (name)
52-
`(cffi:foreign-slot-value m '(:struct bio-method) ,name)))
52+
`(cffi:foreign-slot-value m '(:struct bio-method) ,name)))
5353
(setf (slot 'name) (cffi:foreign-string-alloc "lisp"))
5454
(setf (slot 'bwrite) (cffi:callback lisp-write))
5555
(setf (slot 'bread) (cffi:callback lisp-read))
@@ -76,34 +76,34 @@
7676

7777
(defun clear-retry-flags (bio)
7878
(setf (cffi:foreign-slot-value bio '(:struct bio) 'flags)
79-
(logandc2 (cffi:foreign-slot-value bio '(:struct bio) 'flags)
80-
(logior +BIO_FLAGS_READ+
81-
+BIO_FLAGS_WRITE+
82-
+BIO_FLAGS_SHOULD_RETRY+))))
79+
(logandc2 (cffi:foreign-slot-value bio '(:struct bio) 'flags)
80+
(logior +BIO_FLAGS_READ+
81+
+BIO_FLAGS_WRITE+
82+
+BIO_FLAGS_SHOULD_RETRY+))))
8383

8484
(defun set-retry-read (bio)
8585
(setf (cffi:foreign-slot-value bio '(:struct bio) 'flags)
86-
(logior (cffi:foreign-slot-value bio '(:struct bio) 'flags)
87-
+BIO_FLAGS_READ+
88-
+BIO_FLAGS_SHOULD_RETRY+)))
86+
(logior (cffi:foreign-slot-value bio '(:struct bio) 'flags)
87+
+BIO_FLAGS_READ+
88+
+BIO_FLAGS_SHOULD_RETRY+)))
8989

9090
(cffi:defcallback lisp-read :int ((bio :pointer) (buf :pointer) (n :int))
9191
bio buf n
9292
(let ((i 0))
9393
(handler-case
94-
(unless (or (cffi:null-pointer-p buf) (null n))
95-
(clear-retry-flags bio)
96-
(when (or *blockp* (listen *socket*))
94+
(unless (or (cffi:null-pointer-p buf) (null n))
95+
(clear-retry-flags bio)
96+
(when (or *blockp* (listen *socket*))
9797
(setf (cffi:mem-ref buf :unsigned-char i) (read-byte *socket*))
9898
(incf i))
99-
(loop
100-
while (and (< i n)
99+
(loop
100+
while (and (< i n)
101101
(or (null *partial-read-p*) (listen *socket*)))
102-
do
103-
(setf (cffi:mem-ref buf :unsigned-char i) (read-byte *socket*))
104-
(incf i))
105-
#+(or)
106-
(when (zerop i) (set-retry-read bio)))
102+
do
103+
(setf (cffi:mem-ref buf :unsigned-char i) (read-byte *socket*))
104+
(incf i))
105+
#+(or)
106+
(when (zerop i) (set-retry-read bio)))
107107
(end-of-file ()))
108108
i))
109109

@@ -135,4 +135,4 @@
135135
(setf (cffi:foreign-slot-value bio '(:struct bio) 'flags) 0)
136136
1)))
137137

138-
(setf *bio-lisp-method* nil) ;force reinit if anything changed here
138+
(setf *bio-lisp-method* nil) ;force reinit if anything changed here

conditions.lisp

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ by READ-SSL-ERROR-QUEUE) or an SSL-ERROR condition."
6868
(format stream "Unspecified error ~A on handle ~A"
6969
(ssl-error-ret condition)
7070
(ssl-error-handle condition))
71-
(format-ssl-error-queue stream condition))))
71+
(format-ssl-error-queue stream condition))))
7272

7373
(define-condition ssl-error-initialize (ssl-error)
7474
((reason :initarg :reason
7575
:reader ssl-error-reason))
7676
(:report (lambda (condition stream)
7777
(format stream "SSL initialization error: ~A"
7878
(ssl-error-reason condition))
79-
(format-ssl-error-queue stream condition))))
79+
(format-ssl-error-queue stream condition))))
8080

8181

8282
(define-condition ssl-error-want-something (ssl-error/handle)
@@ -92,7 +92,7 @@ by READ-SSL-ERROR-QUEUE) or an SSL-ERROR condition."
9292
(format stream "The TLS/SSL operation on handle ~A completed (return code: ~A). "
9393
(ssl-error-handle condition)
9494
(ssl-error-ret condition))
95-
(format-ssl-error-queue stream condition))))
95+
(format-ssl-error-queue stream condition))))
9696

9797
;; SSL_ERROR_ZERO_RETURN
9898
(define-condition ssl-error-zero-return (ssl-error/handle)
@@ -108,7 +108,7 @@ by READ-SSL-ERROR-QUEUE) or an SSL-ERROR condition."
108108
(format stream "The TLS/SSL connection on handle ~A has been closed (return code: ~A). "
109109
(ssl-error-handle condition)
110110
(ssl-error-ret condition))
111-
(format-ssl-error-queue stream condition))))
111+
(format-ssl-error-queue stream condition))))
112112

113113
;; SSL_ERROR_WANT_READ
114114
(define-condition ssl-error-want-read (ssl-error-want-something)
@@ -127,7 +127,7 @@ by READ-SSL-ERROR-QUEUE) or an SSL-ERROR condition."
127127
(format stream "The TLS/SSL operation on handle ~A did not complete: It wants a READ (return code: ~A). "
128128
(ssl-error-handle condition)
129129
(ssl-error-ret condition))
130-
(format-ssl-error-queue stream condition))))
130+
(format-ssl-error-queue stream condition))))
131131

132132
;; SSL_ERROR_WANT_WRITE
133133
(define-condition ssl-error-want-write (ssl-error-want-something)
@@ -146,7 +146,7 @@ by READ-SSL-ERROR-QUEUE) or an SSL-ERROR condition."
146146
(format stream "The TLS/SSL operation on handle ~A did not complete: It wants a WRITE (return code: ~A). "
147147
(ssl-error-handle condition)
148148
(ssl-error-ret condition))
149-
(format-ssl-error-queue stream condition))))
149+
(format-ssl-error-queue stream condition))))
150150

151151
;; SSL_ERROR_WANT_CONNECT
152152
(define-condition ssl-error-want-connect (ssl-error-want-something)
@@ -165,7 +165,7 @@ by READ-SSL-ERROR-QUEUE) or an SSL-ERROR condition."
165165
(format stream "The TLS/SSL operation on handle ~A did not complete: It wants a connect first (return code: ~A). "
166166
(ssl-error-handle condition)
167167
(ssl-error-ret condition))
168-
(format-ssl-error-queue stream condition))))
168+
(format-ssl-error-queue stream condition))))
169169

170170
;; SSL_ERROR_WANT_X509_LOOKUP
171171
(define-condition ssl-error-want-x509-lookup (ssl-error-want-something)
@@ -179,7 +179,7 @@ by READ-SSL-ERROR-QUEUE) or an SSL-ERROR condition."
179179
(format stream "The TLS/SSL operation on handle ~A did not complete: An application callback wants to be called again (return code: ~A). "
180180
(ssl-error-handle condition)
181181
(ssl-error-ret condition))
182-
(format-ssl-error-queue stream condition))))
182+
(format-ssl-error-queue stream condition))))
183183

184184
;; SSL_ERROR_SYSCALL
185185
(define-condition ssl-error-syscall (ssl-error/handle)
@@ -202,7 +202,7 @@ by READ-SSL-ERROR-QUEUE) or an SSL-ERROR condition."
202202
(ssl-error-ret condition))))
203203
(format stream "An UNKNOWN I/O error occurred in the underlying BIO (return code: ~A). "
204204
(ssl-error-ret condition)))
205-
(format-ssl-error-queue stream condition))))
205+
(format-ssl-error-queue stream condition))))
206206

207207
;; SSL_ERROR_SSL
208208
(define-condition ssl-error-ssl (ssl-error/handle)
@@ -212,33 +212,33 @@ by READ-SSL-ERROR-QUEUE) or an SSL-ERROR condition."
212212
OpenSSL error queue contains more information on the error.")
213213
(:report (lambda (condition stream)
214214
(format stream
215-
"A failure in the SSL library occurred on handle ~A (return code: ~A). "
215+
"A failure in the SSL library occurred on handle ~A (return code: ~A). "
216216
(ssl-error-handle condition)
217217
(ssl-error-ret condition))
218-
(format-ssl-error-queue stream condition))))
218+
(format-ssl-error-queue stream condition))))
219219

220220
(defun ssl-signal-error (handle syscall error-code original-error)
221221
(let ((queue (read-ssl-error-queue)))
222222
(if (and (eql error-code #.+ssl-error-syscall+)
223-
(not (zerop original-error)))
224-
(error 'ssl-error-syscall
225-
:handle handle
226-
:ret error-code
227-
:queue queue
228-
:syscall syscall)
223+
(not (zerop original-error)))
224+
(error 'ssl-error-syscall
225+
:handle handle
226+
:ret error-code
227+
:queue queue
228+
:syscall syscall)
229229
(error (case error-code
230-
(#.+ssl-error-none+ 'ssl-error-none)
231-
(#.+ssl-error-ssl+ 'ssl-error-ssl)
232-
(#.+ssl-error-want-read+ 'ssl-error-want-read)
233-
(#.+ssl-error-want-write+ 'ssl-error-want-write)
234-
(#.+ssl-error-want-x509-lookup+ 'ssl-error-want-x509-lookup)
235-
(#.+ssl-error-zero-return+ 'ssl-error-zero-return)
236-
(#.+ssl-error-want-connect+ 'ssl-error-want-connect)
237-
(#.+ssl-error-syscall+ 'ssl-error-zero-return) ; this is intentional here. we got an EOF from the syscall (ret is 0)
238-
(t 'ssl-error/handle))
239-
:handle handle
240-
:ret error-code
241-
:queue queue))))
230+
(#.+ssl-error-none+ 'ssl-error-none)
231+
(#.+ssl-error-ssl+ 'ssl-error-ssl)
232+
(#.+ssl-error-want-read+ 'ssl-error-want-read)
233+
(#.+ssl-error-want-write+ 'ssl-error-want-write)
234+
(#.+ssl-error-want-x509-lookup+ 'ssl-error-want-x509-lookup)
235+
(#.+ssl-error-zero-return+ 'ssl-error-zero-return)
236+
(#.+ssl-error-want-connect+ 'ssl-error-want-connect)
237+
(#.+ssl-error-syscall+ 'ssl-error-zero-return) ; this is intentional here. we got an EOF from the syscall (ret is 0)
238+
(t 'ssl-error/handle))
239+
:handle handle
240+
:ret error-code
241+
:queue queue))))
242242

243243
(defparameter *ssl-verify-error-alist*
244244
'((0 :X509_V_OK)

example.lisp

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@
2121
(let ((s (make-string-output-stream)))
2222
(loop
2323
for empty = t then nil
24-
for c = (read-char stream eof-error-p nil)
25-
while (and c (not (eql c #\return)))
26-
do
27-
(unless (eql c #\newline)
28-
(write-char c s))
29-
finally
30-
(return
31-
(if empty nil (get-output-stream-string s))))))
24+
for c = (read-char stream eof-error-p nil)
25+
while (and c (not (eql c #\return)))
26+
do
27+
(unless (eql c #\newline)
28+
(write-char c s))
29+
finally
30+
(return
31+
(if empty nil (get-output-stream-string s))))))
3232

3333
(defun test-nntps-client (&optional (host "snews.gmane.org") (port 563))
3434
(let* ((fd (trivial-sockets:open-stream host port
35-
:element-type '(unsigned-byte 8)))
35+
:element-type '(unsigned-byte 8)))
3636
(nntps (cl+ssl:make-ssl-client-stream fd :external-format '(:iso-8859-1 :eol-style :lf))))
3737
(format t "NNTPS> ~A~%" (read-line-crlf nntps))
3838
(write-line "HELP" nntps)
@@ -46,29 +46,29 @@
4646
;; HEAD request
4747
(defun test-https-client (host &optional (port 443))
4848
(let* ((deadline (+ (get-internal-real-time)
49-
(* 3 internal-time-units-per-second)))
50-
(socket (ccl:make-socket :address-family :internet
51-
:connect :active
52-
:type :stream
53-
:remote-host host
54-
:remote-port port
55-
;; :local-host (resolve-hostname local-host)
56-
;; :local-port local-port
57-
:deadline deadline))
49+
(* 3 internal-time-units-per-second)))
50+
(socket (ccl:make-socket :address-family :internet
51+
:connect :active
52+
:type :stream
53+
:remote-host host
54+
:remote-port port
55+
;; :local-host (resolve-hostname local-host)
56+
;; :local-port local-port
57+
:deadline deadline))
5858
(https
59-
(progn
60-
(cl+ssl:make-ssl-client-stream
61-
socket
62-
:unwrap-stream-p t
63-
:external-format '(:iso-8859-1 :eol-style :lf)))))
59+
(progn
60+
(cl+ssl:make-ssl-client-stream
61+
socket
62+
:unwrap-stream-p t
63+
:external-format '(:iso-8859-1 :eol-style :lf)))))
6464
(unwind-protect
65-
(progn
66-
(format https "GET / HTTP/1.0~%Host: ~a~%~%" host)
67-
(force-output https)
68-
(loop :for line = (read-line-crlf https nil)
69-
:while line :do
70-
(format t "HTTPS> ~a~%" line)))
71-
(close https))))
65+
(progn
66+
(format https "GET / HTTP/1.0~%Host: ~a~%~%" host)
67+
(force-output https)
68+
(loop :for line = (read-line-crlf https nil)
69+
:while line :do
70+
(format t "HTTPS> ~a~%" line)))
71+
(close https))))
7272

7373
;; start a simple HTTPS server. See the mod_ssl documentation at
7474
;; <URL:http://www.modssl.org/> for information on generating the
@@ -80,31 +80,31 @@
8080
;;
8181
(defun test-https-server
8282
(&key (port 8080)
83-
(cert "/home/david/newcert.pem")
84-
(key "/home/david/newkey.pem"))
83+
(cert "/home/david/newcert.pem")
84+
(key "/home/david/newkey.pem"))
8585
(format t "~&SSL server listening on port ~d~%" port)
8686
(trivial-sockets:with-server (server (:port port))
8787
(loop
8888
(let* ((socket (trivial-sockets:accept-connection
89-
server
90-
:element-type '(unsigned-byte 8)))
91-
(client (cl+ssl:make-ssl-server-stream
92-
socket
93-
:external-format '(:iso-8859-1 :eol-style :lf)
94-
:certificate cert
95-
:key key)))
96-
(unwind-protect
97-
(progn
98-
(loop :for line = (read-line-crlf client nil)
99-
:while (> (length line) 1) :do
100-
(format t "HTTPS> ~a~%" line))
101-
(format client "HTTP/1.0 200 OK~%")
102-
(format client "Server: SSL-CMUCL/1.1~%")
103-
(format client "Content-Type: text/plain~%")
104-
(terpri client)
105-
(format client "G'day at ~A!~%"
106-
(multiple-value-list (get-decoded-time)))
107-
(format client "CL+SSL running in ~A ~A~%"
108-
(lisp-implementation-type)
109-
(lisp-implementation-version)))
110-
(close client))))))
89+
server
90+
:element-type '(unsigned-byte 8)))
91+
(client (cl+ssl:make-ssl-server-stream
92+
socket
93+
:external-format '(:iso-8859-1 :eol-style :lf)
94+
:certificate cert
95+
:key key)))
96+
(unwind-protect
97+
(progn
98+
(loop :for line = (read-line-crlf client nil)
99+
:while (> (length line) 1) :do
100+
(format t "HTTPS> ~a~%" line))
101+
(format client "HTTP/1.0 200 OK~%")
102+
(format client "Server: SSL-CMUCL/1.1~%")
103+
(format client "Content-Type: text/plain~%")
104+
(terpri client)
105+
(format client "G'day at ~A!~%"
106+
(multiple-value-list (get-decoded-time)))
107+
(format client "CL+SSL running in ~A ~A~%"
108+
(lisp-implementation-type)
109+
(lisp-implementation-version)))
110+
(close client))))))

0 commit comments

Comments
 (0)