[packages] libiconv: extend the stub implementation a bit; if mappings between equal charsets or from ASCII to UTF-8 or ASCII to ISO-8859-* are requested, simply copy the input to the output buffer, this fixes programs like mpd
git-svn-id: svn://svn.openwrt.org/openwrt/packages@24777 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
0638217836
commit
4b0e0a7e17
@ -8,7 +8,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=libiconv
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=2
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
@ -27,7 +27,7 @@ define Build/Configure
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(TARGET_CC) -c $(PKG_BUILD_DIR)/iconv.c -o $(PKG_BUILD_DIR)/iconv.o -I$(PKG_BUILD_DIR)/include
|
||||
$(TARGET_CC) -c $(PKG_BUILD_DIR)/iconv.c -o $(PKG_BUILD_DIR)/iconv.o -I$(PKG_BUILD_DIR)/include $(FPIC)
|
||||
$(TARGET_CROSS)ar rcs $(PKG_BUILD_DIR)/libiconv.a $(PKG_BUILD_DIR)/iconv.o
|
||||
endef
|
||||
|
||||
|
@ -3,19 +3,72 @@
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <iconv.h>
|
||||
|
||||
int _libiconv_version = _LIBICONV_VERSION;
|
||||
|
||||
iconv_t iconv_open (const char *tocode, const char *fromcode)
|
||||
{
|
||||
return (iconv_t)(-1);
|
||||
/* ASCII -> UTF8 and ASCII -> ISO-8859-x mappings can be
|
||||
* faked without doing any actual conversion, mapping
|
||||
* between identical charsets is a no-op, so claim to
|
||||
* support those. */
|
||||
if (!strncasecmp(fromcode, tocode, strlen(fromcode)) ||
|
||||
(!strncasecmp(tocode, "UTF-8", strlen("UTF-8")) &&
|
||||
!strncasecmp(fromcode, "ASCII", strlen("ASCII"))) ||
|
||||
(!strncasecmp(tocode, "ISO-8859-", strlen("ISO-8859-")) &&
|
||||
!strncasecmp(fromcode, "ASCII", strlen("ASCII"))))
|
||||
{
|
||||
return (iconv_t)(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (iconv_t)(-1);
|
||||
}
|
||||
}
|
||||
|
||||
size_t iconv (iconv_t cd, char **inbuf, size_t *inbytesleft,
|
||||
char **outbuf, size_t *outbytesleft)
|
||||
{
|
||||
return 0;
|
||||
size_t len = 0;
|
||||
|
||||
if (cd == (iconv_t)(1))
|
||||
{
|
||||
if ((*inbytesleft < 0) || (*outbytesleft < 0) ||
|
||||
(outbuf == NULL) || (*outbuf == NULL))
|
||||
{
|
||||
errno = EINVAL;
|
||||
return (size_t)(-1);
|
||||
}
|
||||
|
||||
if ((inbuf != NULL) && (*inbuf != NULL))
|
||||
{
|
||||
len = (*inbytesleft > *outbytesleft)
|
||||
? *outbytesleft : *inbytesleft;
|
||||
|
||||
memcpy(*outbuf, *inbuf, len);
|
||||
|
||||
*inbuf += len;
|
||||
*inbytesleft -= len;
|
||||
*outbuf += len;
|
||||
*outbytesleft -= len;
|
||||
|
||||
if (*inbytesleft > 0)
|
||||
{
|
||||
errno = E2BIG;
|
||||
return (size_t)(-1);
|
||||
}
|
||||
}
|
||||
|
||||
return (size_t)(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
errno = EBADF;
|
||||
return (size_t)(-1);
|
||||
}
|
||||
}
|
||||
|
||||
int iconv_close (iconv_t cd)
|
||||
|
Loading…
x
Reference in New Issue
Block a user