| lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /* idna.h	Declarations for IDNA. | 
|  | 2 | * Copyright (C) 2002, 2003, 2004  Simon Josefsson | 
|  | 3 | * | 
|  | 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 the GNU Lesser General Public | 
|  | 8 | * License as published by the Free Software Foundation; either | 
|  | 9 | * version 2.1 of the License, or (at your option) any later version. | 
|  | 10 | * | 
|  | 11 | * GNU Libidn is distributed in the hope that it will be useful, | 
|  | 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 | * | 
|  | 16 | * You should have received a copy of the GNU Lesser General Public | 
|  | 17 | * License along with GNU Libidn; if not, see <http://www.gnu.org/licenses/>. | 
|  | 18 | */ | 
|  | 19 |  | 
|  | 20 | #ifndef _IDNA_H | 
|  | 21 | #define _IDNA_H | 
|  | 22 |  | 
|  | 23 | #ifdef __cplusplus | 
|  | 24 | extern "C" | 
|  | 25 | { | 
|  | 26 | #endif | 
|  | 27 |  | 
|  | 28 | #include <stddef.h>		/* size_t */ | 
|  | 29 | #include <stdint.h>		/* uint32_t */ | 
|  | 30 |  | 
|  | 31 | /* Error codes. */ | 
|  | 32 | typedef enum | 
|  | 33 | { | 
|  | 34 | IDNA_SUCCESS = 0, | 
|  | 35 | IDNA_STRINGPREP_ERROR = 1, | 
|  | 36 | IDNA_PUNYCODE_ERROR = 2, | 
|  | 37 | IDNA_CONTAINS_NON_LDH = 3, | 
|  | 38 | /* Workaround typo in earlier versions. */ | 
|  | 39 | IDNA_CONTAINS_LDH = IDNA_CONTAINS_NON_LDH, | 
|  | 40 | IDNA_CONTAINS_MINUS = 4, | 
|  | 41 | IDNA_INVALID_LENGTH = 5, | 
|  | 42 | IDNA_NO_ACE_PREFIX = 6, | 
|  | 43 | IDNA_ROUNDTRIP_VERIFY_ERROR = 7, | 
|  | 44 | IDNA_CONTAINS_ACE_PREFIX = 8, | 
|  | 45 | IDNA_ICONV_ERROR = 9, | 
|  | 46 | /* Internal errors. */ | 
|  | 47 | IDNA_MALLOC_ERROR = 201, | 
|  | 48 | IDNA_DLOPEN_ERROR = 202 | 
|  | 49 | } Idna_rc; | 
|  | 50 |  | 
|  | 51 | /* IDNA flags */ | 
|  | 52 | typedef enum | 
|  | 53 | { | 
|  | 54 | IDNA_ALLOW_UNASSIGNED = 0x0001, | 
|  | 55 | IDNA_USE_STD3_ASCII_RULES = 0x0002 | 
|  | 56 | } Idna_flags; | 
|  | 57 |  | 
|  | 58 | #ifndef IDNA_ACE_PREFIX | 
|  | 59 | #define IDNA_ACE_PREFIX "xn--" | 
|  | 60 | #endif | 
|  | 61 |  | 
|  | 62 | /* Core functions */ | 
|  | 63 | extern int idna_to_ascii_4i (const uint32_t * in, size_t inlen, | 
|  | 64 | char *out, int flags); | 
|  | 65 | extern int idna_to_unicode_44i (const uint32_t * in, size_t inlen, | 
|  | 66 | uint32_t * out, size_t * outlen, int flags); | 
|  | 67 |  | 
|  | 68 | /* Wrappers that handle several labels */ | 
|  | 69 |  | 
|  | 70 | extern int idna_to_ascii_4z (const uint32_t * input, | 
|  | 71 | char **output, int flags); | 
|  | 72 |  | 
|  | 73 | extern int idna_to_ascii_8z (const char *input, char **output, int flags); | 
|  | 74 |  | 
|  | 75 | extern int idna_to_ascii_lz (const char *input, char **output, int flags); | 
|  | 76 |  | 
|  | 77 |  | 
|  | 78 | extern int idna_to_unicode_4z4z (const uint32_t * input, | 
|  | 79 | uint32_t ** output, int flags); | 
|  | 80 |  | 
|  | 81 | extern int idna_to_unicode_8z4z (const char *input, | 
|  | 82 | uint32_t ** output, int flags); | 
|  | 83 |  | 
|  | 84 | extern int idna_to_unicode_8z8z (const char *input, | 
|  | 85 | char **output, int flags); | 
|  | 86 |  | 
|  | 87 | extern int idna_to_unicode_8zlz (const char *input, | 
|  | 88 | char **output, int flags); | 
|  | 89 |  | 
|  | 90 | extern int idna_to_unicode_lzlz (const char *input, | 
|  | 91 | char **output, int flags); | 
|  | 92 |  | 
|  | 93 | #ifdef __cplusplus | 
|  | 94 | } | 
|  | 95 | #endif | 
|  | 96 | #endif				/* _PUNYCODE_H */ |