Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Citrus iconv support(4)



details:   https://anonhg.NetBSD.org/src/rev/ce579f1d8857
branches:  trunk
changeset: 548455:ce579f1d8857
user:      tshiozak <tshiozak%NetBSD.org@localhost>
date:      Fri Jun 27 05:21:49 2003 +0000

description:
Citrus iconv support(4)
add iconv external I/F (iconv.h - iconv_open()/iconv()/iconv_close()) and
iconv(1) utility.
TODO:
  - bump libc minor.
  - add iconv data files.
  - create manpages: iconv_open(3)/iconv(3)/iconv_close(3)/iconv(1)/
    mkesdb(1)/mkcsmapper(1).

diffstat:

 distrib/sets/lists/base/mi   |    3 +-
 distrib/sets/lists/comp/mi   |    3 +-
 include/Makefile             |    4 +-
 include/iconv.h              |   58 ++++++++++++
 lib/libc/Makefile            |    5 +-
 lib/libc/iconv/Makefile.inc  |    9 +
 lib/libc/iconv/iconv.c       |  184 +++++++++++++++++++++++++++++++++++++++
 lib/libc/include/namespace.h |    5 +-
 usr.bin/Makefile             |    4 +-
 usr.bin/iconv/Makefile       |    9 +
 usr.bin/iconv/iconv.c        |  202 +++++++++++++++++++++++++++++++++++++++++++
 11 files changed, 477 insertions(+), 9 deletions(-)

diffs (truncated from 595 to 300 lines):

diff -r 7c9cb47d2998 -r ce579f1d8857 distrib/sets/lists/base/mi
--- a/distrib/sets/lists/base/mi        Fri Jun 27 05:01:21 2003 +0000
+++ b/distrib/sets/lists/base/mi        Fri Jun 27 05:21:49 2003 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.413 2003/06/26 09:25:58 wiz Exp $
+# $NetBSD: mi,v 1.414 2003/06/27 05:21:49 tshiozak Exp $
 .                      base-sys-root
 ./altroot              base-sys-root
 ./bin                  base-sys-root
@@ -251,6 +251,7 @@
 ./usr/bin/hexdump      base-util-bin
 ./usr/bin/host         base-netutil-bin
 ./usr/bin/hoststat     base-mailwrapper-bin
+./usr/bin/iconv                base-util-bin
 ./usr/bin/id           base-util-bin
 # This is in `base-util-bin', not `base-rcs-bin' as it is used by pkgsrc
 ./usr/bin/ident                base-util-bin
diff -r 7c9cb47d2998 -r ce579f1d8857 distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi        Fri Jun 27 05:01:21 2003 +0000
+++ b/distrib/sets/lists/comp/mi        Fri Jun 27 05:21:49 2003 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: mi,v 1.585 2003/06/25 18:58:23 tshiozak Exp $
+#      $NetBSD: mi,v 1.586 2003/06/27 05:21:51 tshiozak Exp $
 ./usr/bin/addr2line            comp-debug-bin
 ./usr/bin/ar                   comp-util-bin
 ./usr/bin/as                   comp-util-bin
@@ -235,6 +235,7 @@
 ./usr/include/gssapi/gssapi.h          comp-krb5-include
 ./usr/include/hesiod.h                 comp-c-include
 ./usr/include/histedit.h               comp-c-include
+./usr/include/iconv.h                  comp-c-include
 ./usr/include/ifaddrs.h                        comp-c-include
 ./usr/include/inttypes.h               comp-c-include
 ./usr/include/iso646.h                 comp-c-include
diff -r 7c9cb47d2998 -r ce579f1d8857 include/Makefile
--- a/include/Makefile  Fri Jun 27 05:01:21 2003 +0000
+++ b/include/Makefile  Fri Jun 27 05:21:49 2003 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.109 2003/03/22 12:45:51 jdolecek Exp $
+#      $NetBSD: Makefile,v 1.110 2003/06/27 05:21:56 tshiozak Exp $
 #      @(#)Makefile    8.2 (Berkeley) 1/4/94
 
 # Doing a make includes builds /usr/include
@@ -9,7 +9,7 @@
 
 INCS=  a.out.h ar.h assert.h bitstring.h bm.h cpio.h ctype.h db.h dirent.h \
        disktab.h dlfcn.h err.h errno.h fmtmsg.h fnmatch.h fstab.h fts.h \
-       getopt.h glob.h grp.h ifaddrs.h \
+       getopt.h glob.h grp.h ifaddrs.h iconv.h \
        inttypes.h iso646.h kvm.h langinfo.h libgen.h \
        limits.h link.h link_aout.h link_elf.h locale.h \
        login_cap.h lwp.h malloc.h math.h md2.h md4.h md5.h \
diff -r 7c9cb47d2998 -r ce579f1d8857 include/iconv.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/include/iconv.h   Fri Jun 27 05:21:49 2003 +0000
@@ -0,0 +1,58 @@
+/*     $NetBSD: iconv.h,v 1.1 2003/06/27 05:21:56 tshiozak Exp $       */
+
+/*-
+ * Copyright (c)2003 Citrus Project,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#ifndef _ICONV_H_
+#define _ICONV_H_
+
+#include <sys/cdefs.h>
+#include <machine/ansi.h>
+
+#ifdef _BSD_SIZE_T_
+typedef        _BSD_SIZE_T_    size_t;
+#undef _BSD_SIZE_T_
+#endif
+
+typedef        void    *iconv_t;
+
+__BEGIN_DECLS
+iconv_t        iconv_open      __P((const char *, const char *));
+size_t iconv           __P((iconv_t, const char **, size_t *, char **,
+                            size_t *));
+int    iconv_close     __P((iconv_t));
+/*
+ * non-portable interfaces for iconv
+ */
+int    __iconv_get_list        __P((char ***, size_t *));
+void   __iconv_free_list       __P((char **, size_t));
+size_t __iconv                 __P((iconv_t, const char **, size_t *, char **,
+                                    size_t *, __uint32_t, size_t *));
+#define __ICONV_F_HIDE_INVALID 0x0001
+__END_DECLS
+
+#endif
diff -r 7c9cb47d2998 -r ce579f1d8857 lib/libc/Makefile
--- a/lib/libc/Makefile Fri Jun 27 05:01:21 2003 +0000
+++ b/lib/libc/Makefile Fri Jun 27 05:21:49 2003 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.110 2003/04/14 05:21:50 salo Exp $
+#      $NetBSD: Makefile,v 1.111 2003/06/27 05:21:52 tshiozak Exp $
 #      @(#)Makefile    8.2 (Berkeley) 2/3/94
 #
 # All library objects contain sccsid strings by default; they may be
@@ -71,12 +71,13 @@
 .endif
 
 .include "${.CURDIR}/db/Makefile.inc"
+.include "${.CURDIR}/citrus/Makefile.inc"
 .include "${.CURDIR}/compat-43/Makefile.inc"
 .include "${.CURDIR}/dlfcn/Makefile.inc"
 .include "${.CURDIR}/gen/Makefile.inc"
 .include "${.CURDIR}/gmon/Makefile.inc"
 .include "${.CURDIR}/hash/Makefile.inc"
-.include "${.CURDIR}/citrus/Makefile.inc"
+.include "${.CURDIR}/iconv/Makefile.inc"
 .include "${.CURDIR}/locale/Makefile.inc"
 .include "${.CURDIR}/md/Makefile.inc"
 .include "${.CURDIR}/net/Makefile.inc"
diff -r 7c9cb47d2998 -r ce579f1d8857 lib/libc/iconv/Makefile.inc
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/iconv/Makefile.inc       Fri Jun 27 05:21:49 2003 +0000
@@ -0,0 +1,9 @@
+#      $NetBSD: Makefile.inc,v 1.1 2003/06/27 05:21:53 tshiozak Exp $
+
+.PATH: ${ARCHDIR}/iconv ${.CURDIR}/iconv
+
+SRCS+= iconv.c
+
+.if ${CITRUS} == "yes"
+CPPFLAGS+= -DCITRUS_ICONV
+.endif
diff -r 7c9cb47d2998 -r ce579f1d8857 lib/libc/iconv/iconv.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libc/iconv/iconv.c    Fri Jun 27 05:21:49 2003 +0000
@@ -0,0 +1,184 @@
+/*     $NetBSD: iconv.c,v 1.1 2003/06/27 05:21:53 tshiozak Exp $       */
+
+/*-
+ * Copyright (c)2003 Citrus Project,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: iconv.c,v 1.1 2003/06/27 05:21:53 tshiozak Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include "namespace.h"
+#include <assert.h>
+#include <errno.h>
+#include <paths.h>
+
+#include <iconv.h>
+
+#ifdef CITRUS_ICONV
+#include <sys/types.h>
+#include <citrus/citrus_types.h>
+#include <citrus/citrus_module.h>
+#include <citrus/citrus_esdb.h>
+#include <citrus/citrus_iconv.h>
+
+#define ISBADF(_h_)    (!(_h_) || (_h_) == (iconv_t)-1)
+
+#ifdef __weak_alias
+__weak_alias(iconv, _iconv)
+__weak_alias(iconv_open, _iconv_open)
+__weak_alias(iconv_close, _iconv_close)
+#endif
+
+iconv_t
+_iconv_open(const char *out, const char *in)
+{
+       int ret;
+       struct _citrus_iconv *handle;
+
+       ret = _citrus_iconv_open(&handle, _PATH_ICONV, in, out);
+       if (ret) {
+               errno = ret;
+               return ((iconv_t)-1);
+       }
+
+       return ((iconv_t)handle);
+}
+
+int
+_iconv_close(iconv_t handle)
+{
+       if (ISBADF(handle)) {
+               errno = EBADF;
+               return (-1);
+       }
+
+       _citrus_iconv_close((struct _citrus_iconv *)handle);
+
+       return (0);
+}
+
+size_t
+_iconv(iconv_t handle, const char **in, size_t *szin, char **out, size_t *szout)
+{
+       int err;
+       size_t ret;
+
+       if (ISBADF(handle)) {
+               errno = EBADF;
+               return ((size_t)-1);
+       }
+
+       err = _citrus_iconv_convert(
+               (struct _citrus_iconv *)handle, in, szin, out, szout, 0, &ret);
+       if (err) {
+               errno = err;
+               ret = (size_t)-1;
+       }
+
+       return (ret);
+}
+
+size_t
+__iconv(iconv_t handle, const char **in, size_t *szin, char **out,
+       size_t *szout, u_int32_t flags, size_t *invalids)
+{
+       int err;
+       size_t ret;
+
+       if (ISBADF(handle)) {
+               errno = EBADF;
+               return ((size_t)-1);
+       }
+
+       err = _citrus_iconv_convert(
+               (struct _citrus_iconv *)handle, in, szin, out, szout,
+               flags, &ret);
+       if (invalids)
+               *invalids = ret;
+       if (err) {
+               errno = err;
+               ret = (size_t)-1;
+       }
+
+       return (ret);
+}
+
+int
+__iconv_get_list(char ***rlist, size_t *rsz)
+{
+       int ret;
+
+       ret = _citrus_esdb_get_list(rlist, rsz);
+       if (ret) {
+               errno = ret;
+               return -1;
+       }
+
+       return 0;
+}
+
+void
+__iconv_free_list(char **list, size_t sz)



Home | Main Index | Thread Index | Old Index