(defpackage :dbus (:use :common-lisp :cffi) (:documentation "A high-level binding for the DBus IPC system.")) (in-package :dbus) (defun with-error (func) "Call proc with a dbus-error struct." (let ((error (foreign-alloc 'libdbus:dbus-error))) (libdbus:dbus-error-init error) (let ((return-value (funcall func error))) (if (libdbus:dbus-error-is-set error) (let ((msg (foreign-slot-value error 'libdbus:dbus-error 'libdbus::message))) (libdbus:dbus-error-free error) (foreign-free error) (error "DBus error ~A" msg) ) (progn (libdbus:dbus-error-free error) (foreign-free error) return-value ) ) ) ) ) (defun slurp-file (path) (let ((stream (open path))) (let ((seq (make-string (file-length stream)))) (read-sequence seq stream) seq) ) )