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 * Conversion parameters: 26 * inFile = glib-Hostname-Utilities.html 27 * outPack = glib 28 * outFile = Hostname 29 * strct = 30 * realStrct= 31 * ctorStrct= 32 * clss = Hostname 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - g_hostname_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * structWrap: 48 * module aliases: 49 * local aliases: 50 * overrides: 51 */ 52 53 module glib.Hostname; 54 55 public import gtkc.glibtypes; 56 57 private import gtkc.glib; 58 private import glib.ConstructionException; 59 60 private import glib.Str; 61 62 63 64 /** 65 * Functions for manipulating internet hostnames; in particular, for 66 * converting between Unicode and ASCII-encoded forms of 67 * Internationalized Domain Names (IDNs). 68 * 69 * The Internationalized Domain 70 * Names for Applications (IDNA) standards allow for the use 71 * of Unicode domain names in applications, while providing 72 * backward-compatibility with the old ASCII-only DNS, by defining an 73 * ASCII-Compatible Encoding of any given Unicode name, which can be 74 * used with non-IDN-aware applications and protocols. (For example, 75 * "Παν語.org" maps to "xn--4wa8awb4637h.org".) 76 */ 77 public class Hostname 78 { 79 80 /** 81 */ 82 83 /** 84 * Converts hostname to its canonical ASCII form; an ASCII-only 85 * string containing no uppercase letters and not ending with a 86 * trailing dot. 87 * Since 2.22 88 * Params: 89 * hostname = a valid UTF-8 or ASCII hostname 90 * Returns: an ASCII hostname, which must be freed, or NULL if hostname is in some way invalid. 91 */ 92 public static string toAscii(string hostname) 93 { 94 // gchar * g_hostname_to_ascii (const gchar *hostname); 95 return Str.toString(g_hostname_to_ascii(Str.toStringz(hostname))); 96 } 97 98 /** 99 * Converts hostname to its canonical presentation form; a UTF-8 100 * string in Unicode normalization form C, containing no uppercase 101 * letters, no forbidden characters, and no ASCII-encoded segments, 102 * and not ending with a trailing dot. 103 * Of course if hostname is not an internationalized hostname, then 104 * the canonical presentation form will be entirely ASCII. 105 * Since 2.22 106 * Params: 107 * hostname = a valid UTF-8 or ASCII hostname 108 * Returns: a UTF-8 hostname, which must be freed, or NULL if hostname is in some way invalid. 109 */ 110 public static string toUnicode(string hostname) 111 { 112 // gchar * g_hostname_to_unicode (const gchar *hostname); 113 return Str.toString(g_hostname_to_unicode(Str.toStringz(hostname))); 114 } 115 116 /** 117 * Tests if hostname contains Unicode characters. If this returns 118 * TRUE, you need to encode the hostname with g_hostname_to_ascii() 119 * before using it in non-IDN-aware contexts. 120 * Note that a hostname might contain a mix of encoded and unencoded 121 * segments, and so it is possible for g_hostname_is_non_ascii() and 122 * g_hostname_is_ascii_encoded() to both return TRUE for a name. 123 * Since 2.22 124 * Params: 125 * hostname = a hostname 126 * Returns: TRUE if hostname contains any non-ASCII characters 127 */ 128 public static int isNonAscii(string hostname) 129 { 130 // gboolean g_hostname_is_non_ascii (const gchar *hostname); 131 return g_hostname_is_non_ascii(Str.toStringz(hostname)); 132 } 133 134 /** 135 * Tests if hostname contains segments with an ASCII-compatible 136 * encoding of an Internationalized Domain Name. If this returns 137 * TRUE, you should decode the hostname with g_hostname_to_unicode() 138 * before displaying it to the user. 139 * Note that a hostname might contain a mix of encoded and unencoded 140 * segments, and so it is possible for g_hostname_is_non_ascii() and 141 * g_hostname_is_ascii_encoded() to both return TRUE for a name. 142 * Since 2.22 143 * Params: 144 * hostname = a hostname 145 * Returns: TRUE if hostname contains any ASCII-encoded segments. 146 */ 147 public static int isAsciiEncoded(string hostname) 148 { 149 // gboolean g_hostname_is_ascii_encoded (const gchar *hostname); 150 return g_hostname_is_ascii_encoded(Str.toStringz(hostname)); 151 } 152 153 /** 154 * Tests if hostname is the string form of an IPv4 or IPv6 address. 155 * (Eg, "192.168.0.1".) 156 * Since 2.22 157 * Params: 158 * hostname = a hostname (or IP address in string form) 159 * Returns: TRUE if hostname is an IP address 160 */ 161 public static int isIpAddress(string hostname) 162 { 163 // gboolean g_hostname_is_ip_address (const gchar *hostname); 164 return g_hostname_is_ip_address(Str.toStringz(hostname)); 165 } 166 }