rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | /* Copyright (C) 1999-2003 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, write to the Free Software Foundation, Inc., 59 Temple Place - |
| 17 | Suite 330, Boston, MA 02111-1307, USA. */ |
| 18 | |
| 19 | /* When installed, this file is called "iconv.h". */ |
| 20 | |
| 21 | #ifndef _LIBICONV_H |
| 22 | #define _LIBICONV_H |
| 23 | |
| 24 | #define _LIBICONV_VERSION 0x0109 /* version number: (major<<8) + minor */ |
| 25 | extern 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 | #include <stddef.h> |
| 51 | |
| 52 | /* Get errno declaration and values. */ |
| 53 | #include <errno.h> |
| 54 | /* Some systems, like SunOS 4, don't have EILSEQ. Some systems, like BSD/OS, |
| 55 | have EILSEQ in a different header. On these systems, define EILSEQ |
| 56 | ourselves. */ |
| 57 | #ifndef EILSEQ |
| 58 | /* Igor: called upon EILSEQ from glibc, since autogeneration of this header |
| 59 | on Windows didn't do the job. */ |
| 60 | /* #define EILSEQ @EILSEQ@ */ |
| 61 | #define EILSEQ 84 |
| 62 | #endif |
| 63 | |
| 64 | |
| 65 | #ifdef __cplusplus |
| 66 | extern "C" { |
| 67 | #endif |
| 68 | |
| 69 | |
| 70 | /* Allocates descriptor for code conversion from encoding `fromcode' to |
| 71 | encoding `tocode'. */ |
| 72 | #ifndef LIBICONV_PLUG |
| 73 | #define iconv_open libiconv_open |
| 74 | #endif |
| 75 | extern iconv_t iconv_open (const char* tocode, const char* fromcode); |
| 76 | |
| 77 | /* Converts, using conversion descriptor `cd', at most `*inbytesleft' bytes |
| 78 | starting at `*inbuf', writing at most `*outbytesleft' bytes starting at |
| 79 | `*outbuf'. |
| 80 | Decrements `*inbytesleft' and increments `*inbuf' by the same amount. |
| 81 | Decrements `*outbytesleft' and increments `*outbuf' by the same amount. */ |
| 82 | #ifndef LIBICONV_PLUG |
| 83 | #define iconv libiconv |
| 84 | #endif |
| 85 | extern size_t iconv (iconv_t cd, const char* * inbuf, size_t *inbytesleft, char* * outbuf, size_t *outbytesleft); |
| 86 | |
| 87 | /* Frees resources allocated for conversion descriptor `cd'. */ |
| 88 | #ifndef LIBICONV_PLUG |
| 89 | #define iconv_close libiconv_close |
| 90 | #endif |
| 91 | extern int iconv_close (iconv_t cd); |
| 92 | |
| 93 | |
| 94 | #ifndef LIBICONV_PLUG |
| 95 | |
| 96 | /* Nonstandard extensions. */ |
| 97 | |
| 98 | /* Control of attributes. */ |
| 99 | #define iconvctl libiconvctl |
| 100 | extern int iconvctl (iconv_t cd, int request, void* argument); |
| 101 | |
| 102 | /* Requests for iconvctl. */ |
| 103 | #define ICONV_TRIVIALP 0 /* int *argument */ |
| 104 | #define ICONV_GET_TRANSLITERATE 1 /* int *argument */ |
| 105 | #define ICONV_SET_TRANSLITERATE 2 /* const int *argument */ |
| 106 | #define ICONV_GET_DISCARD_ILSEQ 3 /* int *argument */ |
| 107 | #define ICONV_SET_DISCARD_ILSEQ 4 /* const int *argument */ |
| 108 | |
| 109 | /* Listing of locale independent encodings. */ |
| 110 | #define iconvlist libiconvlist |
| 111 | extern void iconvlist (int (*do_one) (unsigned int namescount, |
| 112 | const char * const * names, |
| 113 | void* data), |
| 114 | void* data); |
| 115 | |
| 116 | /* Support for relocatable packages. */ |
| 117 | |
| 118 | /* Sets the original and the current installation prefix of the package. |
| 119 | Relocation simply replaces a pathname starting with the original prefix |
| 120 | by the corresponding pathname with the current prefix instead. Both |
| 121 | prefixes should be directory names without trailing slash (i.e. use "" |
| 122 | instead of "/"). */ |
| 123 | extern void libiconv_set_relocation_prefix (const char *orig_prefix, |
| 124 | const char *curr_prefix); |
| 125 | |
| 126 | #endif |
| 127 | |
| 128 | |
| 129 | #ifdef __cplusplus |
| 130 | } |
| 131 | #endif |
| 132 | |
| 133 | |
| 134 | #endif /* _LIBICONV_H */ |