Commit aa336e09 authored by Pekka Pessi's avatar Pekka Pessi

Doxument host name predicates.

darcs-hash:20060310181947-65a35-c37cadd406044ec69b9b453c4a6828fca6e07f2d.gz
parent 993bdc01
......@@ -663,10 +663,9 @@ int host_is_ip4_address(char const *string)
return n > 0 && string[n] == '\0';
}
/** Return true if @a string is valid IP4 address in dot-notation.
/** Return true if @a string is valid IP6 address in hex notation.
*
* @note Only 4-octet form is accepted, e.g., @c 127.1 is not considered
* valid IP4 address.
* E.g., fe80::1 is a valid IP6 address.
*/
int host_is_ip6_address(char const *string)
{
......@@ -674,31 +673,53 @@ int host_is_ip6_address(char const *string)
return n > 0 && string[n] == '\0';
}
/** Return true if @a string is valid IP6 reference,
* i.e. hex notation in square brackets.
*
* E.g., [::1] is a valid IP6 reference.
*/
int host_ip6_reference(char const *string)
{
int n = span_ip6_reference(string);
return n > 0 && string[n] == '\0';
}
/** Return true if @a string is valid IP address.
*
* Valid IP address is either a IP4 adddress in quad-octet notation,
* IP6 hex address or IP6 reference in square brackets ([]).
*/
int host_is_ip_address(char const *string)
{
int n = span_ip_address(string);
return n > 0 && string[n] == '\0';
}
/** Return true if @a string is valid a domain name.
*
* Valid domain name consists of alphanumeric labels separated with
* dot ("."). There can be a "-" in the middle of label.
* The last label must start with a letter.
*
* @code
* hostname = *( domainlabel "." ) toplabel [ "." ]
* domainlabel = alphanum
* / alphanum *( alphanum / "-" ) alphanum
* toplabel = ALPHA / ALPHA *( alphanum / "-" ) alphanum
* @endcode
*/
int host_is_domain(char *string)
{
int n = span_domain(string);
return n > 0 && string[n] == '\0';
}
/** Return true if @a string is valid a host name.
*
* Check if the @a string is a domain name, IP address or IP6 reference.
*/
int host_is_valid(char const *string)
{
int n = span_host(string);
return n > 0 && string[n] == '\0';
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment