netatalk  4.4.0dev
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
iconv.c File Reference

Samba wrapper/stub for iconv character set conversion. More...

#include <arpa/inet.h>
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <unistd.h>
#include <atalk/byteorder.h>
#include <atalk/logger.h>
#include <atalk/unicode.h>
#include <atalk/util.h>

Macros

#define CHARSET_WIDECHAR   32
#define UCS2ICONV   "UCS-2"
#define DLIST_ADD(list, p)

Functions

static size_t ascii_pull (void *, char **, size_t *, char **, size_t *)
static size_t ascii_push (void *, char **, size_t *, char **, size_t *)
static size_t iconv_copy (void *, char **, size_t *, char **, size_t *)
struct charset_functionsfind_charset_functions (const char *name)
int atalk_register_charset (struct charset_functions *funcs)
static void lazy_initialize_iconv (void)
static size_t sys_iconv (void *cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
size_t atalk_iconv (atalk_iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
atalk_iconv_t atalk_iconv_open (const char *tocode, const char *fromcode)
int atalk_iconv_close (atalk_iconv_t cd)
static size_t ascii_pull (void *cd _U_, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
static size_t ascii_push (void *cd _U_, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
static size_t iconv_copy (void *cd _U_, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)

Variables

struct charset_functions charset_mac_roman
struct charset_functions charset_mac_hebrew
struct charset_functions charset_mac_centraleurope
struct charset_functions charset_mac_cyrillic
struct charset_functions charset_mac_greek
struct charset_functions charset_mac_turkish
struct charset_functions charset_utf8
struct charset_functions charset_utf8_mac
static struct charset_functions builtin_functions []
static struct charset_functionscharsets = NULL

Detailed Description

Samba wrapper/stub for iconv character set conversion.

iconv is the XPG2 interface for converting between character encodings. This file provides a Samba wrapper around it, and also a simple reimplementation that is used if the system does not implement iconv.

Samba only works with encodings that are supersets of ASCII: ascii characters like whitespace can be tested for directly, multibyte sequences start with a byte with the high bit set, and strings are terminated by a nul byte.

Note that the only function provided by iconv is conversion between characters. It doesn't directly support operations like uppercasing or comparison. We have to convert to UCS-2 and compare there.

See also
Samba Developers Guide

Macro Definition Documentation

◆ CHARSET_WIDECHAR

#define CHARSET_WIDECHAR   32

◆ DLIST_ADD

#define DLIST_ADD ( list,
p )
Value:
{ \
if (!(list)) { \
(list) = (p); \
(p)->next = (p)->prev = NULL; \
} else { \
(list)->prev = (p); \
(p)->next = (list); \
(p)->prev = NULL; \
(list) = (p); \
}\
}
#define next
Definition hash.c:35
Definition etc/atalkd/list.h:6
static gcry_mpi_t p
Definition uams_dhx2_pam.c:39

◆ UCS2ICONV

#define UCS2ICONV   "UCS-2"

Function Documentation

◆ ascii_pull() [1/2]

size_t ascii_pull ( void * ,
char ** ,
size_t * ,
char ** ,
size_t *  )
static

◆ ascii_pull() [2/2]

size_t ascii_pull ( void *cd _U_,
char ** inbuf,
size_t * inbytesleft,
char ** outbuf,
size_t * outbytesleft )
static

◆ ascii_push() [1/2]

size_t ascii_push ( void * ,
char ** ,
size_t * ,
char ** ,
size_t *  )
static

◆ ascii_push() [2/2]

size_t ascii_push ( void *cd _U_,
char ** inbuf,
size_t * inbytesleft,
char ** outbuf,
size_t * outbytesleft )
static

◆ atalk_iconv()

size_t atalk_iconv ( atalk_iconv_t cd,
const char ** inbuf,
size_t * inbytesleft,
char ** outbuf,
size_t * outbytesleft )

This is a simple portable iconv() implementaion.

It only knows about a very small number of character sets - just enough that netatalk works on systems that don't have iconv.

◆ atalk_iconv_close()

int atalk_iconv_close ( atalk_iconv_t cd)

◆ atalk_iconv_open()

atalk_iconv_t atalk_iconv_open ( const char * tocode,
const char * fromcode )

◆ atalk_register_charset()

int atalk_register_charset ( struct charset_functions * funcs)

◆ find_charset_functions()

struct charset_functions * find_charset_functions ( const char * name)

◆ iconv_copy() [1/2]

size_t iconv_copy ( void * ,
char ** ,
size_t * ,
char ** ,
size_t *  )
static

◆ iconv_copy() [2/2]

size_t iconv_copy ( void *cd _U_,
char ** inbuf,
size_t * inbytesleft,
char ** outbuf,
size_t * outbytesleft )
static

◆ lazy_initialize_iconv()

void lazy_initialize_iconv ( void )
static

◆ sys_iconv()

size_t sys_iconv ( void * cd,
char ** inbuf,
size_t * inbytesleft,
char ** outbuf,
size_t * outbytesleft )
static

Variable Documentation

◆ builtin_functions

struct charset_functions builtin_functions[]
static
Initial value:
= {
{"UCS-2", 0, iconv_copy, iconv_copy, CHARSET_WIDECHAR | CHARSET_PRECOMPOSED, NULL, NULL, NULL},
{"ASCII", 0, ascii_pull, ascii_push, CHARSET_MULTIBYTE | CHARSET_PRECOMPOSED, NULL, NULL, NULL},
{NULL, 0, NULL, NULL, 0, NULL, NULL, NULL}
}
static size_t iconv_copy(void *, char **, size_t *, char **, size_t *)
static size_t ascii_pull(void *, char **, size_t *, char **, size_t *)
static size_t ascii_push(void *, char **, size_t *, char **, size_t *)
#define CHARSET_PRECOMPOSED
Definition unicode.h:30
#define CHARSET_MULTIBYTE
Definition unicode.h:32
#define CHARSET_WIDECHAR
Definition unicode.h:33

◆ charset_mac_centraleurope

struct charset_functions charset_mac_centraleurope
extern

◆ charset_mac_cyrillic

struct charset_functions charset_mac_cyrillic
extern

◆ charset_mac_greek

struct charset_functions charset_mac_greek
extern

◆ charset_mac_hebrew

struct charset_functions charset_mac_hebrew
extern

◆ charset_mac_roman

struct charset_functions charset_mac_roman
extern

◆ charset_mac_turkish

struct charset_functions charset_mac_turkish
extern

◆ charset_utf8

struct charset_functions charset_utf8
extern

◆ charset_utf8_mac

struct charset_functions charset_utf8_mac
extern

◆ charsets

struct charset_functions* charsets = NULL
static