closure issues added by Pixel_Outlaw on Sun May 17 07:53:08 2015

(use mysql-client)                                    

(use extras ;; for pp
     posix) ;; for call-with-input-pipe

(define (terminal-dimensions)
  (call-with-input-pipe "stty size"
                        (lambda (port)
                          (cons (read port) (read port)))))


(pp (terminal-dimensions))

;; Make a series of closures for cursors
(define mysql (make-mysql-connection "localhost" "BBS_admin" "password" "BBS"))
(define sections-fetcher (mysql "SELECT section FROM sections ORDER BY id"))
(define threads-fetcher (mysql "SELECT thread FROM threads ORDER BY modify_date"))
(define tables-fetcher (mysql "show tables"))

(define (get-sql-closure-as-list fetch-closure)
  (let ((a (fetch-closure)))
    (cond ((eq? a #f) '())
          (else
           (cons a (get-sql-closure-as-list fetch-closure))))))

(print "Welcome to the Bullitin Board for Tiny Server")
(print "Below are the sections you may visit")
(print)
(get-sql-closure-as-list tables-fetcher)