1/* 2 * Copyright (C) 1999-2006 Free Software Foundation, Inc. 3 * This file is part of the GNU LIBICONV Library. 4 * 5 * The GNU LIBICONV Library is free software; you can redistribute it 6 * and/or modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either version 2 8 * of the License, or (at your option) any later version. 9 * 10 * The GNU LIBICONV Library is distributed in the hope that it will be 11 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public 16 * License along with the GNU LIBICONV Library; see the file COPYING.LIB. 17 * If not, write to the Free Software Foundation, Inc., 51 Franklin Street, 18 * Fifth Floor, Boston, MA 02110-1301, USA. 19 */ 20 21#include <iconv.h> 22 23#include <stdlib.h> 24#include <string.h> 25#include "config.h" 26#include "localcharset.h" 27 28#if ENABLE_EXTRA 29/* 30 * Consider all system dependent encodings, for any system, 31 * and the extra encodings. 32 */ 33#define USE_AIX 34#define USE_OSF1 35#define USE_DOS 36#define USE_EXTRA 37#else 38/* 39 * Consider those system dependent encodings that are needed for the 40 * current system. 41 */ 42#ifdef _AIX 43#define USE_AIX 44#endif 45#if defined(__osf__) || defined(VMS) 46#define USE_OSF1 47#endif 48#if defined(__DJGPP__) || (defined(_WIN32) && (defined(_MSC_VER) || defined(__MINGW32__))) 49#define USE_DOS 50#endif 51#endif 52 53/* 54 * Data type for general conversion loop. 55 */ 56struct loop_funcs { 57 size_t (*loop_convert) (iconv_t icd, 58 const char* * inbuf, size_t *inbytesleft, 59 char* * outbuf, size_t *outbytesleft); 60 size_t (*loop_reset) (iconv_t icd, 61 char* * outbuf, size_t *outbytesleft); 62}; 63 64/* 65 * Converters. 66 */ 67#include "converters.h" 68 69/* 70 * Transliteration tables. 71 */ 72#include "cjk_variants.h" 73#include "translit.h" 74 75/* 76 * Table of all supported encodings. 77 */ 78struct encoding { 79 struct mbtowc_funcs ifuncs; /* conversion multibyte -> unicode */ 80 struct wctomb_funcs ofuncs; /* conversion unicode -> multibyte */ 81 int oflags; /* flags for unicode -> multibyte conversion */ 82}; 83enum { 84#define DEFENCODING(xxx_names,xxx,xxx_ifuncs1,xxx_ifuncs2,xxx_ofuncs1,xxx_ofuncs2) \ 85 ei_##xxx , 86#include "encodings.def" 87#ifdef USE_AIX 88#include "encodings_aix.def" 89#endif 90#ifdef USE_OSF1 91#include "encodings_osf1.def" 92#endif 93#ifdef USE_DOS 94#include "encodings_dos.def" 95#endif 96#ifdef USE_EXTRA 97#include "encodings_extra.def" 98#endif 99#include "encodings_local.def" 100#undef DEFENCODING 101ei_for_broken_compilers_that_dont_like_trailing_commas 102}; 103#include "flags.h" 104static struct encoding const all_encodings[] = { 105#define DEFENCODING(xxx_names,xxx,xxx_ifuncs1,xxx_ifuncs2,xxx_ofuncs1,xxx_ofuncs2) \ 106 { xxx_ifuncs1,xxx_ifuncs2, xxx_ofuncs1,xxx_ofuncs2, ei_##xxx##_oflags }, 107#include "encodings.def" 108#ifdef USE_AIX 109#include "encodings_aix.def" 110#endif 111#ifdef USE_OSF1 112#include "encodings_osf1.def" 113#endif 114#ifdef USE_DOS 115#include "encodings_dos.def" 116#endif 117#ifdef USE_EXTRA 118#include "encodings_extra.def" 119#endif 120#undef DEFENCODING 121#define DEFENCODING(xxx_names,xxx,xxx_ifuncs1,xxx_ifuncs2,xxx_ofuncs1,xxx_ofuncs2) \ 122 { xxx_ifuncs1,xxx_ifuncs2, xxx_ofuncs1,xxx_ofuncs2, 0 }, 123#include "encodings_local.def" 124#undef DEFENCODING 125}; 126 127/* 128 * Conversion loops. 129 */ 130#include "loops.h" 131 132/* 133 * Alias lookup function. 134 * Defines 135 * struct alias { int name; unsigned int encoding_index; }; 136 * const struct alias * aliases_lookup (const char *str, unsigned int len); 137 * #define MAX_WORD_LENGTH ... 138 */ 139#include "aliases.h" 140 141/* 142 * System dependent alias lookup function. 143 * Defines 144 * const struct alias * aliases2_lookup (const char *str); 145 */ 146#if defined(USE_AIX) || defined(USE_OSF1) || defined(USE_DOS) || defined(USE_EXTRA) /* || ... */ 147struct stringpool2_t { 148#define S(tag,name,encoding_index) char stringpool_##tag[sizeof(name)]; 149#include "aliases2.h" 150#undef S 151}; 152static const struct stringpool2_t stringpool2_contents = { 153#define S(tag,name,encoding_index) name, 154#include "aliases2.h" 155#undef S 156}; 157#define stringpool2 ((const char *) &stringpool2_contents) 158static const struct alias sysdep_aliases[] = { 159#define S(tag,name,encoding_index) { (int)(long)&((struct stringpool2_t *)0)->stringpool_##tag, encoding_index }, 160#include "aliases2.h" 161#undef S 162}; 163const struct alias * 164aliases2_lookup (register const char *str) 165{ 166 const struct alias * ptr; 167 unsigned int count; 168 for (ptr = sysdep_aliases, count = sizeof(sysdep_aliases)/sizeof(sysdep_aliases[0]); count > 0; ptr++, count--) 169 if (!strcmp(str, stringpool2 + ptr->name)) 170 return ptr; 171 return NULL; 172} 173#else 174#define aliases2_lookup(str) NULL 175#define stringpool2 NULL 176#endif 177 178#if 0 179/* Like !strcasecmp, except that the both strings can be assumed to be ASCII 180 and the first string can be assumed to be in uppercase. */ 181static int strequal (const char* str1, const char* str2) 182{ 183 unsigned char c1; 184 unsigned char c2; 185 for (;;) { 186 c1 = * (unsigned char *) str1++; 187 c2 = * (unsigned char *) str2++; 188 if (c1 == 0) 189 break; 190 if (c2 >= 'a' && c2 <= 'z') 191 c2 -= 'a'-'A'; 192 if (c1 != c2) 193 break; 194 } 195 return (c1 == c2); 196} 197#endif 198 199iconv_t iconv_open (const char* tocode, const char* fromcode) 200{ 201 struct conv_struct * cd; 202 char buf[MAX_WORD_LENGTH+10+1]; 203 const char* cp; 204 char* bp; 205 const struct alias * ap; 206 unsigned int count; 207 unsigned int from_index; 208 int from_wchar; 209 unsigned int to_index; 210 int to_wchar; 211 int transliterate = 0; 212 int discard_ilseq = 0; 213 214 /* Before calling aliases_lookup, convert the input string to upper case, 215 * and check whether it's entirely ASCII (we call gperf with option "-7" 216 * to achieve a smaller table) and non-empty. If it's not entirely ASCII, 217 * or if it's too long, it is not a valid encoding name. 218 */ 219 for (to_wchar = 0;;) { 220 /* Search tocode in the table. */ 221 for (cp = tocode, bp = buf, count = MAX_WORD_LENGTH+10+1; ; cp++, bp++) { 222 unsigned char c = * (unsigned char *) cp; 223 if (c >= 0x80) 224 goto invalid; 225 if (c >= 'a' && c <= 'z') 226 c -= 'a'-'A'; 227 *bp = c; 228 if (c == '\0') 229 break; 230 if (--count == 0) 231 goto invalid; 232 } 233 for (;;) { 234 if (bp-buf >= 10 && memcmp(bp-10,"//TRANSLIT",10)==0) { 235 bp -= 10; 236 *bp = '\0'; 237 transliterate = 1; 238 continue; 239 } 240 if (bp-buf >= 8 && memcmp(bp-8,"//IGNORE",8)==0) { 241 bp -= 8; 242 *bp = '\0'; 243 discard_ilseq = 1; 244 continue; 245 } 246 break; 247 } 248 if (buf[0] == '\0') { 249 tocode = locale_charset(); 250 /* Avoid an endless loop that could occur when using an older version 251 of localcharset.c. */ 252 if (tocode[0] == '\0') 253 goto invalid; 254 continue; 255 } 256 ap = aliases_lookup(buf,(unsigned int)(bp-buf)); 257 if (ap == NULL) { 258 ap = aliases2_lookup(buf); 259 if (ap == NULL) 260 goto invalid; 261 } 262 if (ap->encoding_index == ei_local_char) { 263 tocode = locale_charset(); 264 /* Avoid an endless loop that could occur when using an older version 265 of localcharset.c. */ 266 if (tocode[0] == '\0') 267 goto invalid; 268 continue; 269 } 270 if (ap->encoding_index == ei_local_wchar_t) { 271#if __STDC_ISO_10646__ 272 if (sizeof(wchar_t) == 4) { 273 to_index = ei_ucs4internal; 274 break; 275 } 276 if (sizeof(wchar_t) == 2) { 277 to_index = ei_ucs2internal; 278 break; 279 } 280 if (sizeof(wchar_t) == 1) { 281 to_index = ei_iso8859_1; 282 break; 283 } 284#endif 285#if HAVE_MBRTOWC 286 to_wchar = 1; 287 tocode = locale_charset(); 288 continue; 289#endif 290 goto invalid; 291 } 292 to_index = ap->encoding_index; 293 break; 294 } 295 for (from_wchar = 0;;) { 296 /* Search fromcode in the table. */ 297 for (cp = fromcode, bp = buf, count = MAX_WORD_LENGTH+10+1; ; cp++, bp++) { 298 unsigned char c = * (unsigned char *) cp; 299 if (c >= 0x80) 300 goto invalid; 301 if (c >= 'a' && c <= 'z') 302 c -= 'a'-'A'; 303 *bp = c; 304 if (c == '\0') 305 break; 306 if (--count == 0) 307 goto invalid; 308 } 309 for (;;) { 310 if (bp-buf >= 10 && memcmp(bp-10,"//TRANSLIT",10)==0) { 311 bp -= 10; 312 *bp = '\0'; 313 continue; 314 } 315 if (bp-buf >= 8 && memcmp(bp-8,"//IGNORE",8)==0) { 316 bp -= 8; 317 *bp = '\0'; 318 continue; 319 } 320 break; 321 } 322 if (buf[0] == '\0') { 323 fromcode = locale_charset(); 324 /* Avoid an endless loop that could occur when using an older version 325 of localcharset.c. */ 326 if (fromcode[0] == '\0') 327 goto invalid; 328 continue; 329 } 330 ap = aliases_lookup(buf,(unsigned int)(bp-buf)); 331 if (ap == NULL) { 332 ap = aliases2_lookup(buf); 333 if (ap == NULL) 334 goto invalid; 335 } 336 if (ap->encoding_index == ei_local_char) { 337 fromcode = locale_charset(); 338 /* Avoid an endless loop that could occur when using an older version 339 of localcharset.c. */ 340 if (fromcode[0] == '\0') 341 goto invalid; 342 continue; 343 } 344 if (ap->encoding_index == ei_local_wchar_t) { 345#if __STDC_ISO_10646__ 346 if (sizeof(wchar_t) == 4) { 347 from_index = ei_ucs4internal; 348 break; 349 } 350 if (sizeof(wchar_t) == 2) { 351 from_index = ei_ucs2internal; 352 break; 353 } 354 if (sizeof(wchar_t) == 1) { 355 from_index = ei_iso8859_1; 356 break; 357 } 358#endif 359#if HAVE_WCRTOMB 360 from_wchar = 1; 361 fromcode = locale_charset(); 362 continue; 363#endif 364 goto invalid; 365 } 366 from_index = ap->encoding_index; 367 break; 368 } 369 cd = (struct conv_struct *) malloc(from_wchar != to_wchar 370 ? sizeof(struct wchar_conv_struct) 371 : sizeof(struct conv_struct)); 372 if (cd == NULL) { 373 errno = ENOMEM; 374 return (iconv_t)(-1); 375 } 376 cd->iindex = from_index; 377 cd->ifuncs = all_encodings[from_index].ifuncs; 378 cd->oindex = to_index; 379 cd->ofuncs = all_encodings[to_index].ofuncs; 380 cd->oflags = all_encodings[to_index].oflags; 381 /* Initialize the loop functions. */ 382#if HAVE_MBRTOWC 383 if (to_wchar) { 384#if HAVE_WCRTOMB 385 if (from_wchar) { 386 cd->lfuncs.loop_convert = wchar_id_loop_convert; 387 cd->lfuncs.loop_reset = wchar_id_loop_reset; 388 } else 389#endif 390 { 391 cd->lfuncs.loop_convert = wchar_to_loop_convert; 392 cd->lfuncs.loop_reset = wchar_to_loop_reset; 393 } 394 } else 395#endif 396 { 397#if HAVE_WCRTOMB 398 if (from_wchar) { 399 cd->lfuncs.loop_convert = wchar_from_loop_convert; 400 cd->lfuncs.loop_reset = wchar_from_loop_reset; 401 } else 402#endif 403 { 404 cd->lfuncs.loop_convert = unicode_loop_convert; 405 cd->lfuncs.loop_reset = unicode_loop_reset; 406 } 407 } 408 /* Initialize the states. */ 409 memset(&cd->istate,'\0',sizeof(state_t)); 410 memset(&cd->ostate,'\0',sizeof(state_t)); 411 /* Initialize the operation flags. */ 412 cd->transliterate = transliterate; 413 cd->discard_ilseq = discard_ilseq; 414 #ifndef LIBICONV_PLUG 415 cd->fallbacks.mb_to_uc_fallback = NULL; 416 cd->fallbacks.uc_to_mb_fallback = NULL; 417 cd->fallbacks.mb_to_wc_fallback = NULL; 418 cd->fallbacks.wc_to_mb_fallback = NULL; 419 cd->fallbacks.data = NULL; 420 cd->hooks.uc_hook = NULL; 421 cd->hooks.wc_hook = NULL; 422 cd->hooks.data = NULL; 423 #endif 424 /* Initialize additional fields. */ 425 if (from_wchar != to_wchar) { 426 struct wchar_conv_struct * wcd = (struct wchar_conv_struct *) cd; 427 memset(&wcd->state,'\0',sizeof(mbstate_t)); 428 } 429 /* Done. */ 430 return (iconv_t)cd; 431invalid: 432 errno = EINVAL; 433 return (iconv_t)(-1); 434} 435 436size_t iconv (iconv_t icd, 437 char* * __restrict inbuf, size_t * __restrict inbytesleft, 438 char* * __restrict outbuf, size_t * __restrict outbytesleft) 439{ 440 conv_t cd = (conv_t) icd; 441 if (inbuf == NULL || *inbuf == NULL) 442 return cd->lfuncs.loop_reset(icd,outbuf,outbytesleft); 443 else 444 return cd->lfuncs.loop_convert(icd, 445 (const char* *)inbuf,inbytesleft, 446 outbuf,outbytesleft); 447} 448 449int iconv_close (iconv_t icd) 450{ 451 conv_t cd = (conv_t) icd; 452 free(cd); 453 return 0; 454} 455 456#ifndef LIBICONV_PLUG 457 458int iconvctl (iconv_t icd, int request, void* argument) 459{ 460 conv_t cd = (conv_t) icd; 461 switch (request) { 462 case ICONV_TRIVIALP: 463 *(int *)argument = 464 ((cd->lfuncs.loop_convert == unicode_loop_convert 465 && cd->iindex == cd->oindex) 466 || cd->lfuncs.loop_convert == wchar_id_loop_convert 467 ? 1 : 0); 468 return 0; 469 case ICONV_GET_TRANSLITERATE: 470 *(int *)argument = cd->transliterate; 471 return 0; 472 case ICONV_SET_TRANSLITERATE: 473 cd->transliterate = (*(const int *)argument ? 1 : 0); 474 return 0; 475 case ICONV_GET_DISCARD_ILSEQ: 476 *(int *)argument = cd->discard_ilseq; 477 return 0; 478 case ICONV_SET_DISCARD_ILSEQ: 479 cd->discard_ilseq = (*(const int *)argument ? 1 : 0); 480 return 0; 481 case ICONV_SET_HOOKS: 482 if (argument != NULL) { 483 cd->hooks = *(const struct iconv_hooks *)argument; 484 } else { 485 cd->hooks.uc_hook = NULL; 486 cd->hooks.wc_hook = NULL; 487 cd->hooks.data = NULL; 488 } 489 return 0; 490 case ICONV_SET_FALLBACKS: 491 if (argument != NULL) { 492 cd->fallbacks = *(const struct iconv_fallbacks *)argument; 493 } else { 494 cd->fallbacks.mb_to_uc_fallback = NULL; 495 cd->fallbacks.uc_to_mb_fallback = NULL; 496 cd->fallbacks.mb_to_wc_fallback = NULL; 497 cd->fallbacks.wc_to_mb_fallback = NULL; 498 cd->fallbacks.data = NULL; 499 } 500 return 0; 501 default: 502 errno = EINVAL; 503 return -1; 504 } 505} 506 507/* An alias after its name has been converted from 'int' to 'const char*'. */ 508struct nalias { const char* name; unsigned int encoding_index; }; 509 510static int compare_by_index (const void * arg1, const void * arg2) 511{ 512 const struct nalias * alias1 = (const struct nalias *) arg1; 513 const struct nalias * alias2 = (const struct nalias *) arg2; 514 return (int)alias1->encoding_index - (int)alias2->encoding_index; 515} 516 517static int compare_by_name (const void * arg1, const void * arg2) 518{ 519 const char * name1 = *(const char **)arg1; 520 const char * name2 = *(const char **)arg2; 521 /* Compare alphabetically, but put "CS" names at the end. */ 522 int sign = strcmp(name1,name2); 523 if (sign != 0) { 524 sign = ((name1[0]=='C' && name1[1]=='S') - (name2[0]=='C' && name2[1]=='S')) 525 * 4 + (sign >= 0 ? 1 : -1); 526 } 527 return sign; 528} 529 530void iconvlist (int (*do_one) (unsigned int namescount, 531 const char * const * names, 532 void* data), 533 void* data) 534{ 535#define aliascount1 (unsigned int)(sizeof(aliases)/sizeof(aliases[0])) 536#ifndef aliases2_lookup 537#define aliascount2 (unsigned int)(sizeof(sysdep_aliases)/sizeof(sysdep_aliases[0])) 538#else 539#define aliascount2 0 540#endif 541#define aliascount (aliascount1+aliascount2) 542 struct nalias aliasbuf[aliascount]; 543 const char * namesbuf[aliascount]; 544 unsigned int num_aliases; 545 { 546 /* Put all existing aliases into a buffer. */ 547 unsigned int i; 548 unsigned int j; 549 j = 0; 550 for (i = 0; i < aliascount1; i++) { 551 const struct alias * p = &aliases[i]; 552 if (p->name >= 0 553 && p->encoding_index != ei_local_char 554 && p->encoding_index != ei_local_wchar_t) { 555 aliasbuf[j].name = stringpool + p->name; 556 aliasbuf[j].encoding_index = p->encoding_index; 557 j++; 558 } 559 } 560#ifndef aliases2_lookup 561 for (i = 0; i < aliascount2; i++) { 562 aliasbuf[j].name = stringpool2 + sysdep_aliases[i].name; 563 aliasbuf[j].encoding_index = sysdep_aliases[i].encoding_index; 564 j++; 565 } 566#endif 567 num_aliases = j; 568 } 569 /* Sort by encoding_index. */ 570 if (num_aliases > 1) 571 qsort(aliasbuf, num_aliases, sizeof(struct nalias), compare_by_index); 572 { 573 /* Process all aliases with the same encoding_index together. */ 574 unsigned int j; 575 j = 0; 576 while (j < num_aliases) { 577 unsigned int ei = aliasbuf[j].encoding_index; 578 unsigned int i = 0; 579 do 580 namesbuf[i++] = aliasbuf[j++].name; 581 while (j < num_aliases && aliasbuf[j].encoding_index == ei); 582 if (i > 1) 583 qsort(namesbuf, i, sizeof(const char *), compare_by_name); 584 /* Call the callback. */ 585 if (do_one(i,namesbuf,data)) 586 break; 587 } 588 } 589#undef aliascount 590#undef aliascount2 591#undef aliascount1 592} 593 594/* 595 * Table of canonical names of encodings. 596 * Instead of strings, it contains offsets into stringpool and stringpool2. 597 */ 598static const unsigned short all_canonical[] = { 599#include "canonical.h" 600#ifdef USE_AIX 601#include "canonical_aix.h" 602#endif 603#ifdef USE_OSF1 604#include "canonical_osf1.h" 605#endif 606#ifdef USE_DOS 607#include "canonical_dos.h" 608#endif 609#ifdef USE_EXTRA 610#include "canonical_extra.h" 611#endif 612#include "canonical_local.h" 613}; 614 615const char * iconv_canonicalize (const char * name) 616{ 617 const char* code; 618 char buf[MAX_WORD_LENGTH+10+1]; 619 const char* cp; 620 char* bp; 621 const struct alias * ap; 622 unsigned int count; 623 unsigned int index; 624 const char* pool; 625 626 /* Before calling aliases_lookup, convert the input string to upper case, 627 * and check whether it's entirely ASCII (we call gperf with option "-7" 628 * to achieve a smaller table) and non-empty. If it's not entirely ASCII, 629 * or if it's too long, it is not a valid encoding name. 630 */ 631 for (code = name;;) { 632 /* Search code in the table. */ 633 for (cp = code, bp = buf, count = MAX_WORD_LENGTH+10+1; ; cp++, bp++) { 634 unsigned char c = * (unsigned char *) cp; 635 if (c >= 0x80) 636 goto invalid; 637 if (c >= 'a' && c <= 'z') 638 c -= 'a'-'A'; 639 *bp = c; 640 if (c == '\0') 641 break; 642 if (--count == 0) 643 goto invalid; 644 } 645 for (;;) { 646 if (bp-buf >= 10 && memcmp(bp-10,"//TRANSLIT",10)==0) { 647 bp -= 10; 648 *bp = '\0'; 649 continue; 650 } 651 if (bp-buf >= 8 && memcmp(bp-8,"//IGNORE",8)==0) { 652 bp -= 8; 653 *bp = '\0'; 654 continue; 655 } 656 break; 657 } 658 if (buf[0] == '\0') { 659 code = locale_charset(); 660 /* Avoid an endless loop that could occur when using an older version 661 of localcharset.c. */ 662 if (code[0] == '\0') 663 goto invalid; 664 continue; 665 } 666 pool = stringpool; 667 ap = aliases_lookup(buf,(unsigned int)(bp-buf)); 668 if (ap == NULL) { 669 pool = stringpool2; 670 ap = aliases2_lookup(buf); 671 if (ap == NULL) 672 goto invalid; 673 } 674 if (ap->encoding_index == ei_local_char) { 675 code = locale_charset(); 676 /* Avoid an endless loop that could occur when using an older version 677 of localcharset.c. */ 678 if (code[0] == '\0') 679 goto invalid; 680 continue; 681 } 682 if (ap->encoding_index == ei_local_wchar_t) { 683#if __STDC_ISO_10646__ 684 if (sizeof(wchar_t) == 4) { 685 index = ei_ucs4internal; 686 break; 687 } 688 if (sizeof(wchar_t) == 2) { 689 index = ei_ucs2internal; 690 break; 691 } 692 if (sizeof(wchar_t) == 1) { 693 index = ei_iso8859_1; 694 break; 695 } 696#endif 697 } 698 index = ap->encoding_index; 699 break; 700 } 701 return all_canonical[index] + pool; 702 invalid: 703 return name; 704} 705 706int _libiconv_version = _LIBICONV_VERSION; 707 708#if defined __FreeBSD__ && !defined __gnu_freebsd__ 709/* GNU libiconv is the native FreeBSD iconv implementation since 2002. 710 It wants to define the symbols 'iconv_open', 'iconv', 'iconv_close'. */ 711#define strong_alias(name, aliasname) _strong_alias(name, aliasname) 712#define _strong_alias(name, aliasname) \ 713 extern __typeof (name) aliasname __attribute__ ((alias (#name))); 714#undef iconv_open 715#undef iconv 716#undef iconv_close 717strong_alias (libiconv_open, iconv_open) 718strong_alias (libiconv, iconv) 719strong_alias (libiconv_close, iconv_close) 720#elif defined __APPLE__ 721#if defined(__ppc__) || defined(__i386__) 722/* backward compatibility */ 723iconv_t 724libiconv_open(const char *tocode, const char *fromcode) 725{ 726 return iconv_open(tocode, fromcode); 727} 728 729size_t 730libiconv(iconv_t cd, const char ** inbuf, 731 size_t * inbytesleft, char ** outbuf, 732 size_t * outbytesleft) 733{ 734 return iconv(cd, (char **)inbuf, inbytesleft, outbuf, outbytesleft); 735} 736 737int 738libiconv_close(iconv_t cd) 739{ 740 return iconv_close(cd); 741} 742 743int 744libiconvctl(iconv_t cd, int request, void* argument) 745{ 746 return iconvctl(cd, request, argument); 747} 748 749void 750libiconvlist(int (*do_one) (unsigned int namescount, 751 const char * const * names, 752 void* data), 753 void* data) 754{ 755 iconvlist(do_one, data); 756} 757 758#endif /* __ppc__ || __i386__ */ 759#endif 760 761#endif 762