2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 1993, 2011, Oracle and/or its affiliates. All rights reserved. 2N/A const char *,
char *,
int,
int);
2N/Astatic void free_names(
char *,
const char *,
char *,
const char *);
2N/A * These functions are mainly implemented by using a shared object and 2N/A * the dlopen() functions. The actual conversion algorithm for a particular 2N/A * conversion is implemented via a shared object as a loadable conversion 2N/A * module which is linked dynamically at run time. 2N/A * The loadable conversion module resides as either: 2N/A * if the conversion is supported through a geniconvtbl code conversion 2N/A * binary table or as a module that directly specifies the conversion at: 2N/A * where fromcode is the source encoding and tocode is the target encoding. 2N/A * The modules have three must-have entries, _icv_open(), _icv_iconv(), and 2N/A * _icv_close(), and three optional entries, _icv_open_attr(), _icv_iconvctl(), 2N/A * and _icv_iconvstr(). 2N/A * If there is no code conversion supported and if the fromcode and the tocode 2N/A * are specifying the same codeset, then, the byte-by-byte, pass-through code 2N/A * conversion that is embedded in the libc is used instead. 2N/A * The following are the related PSARC cases: 2N/A * PSARC/1999/292 Addition of geniconvtbl(1) 2N/A * PSARC/2001/072 GNU gettext support 2N/A * PSARC/2009/561 Pass-through iconv code conversion 2N/A * PSARC/2010/160 Libc iconv enhancement 2N/A /* found a valid module for this conversion */ 2N/A * Now, try using the encoding name aliasing table 2N/A * As the last resort, check if the tocode and the fromcode 2N/A * are referring to the same codeset name or not. If so, 2N/A * assign the embedded pass-through code conversion. 2N/A * No valid conversion available. Do failure retrun 2N/A * with the errno set by iconv_search_alias(). 2N/A * For a pass-through byte-by-byte code conversion, allocate 2N/A * an internal conversion descriptor and initialize the data 2N/A * fields appropriately and we are done. 2N/A /* found a valid module for this conversion */ 2N/A * Line beginning with '#' is a comment 2N/A while ((q > p) && (*p++ !=
'\n'))
2N/A /* skip leading spaces */ 2N/A ((*p ==
' ') || (*p ==
'\t')))
2N/A while ((q > p) && (*p !=
' ') &&
2N/A (*p !=
'\t') && (*p !=
'\n'))
2N/A /* skip remaining chars in this line */ 2N/A while ((q > p) && (*p++ !=
'\n'))
2N/A /* matching entry found */ 2N/A ((*p ==
' ') || (*p ==
'\t')))
2N/A while ((q > p) && (*p !=
' ') &&
2N/A (*p !=
'\t') && (*p !=
'\n'))
2N/A while ((q > p) && (*p++ !=
'\n'))
2N/A * First, try using the geniconvtbl conversion, which is 2N/A * the conversion table file: 2N/A * If the geniconvtbl conversion cannot be done, 2N/A * try the conversion by the individual shared object. 2N/A * from%to.bt exists in the table dir 2N/A /* found a valid module for this conversion */ 2N/A * errno will be set by iconv_open_private on error 2N/A /* no valid module for this conversion found */ 2N/A * if no alias file found, 2N/A * errno will be set to EINVAL. 2N/A /* use errno set by fstat64 */ 2N/A /* use errno set by mmap */ 2N/A /* errno set by iconv_open_all on error */ 2N/A * If this is called from iconvstr(), get the address of 2N/A * _icv_iconvstr and return since that's all we need. 2N/A * Get address of _icv_open or _icv_open_attr depending on whether 2N/A * we have at least a value defined in the flag. 2N/A * gets address of _icv_iconv in the loadable conversion module 2N/A * and stores it in cdpath->_icv_iconv 2N/A * gets address of _icv_close in the loadable conversion module 2N/A * and stores it in cd->_icv_close 2N/A * Get the address of _icv_iconvctl() from the module. 2N/A * Saving NULL via dlsym() is normal and, in that case, simply, 2N/A * the module doesn't support the iconvctl(). 2N/A * Initialize the state of the _icv_iconv conversion routine by 2N/A * calling _icv_open() or _icv_open_attr(). 2N/A * For all regular iconv modules, NULL will be passed for the tbl 2N/A * argument although the iconv_open() of the module won't use that. 2N/A /* check if cd is valid */ 2N/A /* direct conversion */ 2N/A/*LINTED E_FUNC_ARG_UNUSED*/ 2N/A /* For any state reset request, return success. */ 2N/A * Initialize internally used variables for a better performance 2N/A * and prepare for a couple of the return values before the actual 2N/A * copying of the bytes. 2N/A * Do the copy using memmove(). There are no EILSEQ or EINVAL 2N/A * checkings since this is a simple copying. 2N/A /* Update the return values related to the buffers then do return. */ 2N/A * The following function maps "", "char", and "wchar_t" into some 2N/A * the materials directory of PSARC/2010/160. 2N/A * For any other names, if requested, it duplicates the name into 2N/A * a new memory block and returns. 2N/A * The min and max lengths of all indicators at this point are 6 of "IGNORE" 2N/A * and 27 of "NON_IDENTICAL_TRANSLITERATE", respectively. 2N/A * The following function clears any prior flag values that are 2N/A * conflicting with the new value asked in "s" and then sets the new 2N/A * code conversion behavior modification indicators if any and the actual 2N/A * codeset name from the name and sets the flag. It also processes special 2N/A * process_special_names().