summaryrefslogtreecommitdiff
path: root/ecore/src/lib/ecore_txt
diff options
context:
space:
mode:
Diffstat (limited to 'ecore/src/lib/ecore_txt')
-rw-r--r--ecore/src/lib/ecore_txt/.cvsignore6
-rw-r--r--ecore/src/lib/ecore_txt/CVS/Entries6
-rw-r--r--ecore/src/lib/ecore_txt/CVS/Repository1
-rw-r--r--ecore/src/lib/ecore_txt/CVS/Root1
-rw-r--r--ecore/src/lib/ecore_txt/CVS/Tag1
-rw-r--r--ecore/src/lib/ecore_txt/Ecore_Txt.h36
-rw-r--r--ecore/src/lib/ecore_txt/Makefile.am34
-rw-r--r--ecore/src/lib/ecore_txt/ecore_txt.c78
-rw-r--r--ecore/src/lib/ecore_txt/ecore_txt_private.h4
9 files changed, 167 insertions, 0 deletions
diff --git a/ecore/src/lib/ecore_txt/.cvsignore b/ecore/src/lib/ecore_txt/.cvsignore
new file mode 100644
index 0000000..e599172
--- /dev/null
+++ b/ecore/src/lib/ecore_txt/.cvsignore
@@ -0,0 +1,6 @@
+.deps
+.libs
+Makefile
+Makefile.in
+ecore_txt.lo
+libecore_txt.la
diff --git a/ecore/src/lib/ecore_txt/CVS/Entries b/ecore/src/lib/ecore_txt/CVS/Entries
new file mode 100644
index 0000000..bdeacd8
--- /dev/null
+++ b/ecore/src/lib/ecore_txt/CVS/Entries
@@ -0,0 +1,6 @@
+/.cvsignore/1.2/Fri Jan 16 16:59:05 2004//THEAD
+/Ecore_Txt.h/1.4/Mon Nov 29 22:26:30 2004//THEAD
+/Makefile.am/1.5/Thu Mar 10 15:19:42 2005//THEAD
+/ecore_txt.c/1.6/Wed Mar 2 07:06:42 2005//THEAD
+/ecore_txt_private.h/1.1/Thu Oct 9 07:49:59 2003//THEAD
+D
diff --git a/ecore/src/lib/ecore_txt/CVS/Repository b/ecore/src/lib/ecore_txt/CVS/Repository
new file mode 100644
index 0000000..6d66175
--- /dev/null
+++ b/ecore/src/lib/ecore_txt/CVS/Repository
@@ -0,0 +1 @@
+e17/libs/ecore/src/lib/ecore_txt
diff --git a/ecore/src/lib/ecore_txt/CVS/Root b/ecore/src/lib/ecore_txt/CVS/Root
new file mode 100644
index 0000000..0b69fe3
--- /dev/null
+++ b/ecore/src/lib/ecore_txt/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@cvs.sourceforge.net:/cvsroot/enlightenment
diff --git a/ecore/src/lib/ecore_txt/CVS/Tag b/ecore/src/lib/ecore_txt/CVS/Tag
new file mode 100644
index 0000000..3903919
--- /dev/null
+++ b/ecore/src/lib/ecore_txt/CVS/Tag
@@ -0,0 +1 @@
+NHEAD
diff --git a/ecore/src/lib/ecore_txt/Ecore_Txt.h b/ecore/src/lib/ecore_txt/Ecore_Txt.h
new file mode 100644
index 0000000..60dc659
--- /dev/null
+++ b/ecore/src/lib/ecore_txt/Ecore_Txt.h
@@ -0,0 +1,36 @@
+#ifndef _ECORE_TXT_H
+#define _ECORE_TXT_H
+
+#ifdef EAPI
+#undef EAPI
+#endif
+#ifdef WIN32
+# ifdef BUILDING_DLL
+# define EAPI __declspec(dllexport)
+# else
+# define EAPI __declspec(dllimport)
+# endif
+#else
+# ifdef GCC_HASCLASSVISIBILITY
+# define EAPI __attribute__ ((visibility("default")))
+# else
+# define EAPI
+# endif
+#endif
+
+/**
+ * @file Ecore_Txt.h
+ * @brief Provides a text encoding conversion function.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+EAPI char *ecore_txt_convert(const char *enc_from, const char *enc_to, const char *text);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/ecore/src/lib/ecore_txt/Makefile.am b/ecore/src/lib/ecore_txt/Makefile.am
new file mode 100644
index 0000000..e3fdd01
--- /dev/null
+++ b/ecore/src/lib/ecore_txt/Makefile.am
@@ -0,0 +1,34 @@
+MAINTAINERCLEANFILES = Makefile.in
+
+INCLUDES = \
+-I$(top_srcdir)/src/lib/ecore \
+-I$(top_builddir)/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
diff --git a/ecore/src/lib/ecore_txt/ecore_txt.c b/ecore/src/lib/ecore_txt/ecore_txt.c
new file mode 100644
index 0000000..cab8f5d
--- /dev/null
+++ b/ecore/src/lib/ecore_txt/ecore_txt.c
@@ -0,0 +1,78 @@
+#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>
+
+/**
+ * To be documented.
+ *
+ * FIXME: Finish this.
+ */
+char *
+ecore_txt_convert(const char *enc_from, const char *enc_to, const 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 = (char*)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 == (size_t)(-1))
+ {
+ if (errno == E2BIG)
+ {
+ new_txt = realloc(new_txt, outalloc + 64);
+ outalloc += 64;
+ outb += 64;
+ }
+ else if (errno == EILSEQ)
+ {
+ if (new_txt) free(new_txt);
+ new_txt = NULL;
+ break;
+ }
+ else if (errno == EINVAL)
+ {
+ if (new_txt) free(new_txt);
+ new_txt = NULL;
+ break;
+ }
+ else
+ {
+ if (new_txt) free(new_txt);
+ new_txt = NULL;
+ break;
+ }
+ }
+ if (inb == 0)
+ {
+ if (outalloc == outlen) new_txt = realloc(new_txt, outalloc + 1);
+ new_txt[outlen] = 0;
+ break;
+ }
+ }
+ iconv_close(ic);
+ return new_txt;
+}
diff --git a/ecore/src/lib/ecore_txt/ecore_txt_private.h b/ecore/src/lib/ecore_txt/ecore_txt_private.h
new file mode 100644
index 0000000..b3e975a
--- /dev/null
+++ b/ecore/src/lib/ecore_txt/ecore_txt_private.h
@@ -0,0 +1,4 @@
+#ifndef _ECORE_TXT_PRIVATE_H
+#define _ECORE_TXT_PRIVATE_H
+
+#endif