Annotation of embedaddon/libiconv/include/iconv.h.in, revision 1.1.1.2

1.1.1.2 ! misho       1: /* Copyright (C) 1999-2003, 2005-2006, 2008-2011 Free Software Foundation, Inc.
1.1       misho       2:    This file is part of the GNU LIBICONV Library.
                      3: 
                      4:    The GNU LIBICONV Library is free software; you can redistribute it
                      5:    and/or modify it under the terms of the GNU Library General Public
                      6:    License as published by the Free Software Foundation; either version 2
                      7:    of the License, or (at your option) any later version.
                      8: 
                      9:    The GNU LIBICONV Library is distributed in the hope that it will be
                     10:    useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
                     11:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
                     12:    Library General Public License for more details.
                     13: 
                     14:    You should have received a copy of the GNU Library General Public
                     15:    License along with the GNU LIBICONV Library; see the file COPYING.LIB.
                     16:    If not, write to the Free Software Foundation, Inc., 51 Franklin Street,
                     17:    Fifth Floor, Boston, MA 02110-1301, USA.  */
                     18: 
                     19: /* When installed, this file is called "iconv.h". */
                     20: 
                     21: #ifndef _LIBICONV_H
                     22: #define _LIBICONV_H
                     23: 
1.1.1.2 ! misho      24: #define _LIBICONV_VERSION 0x010E    /* version number: (major<<8) + minor */
1.1       misho      25: extern @DLL_VARIABLE@ int _libiconv_version; /* Likewise */
                     26: 
                     27: /* We would like to #include any system header file which could define
                     28:    iconv_t, 1. in order to eliminate the risk that the user gets compilation
                     29:    errors because some other system header file includes /usr/include/iconv.h
                     30:    which defines iconv_t or declares iconv after this file, 2. when compiling
                     31:    for LIBICONV_PLUG, we need the proper iconv_t type in order to produce
                     32:    binary compatible code.
                     33:    But gcc's #include_next is not portable. Thus, once libiconv's iconv.h
                     34:    has been installed in /usr/local/include, there is no way any more to
                     35:    include the original /usr/include/iconv.h. We simply have to get away
                     36:    without it.
                     37:    Ad 1. The risk that a system header file does
                     38:    #include "iconv.h"  or  #include_next "iconv.h"
                     39:    is small. They all do #include <iconv.h>.
                     40:    Ad 2. The iconv_t type is a pointer type in all cases I have seen. (It
                     41:    has to be a scalar type because (iconv_t)(-1) is a possible return value
                     42:    from iconv_open().) */
                     43: 
                     44: /* Define iconv_t ourselves. */
                     45: #undef iconv_t
                     46: #define iconv_t libiconv_t
                     47: typedef void* iconv_t;
                     48: 
                     49: /* Get size_t declaration.
                     50:    Get wchar_t declaration if it exists. */
                     51: #include <stddef.h>
                     52: 
                     53: /* Get errno declaration and values. */
                     54: #include <errno.h>
                     55: /* Some systems, like SunOS 4, don't have EILSEQ. Some systems, like BSD/OS,
                     56:    have EILSEQ in a different header.  On these systems, define EILSEQ
                     57:    ourselves. */
                     58: #ifndef EILSEQ
                     59: #define EILSEQ @EILSEQ@
                     60: #endif
                     61: 
                     62: 
                     63: #ifdef __cplusplus
                     64: extern "C" {
                     65: #endif
                     66: 
                     67: 
                     68: /* Allocates descriptor for code conversion from encoding ‘fromcode’ to
                     69:    encoding ‘tocode’. */
                     70: #ifndef LIBICONV_PLUG
                     71: #define iconv_open libiconv_open
                     72: #endif
                     73: extern iconv_t iconv_open (const char* tocode, const char* fromcode);
                     74: 
                     75: /* Converts, using conversion descriptor ‘cd’, at most ‘*inbytesleft’ bytes
                     76:    starting at ‘*inbuf’, writing at most ‘*outbytesleft’ bytes starting at
                     77:    ‘*outbuf’.
                     78:    Decrements ‘*inbytesleft’ and increments ‘*inbuf’ by the same amount.
                     79:    Decrements ‘*outbytesleft’ and increments ‘*outbuf’ by the same amount. */
                     80: #ifndef LIBICONV_PLUG
                     81: #define iconv libiconv
                     82: #endif
                     83: extern size_t iconv (iconv_t cd, @ICONV_CONST@ char* * inbuf, size_t *inbytesleft, char* * outbuf, size_t *outbytesleft);
                     84: 
                     85: /* Frees resources allocated for conversion descriptor ‘cd’. */
                     86: #ifndef LIBICONV_PLUG
                     87: #define iconv_close libiconv_close
                     88: #endif
                     89: extern int iconv_close (iconv_t cd);
                     90: 
                     91: 
1.1.1.2 ! misho      92: #ifdef __cplusplus
        !            93: }
        !            94: #endif
        !            95: 
        !            96: 
1.1       misho      97: #ifndef LIBICONV_PLUG
                     98: 
                     99: /* Nonstandard extensions. */
                    100: 
                    101: #if @USE_MBSTATE_T@
                    102: #if @BROKEN_WCHAR_H@
                    103: /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
                    104:    <wchar.h>.
                    105:    BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
                    106:    included before <wchar.h>.  */
                    107: #include <stddef.h>
                    108: #include <stdio.h>
                    109: #include <time.h>
                    110: #endif
                    111: #include <wchar.h>
                    112: #endif
                    113: 
1.1.1.2 ! misho     114: #ifdef __cplusplus
        !           115: extern "C" {
        !           116: #endif
        !           117: 
1.1       misho     118: /* A type that holds all memory needed by a conversion descriptor.
                    119:    A pointer to such an object can be used as an iconv_t. */
                    120: typedef struct {
                    121:   void* dummy1[28];
                    122: #if @USE_MBSTATE_T@
                    123:   mbstate_t dummy2;
                    124: #endif
                    125: } iconv_allocation_t;
                    126: 
                    127: /* Allocates descriptor for code conversion from encoding ‘fromcode’ to
                    128:    encoding ‘tocode’ into preallocated memory. Returns an error indicator
                    129:    (0 or -1 with errno set). */
                    130: #define iconv_open_into libiconv_open_into
                    131: extern int iconv_open_into (const char* tocode, const char* fromcode,
                    132:                             iconv_allocation_t* resultp);
                    133: 
                    134: /* Control of attributes. */
                    135: #define iconvctl libiconvctl
                    136: extern int iconvctl (iconv_t cd, int request, void* argument);
                    137: 
                    138: /* Hook performed after every successful conversion of a Unicode character. */
                    139: typedef void (*iconv_unicode_char_hook) (unsigned int uc, void* data);
                    140: /* Hook performed after every successful conversion of a wide character. */
                    141: typedef void (*iconv_wide_char_hook) (wchar_t wc, void* data);
                    142: /* Set of hooks. */
                    143: struct iconv_hooks {
                    144:   iconv_unicode_char_hook uc_hook;
                    145:   iconv_wide_char_hook wc_hook;
                    146:   void* data;
                    147: };
                    148: 
                    149: /* Fallback function.  Invoked when a small number of bytes could not be
                    150:    converted to a Unicode character.  This function should process all
                    151:    bytes from inbuf and may produce replacement Unicode characters by calling
                    152:    the write_replacement callback repeatedly.  */
                    153: typedef void (*iconv_unicode_mb_to_uc_fallback)
                    154:              (const char* inbuf, size_t inbufsize,
                    155:               void (*write_replacement) (const unsigned int *buf, size_t buflen,
                    156:                                          void* callback_arg),
                    157:               void* callback_arg,
                    158:               void* data);
                    159: /* Fallback function.  Invoked when a Unicode character could not be converted
                    160:    to the target encoding.  This function should process the character and
                    161:    may produce replacement bytes (in the target encoding) by calling the
                    162:    write_replacement callback repeatedly.  */
                    163: typedef void (*iconv_unicode_uc_to_mb_fallback)
                    164:              (unsigned int code,
                    165:               void (*write_replacement) (const char *buf, size_t buflen,
                    166:                                          void* callback_arg),
                    167:               void* callback_arg,
                    168:               void* data);
                    169: #if @HAVE_WCHAR_T@
                    170: /* Fallback function.  Invoked when a number of bytes could not be converted to
                    171:    a wide character.  This function should process all bytes from inbuf and may
                    172:    produce replacement wide characters by calling the write_replacement
                    173:    callback repeatedly.  */
                    174: typedef void (*iconv_wchar_mb_to_wc_fallback)
                    175:              (const char* inbuf, size_t inbufsize,
                    176:               void (*write_replacement) (const wchar_t *buf, size_t buflen,
                    177:                                          void* callback_arg),
                    178:               void* callback_arg,
                    179:               void* data);
                    180: /* Fallback function.  Invoked when a wide character could not be converted to
                    181:    the target encoding.  This function should process the character and may
                    182:    produce replacement bytes (in the target encoding) by calling the
                    183:    write_replacement callback repeatedly.  */
                    184: typedef void (*iconv_wchar_wc_to_mb_fallback)
                    185:              (wchar_t code,
                    186:               void (*write_replacement) (const char *buf, size_t buflen,
                    187:                                          void* callback_arg),
                    188:               void* callback_arg,
                    189:               void* data);
                    190: #else
                    191: /* If the wchar_t type does not exist, these two fallback functions are never
                    192:    invoked.  Their argument list therefore does not matter.  */
                    193: typedef void (*iconv_wchar_mb_to_wc_fallback) ();
                    194: typedef void (*iconv_wchar_wc_to_mb_fallback) ();
                    195: #endif
                    196: /* Set of fallbacks. */
                    197: struct iconv_fallbacks {
                    198:   iconv_unicode_mb_to_uc_fallback mb_to_uc_fallback;
                    199:   iconv_unicode_uc_to_mb_fallback uc_to_mb_fallback;
                    200:   iconv_wchar_mb_to_wc_fallback mb_to_wc_fallback;
                    201:   iconv_wchar_wc_to_mb_fallback wc_to_mb_fallback;
                    202:   void* data;
                    203: };
                    204: 
                    205: /* Requests for iconvctl. */
                    206: #define ICONV_TRIVIALP            0  /* int *argument */
                    207: #define ICONV_GET_TRANSLITERATE   1  /* int *argument */
                    208: #define ICONV_SET_TRANSLITERATE   2  /* const int *argument */
                    209: #define ICONV_GET_DISCARD_ILSEQ   3  /* int *argument */
                    210: #define ICONV_SET_DISCARD_ILSEQ   4  /* const int *argument */
                    211: #define ICONV_SET_HOOKS           5  /* const struct iconv_hooks *argument */
                    212: #define ICONV_SET_FALLBACKS       6  /* const struct iconv_fallbacks *argument */
                    213: 
                    214: /* Listing of locale independent encodings. */
                    215: #define iconvlist libiconvlist
                    216: extern void iconvlist (int (*do_one) (unsigned int namescount,
                    217:                                       const char * const * names,
                    218:                                       void* data),
                    219:                        void* data);
                    220: 
                    221: /* Canonicalize an encoding name.
                    222:    The result is either a canonical encoding name, or name itself. */
                    223: extern const char * iconv_canonicalize (const char * name);
                    224: 
                    225: /* Support for relocatable packages.  */
                    226: 
                    227: /* Sets the original and the current installation prefix of the package.
                    228:    Relocation simply replaces a pathname starting with the original prefix
                    229:    by the corresponding pathname with the current prefix instead.  Both
                    230:    prefixes should be directory names without trailing slash (i.e. use ""
                    231:    instead of "/").  */
                    232: extern void libiconv_set_relocation_prefix (const char *orig_prefix,
1.1.1.2 ! misho     233:                                             const char *curr_prefix);
1.1       misho     234: 
                    235: #ifdef __cplusplus
                    236: }
                    237: #endif
                    238: 
1.1.1.2 ! misho     239: #endif
        !           240: 
1.1       misho     241: 
                    242: #endif /* _LIBICONV_H */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>