forked from enlightenment/efl
text utility routines... iconv wrapper there :)
SVN revision: 7521
This commit is contained in:
parent
b3c6078785
commit
bf3c32e3c4
|
@ -9,3 +9,4 @@
|
|||
#undef BUILD_ECORE_X
|
||||
#undef BUILD_ECORE_CON
|
||||
#undef BUILD_ECORE_IPC
|
||||
#undef BUILD_ECORE_TXT
|
||||
|
|
|
@ -14,4 +14,5 @@ fi
|
|||
--enable-ecore-job \
|
||||
--enable-ecore-con \
|
||||
--enable-ecore-ipc \
|
||||
--enable-ecore-txt \
|
||||
$@
|
||||
|
|
|
@ -263,6 +263,34 @@ AC_ARG_ENABLE(ecore-ipc,
|
|||
AC_SUBST(ecore_ipc_cflags)
|
||||
AC_SUBST(ecore_ipc_libs)
|
||||
|
||||
|
||||
AC_MSG_CHECKING(whether ecore_txt module is to be built)
|
||||
|
||||
# FIXME: detect if we need -liconv or not for iconv_libs
|
||||
iconv_cflags=""
|
||||
iconv_libs=""
|
||||
|
||||
ecore_txt_cflags="";
|
||||
ecore_txt_libs="";
|
||||
|
||||
AC_ARG_ENABLE(ecore-txt,
|
||||
[ --enable-ecore-txt enable the ecore_txt module], [
|
||||
AC_MSG_RESULT(yes)
|
||||
AM_CONDITIONAL(BUILD_ECORE_TXT, test "$enableval" = "yes")
|
||||
AC_DEFINE(BUILD_ECORE_TXT)
|
||||
ecore_txt_libs="-lecore_txt"
|
||||
], [
|
||||
AC_MSG_RESULT(no)
|
||||
AM_CONDITIONAL(BUILD_ECORE_TXT, false)
|
||||
]
|
||||
)
|
||||
|
||||
AC_SUBST(iconv_cflags)
|
||||
AC_SUBST(iconv_libs)
|
||||
|
||||
AC_SUBST(ecore_txt_cflags)
|
||||
AC_SUBST(ecore_txt_libs)
|
||||
|
||||
AC_OUTPUT([
|
||||
Makefile
|
||||
ecore-config
|
||||
|
@ -276,6 +304,7 @@ src/lib/ecore_fb/Makefile
|
|||
src/lib/ecore_evas/Makefile
|
||||
src/lib/ecore_con/Makefile
|
||||
src/lib/ecore_ipc/Makefile
|
||||
src/lib/ecore_txt/Makefile
|
||||
debian/Makefile
|
||||
], [
|
||||
chmod +x ecore-config
|
||||
|
|
|
@ -46,7 +46,7 @@ while test $# -gt 0; do
|
|||
;;
|
||||
--libs)
|
||||
libdirs=-L@libdir@
|
||||
echo $libdirs -lecore @ecore_job_libs@ @ecore_x_libs@ @ecore_evas_libs@ @ecore_con_libs@ @ecore_ipc_libs@ @ecore_fb_libs@ -lm
|
||||
echo $libdirs -lecore @ecore_job_libs@ @ecore_x_libs@ @ecore_evas_libs@ @ecore_con_libs@ @ecore_ipc_libs@ @ecore_txt_libs@ @ecore_fb_libs@ -lm
|
||||
;;
|
||||
*)
|
||||
echo "${usage}" 1>&2
|
||||
|
|
|
@ -6,7 +6,8 @@ make clean distclean
|
|||
--enable-ecore-evas \
|
||||
--enable-ecore-job \
|
||||
--enable-ecore-con \
|
||||
--enable-ecore-ipc
|
||||
--enable-ecore-ipc \
|
||||
--enable-ecore-txt
|
||||
|
||||
CC="/skiff/local/bin/arm-linux-gcc"
|
||||
ST="/skiff/local/bin/arm-linux-strip"
|
||||
|
@ -26,13 +27,13 @@ pushd src
|
|||
|
||||
pushd lib
|
||||
|
||||
for I in ecore ecore_fb ecore_job ecore_evas ecore_con ecore_ipc; do
|
||||
for I in ecore ecore_fb ecore_job ecore_evas ecore_con ecore_ipc ecore_txt; do
|
||||
LIB=$I
|
||||
pushd $LIB
|
||||
$CC \
|
||||
*.c \
|
||||
$CFLAGS \
|
||||
-I. -I../ecore -I../ecore_x -I../ecore_fb -I../ecore_job -I../ecore_evas -I../ecore_con -I../ecore_ipc \
|
||||
-I. -I../ecore -I../ecore_x -I../ecore_fb -I../ecore_job -I../ecore_evas -I../ecore_con -I../ecore_ipc -I../ecore_txt \
|
||||
-I../../.. \
|
||||
-I/skiff/local/include \
|
||||
-shared -fPIC -DPIC \
|
||||
|
@ -56,10 +57,10 @@ pushd src
|
|||
BIN="ecore_test"
|
||||
$CC $BIN".c" \
|
||||
-I../.. -I../lib \
|
||||
-I. -I../lib/ecore -I../lib/ecore_x -I../lib/ecore_fb -I../lib/ecore_job -I../lib/ecore_evas -I../lib/ecore_con -I../lib/ecore_ipc \
|
||||
-I. -I../lib/ecore -I../lib/ecore_x -I../lib/ecore_fb -I../lib/ecore_job -I../lib/ecore_evas -I../lib/ecore_con -I../lib/ecore_ipc -I../lib/ecore_txt \
|
||||
-I/skiff/local/include \
|
||||
-L. -L../lib/ecore -L../lib/ecore_x -L../lib/ecore_fb -L../lib/ecore_job -L../lib/ecore_evas -L../lib/ecore_con -L../lib/ecore_ipc \
|
||||
-lecore -lecore_evas -lecore_fb -lecore_job -lecore_con -lecore_ipc -levas -lfreetype -ljpeg -lpng -lz -lm \
|
||||
-L. -L../lib/ecore -L../lib/ecore_x -L../lib/ecore_fb -L../lib/ecore_job -L../lib/ecore_evas -L../lib/ecore_con -L../lib/ecore_ipc -L../lib/ecore_txt \
|
||||
-lecore -lecore_evas -lecore_fb -lecore_job -lecore_con -lecore_ipc -lecore_txt -levas -lfreetype -ljpeg -lpng -lz -lm \
|
||||
-o $BIN
|
||||
$ST $BIN
|
||||
cp -a $BIN $DST"/bin";
|
||||
|
@ -70,10 +71,10 @@ pushd src
|
|||
ecore_evas_test_bg.c \
|
||||
ecore_evas_test_calibrate.c \
|
||||
-I../.. -I../lib \
|
||||
-I. -I../lib/ecore -I../lib/ecore_x -I../lib/ecore_fb -I../lib/ecore_job -I../lib/ecore_evas -I../lib/ecore_con -I../lib/ecore_ipc \
|
||||
-I. -I../lib/ecore -I../lib/ecore_x -I../lib/ecore_fb -I../lib/ecore_job -I../lib/ecore_evas -I../lib/ecore_con -I../lib/ecore_ipc -I../lib/ecore_txt \
|
||||
-I/skiff/local/include \
|
||||
-L. -L../lib/ecore -L../lib/ecore_x -L../lib/ecore_fb -L../lib/ecore_job -L../lib/ecore_evas -L../lib/ecore_con -L../lib/ecore_ipc \
|
||||
-lecore -lecore_evas -lecore_fb -lecore_con -lecore_con -lecore_ipc -levas -lfreetype -ljpeg -lpng -lz -lm \
|
||||
-L. -L../lib/ecore -L../lib/ecore_x -L../lib/ecore_fb -L../lib/ecore_job -L../lib/ecore_evas -L../lib/ecore_con -L../lib/ecore_ipc -L../lib/ecore_txt \
|
||||
-lecore -lecore_evas -lecore_fb -lecore_con -lecore_con -lecore_ipc -lecore_txt -levas -lfreetype -ljpeg -lpng -lz -lm \
|
||||
-o $BIN
|
||||
$ST $BIN
|
||||
cp -a $BIN $DST"/bin";
|
||||
|
|
|
@ -6,4 +6,5 @@ ecore_x \
|
|||
ecore_fb \
|
||||
ecore_evas \
|
||||
ecore_con \
|
||||
ecore_ipc
|
||||
ecore_ipc \
|
||||
ecore_txt
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef _ECORE_TXT_H
|
||||
#define _ECORE_TXT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
char *ecore_txt_convert(char *enc_from, char *enc_to, char *text);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -0,0 +1,33 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir)/src/lib/ecore \
|
||||
@iconv_cflags@
|
||||
|
||||
libecore_txt_la_LDFLAGS = -version-info 1:0:0 \
|
||||
-L$(top_builddir)/src/lib/ecore/.libs
|
||||
|
||||
if BUILD_ECORE_TXT
|
||||
|
||||
lib_LTLIBRARIES = libecore_txt.la
|
||||
include_HEADERS = \
|
||||
Ecore_Txt.h
|
||||
|
||||
libecore_txt_la_SOURCES = \
|
||||
ecore_txt.c \
|
||||
ecore_txt_private.h
|
||||
|
||||
# FIXME: may have to link with -liconv
|
||||
libecore_txt_la_LIBADD = \
|
||||
@iconv_libs@
|
||||
|
||||
|
||||
libecore_txt_la_DEPENDENCIES =
|
||||
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST = \
|
||||
Ecore_Txt.h \
|
||||
ecore_txt.c \
|
||||
ecore_txt_private.h
|
|
@ -0,0 +1,55 @@
|
|||
#include "ecore_txt_private.h"
|
||||
#include "Ecore_Txt.h"
|
||||
|
||||
#include <iconv.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
char *
|
||||
ecore_txt_convert(char *enc_from, char *enc_to, char *text)
|
||||
{
|
||||
iconv_t ic;
|
||||
char *new_txt, *inp, *outp;
|
||||
size_t inb, outb, outlen, tob, outalloc;
|
||||
|
||||
if (!text) return strdup("");
|
||||
ic = iconv_open(enc_to, enc_from);
|
||||
if (!ic) return strdup("");
|
||||
new_txt = malloc(64);
|
||||
inb = strlen(text);
|
||||
outb = 64;
|
||||
inp = text;
|
||||
outp = new_txt;
|
||||
outalloc = 64;
|
||||
outlen = 0;
|
||||
tob = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
size_t count;
|
||||
|
||||
tob = outb;
|
||||
count = iconv(ic, &inp, &inb, &outp, &outb);
|
||||
outlen += tob - outb;
|
||||
if (count == -1)
|
||||
{
|
||||
if (errno == E2BIG)
|
||||
{
|
||||
new_txt = realloc(new_txt, outalloc + 64);
|
||||
outalloc += 64;
|
||||
outb += 64;
|
||||
}
|
||||
}
|
||||
if (inb == 0)
|
||||
{
|
||||
if (outalloc == outlen) new_txt = realloc(new_txt, outalloc + 1);
|
||||
new_txt[outlen] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
iconv_close(ic);
|
||||
return new_txt;
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
#ifndef _ECORE_TXT_PRIVATE_H
|
||||
#define _ECORE_TXT_PRIVATE_H
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue