diff options
author | kremlin <ian@kremlin.cc> | 2014-05-28 09:45:02 +0800 |
---|---|---|
committer | kremlin <ian@kremlin.cc> | 2014-05-28 09:45:02 +0800 |
commit | ea207ed3d155cde4001063c981f7a263c47daf64 (patch) | |
tree | 620681056dfaee46812c5f534f7673735b272f7a | |
parent | a262d8ee186bd0b828ea201549aca5990b47efb7 (diff) | |
download | systembsd-ea207ed3d155cde4001063c981f7a263c47daf64.tar systembsd-ea207ed3d155cde4001063c981f7a263c47daf64.tar.gz systembsd-ea207ed3d155cde4001063c981f7a263c47daf64.tar.bz2 systembsd-ea207ed3d155cde4001063c981f7a263c47daf64.tar.lz systembsd-ea207ed3d155cde4001063c981f7a263c47daf64.tar.xz systembsd-ea207ed3d155cde4001063c981f7a263c47daf64.tar.zst systembsd-ea207ed3d155cde4001063c981f7a263c47daf64.zip |
begin hostnamed, clean up
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | src/main.c | 4 | ||||
-rw-r--r-- | src/modules/hostnamed/hostnamed.c | 35 | ||||
-rw-r--r-- | src/modules/hostnamed/tmp | 1 | ||||
-rw-r--r-- | src/test.c | 7 |
5 files changed, 39 insertions, 12 deletions
@@ -5,7 +5,7 @@ DEBUGF=-O0 -v -g SRCDIR=src MODDIR=$(SRCDIR)/modules -GLIBF=`pkg-config --cflags --libs glib-2.0 gobject-2.0` +GLIBF=`pkg-config --cflags --libs glib-2.0 gobject-2.0 gio-2.0` hostnamed: - gcc -o bin/out.bin $(CFLAGS) $(DEBUGF) $(GLIBF) $(SRCDIR)/main.c + gcc -o bin/out.bin $(DEBUGF) $(GLIBF) $(SRCDIR)/main.c @@ -1,5 +1,7 @@ #include "modules/hostnamed/hostnamed.c" int main() { + hostnamed_init(); + for(;;) {} return 0; -} +} diff --git a/src/modules/hostnamed/hostnamed.c b/src/modules/hostnamed/hostnamed.c index ee25324..f3632f6 100644 --- a/src/modules/hostnamed/hostnamed.c +++ b/src/modules/hostnamed/hostnamed.c @@ -1,2 +1,35 @@ -#include <glib-2.0/glib.h> +/* #include <glib-2.0/glib.h> */ +#include <gio/gio.h> + +static void on_bus_acquired(GDBusConnection *conn, const gchar *name, gpointer user_data) { + g_print("got bus, name: %s\n", name); + + /* g_print("at %p, data @ %p\n", (void*)conn, user_data); */ +} + +static void on_name_acquired(GDBusConnection *conn, const gchar *name, gpointer user_data) { + g_print("got name %s\n", name); + + /* g_print("at %p, data @ %p\n", (void*)conn, user_data); */ +} + +static void on_name_lost(GDBusConnection *conn, const gchar *name, gpointer user_data) { + g_print("lost name %s\n", name); + + /* g_print("at %p, data @ %p\n", (void*)conn, user_data); */ +} + +void hostnamed_init() { + guint bus_descriptor; + GError *err = NULL; + + bus_descriptor = g_bus_own_name(G_BUS_TYPE_SYSTEM, + (gchar *)"org.freedesktop.hostname1", + G_BUS_NAME_OWNER_FLAGS_NONE, + on_bus_acquired, + on_name_acquired, + on_name_lost, + NULL, + NULL); +} diff --git a/src/modules/hostnamed/tmp b/src/modules/hostnamed/tmp deleted file mode 100644 index c32d7ff..0000000 --- a/src/modules/hostnamed/tmp +++ /dev/null @@ -1 +0,0 @@ -TODO: delete me diff --git a/src/test.c b/src/test.c deleted file mode 100644 index 7a0d21a..0000000 --- a/src/test.c +++ /dev/null @@ -1,7 +0,0 @@ -#include <sys/types.h> - -#include <glib.h> - -int main() { - return 0; -} |