aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/libidn/lib/stringprep.h
diff options
context:
space:
mode:
authorarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-03-10 13:12:41 +0300
committerarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-03-10 13:12:41 +0300
commit712efbec47eaf34f7090523deae64736322625ff (patch)
treef09ca53b6a1610fadc8050585f193036f9d6693c /contrib/libs/libidn/lib/stringprep.h
parent4cee9b5ad6d8fef0473d919c885dd4dbd4e1f528 (diff)
downloadydb-712efbec47eaf34f7090523deae64736322625ff.tar.gz
intermediate changes
ref:fb7ad851ba1976a5ebbb58c649dad3fda69b7111
Diffstat (limited to 'contrib/libs/libidn/lib/stringprep.h')
-rw-r--r--contrib/libs/libidn/lib/stringprep.h241
1 files changed, 241 insertions, 0 deletions
diff --git a/contrib/libs/libidn/lib/stringprep.h b/contrib/libs/libidn/lib/stringprep.h
new file mode 100644
index 0000000000..9b977d3142
--- /dev/null
+++ b/contrib/libs/libidn/lib/stringprep.h
@@ -0,0 +1,241 @@
+/* stringprep.h --- Header file for stringprep functions. -*- c -*-
+ * Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Simon Josefsson
+ *
+ * This file is part of GNU Libidn.
+ *
+ * GNU Libidn is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * GNU Libidn is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GNU Libidn; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ *
+ */
+
+#ifndef _STRINGPREP_H
+#define _STRINGPREP_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <stddef.h> /* size_t */
+#ifdef _WIN32
+ #include "win/unistd.h"
+#else
+ #include <unistd.h> /* ssize_t */
+#endif
+#include "idn-int.h" /* uint32_t */
+
+ /* On Windows, variables that may be in a DLL must be marked
+ * specially. This is only active when not building libidn itself
+ * (!LIBIDN_BUILDING). It is only used for MinGW which declare
+ * __DECLSPEC_SUPPORTED or MSVC (_MSC_VER && _DLL). */
+#if !defined (LIBIDN_BUILDING) && (defined(__DECLSPEC_SUPPORTED) || (defined(_MSC_VER) && defined(_DLL)))
+# define IDN_DLL_VAR __declspec (dllimport)
+#else
+# define IDN_DLL_VAR
+#endif
+
+#define STRINGPREP_VERSION "1.9"
+#define LIBIDN_STATIC
+
+/* Libidn Windows DLL */
+#ifndef LIBIDN_API
+# if defined(_WIN32) && !defined(LIBIDN_STATIC)
+# ifdef LIBIDN_EXPORTS
+# define LIBIDN_API __declspec(dllexport)
+# else /* LIBIDN_EXPORTS */
+# define LIBIDN_API __declspec(dllimport)
+# endif /* LIBIDN_EXPORTS */
+# else /* _WIN32 && !LIBIDN_STATIC */
+# define LIBIDN_API extern
+# endif /* _WIN32 && !LIBIDN_STATIC */
+#endif /* LIBIDN_API */
+
+/* Error codes. */
+ typedef enum
+ {
+ STRINGPREP_OK = 0,
+ /* Stringprep errors. */
+ STRINGPREP_CONTAINS_UNASSIGNED = 1,
+ STRINGPREP_CONTAINS_PROHIBITED = 2,
+ STRINGPREP_BIDI_BOTH_L_AND_RAL = 3,
+ STRINGPREP_BIDI_LEADTRAIL_NOT_RAL = 4,
+ STRINGPREP_BIDI_CONTAINS_PROHIBITED = 5,
+ /* Error in calling application. */
+ STRINGPREP_TOO_SMALL_BUFFER = 100,
+ STRINGPREP_PROFILE_ERROR = 101,
+ STRINGPREP_FLAG_ERROR = 102,
+ STRINGPREP_UNKNOWN_PROFILE = 103,
+ /* Internal errors. */
+ STRINGPREP_NFKC_FAILED = 200,
+ STRINGPREP_MALLOC_ERROR = 201
+ } Stringprep_rc;
+
+/* Flags used when calling stringprep(). */
+ typedef enum
+ {
+ STRINGPREP_NO_NFKC = 1,
+ STRINGPREP_NO_BIDI = 2,
+ STRINGPREP_NO_UNASSIGNED = 4
+ } Stringprep_profile_flags;
+
+/* Steps in a stringprep profile. */
+ typedef enum
+ {
+ STRINGPREP_NFKC = 1,
+ STRINGPREP_BIDI = 2,
+ STRINGPREP_MAP_TABLE = 3,
+ STRINGPREP_UNASSIGNED_TABLE = 4,
+ STRINGPREP_PROHIBIT_TABLE = 5,
+ STRINGPREP_BIDI_PROHIBIT_TABLE = 6,
+ STRINGPREP_BIDI_RAL_TABLE = 7,
+ STRINGPREP_BIDI_L_TABLE = 8
+ } Stringprep_profile_steps;
+
+#define STRINGPREP_MAX_MAP_CHARS 4
+
+ struct Stringprep_table_element
+ {
+ uint32_t start;
+ uint32_t end; /* 0 if only one character */
+ uint32_t map[STRINGPREP_MAX_MAP_CHARS]; /* NULL if end is not 0 */
+ };
+ typedef struct Stringprep_table_element Stringprep_table_element;
+
+ struct Stringprep_table
+ {
+ Stringprep_profile_steps operation;
+ Stringprep_profile_flags flags;
+ const Stringprep_table_element *table;
+ };
+ typedef struct Stringprep_table Stringprep_profile;
+
+ struct Stringprep_profiles
+ {
+ const char *name;
+ const Stringprep_profile *tables;
+ };
+ typedef struct Stringprep_profiles Stringprep_profiles;
+
+ LIBIDN_API const Stringprep_profiles stringprep_profiles[];
+
+/* Profiles */
+ LIBIDN_API const Stringprep_table_element stringprep_rfc3454_A_1[];
+ LIBIDN_API const Stringprep_table_element stringprep_rfc3454_B_1[];
+ LIBIDN_API const Stringprep_table_element stringprep_rfc3454_B_2[];
+ LIBIDN_API const Stringprep_table_element stringprep_rfc3454_B_3[];
+ LIBIDN_API const Stringprep_table_element stringprep_rfc3454_C_1_1[];
+ LIBIDN_API const Stringprep_table_element stringprep_rfc3454_C_1_2[];
+ LIBIDN_API const Stringprep_table_element stringprep_rfc3454_C_2_1[];
+ LIBIDN_API const Stringprep_table_element stringprep_rfc3454_C_2_2[];
+ LIBIDN_API const Stringprep_table_element stringprep_rfc3454_C_3[];
+ LIBIDN_API const Stringprep_table_element stringprep_rfc3454_C_4[];
+ LIBIDN_API const Stringprep_table_element stringprep_rfc3454_C_5[];
+ LIBIDN_API const Stringprep_table_element stringprep_rfc3454_C_6[];
+ LIBIDN_API const Stringprep_table_element stringprep_rfc3454_C_7[];
+ LIBIDN_API const Stringprep_table_element stringprep_rfc3454_C_8[];
+ LIBIDN_API const Stringprep_table_element stringprep_rfc3454_C_9[];
+ LIBIDN_API const Stringprep_table_element stringprep_rfc3454_D_1[];
+ LIBIDN_API const Stringprep_table_element stringprep_rfc3454_D_2[];
+
+ /* Nameprep */
+
+ LIBIDN_API const Stringprep_profile stringprep_nameprep[];
+
+#define stringprep_nameprep(in, maxlen) \
+ stringprep(in, maxlen, 0, stringprep_nameprep)
+
+#define stringprep_nameprep_no_unassigned(in, maxlen) \
+ stringprep(in, maxlen, STRINGPREP_NO_UNASSIGNED, stringprep_nameprep)
+
+ /* SASL */
+
+ LIBIDN_API const Stringprep_profile stringprep_saslprep[];
+ LIBIDN_API const Stringprep_profile stringprep_plain[];
+ LIBIDN_API const Stringprep_profile stringprep_trace[];
+
+#define stringprep_plain(in, maxlen) \
+ stringprep(in, maxlen, 0, stringprep_plain)
+
+ /* Kerberos */
+
+ LIBIDN_API const Stringprep_profile stringprep_kerberos5[];
+
+#define stringprep_kerberos5(in, maxlen) \
+ stringprep(in, maxlen, 0, stringprep_kerberos5)
+
+ /* XMPP */
+
+ LIBIDN_API const Stringprep_profile stringprep_xmpp_nodeprep[];
+ LIBIDN_API const Stringprep_profile stringprep_xmpp_resourceprep[];
+ LIBIDN_API const Stringprep_table_element stringprep_xmpp_nodeprep_prohibit[];
+
+#define stringprep_xmpp_nodeprep(in, maxlen) \
+ stringprep(in, maxlen, 0, stringprep_xmpp_nodeprep)
+#define stringprep_xmpp_resourceprep(in, maxlen) \
+ stringprep(in, maxlen, 0, stringprep_xmpp_resourceprep)
+
+ /* iSCSI */
+
+ LIBIDN_API const Stringprep_profile stringprep_iscsi[];
+
+#define stringprep_iscsi(in, maxlen) \
+ stringprep(in, maxlen, 0, stringprep_iscsi)
+
+ /* API */
+
+ LIBIDN_API int stringprep_4i (uint32_t * ucs4, size_t * len, size_t maxucs4len,
+ Stringprep_profile_flags flags,
+ const Stringprep_profile * profile);
+ LIBIDN_API int stringprep_4zi (uint32_t * ucs4, size_t maxucs4len,
+ Stringprep_profile_flags flags,
+ const Stringprep_profile * profile);
+ LIBIDN_API int stringprep (char *in, size_t maxlen,
+ Stringprep_profile_flags flags,
+ const Stringprep_profile * profile);
+
+ LIBIDN_API int stringprep_profile (const char *in,
+ char **out,
+ const char *profile,
+ Stringprep_profile_flags flags);
+
+ LIBIDN_API const char *stringprep_strerror (Stringprep_rc rc);
+
+ LIBIDN_API const char *stringprep_check_version (const char *req_version);
+
+/* Utility */
+
+ LIBIDN_API int stringprep_unichar_to_utf8 (uint32_t c, char *outbuf);
+ LIBIDN_API uint32_t stringprep_utf8_to_unichar (const char *p);
+
+ LIBIDN_API uint32_t *stringprep_utf8_to_ucs4 (const char *str, ssize_t len,
+ size_t * items_written);
+ LIBIDN_API char *stringprep_ucs4_to_utf8 (const uint32_t * str, ssize_t len,
+ size_t * items_read,
+ size_t * items_written);
+
+ LIBIDN_API char *stringprep_utf8_nfkc_normalize (const char *str, ssize_t len);
+ LIBIDN_API uint32_t *stringprep_ucs4_nfkc_normalize (uint32_t * str,
+ ssize_t len);
+
+ LIBIDN_API const char *stringprep_locale_charset (void);
+ LIBIDN_API char *stringprep_convert (const char *str,
+ const char *to_codeset,
+ const char *from_codeset);
+ LIBIDN_API char *stringprep_locale_to_utf8 (const char *str);
+ LIBIDN_API char *stringprep_utf8_to_locale (const char *str);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _STRINGPREP_H */