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 public  import gtkc.glibtypes;
31 
32 
33 /** */
34 public struct Hostname
35 {
36 
37 	/**
38 	 * Tests if @hostname contains segments with an ASCII-compatible
39 	 * encoding of an Internationalized Domain Name. If this returns
40 	 * %TRUE, you should decode the hostname with g_hostname_to_unicode()
41 	 * before displaying it to the user.
42 	 *
43 	 * Note that a hostname might contain a mix of encoded and unencoded
44 	 * segments, and so it is possible for g_hostname_is_non_ascii() and
45 	 * g_hostname_is_ascii_encoded() to both return %TRUE for a name.
46 	 *
47 	 * Params:
48 	 *     hostname = a hostname
49 	 *
50 	 * Returns: %TRUE if @hostname contains any ASCII-encoded
51 	 *     segments.
52 	 *
53 	 * Since: 2.22
54 	 */
55 	public static bool isAsciiEncoded(string hostname)
56 	{
57 		return g_hostname_is_ascii_encoded(Str.toStringz(hostname)) != 0;
58 	}
59 
60 	/**
61 	 * Tests if @hostname is the string form of an IPv4 or IPv6 address.
62 	 * (Eg, "192.168.0.1".)
63 	 *
64 	 * Params:
65 	 *     hostname = a hostname (or IP address in string form)
66 	 *
67 	 * Returns: %TRUE if @hostname is an IP address
68 	 *
69 	 * Since: 2.22
70 	 */
71 	public static bool isIpAddress(string hostname)
72 	{
73 		return g_hostname_is_ip_address(Str.toStringz(hostname)) != 0;
74 	}
75 
76 	/**
77 	 * Tests if @hostname contains Unicode characters. If this returns
78 	 * %TRUE, you need to encode the hostname with g_hostname_to_ascii()
79 	 * before using it in non-IDN-aware contexts.
80 	 *
81 	 * Note that a hostname might contain a mix of encoded and unencoded
82 	 * segments, and so it is possible for g_hostname_is_non_ascii() and
83 	 * g_hostname_is_ascii_encoded() to both return %TRUE for a name.
84 	 *
85 	 * Params:
86 	 *     hostname = a hostname
87 	 *
88 	 * Returns: %TRUE if @hostname contains any non-ASCII characters
89 	 *
90 	 * Since: 2.22
91 	 */
92 	public static bool isNonAscii(string hostname)
93 	{
94 		return g_hostname_is_non_ascii(Str.toStringz(hostname)) != 0;
95 	}
96 
97 	/**
98 	 * Converts @hostname to its canonical ASCII form; an ASCII-only
99 	 * string containing no uppercase letters and not ending with a
100 	 * trailing dot.
101 	 *
102 	 * Params:
103 	 *     hostname = a valid UTF-8 or ASCII hostname
104 	 *
105 	 * Returns: an ASCII hostname, which must be freed, or %NULL if
106 	 *     @hostname is in some way invalid.
107 	 *
108 	 * Since: 2.22
109 	 */
110 	public static string toAscii(string hostname)
111 	{
112 		auto retStr = g_hostname_to_ascii(Str.toStringz(hostname));
113 
114 		scope(exit) Str.freeString(retStr);
115 		return Str.toString(retStr);
116 	}
117 
118 	/**
119 	 * Converts @hostname to its canonical presentation form; a UTF-8
120 	 * string in Unicode normalization form C, containing no uppercase
121 	 * letters, no forbidden characters, and no ASCII-encoded segments,
122 	 * and not ending with a trailing dot.
123 	 *
124 	 * Of course if @hostname is not an internationalized hostname, then
125 	 * the canonical presentation form will be entirely ASCII.
126 	 *
127 	 * Params:
128 	 *     hostname = a valid UTF-8 or ASCII hostname
129 	 *
130 	 * Returns: a UTF-8 hostname, which must be freed, or %NULL if
131 	 *     @hostname is in some way invalid.
132 	 *
133 	 * Since: 2.22
134 	 */
135 	public static string toUnicode(string hostname)
136 	{
137 		auto retStr = g_hostname_to_unicode(Str.toStringz(hostname));
138 
139 		scope(exit) Str.freeString(retStr);
140 		return Str.toString(retStr);
141 	}
142 }