Example #1
0
/*
 * SOA RNAMEs and RP RNAMEs can have any printable character in their first
 * label, but the rest of the name has to look like a host name.
 */
int
res_mailok(
    const char *dn
    )
{
    int ch, escaped = 0;

    /* "." is a valid missing representation */
    if (*dn == '\0')
        return (1);

    /* otherwise <label>.<hostname> */
    while ((ch = *dn++) != '\0') {
        if (!domainchar(ch))
            return (0);
        if (!escaped && periodchar(ch))
            break;
        if (escaped)
            escaped = 0;
        else if (bslashchar(ch))
            escaped = 1;
    }
    if (periodchar(ch))
        return (res_hnok(dn));
    return (0);
}
Example #2
0
int
res_hnok(
    const char *dn
    )
{
    int ppch = '\0', pch = PERIOD, ch = *dn++;

    while (ch != '\0') {
        int nch = *dn++;

        if (periodchar(ch)) {
            (void)NULL;
        } else if (periodchar(pch)) {
            if (!borderchar(ch))
                return (0);
        } else if (periodchar(nch) || nch == '\0') {
            if (!borderchar(ch))
                return (0);
        } else {
            if (!middlechar(ch))
                return (0);
        }
        ppch = pch, pch = ch, ch = nch;
    }
    return (1);
}
Example #3
0
/*
 * hostname-like (A, MX, WKS) owners can have "*" as their first label
 * but must otherwise be as a host name.
 */
int
res_ownok(const char *dn) {
	if (asterchar(dn[0])) {
		if (periodchar(dn[1]))
			return (res_hnok(dn+2));
		if (dn[1] == '\0')
			return (1);
	}
	return (res_hnok(dn));
}