X-Git-Url: https://uglyman.kremlin.cc/gitweb/gitweb.cgi?a=blobdiff_plain;f=src%2Finterfaces%2Fhostnamed%2Fhostnamed.c;h=0cdbd36ad6af75039cc85c5c132ac48a9d3e63aa;hb=1e8c7c889a1c3b92c58fb1590b2f1192dd86623b;hp=ad7df31fa55ba1badf37f2b7aa7d7742c314db18;hpb=5b005882b2af5868261a01a386028291516aabb0;p=systembsd.git diff --git a/src/interfaces/hostnamed/hostnamed.c b/src/interfaces/hostnamed/hostnamed.c index ad7df31..0cdbd36 100644 --- a/src/interfaces/hostnamed/hostnamed.c +++ b/src/interfaces/hostnamed/hostnamed.c @@ -17,11 +17,9 @@ #include #include -#include -#include +#include -#include "hostnamed.h" -#include "hostnamed-gen.c" +#include "hostnamed-gen.h" GPtrArray *hostnamed_freeable; GDBusNodeInfo *spect_data; @@ -79,7 +77,13 @@ on_handle_set_icon_name(hostnamedHostname1 *hn1_passed_interf, const gchar * our_get_hostname() { - return "TODO"; + int hostname_try; + gchar *hostname_buf; + + hostname_buf = (gchar*) g_malloc0(MAXHOSTNAMELEN); + hostname_try = gethostname(hostname_buf, MAXHOSTNAMELEN); + + return hostname_buf; } const gchar * @@ -183,6 +187,12 @@ static void hostnamed_on_name_acquired(GDBusConnection *conn, } +/* free()'s */ +void hostnamed_mem_clean() { + + g_ptr_array_foreach(hostnamed_freeable, (GFunc) g_free, NULL); +} + static void hostnamed_on_name_lost(GDBusConnection *conn, const gchar *name, gpointer user_data) { @@ -196,22 +206,9 @@ static void hostnamed_on_name_lost(GDBusConnection *conn, } /* safe call to try and start hostnamed */ -GError *hostnamed_init() { +void hostnamed_init() { guint bus_descriptor; - GError *err = NULL; - gchar **hostnamed_ispect_xml; - gchar *hostnamed_joined_xml; - - hostnamed_freeable = g_ptr_array_new(); - hostnamed_ispect_xml = g_malloc(3000); - - g_file_get_contents("conf/hostnamed-ispect.xml", hostnamed_ispect_xml, NULL, NULL); - hostnamed_joined_xml = g_strjoinv("\n", hostnamed_ispect_xml); - spect_data = g_dbus_node_info_new_for_xml(hostnamed_joined_xml, NULL); - - g_free(hostnamed_ispect_xml); - g_ptr_array_add(hostnamed_freeable, hostnamed_joined_xml); bus_descriptor = g_bus_own_name(G_BUS_TYPE_SYSTEM, "org.freedesktop.hostname1", @@ -223,13 +220,21 @@ GError *hostnamed_init() { NULL); /* TODO: malloc and return reference as if a main() closed */ - return err; } -/* free()'s */ -void hostnamed_mem_clean() { +int main() { - g_ptr_array_foreach(hostnamed_freeable, (GFunc) g_free, NULL); + GMainLoop *hostnamed_loop; + hostnamed_loop = g_main_loop_new(NULL, TRUE); + + /* config stuff here */ + + + hostnamed_init(); + g_main_loop_run(hostnamed_loop); + g_main_loop_unref(hostnamed_loop); + + return 0; } /* TODO figure out DMI variables on obsd */ @@ -277,3 +282,4 @@ void hostnamed_mem_clean() { g_free (filebuf); return ret; }*/ +