Add current page size in Kb and the whole bandwidth usage at the end - clic - Clic is an command line interactive client for gopher written in Common LISP
 (HTM) git clone git://bitreich.org/clic/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/clic/
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Tags
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 1f6eeef4e3b769c19b558f9218d618b59383a54d
 (DIR) parent e621aa67e792e7fa10c602cdf2820d652b3afe3e
 (HTM) Author: Solene Rapenne <solene@perso.pw>
       Date:   Mon, 13 Aug 2018 12:33:37 +0200
       
       Add current page size in Kb and the whole bandwidth usage at the end
       
       Diffstat:
         M clic.lisp                           |      17 ++++++++++++++---
       
       1 file changed, 14 insertions(+), 3 deletions(-)
       ---
 (DIR) diff --git a/clic.lisp b/clic.lisp
       @@ -63,6 +63,10 @@
        ;;; array of lines of last menu
        (defparameter *previous-buffer* nil)
        
       +;;; bandwidth usage counter
       +(defparameter *total-bandwidth-in* 0)
       +(defparameter *last-bandwidth-in* 0)
       +
        ;;; a list containing the last viewed pages
        (defparameter *history*   '())
        
       @@ -303,6 +307,7 @@
                            :fill-pointer 0
                            :initial-element nil
                            :adjustable t))
       +  (setf *last-bandwidth-in* 0)
        
          (let ((real-time (get-internal-real-time)))
            ;; we prepare informations about the connection
       @@ -319,11 +324,15 @@
                count line into lines
                while line
                do
       +        ;; count bandwidth usage
       +        (incf *total-bandwidth-in* (length line))
       +        (incf *last-bandwidth-in* (length line))
                ;; increase array size if needed
                  (when (= lines (- (array-total-size *buffer*) 1))
                    (adjust-array *buffer* (+ 200 (array-total-size *buffer*))))
                  (vector-push line *buffer*)))
        
       +
            ;; we store the duration of the connection
            (setf *duration* (float (/ (- (get-internal-real-time) real-time)
                                       internal-time-units-per-second)))))
       @@ -707,13 +716,14 @@
        
        (defun display-prompt()
          (let ((last-page (car *history*)))
       -    (format t "~agopher://~a:~a/~a~a (~as) / (p)rev (r)edisplay (h)istory : "
       +    (format t "~agopher://~a:~a/~a~a (~as, ~aKb) / (p)rev (r)edisplay (h)istory : "
                    (if *kiosk-mode* "KIOSK " "")
                    (location-host last-page)
                    (location-port last-page)
                    (location-type last-page)
                    (location-uri last-page)
       -            *duration*))
       +            *duration*
       +            (floor (/ *last-bandwidth-in* 1024.0))))
          (force-output))
        
        (defun shell()
       @@ -769,7 +779,8 @@
                        ;; to look it here
                        (when (not (eq 'end (visit destination)))
                          ;; we continue to the shell if we are in a terminal
       -                  (shell))))
       +                  (shell)))
       +            (format t "~a kB in.~%" (floor (/ *total-bandwidth-in* 1024.0))))
                  (pipe-to-stdout destination)))))
        
        ;; we allow ecl to use a new kind of argument