| 1 | /* idna.h Declarations for IDNA.
|
|---|
| 2 | * Copyright (C) 2002, 2003 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, write to the Free Software
|
|---|
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 19 | *
|
|---|
| 20 | */
|
|---|
| 21 |
|
|---|
| 22 | #ifndef _IDNA_H
|
|---|
| 23 | #define _IDNA_H
|
|---|
| 24 |
|
|---|
| 25 | #ifdef __cplusplus
|
|---|
| 26 | extern "C"
|
|---|
| 27 | {
|
|---|
| 28 | #endif
|
|---|
| 29 |
|
|---|
| 30 | #include <stddef.h> /* size_t */
|
|---|
| 31 | #include <idn-int.h> /* my_uint32_t */
|
|---|
| 32 |
|
|---|
| 33 | /* Error codes. */
|
|---|
| 34 | typedef enum
|
|---|
| 35 | {
|
|---|
| 36 | IDNA_SUCCESS = 0,
|
|---|
| 37 | IDNA_STRINGPREP_ERROR = 1,
|
|---|
| 38 | IDNA_PUNYCODE_ERROR = 2,
|
|---|
| 39 | IDNA_CONTAINS_LDH = 3,
|
|---|
| 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_rc;
|
|---|
| 49 |
|
|---|
| 50 | /* IDNA flags */
|
|---|
| 51 | typedef enum
|
|---|
| 52 | {
|
|---|
| 53 | IDNA_ALLOW_UNASSIGNED = 0x0001,
|
|---|
| 54 | IDNA_USE_STD3_ASCII_RULES = 0x0002
|
|---|
| 55 | } Idna_flags;
|
|---|
| 56 |
|
|---|
| 57 | #ifndef IDNA_ACE_PREFIX
|
|---|
| 58 | #define IDNA_ACE_PREFIX "xn--"
|
|---|
| 59 | #endif
|
|---|
| 60 |
|
|---|
| 61 | /* Core functions */
|
|---|
| 62 | extern int idna_to_ascii_4i (const my_uint32_t * in, size_t inlen,
|
|---|
| 63 | char *out, int flags);
|
|---|
| 64 | extern int idna_to_unicode_44i (const my_uint32_t * in, size_t inlen,
|
|---|
| 65 | my_uint32_t * out, size_t * outlen, int flags);
|
|---|
| 66 |
|
|---|
| 67 | /* Wrappers that handle several labels */
|
|---|
| 68 |
|
|---|
| 69 | extern int idna_to_ascii_4z (const my_uint32_t * input,
|
|---|
| 70 | char **output, int flags);
|
|---|
| 71 |
|
|---|
| 72 | extern int idna_to_ascii_8z (const char *input, char **output, int flags);
|
|---|
| 73 |
|
|---|
| 74 | extern int idna_to_ascii_lz (const char *input, char **output, int flags);
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 | extern int idna_to_unicode_4z4z (const my_uint32_t * input,
|
|---|
| 78 | my_uint32_t ** output, int flags);
|
|---|
| 79 |
|
|---|
| 80 | extern int idna_to_unicode_8z4z (const char *input,
|
|---|
| 81 | my_uint32_t ** output, int flags);
|
|---|
| 82 |
|
|---|
| 83 | extern int idna_to_unicode_8z8z (const char *input,
|
|---|
| 84 | char **output, int flags);
|
|---|
| 85 |
|
|---|
| 86 | extern int idna_to_unicode_8zlz (const char *input,
|
|---|
| 87 | char **output, int flags);
|
|---|
| 88 |
|
|---|
| 89 | extern int idna_to_unicode_lzlz (const char *input,
|
|---|
| 90 | char **output, int flags);
|
|---|
| 91 |
|
|---|
| 92 | #ifdef __cplusplus
|
|---|
| 93 | }
|
|---|
| 94 | #endif
|
|---|
| 95 | #endif /* _PUNYCODE_H */
|
|---|