summaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/util.c b/util.c
index 3edaa88..0fcedc7 100644
--- a/util.c
+++ b/util.c
@@ -125,3 +125,34 @@ gint flx_age(const GTimeVal *a) {
return flx_timeval_diff(&now, a);
}
+
+gboolean flx_domain_equal(const gchar *a, const gchar *b) {
+ g_assert(a);
+ g_assert(b);
+
+ for (;;) {
+ if (*a == 0 && *b == 0)
+ return TRUE;
+
+ if (*a == 0 && *b == '.' && *(b+1) == 0)
+ return TRUE;
+
+ if (*a == '.' && *(a+1) == 0 && *b == 0)
+ return TRUE;
+
+ if (*a != *b)
+ return FALSE;
+
+ a++;
+ b++;
+ }
+}
+
+guint flx_domain_hash(const gchar *p) {
+ char t[256];
+ strncpy(t, p, sizeof(t)-1);
+ t[sizeof(t)-1] = 0;
+
+ return g_int_hash(t);
+}
+