summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '3rdParty/LibIDN/src/punycode.h')
-rw-r--r--3rdParty/LibIDN/src/punycode.h139
1 files changed, 80 insertions, 59 deletions
diff --git a/3rdParty/LibIDN/src/punycode.h b/3rdParty/LibIDN/src/punycode.h
index 4872417..dff2105 100644
--- a/3rdParty/LibIDN/src/punycode.h
+++ b/3rdParty/LibIDN/src/punycode.h
@@ -1,74 +1,93 @@
1/* punycode.h --- Declarations for punycode functions. 1/* punycode.h --- Declarations for punycode functions.
2 * Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Simon Josefsson 2 Copyright (C) 2002-2015 Simon Josefsson
3 * 3
4 * This file is part of GNU Libidn. 4 This file is part of GNU Libidn.
5
6 GNU Libidn is free software: you can redistribute it and/or
7 modify it under the terms of either:
8
9 * the GNU Lesser General Public License as published by the Free
10 Software Foundation; either version 3 of the License, or (at
11 your option) any later version.
12
13 or
14
15 * the GNU General Public License as published by the Free
16 Software Foundation; either version 2 of the License, or (at
17 your option) any later version.
18
19 or both in parallel, as here.
20
21 GNU Libidn is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 General Public License for more details.
25
26 You should have received copies of the GNU General Public License and
27 the GNU Lesser General Public License along with this program. If
28 not, see <http://www.gnu.org/licenses/>. */
29
30/*
31 * This file is derived from RFC 3492bis written by Adam M. Costello,
32 * downloaded from http://www.nicemice.net/idn/punycode-spec.gz on
33 * 2015-03-02 with SHA1 a966a8017f6be579d74a50a226accc7607c40133, a
34 * copy of which is stored in the GNU Libidn version controlled
35 * repository under doc/specification/punycode-spec.gz.
5 * 36 *
6 * GNU Libidn is free software; you can redistribute it and/or 37 * The changes compared to Adam's file include: re-indentation, adding
7 * modify it under the terms of the GNU Lesser General Public 38 * the license boilerplate and this comment, adding the #ifndef
8 * License as published by the Free Software Foundation; either 39 * PUNYCODE_H and IDNAPI blocks, changing the return code of
9 * version 2.1 of the License, or (at your option) any later version. 40 * punycode_encode and punycode_decode from enum to int, simplifying
41 * the definition of punycode_uint by #include'ing idn-int.h and using
42 * uint32_t instead of limit.h-based code, adding Punycode_status and
43 * punycode_strerror, adding 'extern IDNAPI' declarations to function
44 * prototypes, and mentioning variable names in function prototypes.
10 * 45 *
11 * GNU Libidn is distributed in the hope that it will be useful, 46 * Adam's file contains the following:
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 * 47 *
16 * You should have received a copy of the GNU Lesser General Public 48 * punycode-sample.c 2.0.0 (2004-Mar-21-Sun)
17 * License along with GNU Libidn; if not, write to the Free Software 49 * http://www.nicemice.net/idn/
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 50 * Adam M. Costello
51 * http://www.nicemice.net/amc/
19 * 52 *
20 */ 53 * This is ANSI C code (C89) implementing Punycode 1.0.x.
21
22/*
23 * This file is derived from RFC 3492bis written by Adam M. Costello.
24 * 54 *
25 * Disclaimer and license: Regarding this entire document or any 55 * Disclaimer and license: Regarding this entire document or any
26 * portion of it (including the pseudocode and C code), the author 56 * portion of it (including the pseudocode and C code), the author
27 * makes no guarantees and is not responsible for any damage resulting 57 * makes no guarantees and is not responsible for any damage resulting
28 * from its use. The author grants irrevocable permission to anyone 58 * from its use. The author grants irrevocable permission to anyone
29 * to use, modify, and distribute it in any way that does not diminish 59 * to use, modify, and distribute it in any way that does not diminish
30 * the rights of anyone else to use, modify, and distribute it, 60 * the rights of anyone else to use, modify, and distribute it,
31 * provided that redistributed derivative works do not contain 61 * provided that redistributed derivative works do not contain
32 * misleading author or version information. Derivative works need 62 * misleading author or version information. Derivative works need
33 * not be licensed under similar terms. 63 * not be licensed under similar terms.
34 *
35 * Copyright (C) The Internet Society (2003). All Rights Reserved.
36 *
37 * This document and translations of it may be copied and furnished to
38 * others, and derivative works that comment on or otherwise explain it
39 * or assist in its implementation may be prepared, copied, published
40 * and distributed, in whole or in part, without restriction of any
41 * kind, provided that the above copyright notice and this paragraph are
42 * included on all such copies and derivative works. However, this
43 * document itself may not be modified in any way, such as by removing
44 * the copyright notice or references to the Internet Society or other
45 * Internet organizations, except as needed for the purpose of
46 * developing Internet standards in which case the procedures for
47 * copyrights defined in the Internet Standards process must be
48 * followed, or as required to translate it into languages other than
49 * English.
50 *
51 * The limited permissions granted above are perpetual and will not be
52 * revoked by the Internet Society or its successors or assigns.
53 *
54 * This document and the information contained herein is provided on an
55 * "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
56 * TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
57 * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
58 * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
59 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
60 */ 64 */
61 65
62#ifndef _PUNYCODE_H 66#ifndef PUNYCODE_H
63#define _PUNYCODE_H 67# define PUNYCODE_H
68
69# ifndef IDNAPI
70# if defined LIBIDN_BUILDING && defined HAVE_VISIBILITY && HAVE_VISIBILITY
71# define IDNAPI __attribute__((__visibility__("default")))
72# elif defined LIBIDN_BUILDING && defined _MSC_VER && ! defined LIBIDN_STATIC
73# define IDNAPI __declspec(dllexport)
74# elif defined _MSC_VER && ! defined LIBIDN_STATIC
75# define IDNAPI __declspec(dllimport)
76# else
77# define IDNAPI
78# endif
79# endif
64 80
65#ifdef __cplusplus 81#ifdef __cplusplus
66extern "C" 82extern "C"
67{ 83{
68#endif 84#endif
69 85
86/************************************************************/
87/* Public interface (would normally go in its own .h file): */
88
70#include <stddef.h> /* size_t */ 89#include <stddef.h> /* size_t */
71#include <idn-int.h> /* uint32_t */ 90#include <idn-int.h> /* uint32_t */
72 91
73 enum punycode_status 92 enum punycode_status
74 { 93 {
@@ -84,21 +103,23 @@ extern "C"
84 PUNYCODE_BAD_INPUT = punycode_bad_input, 103 PUNYCODE_BAD_INPUT = punycode_bad_input,
85 PUNYCODE_BIG_OUTPUT = punycode_big_output, 104 PUNYCODE_BIG_OUTPUT = punycode_big_output,
86 PUNYCODE_OVERFLOW = punycode_overflow 105 PUNYCODE_OVERFLOW = punycode_overflow
87 } Punycode_status; 106 } Punycode_status;
88 107
89 extern const char *punycode_strerror (Punycode_status rc); 108 extern IDNAPI const char *punycode_strerror (Punycode_status rc);
90 109
91/* punycode_uint needs to be unsigned and needs to be */ 110/* punycode_uint needs to be unsigned and needs to be */
92/* at least 26 bits wide. */ 111/* at least 26 bits wide. The particular type can be */
112/* specified by defining PUNYCODE_UINT, otherwise a */
113/* suitable type will be chosen automatically. */
93 114
94 typedef uint32_t punycode_uint; 115 typedef uint32_t punycode_uint;
95 116
96 extern int punycode_encode (size_t input_length, 117 extern IDNAPI int punycode_encode (size_t input_length,
97 const punycode_uint input[], 118 const punycode_uint input[],
98 const unsigned char case_flags[], 119 const unsigned char case_flags[],
99 size_t * output_length, char output[]); 120 size_t * output_length, char output[]);
100 121
101/* 122/*
102 punycode_encode() converts a sequence of code points (presumed to be 123 punycode_encode() converts a sequence of code points (presumed to be
103 Unicode code points) to Punycode. 124 Unicode code points) to Punycode.
104 125
@@ -108,11 +129,11 @@ extern "C"
108 The number of code points in the input array and the number 129 The number of code points in the input array and the number
109 of flags in the case_flags array. 130 of flags in the case_flags array.
110 131
111 input 132 input
112 An array of code points. They are presumed to be Unicode 133 An array of code points. They are presumed to be Unicode
113 code points, but that is not strictly REQUIRED. The 134 code points, but that is not strictly necessary. The
114 array contains code points, not code units. UTF-16 uses 135 array contains code points, not code units. UTF-16 uses
115 code units D800 through DFFF to refer to code points 136 code units D800 through DFFF to refer to code points
116 10000..10FFFF. The code points D800..DFFF do not occur in 137 10000..10FFFF. The code points D800..DFFF do not occur in
117 any valid Unicode string. The code points that can occur in 138 any valid Unicode string. The code points that can occur in
118 Unicode strings (0..D7FF and E000..10FFFF) are also called 139 Unicode strings (0..D7FF and E000..10FFFF) are also called
@@ -151,15 +172,15 @@ extern "C"
151 Can be any of the punycode_status values defined above except 172 Can be any of the punycode_status values defined above except
152 punycode_bad_input. If not punycode_success, then output_size 173 punycode_bad_input. If not punycode_success, then output_size
153 and output might contain garbage. 174 and output might contain garbage.
154*/ 175*/
155 176
156 extern int punycode_decode (size_t input_length, 177 extern IDNAPI int punycode_decode (size_t input_length,
157 const char input[], 178 const char input[],
158 size_t * output_length, 179 size_t * output_length,
159 punycode_uint output[], 180 punycode_uint output[],
160 unsigned char case_flags[]); 181 unsigned char case_flags[]);
161 182
162/* 183/*
163 punycode_decode() converts Punycode to a sequence of code points 184 punycode_decode() converts Punycode to a sequence of code points
164 (presumed to be Unicode code points). 185 (presumed to be Unicode code points).
165 186
@@ -213,6 +234,6 @@ extern "C"
213*/ 234*/
214 235
215#ifdef __cplusplus 236#ifdef __cplusplus
216} 237}
217#endif 238#endif
218#endif /* _PUNYCODE_H */ 239#endif /* PUNYCODE_H */