Back to index

glibc  2.9
idna.h
Go to the documentation of this file.
00001 /* idna.h     Declarations for IDNA.
00002  * Copyright (C) 2002, 2003, 2004  Simon Josefsson
00003  *
00004  * This file is part of GNU Libidn.
00005  *
00006  * GNU Libidn is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * GNU Libidn is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with GNU Libidn; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 #ifndef _IDNA_H
00023 #define _IDNA_H
00024 
00025 #ifdef __cplusplus
00026 extern "C"
00027 {
00028 #endif
00029 
00030 #include <stddef.h>         /* size_t */
00031 #include <stdint.h>         /* uint32_t */
00032 
00033   /* Error codes. */
00034   typedef enum
00035   {
00036     IDNA_SUCCESS = 0,
00037     IDNA_STRINGPREP_ERROR = 1,
00038     IDNA_PUNYCODE_ERROR = 2,
00039     IDNA_CONTAINS_NON_LDH = 3,
00040     /* Workaround typo in earlier versions. */
00041     IDNA_CONTAINS_LDH = IDNA_CONTAINS_NON_LDH,
00042     IDNA_CONTAINS_MINUS = 4,
00043     IDNA_INVALID_LENGTH = 5,
00044     IDNA_NO_ACE_PREFIX = 6,
00045     IDNA_ROUNDTRIP_VERIFY_ERROR = 7,
00046     IDNA_CONTAINS_ACE_PREFIX = 8,
00047     IDNA_ICONV_ERROR = 9,
00048     /* Internal errors. */
00049     IDNA_MALLOC_ERROR = 201,
00050     IDNA_DLOPEN_ERROR = 202
00051   } Idna_rc;
00052 
00053   /* IDNA flags */
00054   typedef enum
00055   {
00056     IDNA_ALLOW_UNASSIGNED = 0x0001,
00057     IDNA_USE_STD3_ASCII_RULES = 0x0002
00058   } Idna_flags;
00059 
00060 #ifndef IDNA_ACE_PREFIX
00061 #define IDNA_ACE_PREFIX "xn--"
00062 #endif
00063 
00064   /* Core functions */
00065   extern int idna_to_ascii_4i (const uint32_t * in, size_t inlen,
00066                             char *out, int flags);
00067   extern int idna_to_unicode_44i (const uint32_t * in, size_t inlen,
00068                               uint32_t * out, size_t * outlen, int flags);
00069 
00070   /* Wrappers that handle several labels */
00071 
00072   extern int idna_to_ascii_4z (const uint32_t * input,
00073                             char **output, int flags);
00074 
00075   extern int idna_to_ascii_8z (const char *input, char **output, int flags);
00076 
00077   extern int idna_to_ascii_lz (const char *input, char **output, int flags);
00078 
00079 
00080   extern int idna_to_unicode_4z4z (const uint32_t * input,
00081                                uint32_t ** output, int flags);
00082 
00083   extern int idna_to_unicode_8z4z (const char *input,
00084                                uint32_t ** output, int flags);
00085 
00086   extern int idna_to_unicode_8z8z (const char *input,
00087                                char **output, int flags);
00088 
00089   extern int idna_to_unicode_8zlz (const char *input,
00090                                char **output, int flags);
00091 
00092   extern int idna_to_unicode_lzlz (const char *input,
00093                                char **output, int flags);
00094 
00095 #ifdef __cplusplus
00096 }
00097 #endif
00098 #endif                      /* _PUNYCODE_H */