FreeBSD kernel libkern code
iconv.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/iconv.h>
#include <sys/malloc.h>
#include <sys/mount.h>
#include <sys/sx.h>
#include <sys/syslog.h>
#include "iconv_converter_if.h"
Include dependency graph for iconv.c:

Go to the source code of this file.

Functions

 __FBSDID ("$FreeBSD$")
 
 SYSCTL_DECL (_kern_iconv)
 
 SYSCTL_NODE (_kern, OID_AUTO, iconv, CTLFLAG_RW|CTLFLAG_MPSAFE, NULL, "kernel iconv interface")
 
 MALLOC_DEFINE (M_ICONV, "iconv", "ICONV structures")
 
static MALLOC_DEFINE (M_ICONVDATA, "iconv_data", "ICONV data")
 
 MODULE_VERSION (libiconv, 2)
 
static TAILQ_HEAD (iconv_converter_list, iconv_converter_class)
 
static int iconv_mod_handler (module_t mod, int type, void *data)
 
 DECLARE_MODULE (iconv, iconv_mod, SI_SUB_DRIVERS, SI_ORDER_SECOND)
 
static int iconv_register_converter (struct iconv_converter_class *dcp)
 
static int iconv_unregister_converter (struct iconv_converter_class *dcp)
 
static int iconv_lookupconv (const char *name, struct iconv_converter_class **dcpp)
 
static int iconv_lookupcs (const char *to, const char *from, struct iconv_cspair **cspp)
 
static int iconv_register_cspair (const char *to, const char *from, struct iconv_converter_class *dcp, void *data, struct iconv_cspair **cspp)
 
static void iconv_unregister_cspair (struct iconv_cspair *csp)
 
int iconv_open (const char *to, const char *from, void **handle)
 
int iconv_close (void *handle)
 
int iconv_conv (void *handle, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
 
int iconv_conv_case (void *handle, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft, int casetype)
 
int iconv_convchr (void *handle, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
 
int iconv_convchr_case (void *handle, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft, int casetype)
 
int towlower (int c, void *handle)
 
int towupper (int c, void *handle)
 
static int iconv_sysctl_drvlist (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_kern_iconv, OID_AUTO, drvlist, CTLFLAG_RD|CTLTYPE_OPAQUE|CTLFLAG_MPSAFE, NULL, 0, iconv_sysctl_drvlist, "S,xlat", "registered converters")
 
static int iconv_sysctl_cslist (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_kern_iconv, OID_AUTO, cslist, CTLFLAG_RD|CTLTYPE_OPAQUE|CTLFLAG_MPSAFE, NULL, 0, iconv_sysctl_cslist, "S,xlat", "registered charset pairs")
 
int iconv_add (const char *converter, const char *to, const char *from)
 
static int iconv_sysctl_add (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC (_kern_iconv, OID_AUTO, add, CTLFLAG_RW|CTLTYPE_OPAQUE|CTLFLAG_MPSAFE, NULL, 0, iconv_sysctl_add, "S,xlat", "register charset pair")
 
int iconv_converter_initstub (struct iconv_converter_class *dp)
 
int iconv_converter_donestub (struct iconv_converter_class *dp)
 
int iconv_converter_tolowerstub (int c, void *handle)
 
int iconv_converter_handler (module_t mod, int type, void *data)
 
char * iconv_convstr (void *handle, char *dst, const char *src)
 
void * iconv_convmem (void *handle, void *dst, const void *src, int size)
 
int iconv_lookupcp (char **cpp, const char *s)
 
int iconv_vfs_refcount (const char *fsname)
 

Variables

static struct sx iconv_lock
 
struct sysctl_oid * iconv_oid_hook = &sysctl___kern_iconv
 
static moduledata_t iconv_mod
 

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ DECLARE_MODULE()

DECLARE_MODULE ( iconv  ,
iconv_mod  ,
SI_SUB_DRIVERS  ,
SI_ORDER_SECOND   
)

◆ iconv_add()

int iconv_add ( const char *  converter,
const char *  to,
const char *  from 
)

Definition at line 391 of file iconv.c.

References iconv_lookupconv(), and iconv_register_cspair().

Referenced by iconv_ucs_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iconv_close()

int iconv_close ( void *  handle)

Definition at line 277 of file iconv.c.

Referenced by iconv_ucs_close(), and iconv_xlat16_close().

Here is the caller graph for this function:

◆ iconv_conv()

int iconv_conv ( void *  handle,
const char **  inbuf,
size_t *  inbytesleft,
char **  outbuf,
size_t *  outbytesleft 
)

Definition at line 283 of file iconv.c.

References inbuf, inbytesleft, outbuf, and outbytesleft.

Referenced by iconv_convmem(), and iconv_convstr().

Here is the caller graph for this function:

◆ iconv_conv_case()

int iconv_conv_case ( void *  handle,
const char **  inbuf,
size_t *  inbytesleft,
char **  outbuf,
size_t *  outbytesleft,
int  casetype 
)

Definition at line 290 of file iconv.c.

References casetype, inbuf, inbytesleft, outbuf, and outbytesleft.

◆ iconv_convchr()

int iconv_convchr ( void *  handle,
const char **  inbuf,
size_t *  inbytesleft,
char **  outbuf,
size_t *  outbytesleft 
)

Definition at line 297 of file iconv.c.

References inbuf, inbytesleft, outbuf, and outbytesleft.

◆ iconv_convchr_case()

int iconv_convchr_case ( void *  handle,
const char **  inbuf,
size_t *  inbytesleft,
char **  outbuf,
size_t *  outbytesleft,
int  casetype 
)

Definition at line 304 of file iconv.c.

References casetype, inbuf, inbytesleft, outbuf, and outbytesleft.

Referenced by iconv_ucs_conv().

Here is the caller graph for this function:

◆ iconv_converter_donestub()

int iconv_converter_donestub ( struct iconv_converter_class *  dp)

Definition at line 469 of file iconv.c.

◆ iconv_converter_handler()

int iconv_converter_handler ( module_t  mod,
int  type,
void *  data 
)

Definition at line 481 of file iconv.c.

References iconv_lock, iconv_register_converter(), and iconv_unregister_converter().

Here is the call graph for this function:

◆ iconv_converter_initstub()

int iconv_converter_initstub ( struct iconv_converter_class *  dp)

Definition at line 463 of file iconv.c.

◆ iconv_converter_tolowerstub()

int iconv_converter_tolowerstub ( int  c,
void *  handle 
)

Definition at line 475 of file iconv.c.

References c.

◆ iconv_convmem()

void * iconv_convmem ( void *  handle,
void *  dst,
const void *  src,
int  size 
)

Definition at line 537 of file iconv.c.

References iconv_conv(), and memcpy().

Here is the call graph for this function:

◆ iconv_convstr()

char * iconv_convstr ( void *  handle,
char *  dst,
const char *  src 
)

Definition at line 515 of file iconv.c.

References iconv_conv(), strcpy(), and strlen().

Here is the call graph for this function:

◆ iconv_lookupconv()

static int iconv_lookupconv ( const char *  name,
struct iconv_converter_class **  dcpp 
)
static

Definition at line 152 of file iconv.c.

References name, and strcmp().

Referenced by iconv_add(), and iconv_sysctl_add().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iconv_lookupcp()

int iconv_lookupcp ( char **  cpp,
const char *  s 
)

Definition at line 561 of file iconv.c.

References strcmp().

Here is the call graph for this function:

◆ iconv_lookupcs()

static int iconv_lookupcs ( const char *  to,
const char *  from,
struct iconv_cspair **  cspp 
)
static

Definition at line 169 of file iconv.c.

References strcasecmp().

Referenced by iconv_open(), and iconv_register_cspair().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iconv_mod_handler()

static int iconv_mod_handler ( module_t  mod,
int  type,
void *  data 
)
static

Definition at line 105 of file iconv.c.

References iconv_lock.

◆ iconv_open()

int iconv_open ( const char *  to,
const char *  from,
void **  handle 
)

Definition at line 240 of file iconv.c.

References cspfrom, cspto, and iconv_lookupcs().

Referenced by iconv_ucs_open(), and iconv_xlat16_open().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iconv_register_converter()

static int iconv_register_converter ( struct iconv_converter_class *  dcp)
static

Definition at line 130 of file iconv.c.

Referenced by iconv_converter_handler().

Here is the caller graph for this function:

◆ iconv_register_cspair()

static int iconv_register_cspair ( const char *  to,
const char *  from,
struct iconv_converter_class *  dcp,
void *  data,
struct iconv_cspair **  cspp 
)
static

Definition at line 185 of file iconv.c.

References iconv_lookupcs(), strcmp(), strcpy(), and strlen().

Referenced by iconv_add(), and iconv_sysctl_add().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ iconv_sysctl_add()

static int iconv_sysctl_add ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 406 of file iconv.c.

References iconv_lock, iconv_lookupconv(), iconv_register_cspair(), iconv_unregister_cspair(), and strnlen().

Here is the call graph for this function:

◆ iconv_sysctl_cslist()

static int iconv_sysctl_cslist ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 361 of file iconv.c.

References iconv_lock, and strcpy().

Here is the call graph for this function:

◆ iconv_sysctl_drvlist()

static int iconv_sysctl_drvlist ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 327 of file iconv.c.

References iconv_lock, name, and strlen().

Here is the call graph for this function:

◆ iconv_unregister_converter()

static int iconv_unregister_converter ( struct iconv_converter_class *  dcp)
static

Definition at line 139 of file iconv.c.

Referenced by iconv_converter_handler().

Here is the caller graph for this function:

◆ iconv_unregister_cspair()

static void iconv_unregister_cspair ( struct iconv_cspair *  csp)
static

Definition at line 226 of file iconv.c.

Referenced by iconv_sysctl_add().

Here is the caller graph for this function:

◆ iconv_vfs_refcount()

int iconv_vfs_refcount ( const char *  fsname)

Definition at line 577 of file iconv.c.

◆ MALLOC_DEFINE() [1/2]

MALLOC_DEFINE ( M_ICONV  ,
"iconv"  ,
"ICONV structures"   
)

◆ MALLOC_DEFINE() [2/2]

static MALLOC_DEFINE ( M_ICONVDATA  ,
"iconv_data"  ,
"ICONV data"   
)
static

◆ MODULE_VERSION()

MODULE_VERSION ( libiconv  ,
 
)

◆ SYSCTL_DECL()

SYSCTL_DECL ( _kern_iconv  )

◆ SYSCTL_NODE()

SYSCTL_NODE ( _kern  ,
OID_AUTO  ,
iconv  ,
CTLFLAG_RW|  CTLFLAG_MPSAFE,
NULL  ,
"kernel iconv interface"   
)

◆ SYSCTL_PROC() [1/3]

SYSCTL_PROC ( _kern_iconv  ,
OID_AUTO  ,
add  ,
CTLFLAG_RW|CTLTYPE_OPAQUE|  CTLFLAG_MPSAFE,
NULL  ,
,
iconv_sysctl_add  ,
S,
xlat"  ,
"register charset pair"   
)

◆ SYSCTL_PROC() [2/3]

SYSCTL_PROC ( _kern_iconv  ,
OID_AUTO  ,
cslist  ,
CTLFLAG_RD|CTLTYPE_OPAQUE|  CTLFLAG_MPSAFE,
NULL  ,
,
iconv_sysctl_cslist  ,
S,
xlat"  ,
"registered charset pairs"   
)

◆ SYSCTL_PROC() [3/3]

SYSCTL_PROC ( _kern_iconv  ,
OID_AUTO  ,
drvlist  ,
CTLFLAG_RD|CTLTYPE_OPAQUE|  CTLFLAG_MPSAFE,
NULL  ,
,
iconv_sysctl_drvlist  ,
S,
xlat"  ,
"registered converters"   
)

◆ TAILQ_HEAD()

static TAILQ_HEAD ( iconv_converter_list  ,
iconv_converter_class   
)
static

Definition at line 70 of file iconv.c.

◆ towlower()

int towlower ( int  c,
void *  handle 
)

Definition at line 311 of file iconv.c.

References c.

Referenced by iconv_ucs_conv(), and iconv_xlat16_conv().

Here is the caller graph for this function:

◆ towupper()

int towupper ( int  c,
void *  handle 
)

Definition at line 317 of file iconv.c.

References c.

Referenced by iconv_ucs_conv(), and iconv_xlat16_conv().

Here is the caller graph for this function:

Variable Documentation

◆ iconv_lock

struct sx iconv_lock
static

◆ iconv_mod

moduledata_t iconv_mod
static
Initial value:
= {
"iconv", iconv_mod_handler, NULL
}
static int iconv_mod_handler(module_t mod, int type, void *data)
Definition: iconv.c:105

Definition at line 123 of file iconv.c.

◆ iconv_oid_hook

struct sysctl_oid* iconv_oid_hook = &sysctl___kern_iconv

Definition at line 65 of file iconv.c.