basic: add STRCASE_IN_SET() which is to STR_IN_SET() what strcaseeq() is to streq()
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
2d4f8cf467
commit
ddd6a22a0f
@@ -12,6 +12,7 @@
|
||||
#include "hostname-util.h"
|
||||
#include "macro.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
|
||||
bool hostname_is_set(void) {
|
||||
struct utsname u;
|
||||
@@ -180,14 +181,16 @@ bool is_localhost(const char *hostname) {
|
||||
/* This tries to identify local host and domain names
|
||||
* described in RFC6761 plus the redhatism of localdomain */
|
||||
|
||||
return strcaseeq(hostname, "localhost") ||
|
||||
strcaseeq(hostname, "localhost.") ||
|
||||
strcaseeq(hostname, "localhost.localdomain") ||
|
||||
strcaseeq(hostname, "localhost.localdomain.") ||
|
||||
endswith_no_case(hostname, ".localhost") ||
|
||||
endswith_no_case(hostname, ".localhost.") ||
|
||||
endswith_no_case(hostname, ".localhost.localdomain") ||
|
||||
endswith_no_case(hostname, ".localhost.localdomain.");
|
||||
return STRCASE_IN_SET(
|
||||
hostname,
|
||||
"localhost",
|
||||
"localhost.",
|
||||
"localhost.localdomain",
|
||||
"localhost.localdomain.") ||
|
||||
endswith_no_case(hostname, ".localhost") ||
|
||||
endswith_no_case(hostname, ".localhost.") ||
|
||||
endswith_no_case(hostname, ".localhost.localdomain") ||
|
||||
endswith_no_case(hostname, ".localhost.localdomain.");
|
||||
}
|
||||
|
||||
bool is_gateway_hostname(const char *hostname) {
|
||||
|
||||
Reference in New Issue
Block a user