r8485: add time for topicwhotime
authorKevin M. Rosenberg <kevin@rosenberg.net>
Sun, 4 Jan 2004 14:10:47 +0000 (14:10 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Sun, 4 Jan 2004 14:10:47 +0000 (14:10 +0000)
irc-logger.asd
logger.lisp

index b36a25d145f300f3e496d3ef5a4de56d8e0d8000..89e883e03d3f4243dffb9cd555a48446c96ce5b6 100644 (file)
@@ -7,7 +7,7 @@
 (in-package irc-logger-system)
 
 (defsystem irc-logger
-    :depends-on (cl-irc cl-ppcre)
+    :depends-on (cl-irc cl-ppcre uffi)
     :components ((:file "package")
                 (:file "logger" :depends-on ("package"))))
 
index 7c341299b3d07f120ed3c9b436477dbbd18197f4..449f154a08e97c76b37f1e0c0e4c43b87347b252 100644 (file)
     (format stream "~S~%" 
            (string-right-trim '(#\return) (raw-message-string msg)))))
 
+(uffi:def-foreign-type time-t :unsigned-long)
+(uffi:def-function ("ctime" c-ctime) 
+    ((time (* time-t)))
+  :returning :cstring)
+
 (defun last-sexp-field (type msg)
   (cond
    ((null msg)
     nil)
    ((eq type :kick)
     (trailing-argument msg))
+   ((eq type :rpl_topicwhotime)
+    (when (stringp (car (last (arguments msg))))
+      (let ((secs (parse-integer (car (last (arguments msg))) :junk-allowed t)))
+       (when secs
+         (string-right-trim '(#\newline #\return)
+                            (uffi:convert-from-cstring
+                             (uffi:with-foreign-object (time 'time-t)
+                               (setf (uffi:deref-pointer time :unsigned-long) secs)
+                               (c-ctime time))))))))
    ((need-user-address? type)
     (user-address msg))))
 
 
 (defun rpl_topicwhotime-hook (msg)
   (output-event msg :rpl_topicwhotime
-               (format nil "~{~A~^ ~}" (arguments msg))
-               (trailing-argument msg)))
+               (second (arguments msg))
+               (third (arguments msg))))
 
 
 (defun invite-hook (msg)
        irc::irc-rpl_killdone-message irc::irc-rpl_closing-message
        irc::irc-rpl_topic-message irc::irc-rpl_namreply-message
        irc::irc-rpl_endofnames-message irc::irc-rpl_topicwhotime-message
-       irc::irc-rpl_motd irc::irc-rpl_motdstart-message irc::irc-rpl_endofmotd-message)
+       irc::irc-rpl_motd-message irc::irc-rpl_motdstart-message
+       irc::irc-rpl_endofmotd-message)
        ;; nothing to do
        )
       (t
 (defun add-logger (nick server &key channels output (password "")
                                    realname username private-log unknown-log
                                    (logging-stream t) (async t)
-                                   (formats '(:text)))
+                                   (formats '(:sexp)))
   (when (find-logger-with-nick nick)
     (format
      (get-private-log-stream (find-logger-with-nick nick))