File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / libiconv / include / iconv.h.build.in
Revision 1.1.1.3 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Mar 17 13:38:46 2021 UTC (3 years, 9 months ago) by misho
Branches: libiconv, MAIN
CVS tags: v1_16p0, HEAD
libiconv 1.16

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

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