X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=util.c;fp=util.c;h=7d3c3b6bf8ff579aa884ac81c3dcf0f69312851e;hb=33ccd714ea9469b5b7d3b36bbe468ba1b0f31dfc;hp=0000000000000000000000000000000000000000;hpb=2095aa52444f9ab598475ddcf8ca1773a02f8e13;p=catta diff --git a/util.c b/util.c new file mode 100644 index 0000000..7d3c3b6 --- /dev/null +++ b/util.c @@ -0,0 +1,26 @@ +#include +#include + +#include "util.h" + +gchar *flx_get_host_name(void) { + char t[256]; + gethostname(t, sizeof(t)); + return g_strndup(t, sizeof(t)); +} + +gchar *flx_normalize_name(gchar *s) { + size_t l; + g_assert(s); + + l = strlen(s); + + if (!l) + return g_strdup("."); + + if (s[l-1] == '.') + return g_strdup(s); + + return g_strdup_printf("%s.", s); +} +