Introduction
Introduction Statistics Contact Development Disclaimer Help
cleaning code - clic - Clic is an command line interactive client for gopher wr…
git clone git://bitreich.org/clic/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65…
Log
Files
Refs
Tags
README
LICENSE
---
commit 6e9a0a50df3a58cdce03da5875fa63cef51cc469
parent 1c31d4653e91070b9f3828a0965ccefda20747c9
Author: Solene Rapenne <[email protected]>
Date: Sun, 5 Nov 2017 00:11:05 +0000
cleaning code
Diffstat:
M clic.lisp | 62 ++++++++++++++---------------…
1 file changed, 27 insertions(+), 35 deletions(-)
---
diff --git a/clic.lisp b/clic.lisp
@@ -54,18 +54,18 @@
"Used to display gopher response with color one line at a time"
(let ((line-type (subseq line 0 1))
(infos (split (subseq line 1) #\Tab)))
-
+
;; see RFC 1436
;; section 3.8
(when (and
(= (length infos) 4)
(member line-type *allowed-selectors* :test #'equal))
-
+
(let ((text (car infos))
(uri (cadr infos))
(host (caddr infos))
(port (parse-integer (cadddr infos))))
-
+
;; RFC, page 4
(check "i"
(print-with-color text))
@@ -134,37 +134,35 @@
(push here *history*)
;; we reset the links table ONLY if we have a new folder
- ;; and we store the location for "previous" command
(when (string= "1" type)
- (setf *links* (make-hash-table))
- (setf (gethash 0 *links*) here)))
+ (setf *links* (make-hash-table)))
- ;; we prepare informations about the connection
- (let* ((address (sb-bsd-sockets:get-host-by-name host))
- (host (car (sb-bsd-sockets:host-ent-addresses address)))
- (socket (make-instance 'sb-bsd-sockets:inet-socket :type :stream :pro…
-
- (sb-bsd-sockets:socket-connect socket host port)
-
- ;; we open a stream for input/output
- (let ((stream (sb-bsd-sockets:socket-make-stream socket :input t :output t…
+ ;; we prepare informations about the connection
+ (let* ((address (sb-bsd-sockets:get-host-by-name host))
+ (host (car (sb-bsd-sockets:host-ent-addresses address)))
+ (socket (make-instance 'sb-bsd-sockets:inet-socket :type :stream :p…
- ;; sending the request here
- ;; if the selector is 1 we omit it
- (format stream "~a~%" uri)
- (force-output stream)
+ (sb-bsd-sockets:socket-connect socket host port)
- ;; for each line we receive we display it
- (loop for line = (read-line stream nil nil)
- counting line into line-number
- while line do
- (cond
- ((string= "1" type)
- (formatted-output line line-number))
- ((string= "0" type)
- (format t "~a~%" line))))))
- (format t "~aRequested gopher://~a:~a/~a~a~a~%" (getcolor 'cyan) host port t…
+ ;; we open a stream for input/output
+ (let ((stream (sb-bsd-sockets:socket-make-stream socket :input t :output…
+
+ ;; sending the request here
+ ;; if the selector is 1 we omit it
+ (format stream "~a~%" uri)
+ (force-output stream)
+
+ ;; for each line we receive we display it
+ (loop for line = (read-line stream nil nil)
+ counting line into line-number
+ while line do
+ (cond
+ ((string= "1" type)
+ (formatted-output line line-number))
+ ((string= "0" type)
+ (format t "~a~%" line))))))
+ (format t "~aRequested gopher://~a:~a/~a~a~a~%" (getcolor 'cyan) host port…
(defun visit(destination)
"visit a location"
@@ -185,12 +183,6 @@
(pop *history*)
(visit (pop *history*))))
-(defun help()
- "show help"
- (format t "HOW TO USE CLI !~%")
- (format t "(getpage \"host\" port \"uri\")~%")
- (format t "~%~%"))
-
(defun help-shell()
"show help for the shell"
(format t "number : go to link n~%")
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.