lib/libc/citrus/citrus_iconv.c
int
_citrus_iconv_open(struct _citrus_iconv * __restrict * __restrict rcv,
		   const char * __restrict basedir,
		   const char * __restrict src, const char * __restrict dst)
{
	int ret;
	struct _citrus_iconv_shared *ci;
	struct _citrus_iconv *cv;
	char realsrc[PATH_MAX], realdst[PATH_MAX];
	char buf[PATH_MAX], path[PATH_MAX];

	init_cache();

	/* resolve codeset name aliases */
	snprintf(path, sizeof(path), "%s/%s", basedir, _CITRUS_ICONV_ALIAS);
	strlcpy(realsrc,
		_lookup_alias(path, src, buf, PATH_MAX, _LOOKUP_CASE_IGNORE),
		PATH_MAX);
	strlcpy(realdst,
		_lookup_alias(path, dst, buf, PATH_MAX, _LOOKUP_CASE_IGNORE),
		PATH_MAX);

	/* sanity check */
	if (strchr(realsrc, '/') != NULL || strchr(realdst, '/'))
		return EINVAL;

	/* get shared record */
	ret = get_shared(&ci, basedir, realsrc, realdst);
	if (ret)
		return ret;

	/* create/init context */
	cv = malloc(sizeof(*cv));
	if (cv == NULL) {
		ret = errno;
		release_shared(ci);
		return ret;
	}
	cv->cv_shared = ci;
	ret = (*ci->ci_ops->io_init_context)(cv);
	if (ret) {
		release_shared(ci);
		free(cv);
		return ret;
	}
	*rcv = cv;

	return 0;
}
/*
 * _citrus_iconv_open:
 *	open a converter for the specified in/out codes.
 */
open a converter for the specified in/out codes.
open a converter for the specified in / out codes .
int
_citrus_iconv_open(struct _citrus_iconv * __restrict * __restrict rcv,
		   const char * __restrict basedir,
		   const char * __restrict src, const char * __restrict dst)
{
	int ret;
	struct _citrus_iconv_shared *ci;
	struct _citrus_iconv *cv;
	char realsrc[PATH_MAX], realdst[PATH_MAX];
	char buf[PATH_MAX], path[PATH_MAX];
	init_cache();
	snprintf(path, sizeof(path), "%s/%s", basedir, _CITRUS_ICONV_ALIAS);
	strlcpy(realsrc,
		_lookup_alias(path, src, buf, PATH_MAX, _LOOKUP_CASE_IGNORE),
		PATH_MAX);
	strlcpy(realdst,
		_lookup_alias(path, dst, buf, PATH_MAX, _LOOKUP_CASE_IGNORE),
		PATH_MAX);
	if (strchr(realsrc, '/') != NULL || strchr(realdst, '/'))
		return EINVAL;
	ret = get_shared(&ci, basedir, realsrc, realdst);
	if (ret)
		return ret;
	cv = malloc(sizeof(*cv));
	if (cv == NULL) {
		ret = errno;
		release_shared(ci);
		return ret;
	}
	cv->cv_shared = ci;
	ret = (*ci->ci_ops->io_init_context)(cv);
	if (ret) {
		release_shared(ci);
		free(cv);
		return ret;
	}
	*rcv = cv;
	return 0;
}
int _citrus_iconv_open ( struct _citrus_iconv * __restrict * __restrict rcv , const char * __restrict basedir , const char * __restrict src , const char * __restrict dst ) { int ret ; struct _citrus_iconv_shared * ci ; struct _citrus_iconv * cv ; char realsrc [ PATH_MAX ] , realdst [ PATH_MAX ] ; char buf [ PATH_MAX ] , path [ PATH_MAX ] ; init_cache ( ) ; snprintf ( path , sizeof ( path ) , " " , basedir , _CITRUS_ICONV_ALIAS ) ; strlcpy ( realsrc , _lookup_alias ( path , src , buf , PATH_MAX , _LOOKUP_CASE_IGNORE ) , PATH_MAX ) ; strlcpy ( realdst , _lookup_alias ( path , dst , buf , PATH_MAX , _LOOKUP_CASE_IGNORE ) , PATH_MAX ) ; if ( strchr ( realsrc , ' ' ) != NULL || strchr ( realdst , ' ' ) ) return EINVAL ; ret = get_shared ( & ci , basedir , realsrc , realdst ) ; if ( ret ) return ret ; cv = malloc ( sizeof ( * cv ) ) ; if ( cv == NULL ) { ret = errno ; release_shared ( ci ) ; return ret ; } cv -> cv_shared = ci ; ret = ( * ci -> ci_ops -> io_init_context ) ( cv ) ; if ( ret ) { release_shared ( ci ) ; free ( cv ) ; return ret ; } * rcv = cv ; return 0 ; }
_citrus_iconv_open:
      open a converter for the specified in/out codes.
_citrus_iconv_open : open a converter for the specified in / out codes .
/* resolve codeset name aliases */ /* sanity check */ /* get shared record */ /* create/init context */