$darkmode
#include <errno.h>#include <stdint.h>#include <sys/param.h>Go to the source code of this file.
Data Structures | |
| struct | atalk_iconv_t |
| struct | charset_functions |
Macros | |
| #define | ucs2_t uint16_t |
| #define | SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0) |
| #define | EILSEQ 84 |
| #define | CHARSET_CLIENT 1 |
| #define | CHARSET_VOLUME 2 |
| #define | CHARSET_PRECOMPOSED 4 |
| #define | CHARSET_DECOMPOSED 8 |
| #define | CHARSET_MULTIBYTE 16 |
| #define | CHARSET_WIDECHAR 32 |
| #define | CHARSET_ICONV 64 |
| #define | IGNORE_CHAR '_' |
| #define | CONV_IGNORE (1<<0) |
| #define | CONV_ESCAPEHEX (1<<1) |
| #define | CONV_ESCAPEDOTS (1<<2) |
| #define | CONV_UNESCAPEHEX (1<<3) |
| #define | CONV_TOUPPER (1<<4) |
| #define | CONV_TOLOWER (1<<5) |
| #define | CONV_PRECOMPOSE (1<<6) |
| #define | CONV_DECOMPOSE (1<<7) |
| #define | CONV_FORCE (1<<8) |
| #define | CONV__EILSEQ (1<<9) |
| #define | CONV_REQMANGLE (1<<14) |
| #define | CONV_REQESCAPE (1<<15) |
| #define | NUM_CHARSETS 5 |
Enumerations | |
| enum | charset_t { CH_UCS2 = 0 , CH_UTF8 = 1 , CH_MAC = 2 , CH_UNIX = 3 , CH_UTF8_MAC = 4 } |
Functions | |
| atalk_iconv_t | atalk_iconv_open (const char *, const char *) |
| size_t | atalk_iconv (atalk_iconv_t, const char **, size_t *, char **, size_t *) |
| This is a simple portable iconv() implementaion. More... | |
| int | atalk_iconv_close (atalk_iconv_t) |
| struct charset_functions * | find_charset_functions (const char *) |
| int | atalk_register_charset (struct charset_functions *) |
| ucs2_t | toupper_w (ucs2_t) |
| uint32_t | toupper_sp (uint32_t) |
| ucs2_t | tolower_w (ucs2_t) |
| uint32_t | tolower_sp (uint32_t) |
| int | strupper_w (ucs2_t *) |
| Convert a string to upper case. More... | |
| int | strlower_w (ucs2_t *) |
| Convert a string to lower case. More... | |
| size_t | strlen_w (const ucs2_t *) |
| wide strlen() More... | |
| size_t | strnlen_w (const ucs2_t *, size_t) |
| wide strnlen() More... | |
| ucs2_t * | strchr_w (const ucs2_t *, ucs2_t) |
| wide strchr() More... | |
| ucs2_t * | strcasechr_w (const ucs2_t *s, ucs2_t c) |
| wide strcasechr() More... | |
| int | strcmp_w (const ucs2_t *, const ucs2_t *) |
| wide strcmp() More... | |
| int | strncmp_w (const ucs2_t *, const ucs2_t *, size_t) |
| wide strncmp() More... | |
| int | strcasecmp_w (const ucs2_t *, const ucs2_t *) |
| wide strcasecmp() More... | |
| int | strncasecmp_w (const ucs2_t *, const ucs2_t *, size_t) |
| wide strncasecmp() More... | |
| ucs2_t * | strstr_w (const ucs2_t *s, const ucs2_t *ins) |
| wide strstr() More... | |
| ucs2_t * | strcasestr_w (const ucs2_t *, const ucs2_t *) |
| wide strcasestr() More... | |
| ucs2_t * | strndup_w (const ucs2_t *, size_t) |
| wide strndup() More... | |
| ucs2_t * | strdup_w (const ucs2_t *) |
| wide strdup() More... | |
| size_t | precompose_w (ucs2_t *, size_t, ucs2_t *, size_t *) |
| pre|decomposition More... | |
| size_t | decompose_w (ucs2_t *, size_t, ucs2_t *, size_t *) |
| int | set_charset_name (charset_t, const char *) |
| void | free_charset_names (void) |
| void | init_iconv (void) |
| Initialize iconv conversion descriptors. More... | |
| size_t | convert_string (charset_t, charset_t, void const *, size_t, void *, size_t) |
| size_t | convert_string_allocate (charset_t, charset_t, void const *, size_t, char **) |
| size_t | charset_strupper (charset_t, const char *, size_t, char *, size_t) |
| size_t | charset_strlower (charset_t, const char *, size_t, char *, size_t) |
| size_t | ucs2_to_charset_allocate (charset_t, char **dest, const ucs2_t *src) |
| size_t | ucs2_to_charset (charset_t, const ucs2_t *src, char *dest, size_t) |
| Copy a string from a UCS2 src to a unix char * destination, allocating a buffer. More... | |
| size_t | convert_charset (charset_t, charset_t, charset_t, const char *, size_t, char *, size_t, uint16_t *) |
| size_t | charset_precompose (charset_t, char *, size_t, char *, size_t) |
| size_t | charset_decompose (charset_t, char *, size_t, char *, size_t) |
| charset_t | add_charset (const char *name) |
| #define CHARSET_CLIENT 1 |
| #define CHARSET_DECOMPOSED 8 |
| #define CHARSET_ICONV 64 |
| #define CHARSET_MULTIBYTE 16 |
| #define CHARSET_PRECOMPOSED 4 |
| #define CHARSET_VOLUME 2 |
| #define CHARSET_WIDECHAR 32 |
| #define CONV__EILSEQ (1<<9) |
ignore EILSEQ, replace with IGNORE_CHAR (try USC2)
| #define CONV_DECOMPOSE (1<<7) |
decompose
| #define CONV_ESCAPEDOTS (1<<2) |
escape leading dots with :2600
| #define CONV_ESCAPEHEX (1<<1) |
escape unconvertable chars with :[UCS2HEX], also escape '/'. Escape ':' if also CONV_ALLOW_COLON, else ':' raises EILSEQ
| #define CONV_FORCE (1<<8) |
force convertion
| #define CONV_IGNORE (1<<0) |
return the first convertable characters.
| #define CONV_PRECOMPOSE (1<<6) |
precompose
| #define CONV_REQESCAPE (1<<15) |
espace unconvertable chars with :[UCS2HEX]
| #define CONV_REQMANGLE (1<<14) |
mangling of returned name is required
| #define CONV_TOLOWER (1<<5) |
convert to lowercase
| #define CONV_TOUPPER (1<<4) |
convert to UPPERcase
| #define CONV_UNESCAPEHEX (1<<3) |
| #define EILSEQ 84 |
Illegal byte sequence.
| #define IGNORE_CHAR '_' |
| #define NUM_CHARSETS 5 |
| #define ucs2_t uint16_t |
| enum charset_t |
| charset_t add_charset | ( | const char * | name | ) |
| 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.
| int atalk_iconv_close | ( | atalk_iconv_t | cd | ) |
simple iconv_close() wrapper
| atalk_iconv_t atalk_iconv_open | ( | const char * | tocode, |
| const char * | fromcode | ||
| ) |
simple iconv_open() wrapper
| int atalk_register_charset | ( | struct charset_functions * | funcs | ) |
| size_t charset_decompose | ( | charset_t | ch, |
| char * | src, | ||
| size_t | inlen, | ||
| char * | dst, | ||
| size_t | outlen | ||
| ) |
| size_t charset_precompose | ( | charset_t | ch, |
| char * | src, | ||
| size_t | inlen, | ||
| char * | dst, | ||
| size_t | outlen | ||
| ) |
| size_t charset_strlower | ( | charset_t | ch, |
| const char * | src, | ||
| size_t | srclen, | ||
| char * | dest, | ||
| size_t | destlen | ||
| ) |
| size_t charset_strupper | ( | charset_t | ch, |
| const char * | src, | ||
| size_t | srclen, | ||
| char * | dest, | ||
| size_t | destlen | ||
| ) |
| size_t convert_charset | ( | charset_t | from_set, |
| charset_t | to_set, | ||
| charset_t | cap_charset, | ||
| const char * | src, | ||
| size_t | src_len, | ||
| char * | dest, | ||
| size_t | dest_len, | ||
| uint16_t * | flags | ||
| ) |
| size_t convert_string | ( | charset_t | from, |
| charset_t | to, | ||
| void const * | src, | ||
| size_t | srclen, | ||
| void * | dest, | ||
| size_t | destlen | ||
| ) |
| size_t convert_string_allocate | ( | charset_t | from, |
| charset_t | to, | ||
| void const * | src, | ||
| size_t | srclen, | ||
| char ** | dest | ||
| ) |
| struct charset_functions * find_charset_functions | ( | const char * | name | ) |
| void free_charset_names | ( | void | ) |
| void init_iconv | ( | void | ) |
Initialize iconv conversion descriptors.
This is called the first time it is needed, and also called again every time the configuration is reloaded, because the charset or codepage might have changed.
pre|decomposition
we can't use static, this stuff needs to be reentrant static char comp[MAXPATHLEN +1];
We don't implement Singleton and Canonical Ordering. We ignore CompositionExclusions.txt because they cause the problem of the roundtrip such as Dancing Icon.
exclude U2000-U2FFF, UFE30-UFE4F and U2F800-U2FA1F ranges in precompose.h from composition according to AFP 3.x spec
| int set_charset_name | ( | charset_t | ch, |
| const char * | name | ||
| ) |
wide strcasechr()
wide strcasecmp()
case insensitive string comparison
wide strcasestr()
wide strchr()
wide strdup()
duplicate string
| size_t strlen_w | ( | const ucs2_t * | src | ) |
wide strlen()
Count the number of characters in a UTF-16 string.
| int strlower_w | ( | ucs2_t * | s | ) |
Convert a string to lower case.
wide strncasecmp()
case insensitive string comparison, length limited
wide strncmp()
wide strndup()
duplicate string
| size_t strnlen_w | ( | const ucs2_t * | src, |
| size_t | max | ||
| ) |
wide strnlen()
Count up to max number of characters in a UTF-16 string.
wide strstr()
| int strupper_w | ( | ucs2_t * | s | ) |
Convert a string to upper case.
| uint32_t tolower_sp | ( | uint32_t | val | ) |
| uint32_t toupper_sp | ( | uint32_t | val | ) |
Copy a string from a UCS2 src to a unix char * destination, allocating a buffer.
| ch | destination character set |
| src | source UCS2 string |
| dest | always set at least to NULL |
| destlen | maximum length of destination buffer |