The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/iconv.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 2000-2001, Boris Popov
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  * 3. All advertising materials mentioning features or use of this software
   14  *    must display the following acknowledgement:
   15  *    This product includes software developed by Boris Popov.
   16  * 4. Neither the name of the author nor the names of any co-contributors
   17  *    may be used to endorse or promote products derived from this software
   18  *    without specific prior written permission.
   19  *
   20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   30  * SUCH DAMAGE.
   31  *
   32  * $FreeBSD: releng/5.0/sys/sys/iconv.h 100080 2002-07-15 13:34:50Z markm $
   33  */
   34 #ifndef _SYS_ICONV_H_
   35 #define _SYS_ICONV_H_
   36 
   37 #define ICONV_CSNMAXLEN         31      /* maximum length of charset name */
   38 #define ICONV_CNVNMAXLEN        31      /* maximum length of converter name */
   39 #define ICONV_CSMAXDATALEN      1024    /* maximum size of data associated with cs pair */
   40 
   41 /*
   42  * Entry for cslist sysctl
   43  */
   44 #define ICONV_CSPAIR_INFO_VER   1
   45 
   46 struct iconv_cspair_info {
   47         int     cs_version;
   48         int     cs_id;
   49         int     cs_base;
   50         int     cs_refcount;
   51         char    cs_to[ICONV_CSNMAXLEN];
   52         char    cs_from[ICONV_CSNMAXLEN];
   53 };
   54 
   55 /*
   56  * Paramters for 'add' sysctl
   57  */
   58 #define ICONV_ADD_VER   1
   59 
   60 struct iconv_add_in {
   61         int     ia_version;
   62         char    ia_converter[ICONV_CNVNMAXLEN];
   63         char    ia_to[ICONV_CSNMAXLEN];
   64         char    ia_from[ICONV_CSNMAXLEN];
   65         int     ia_datalen;
   66         const void *ia_data;
   67 };
   68 
   69 struct iconv_add_out {
   70         int     ia_csid;
   71 };
   72 
   73 #ifndef _KERNEL
   74 
   75 __BEGIN_DECLS
   76 
   77 int   kiconv_add_xlat_table(const char *, const char *, const u_char *);
   78 
   79 __END_DECLS
   80 
   81 #else /* !_KERNEL */
   82 
   83 #include <sys/kobj.h>
   84 #include <sys/queue.h>                  /* can't avoid that */
   85 #include <sys/sysctl.h>                 /* can't avoid that */
   86 
   87 struct iconv_cspair;
   88 struct iconv_cspairdata;
   89 
   90 /*
   91  * iconv converter class definition
   92  */
   93 struct iconv_converter_class {
   94         KOBJ_CLASS_FIELDS;
   95         TAILQ_ENTRY(iconv_converter_class)      cc_link;
   96 };
   97 
   98 struct iconv_cspair {
   99         int             cp_id;          /* unique id of charset pair */
  100         int             cp_refcount;    /* number of references from other pairs */
  101         const char *    cp_from;
  102         const char *    cp_to;
  103         void *          cp_data;
  104         struct iconv_converter_class * cp_dcp;
  105         struct iconv_cspair *cp_base;
  106         TAILQ_ENTRY(iconv_cspair)       cp_link;
  107 };
  108 
  109 #define KICONV_CONVERTER(name,size)                             \
  110     static DEFINE_CLASS(iconv_ ## name, iconv_ ## name ## _methods, (size)); \
  111     static moduledata_t iconv_ ## name ## _mod = {      \
  112         "iconv_"#name, iconv_converter_handler,         \
  113         (void*)&iconv_ ## name ## _class                \
  114     };                                                  \
  115     DECLARE_MODULE(iconv_ ## name, iconv_ ## name ## _mod, SI_SUB_DRIVERS, SI_ORDER_ANY);
  116 
  117 #define KICONV_CES(name,size)                           \
  118     static DEFINE_CLASS(iconv_ces_ ## name, iconv_ces_ ## name ## _methods, (size)); \
  119     static moduledata_t iconv_ces_ ## name ## _mod = {  \
  120         "iconv_ces_"#name, iconv_cesmod_handler,        \
  121         (void*)&iconv_ces_ ## name ## _class            \
  122     };                                                  \
  123     DECLARE_MODULE(iconv_ces_ ## name, iconv_ces_ ## name ## _mod, SI_SUB_DRIVERS, SI_ORDER_ANY);
  124 
  125 #ifdef MALLOC_DECLARE
  126 MALLOC_DECLARE(M_ICONV);
  127 #endif
  128 
  129 /*
  130  * Basic conversion functions
  131  */
  132 int iconv_open(const char *to, const char *from, void **handle);
  133 int iconv_close(void *handle);
  134 int iconv_conv(void *handle, const char **inbuf,
  135         size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
  136 char* iconv_convstr(void *handle, char *dst, const char *src);
  137 void* iconv_convmem(void *handle, void *dst, const void *src, int size);
  138 
  139 /*
  140  * Internal functions
  141  */
  142 int iconv_lookupcp(char **cpp, const char *s);
  143 
  144 int iconv_converter_initstub(struct iconv_converter_class *dp);
  145 int iconv_converter_donestub(struct iconv_converter_class *dp);
  146 int iconv_converter_handler(module_t mod, int type, void *data);
  147 
  148 #ifdef ICONV_DEBUG
  149 #define ICDEBUG(format, ...) printf("%s: "format, __func__ , __VA_ARGS__)
  150 #else
  151 #define ICDEBUG(format, ...)
  152 #endif
  153 
  154 #endif /* !_KERNEL */
  155 
  156 #endif /* !_SYS_ICONV_H_ */

Cache object: eb77223d73988f05764f85bc5db2b6a7


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.