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