renamed psl_is_public() to psl_is_public_suffix()

This commit is contained in:
Tim Ruehsen 2014-04-12 16:04:42 +02:00
parent af717a0d80
commit b49e681d8f
7 changed files with 26 additions and 26 deletions

View File

@ -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

View File

@ -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);

View File

@ -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 != '.')
;

View File

@ -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++;
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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++)