1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module glib.Hostname;
26 
27 private import glib.Str;
28 private import glib.c.functions;
29 public  import glib.c.types;
30 
31 
32 /** */
33 public struct Hostname
34 {
35 
36 	/**
37 	 * Tests if @hostname contains segments with an ASCII-compatible
38 	 * encoding of an Internationalized Domain Name. If this returns
39 	 * %TRUE, you should decode the hostname with g_hostname_to_unicode()
40 	 * before displaying it to the user.
41 	 *
42 	 * Note that a hostname might contain a mix of encoded and unencoded
43 	 * segments, and so it is possible for g_hostname_is_non_ascii() and
44 	 * g_hostname_is_ascii_encoded() to both return %TRUE for a name.
45 	 *
46 	 * Params:
47 	 *     hostname = a hostname
48 	 *
49 	 * Returns: %TRUE if @hostname contains any ASCII-encoded
50 	 *     segments.
51 	 *
52 	 * Since: 2.22
53 	 */
54 	public static bool isAsciiEncoded(string hostname)
55 	{
56 		return g_hostname_is_ascii_encoded(Str.toStringz(hostname)) != 0;
57 	}
58 
59 	/**
60 	 * Tests if @hostname is the string form of an IPv4 or IPv6 address.
61 	 * (Eg, "192.168.0.1".)
62 	 *
63 	 * Since 2.66, IPv6 addresses with a zone-id are accepted (RFC6874).
64 	 *
65 	 * Params:
66 	 *     hostname = a hostname (or IP address in string form)
67 	 *
68 	 * Returns: %TRUE if @hostname is an IP address
69 	 *
70 	 * Since: 2.22
71 	 */
72 	public static bool isIpAddress(string hostname)
73 	{
74 		return g_hostname_is_ip_address(Str.toStringz(hostname)) != 0;
75 	}
76 
77 	/**
78 	 * Tests if @hostname contains Unicode characters. If this returns
79 	 * %TRUE, you need to encode the hostname with g_hostname_to_ascii()
80 	 * before using it in non-IDN-aware contexts.
81 	 *
82 	 * Note that a hostname might contain a mix of encoded and unencoded
83 	 * segments, and so it is possible for g_hostname_is_non_ascii() and
84 	 * g_hostname_is_ascii_encoded() to both return %TRUE for a name.
85 	 *
86 	 * Params:
87 	 *     hostname = a hostname
88 	 *
89 	 * Returns: %TRUE if @hostname contains any non-ASCII characters
90 	 *
91 	 * Since: 2.22
92 	 */
93 	public static bool isNonAscii(string hostname)
94 	{
95 		return g_hostname_is_non_ascii(Str.toStringz(hostname)) != 0;
96 	}
97 
98 	/**
99 	 * Converts @hostname to its canonical ASCII form; an ASCII-only
100 	 * string containing no uppercase letters and not ending with a
101 	 * trailing dot.
102 	 *
103 	 * Params:
104 	 *     hostname = a valid UTF-8 or ASCII hostname
105 	 *
106 	 * Returns: an ASCII hostname, which must be freed,
107 	 *     or %NULL if @hostname is in some way invalid.
108 	 *
109 	 * Since: 2.22
110 	 */
111 	public static string toAscii(string hostname)
112 	{
113 		auto retStr = g_hostname_to_ascii(Str.toStringz(hostname));
114 
115 		scope(exit) Str.freeString(retStr);
116 		return Str.toString(retStr);
117 	}
118 
119 	/**
120 	 * Converts @hostname to its canonical presentation form; a UTF-8
121 	 * string in Unicode normalization form C, containing no uppercase
122 	 * letters, no forbidden characters, and no ASCII-encoded segments,
123 	 * and not ending with a trailing dot.
124 	 *
125 	 * Of course if @hostname is not an internationalized hostname, then
126 	 * the canonical presentation form will be entirely ASCII.
127 	 *
128 	 * Params:
129 	 *     hostname = a valid UTF-8 or ASCII hostname
130 	 *
131 	 * Returns: a UTF-8 hostname, which must be freed,
132 	 *     or %NULL if @hostname is in some way invalid.
133 	 *
134 	 * Since: 2.22
135 	 */
136 	public static string toUnicode(string hostname)
137 	{
138 		auto retStr = g_hostname_to_unicode(Str.toStringz(hostname));
139 
140 		scope(exit) Str.freeString(retStr);
141 		return Str.toString(retStr);
142 	}
143 }