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 gtkc.glib;
29 public  import gtkc.glibtypes;
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 	 * Params:
64 	 *     hostname = a hostname (or IP address in string form)
65 	 *
66 	 * Returns: %TRUE if @hostname is an IP address
67 	 *
68 	 * Since: 2.22
69 	 */
70 	public static bool isIpAddress(string hostname)
71 	{
72 		return g_hostname_is_ip_address(Str.toStringz(hostname)) != 0;
73 	}
74 
75 	/**
76 	 * Tests if @hostname contains Unicode characters. If this returns
77 	 * %TRUE, you need to encode the hostname with g_hostname_to_ascii()
78 	 * before using it in non-IDN-aware contexts.
79 	 *
80 	 * Note that a hostname might contain a mix of encoded and unencoded
81 	 * segments, and so it is possible for g_hostname_is_non_ascii() and
82 	 * g_hostname_is_ascii_encoded() to both return %TRUE for a name.
83 	 *
84 	 * Params:
85 	 *     hostname = a hostname
86 	 *
87 	 * Returns: %TRUE if @hostname contains any non-ASCII characters
88 	 *
89 	 * Since: 2.22
90 	 */
91 	public static bool isNonAscii(string hostname)
92 	{
93 		return g_hostname_is_non_ascii(Str.toStringz(hostname)) != 0;
94 	}
95 
96 	/**
97 	 * Converts @hostname to its canonical ASCII form; an ASCII-only
98 	 * string containing no uppercase letters and not ending with a
99 	 * trailing dot.
100 	 *
101 	 * Params:
102 	 *     hostname = a valid UTF-8 or ASCII hostname
103 	 *
104 	 * Returns: an ASCII hostname, which must be freed, or %NULL if
105 	 *     @hostname is in some way invalid.
106 	 *
107 	 * Since: 2.22
108 	 */
109 	public static string toAscii(string hostname)
110 	{
111 		auto retStr = g_hostname_to_ascii(Str.toStringz(hostname));
112 		
113 		scope(exit) Str.freeString(retStr);
114 		return Str.toString(retStr);
115 	}
116 
117 	/**
118 	 * Converts @hostname to its canonical presentation form; a UTF-8
119 	 * string in Unicode normalization form C, containing no uppercase
120 	 * letters, no forbidden characters, and no ASCII-encoded segments,
121 	 * and not ending with a trailing dot.
122 	 *
123 	 * Of course if @hostname is not an internationalized hostname, then
124 	 * the canonical presentation form will be entirely ASCII.
125 	 *
126 	 * Params:
127 	 *     hostname = a valid UTF-8 or ASCII hostname
128 	 *
129 	 * Returns: a UTF-8 hostname, which must be freed, or %NULL if
130 	 *     @hostname is in some way invalid.
131 	 *
132 	 * Since: 2.22
133 	 */
134 	public static string toUnicode(string hostname)
135 	{
136 		auto retStr = g_hostname_to_unicode(Str.toStringz(hostname));
137 		
138 		scope(exit) Str.freeString(retStr);
139 		return Str.toString(retStr);
140 	}
141 }