source: appstream-generator/build/girepo/glib/Hostname.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

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