diff --git a/docs/libpsl/libpsl-sections.txt b/docs/libpsl/libpsl-sections.txt index a795a1b..7ee9e7f 100644 --- a/docs/libpsl/libpsl-sections.txt +++ b/docs/libpsl/libpsl-sections.txt @@ -6,7 +6,7 @@ psl_free psl_load_file psl_load_fp psl_builtin -psl_is_public +psl_is_public_suffix psl_unregistrable_domain psl_registrable_domain psl_suffix_count diff --git a/include/libpsl.h b/include/libpsl.h index 706b1e8..f356583 100644 --- a/include/libpsl.h +++ b/include/libpsl.h @@ -50,7 +50,7 @@ psl_ctx_t * const psl_ctx_t * psl_builtin(void); int - psl_is_public(const psl_ctx_t *psl, const char *domain); + psl_is_public_suffix(const psl_ctx_t *psl, const char *domain); // returns the longest unregistrable domain within 'domain' or NULL if none found const char * psl_unregistrable_domain(const psl_ctx_t *psl, const char *domain); diff --git a/src/psl.c b/src/psl.c index bce1e6a..8cfff91 100644 --- a/src/psl.c +++ b/src/psl.c @@ -248,7 +248,7 @@ static int _suffix_init(_psl_entry_t *suffix, const char *rule, size_t length) } /** - * psl_is_public: + * psl_is_public_suffix: * @psl: PSL context * @domain: Domain string * @@ -265,7 +265,7 @@ static int _suffix_init(_psl_entry_t *suffix, const char *rule, size_t length) * * Since: 0.1 */ -int psl_is_public(const psl_ctx_t *psl, const char *domain) +int psl_is_public_suffix(const psl_ctx_t *psl, const char *domain) { _psl_entry_t suffix, *rule; const char *p, *label_bak; @@ -369,10 +369,10 @@ const char *psl_unregistrable_domain(const psl_ctx_t *psl, const char *domain) // for being a registered domain. if (!(p = strrchr(domain, '.'))) - return psl_is_public(psl, domain) ? domain : NULL; + return psl_is_public_suffix(psl, domain) ? domain : NULL; for (ret_domain = NULL; ;) { - if (!psl_is_public(psl, p)) + if (!psl_is_public_suffix(psl, p)) return ret_domain; else if (p == domain) return domain; @@ -415,7 +415,7 @@ const char *psl_registrable_domain(const psl_ctx_t *psl, const char *domain) if (!(p = strrchr(domain, '.'))) p = domain; - while ((ispublic = psl_is_public(psl, p)) && p > domain) { + while ((ispublic = psl_is_public_suffix(psl, p)) && p > domain) { // go left to next dot while (p > domain && *--p != '.') ; diff --git a/tests/test-is-public-all.c b/tests/test-is-public-all.c index 016a85c..a784dec 100644 --- a/tests/test-is-public-all.c +++ b/tests/test-is-public-all.c @@ -21,7 +21,7 @@ * * This file is part of the test suite of libpsl. * - * Test psl_is_public() for all entries in effective_tld_names.dat + * Test psl_is_public_suffix() for all entries in effective_tld_names.dat * * Changelog * 19.03.2014 Tim Ruehsen created @@ -67,38 +67,38 @@ static void test_psl(void) *linep = 0; if (*p == '!') { // an exception to a wildcard, e.g. !www.ck (wildcard is *.ck) - if ((result = psl_is_public(psl, p + 1))) { + if ((result = psl_is_public_suffix(psl, p + 1))) { failed++; - printf("psl_is_public(%s)=%d (expected 0)\n", p, result); + printf("psl_is_public_suffix(%s)=%d (expected 0)\n", p, result); } else ok++; - if (!(result = psl_is_public(psl, strchr(p, '.') + 1))) { + if (!(result = psl_is_public_suffix(psl, strchr(p, '.') + 1))) { failed++; - printf("psl_is_public(%s)=%d (expected 1)\n", strchr(p, '.') + 1, result); + printf("psl_is_public_suffix(%s)=%d (expected 1)\n", strchr(p, '.') + 1, result); } else ok++; } else if (*p == '*') { // a wildcard, e.g. *.ck - if (!(result = psl_is_public(psl, p + 1))) { + if (!(result = psl_is_public_suffix(psl, p + 1))) { failed++; - printf("psl_is_public(%s)=%d (expected 1)\n", p + 1, result); + printf("psl_is_public_suffix(%s)=%d (expected 1)\n", p + 1, result); } else ok++; *p = 'x'; - if (!(result = psl_is_public(psl, p))) { + if (!(result = psl_is_public_suffix(psl, p))) { failed++; - printf("psl_is_public(%s)=%d (expected 1)\n", p, result); + printf("psl_is_public_suffix(%s)=%d (expected 1)\n", p, result); } else ok++; } else { - if (!(result = psl_is_public(psl, p))) { + if (!(result = psl_is_public_suffix(psl, p))) { failed++; - printf("psl_is_public(%s)=%d (expected 1)\n", p, result); + printf("psl_is_public_suffix(%s)=%d (expected 1)\n", p, result); } else ok++; snprintf(domain, sizeof(domain), "xxxx.%s", p); - if ((result = psl_is_public(psl, domain))) { + if ((result = psl_is_public_suffix(psl, domain))) { failed++; - printf("psl_is_public(%s)=%d (expected 0)\n", domain, result); + printf("psl_is_public_suffix(%s)=%d (expected 0)\n", domain, result); } else ok++; } } diff --git a/tests/test-is-public-builtin.c b/tests/test-is-public-builtin.c index 0a94915..7f53b63 100644 --- a/tests/test-is-public-builtin.c +++ b/tests/test-is-public-builtin.c @@ -78,13 +78,13 @@ static void test_psl(void) for (it = 0; it < countof(test_data); it++) { const struct test_data *t = &test_data[it]; - int result = psl_is_public(psl, t->domain); + int result = psl_is_public_suffix(psl, t->domain); if (result == t->result) { ok++; } else { failed++; - printf("psl_is_public(%s)=%d (expected %d)\n", t->domain, result, t->result); + printf("psl_is_public_suffix(%s)=%d (expected %d)\n", t->domain, result, t->result); } } diff --git a/tests/test-is-public.c b/tests/test-is-public.c index 0155804..c6dc149 100644 --- a/tests/test-is-public.c +++ b/tests/test-is-public.c @@ -21,7 +21,7 @@ * * This file is part of the test suite of libpsl. * - * Test case for psl_load_file(), psl_is_public(), psl_free() + * Test case for psl_load_file(), psl_is_public_suffix(), psl_free() * * Changelog * 19.03.2014 Tim Ruehsen created from libmget/cookie.c @@ -76,13 +76,13 @@ static void test_psl(void) for (it = 0; it < countof(test_data); it++) { const struct test_data *t = &test_data[it]; - int result = psl_is_public(psl, t->domain); + int result = psl_is_public_suffix(psl, t->domain); if (result == t->result) { ok++; } else { failed++; - printf("psl_is_public(%s)=%d (expected %d)\n", t->domain, result, t->result); + printf("psl_is_public_suffix(%s)=%d (expected %d)\n", t->domain, result, t->result); } } diff --git a/tools/psl.c b/tools/psl.c index ff57435..6b5d0fb 100644 --- a/tools/psl.c +++ b/tools/psl.c @@ -83,7 +83,7 @@ int main(int argc, const char *const *argv) if (mode == 1) { for (; arg < argv + argc; arg++) - printf("%s: %d\n", *arg, psl_is_public(psl, *arg)); + printf("%s: %d\n", *arg, psl_is_public_suffix(psl, *arg)); } else if (mode == 2) { for (; arg < argv + argc; arg++)