]> git.meshlink.io Git - catta/blob - util.c
initial commit
[catta] / util.c
1 #include <string.h>
2 #include <unistd.h>
3
4 #include "util.h"
5
6 gchar *flx_get_host_name(void) {
7     char t[256];
8     gethostname(t, sizeof(t));
9     return g_strndup(t, sizeof(t));
10 }
11
12 gchar *flx_normalize_name(gchar *s) {
13     size_t l;
14     g_assert(s);
15
16     l = strlen(s);
17
18     if (!l)
19         return g_strdup(".");
20
21     if (s[l-1] == '.')
22         return g_strdup(s);
23     
24     return g_strdup_printf("%s.", s);
25 }
26