+/**
+ * Head of DLL of TLDs we map to GNS zones.
+ */
+static struct GNS_TopLevelDomain *tld_head;
+
+/**
+ * Tail of DLL of TLDs we map to GNS zones.
+ */
+static struct GNS_TopLevelDomain *tld_tail;
+
+
+/**
+ * Find GNS zone belonging to TLD @a tld.
+ *
+ * @param tld_str top-level domain to look up
+ * @param[out] pkey public key to set
+ * @return #GNUNET_YES if @a tld was found #GNUNET_NO if not
+ */
+int
+GNS_find_tld (const char *tld_str,
+ struct GNUNET_CRYPTO_EcdsaPublicKey *pkey)
+{
+ if ('\0' == *tld_str)
+ return GNUNET_NO;
+ for (struct GNS_TopLevelDomain *tld = tld_head;
+ NULL != tld;
+ tld = tld->next)
+ {
+ if (0 == strcasecmp (tld_str,
+ tld->tld))
+ {
+ *pkey = tld->pkey;
+ return GNUNET_YES;
+ }
+ }
+ if (GNUNET_OK ==
+ GNUNET_GNSRECORD_zkey_to_pkey (tld_str + 1,
+ pkey))
+ return GNUNET_YES; /* TLD string *was* the public key */
+ return GNUNET_NO;
+}
+
+
+/**
+ * Obtain the TLD of the given @a name.
+ *
+ * @param name a name
+ * @return the part of @a name after the last ".",
+ * or @a name if @a name does not contain a "."
+ */
+const char *
+GNS_get_tld (const char *name)
+{
+ const char *tld;
+
+ tld = strrchr (name,
+ (unsigned char) '.');
+ if (NULL == tld)
+ tld = name;
+ else
+ tld++; /* skip the '.' */
+ return tld;
+}
+