int
ns_samedomain(constchar *a, constchar *b) {
size_t la, lb, i; int diff, escaped; constchar *cp;
la = strlen(a);
lb = strlen(b);
/* Ignore a trailing label separator (i.e. an unescaped dot) in 'a'. */ if (la != 0U && a[la - 1] == '.') {
escaped = 0; /* Note this loop doesn't get executed if la==1. */ for (i = la - 1; i > 0; i--) if (a[i - 1] == '\\') { if (escaped)
escaped = 0; else
escaped = 1;
} else break; if (!escaped)
la--;
}
/* Ignore a trailing label separator (i.e. an unescaped dot) in 'b'. */ if (lb != 0U && b[lb - 1] == '.') {
escaped = 0; /* note this loop doesn't get executed if lb==1 */ for (i = lb - 1; i > 0; i--) if (b[i - 1] == '\\') { if (escaped)
escaped = 0; else
escaped = 1;
} else break; if (!escaped)
lb--;
}
/* lb == 0 means 'b' is the root domain, so 'a' must be in 'b'. */ if (lb == 0U) return (1);
/* 'b' longer than 'a' means 'a' can't be in 'b'. */ if (lb > la) return (0);
/* 'a' and 'b' being equal at this point indicates sameness. */ if (lb == la) return (strncasecmp(a, b, lb) == 0);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.