Creating services in C

Søren Hauberg hauberg at gmail.com
Tue Dec 23 08:31:34 PST 2008


Hi All,
  I'm not quite sure where to ask, so if this is the wrong mailing
list just tell me :-)
Anyway, I'm working on the Octave interpreter (www.octave.org), and
I'd like to have some way for external applications to run code in
this interpreter. So, I figured D-Bus would be the tool for this. I
find the documentation for the Python bindings fairly easy to read,
but I can't seem to wrap my head around the C docs. So, I've written
the program I need in Python, and it is:

== CODE ==
class octave_server (dbus.service.Object):
    @dbus.service.method ("org.octave.interface",
                          in_signature="s", out_signature="")
    def eval_when_idle (self, code):
        print (code)

    @dbus.service.method ("org.octave.interface", in_signature="",
out_signature="")
    def exit (self):
        print ("exiting per request")
        mainloop.quit ()


if __name__ == "__main__":
    dbus.mainloop.glib.DBusGMainLoop (set_as_default=True)

    session_bus = dbus.SessionBus ()
    name = dbus.service.BusName ("org.octave.interface", session_bus)
    object = octave_server (session_bus,  "/octave")

    mainloop = gobject.MainLoop ()
    mainloop.run ()
== END CODE ==

Now, I need to port this code to C. Could anybody give me some
pointers, on which functions to look into, etc. ?

Thanks,
Søren


More information about the dbus mailing list