Why doesnot mpd module support CCL ?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Why doesnot mpd module support CCL ?

z_axis
The mpd module works great with SBCL. But it seems that the mpd module  
doesnot support CCL.

Would anyone knowing CCL like to hack it to support CCL ?


Sincerely!


_______________________________________________
Stumpwm-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/stumpwm-devel
Reply | Threaded
Open this post in threaded view
|

Re: Why doesnot mpd module support CCL ?

Lucas Pandolfo
On 20 April 2012 22:44, z_axis <[hidden email]> wrote:
The mpd module works great with SBCL. But it seems that the mpd module doesnot support CCL.

Would anyone knowing CCL like to hack it to support CCL ?


Sincerely!

If you look at the source code you can see

 #-(or sbcl clisp) (error "unimplemented")

So it won't work with ccl. Mainly because it relies on socket support in these implementations. To make it more portable you should remove the conditional code like this one:

#+clisp
(handler-case (socket:socket-connect *mpd-port* *mpd-server*
                                     :element-type 'character)
               ((or system::simple-os-error error)
                (err)
                  (format t  "Error connecting to mpd: ~a~%" err)))
#+sbcl
(handler-case (let ((s (make-instance 'sb-bsd-sockets:inet-socket
                                      :type :stream :protocol :tcp)))
                (sb-bsd-sockets:socket-connect s *mpd-server*
                                               *mpd-port*)
                (sb-bsd-sockets:socket-make-stream s
                                                   :input t
                                                   :output t
                                                   :buffering :none))
              ((or simple-error error)
               (err)
                 (format t  "Error connecting to mpd: ~a~%" err)))

and reimplement it using usocket.

_______________________________________________
Stumpwm-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/stumpwm-devel
Reply | Threaded
Open this post in threaded view
|

Re: Why doesnot mpd module support CCL ?

Vitaly Mayatskikh
In reply to this post by z_axis
At Sat, 21 Apr 2012 09:44:15 +0800, z_axis wrote:

> The mpd module works great with SBCL. But it seems that the mpd module  
> doesnot support CCL.
>
> Would anyone knowing CCL like to hack it to support CCL ?

From my local git repo:

===File /tmp/123============================================
commit 1e206af2f3dd40060c8ef3f169af081d5fd646a6
Author: Vitaly Mayatskikh <[hidden email]>
Date:   Sun Aug 7 20:16:20 2011 -0400

    contrib/mpd.lisp: added support for Clozure CL.

diff --git a/contrib/mpd.lisp b/contrib/mpd.lisp
index 954fe01..1013e33 100644
--- a/contrib/mpd.lisp
+++ b/contrib/mpd.lisp
@@ -48,7 +48,7 @@
 
 ;;; CODE:
 
-#-(or sbcl clisp) (error "unimplemented")
+#-(or sbcl clisp ccl) (error "unimplemented")
 
 (in-package :stumpwm)
 
@@ -108,7 +108,7 @@
 ;;mpd client
 (defparameter *mpd-socket* nil)
 (defparameter *mpd-server*
-  #+clisp
+  #+(or clisp ccl)
   "localhost"
   #+sbcl
   #(127 0 0 1)
@@ -138,10 +138,11 @@
   (with-mpd-connection
    (#+clisp
     ext:write-char-sequence
-    #+sbcl
+    #+(or sbcl ccl)
     write-sequence
     (concatenate  'string command (string #\Newline))
-    *mpd-socket*)))
+    *mpd-socket*)
+    (force-output *mpd-socket*)))
 
 (defun mpd-send-command (cmd)
   (mpd-send cmd)
@@ -183,24 +184,26 @@
 (defun init-mpd-connection ()
   "Connect to mpd server"
     (setf *mpd-socket*
+        (handler-case
           #+clisp
-        (handler-case (socket:socket-connect *mpd-port* *mpd-server*
-                                             :element-type 'character)
-                      ((or system::simple-os-error error)
-                       (err)
-                         (format t  "Error connecting to mpd: ~a~%" err)))
+          (socket:socket-connect *mpd-port* *mpd-server*
+            :element-type 'character)
           #+sbcl
-          (handler-case (let ((s (make-instance 'sb-bsd-sockets:inet-socket
-                                                :type :stream :protocol :tcp)))
-                          (sb-bsd-sockets:socket-connect s *mpd-server*
-                                                         *mpd-port*)
-                          (sb-bsd-sockets:socket-make-stream s
-                                                             :input t
-                                                             :output t
-                                                             :buffering :none))
-                        ((or simple-error error)
-                         (err)
-                       (format t  "Error connecting to mpd: ~a~%" err))))
+          (let ((s (make-instance 'sb-bsd-sockets:inet-socket
+                                  :type :stream :protocol :tcp)))
+            (sb-bsd-sockets:socket-connect s *mpd-server* *mpd-port*)
+            (sb-bsd-sockets:socket-make-stream s
+                                               :input t
+                                               :output t
+                                               :buffering :none))
+          #+ccl
+          (let ((s (ccl:make-socket :connect :active :format :text
+                                    :remote-host *mpd-server*
+                                    :remote-port *mpd-port*)))
+            (setf (stream-external-format s) :utf-8)
+            s)
+          (error (err)
+            (format t "Error connecting to mpd: ~a~%" err))))
   (when *mpd-socket*
     (when *mpd-timeout*
       (setf *mpd-timer*
============================================================

--
wbr, Vitaly

_______________________________________________
Stumpwm-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/stumpwm-devel