1120492Sfjoe/* 2120492Sfjoe * Copyright (c) 2000-2001, Boris Popov 3120492Sfjoe * All rights reserved. 4120492Sfjoe * 5120492Sfjoe * Redistribution and use in source and binary forms, with or without 6120492Sfjoe * modification, are permitted provided that the following conditions 7120492Sfjoe * are met: 8120492Sfjoe * 1. Redistributions of source code must retain the above copyright 9120492Sfjoe * notice, this list of conditions and the following disclaimer. 10120492Sfjoe * 2. Redistributions in binary form must reproduce the above copyright 11120492Sfjoe * notice, this list of conditions and the following disclaimer in the 12120492Sfjoe * documentation and/or other materials provided with the distribution. 13120492Sfjoe * 3. All advertising materials mentioning features or use of this software 14120492Sfjoe * must display the following acknowledgement: 15120492Sfjoe * This product includes software developed by Boris Popov. 16120492Sfjoe * 4. Neither the name of the author nor the names of any co-contributors 17120492Sfjoe * may be used to endorse or promote products derived from this software 18120492Sfjoe * without specific prior written permission. 19120492Sfjoe * 20120492Sfjoe * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 21120492Sfjoe * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22120492Sfjoe * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23120492Sfjoe * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 24120492Sfjoe * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25120492Sfjoe * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26120492Sfjoe * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27120492Sfjoe * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28120492Sfjoe * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29120492Sfjoe * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30120492Sfjoe * SUCH DAMAGE. 31120492Sfjoe * 32120492Sfjoe * $FreeBSD$ 33120492Sfjoe */ 34120492Sfjoe 35120492Sfjoe/* 36120492Sfjoe * kiconv(3) requires shared linked, and reduce module size 37120492Sfjoe * when statically linked. 38120492Sfjoe */ 39120492Sfjoe 40120492Sfjoe#ifdef PIC 41120492Sfjoe 42120492Sfjoe#include <sys/types.h> 43120492Sfjoe#include <sys/iconv.h> 44120492Sfjoe#include <sys/sysctl.h> 45120492Sfjoe 46120492Sfjoe#include <ctype.h> 47120492Sfjoe#include <errno.h> 48120492Sfjoe#include <string.h> 49120492Sfjoe 50120492Sfjoeint 51120492Sfjoekiconv_add_xlat16_table(const char *to, const char *from, const void *data, int datalen) 52120492Sfjoe{ 53120492Sfjoe struct iconv_add_in din; 54120492Sfjoe struct iconv_add_out dout; 55120492Sfjoe size_t olen; 56120492Sfjoe 57149415Simura if (strlen(from) >= ICONV_CSNMAXLEN || strlen(to) >= ICONV_CSNMAXLEN) 58120492Sfjoe return (EINVAL); 59120492Sfjoe din.ia_version = ICONV_ADD_VER; 60120492Sfjoe strcpy(din.ia_converter, "xlat16"); 61120492Sfjoe strcpy(din.ia_from, from); 62120492Sfjoe strcpy(din.ia_to, to); 63120492Sfjoe din.ia_data = data; 64120492Sfjoe din.ia_datalen = datalen; 65120492Sfjoe olen = sizeof(dout); 66120492Sfjoe if (sysctlbyname("kern.iconv.add", &dout, &olen, &din, sizeof(din)) == -1) 67120492Sfjoe return (errno); 68120492Sfjoe return (0); 69120492Sfjoe} 70120492Sfjoe 71120492Sfjoe#else /* statically linked */ 72120492Sfjoe 73194637Sdelphij#include <sys/types.h> 74194637Sdelphij#include <sys/iconv.h> 75120492Sfjoe#include <errno.h> 76120492Sfjoe 77120492Sfjoeint 78194637Sdelphijkiconv_add_xlat16_table(const char *to __unused, const char *from __unused, 79194637Sdelphij const void *data __unused, int datalen __unused) 80120492Sfjoe{ 81194637Sdelphij 82120492Sfjoe return (EINVAL); 83120492Sfjoe} 84120492Sfjoe 85120492Sfjoe#endif /* PIC */ 86