NCBI C++ ToolKit
Macros | Typedefs | Enumerations | Functions | Variables
iconv.c File Reference

This file implements a very simple iconv. More...

#include <config.h>
#include <assert.h>
#include <ctype.h>
#include <freetds/tds.h>
#include <freetds/bytes.h>
#include <freetds/iconv.h>
#include <freetds/bool.h>
#include <freetds/utils/bjoern-utf8.h>
#include "iconv_charsets.h"
+ Include dependency graph for iconv.c:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Go to the SVN repository for this file.

Macros

#define MASK(n)   ((0xffffffffu << (n)) & 0xffffffffu)
 
#define CP1252(i, o)   case o: c = i; break;
 
#define CD   ((int) (TDS_INTPTR) cd)
 

Typedefs

typedef uint32_t ICONV_CHAR
 
typedef int(* iconv_get_t) (const unsigned char *p, size_t len, ICONV_CHAR *out)
 
typedef int(* iconv_put_t) (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
 

Enumerations

enum  ICONV_CD_VALUE { Like_to_Like = 0x100 , Like_to_Like = 0x100 }
 

Functions

static int get_utf8 (const unsigned char *p, size_t len, ICONV_CHAR *out)
 
static int put_utf8 (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
 
static int get_ucs4le (const unsigned char *p, size_t len, ICONV_CHAR *out)
 
static int put_ucs4le (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
 
static int get_ucs4be (const unsigned char *p, size_t len, ICONV_CHAR *out)
 
static int put_ucs4be (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
 
static int get_utf16le (const unsigned char *p, size_t len, ICONV_CHAR *out)
 
static int put_utf16le (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
 
static int get_utf16be (const unsigned char *p, size_t len, ICONV_CHAR *out)
 
static int put_utf16be (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
 
static int get_iso1 (const unsigned char *p, size_t len, ICONV_CHAR *out)
 
static int put_iso1 (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
 
static int get_ascii (const unsigned char *p, size_t len, ICONV_CHAR *out)
 
static int put_ascii (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
 
static int get_cp1252 (const unsigned char *p, size_t len, ICONV_CHAR *out)
 
static int put_cp1252 (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
 
static int get_err (const unsigned char *p, size_t len, ICONV_CHAR *out)
 
static int put_err (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
 
iconv_t tds_sys_iconv_open (const char *tocode, const char *fromcode)
 Inputs are FreeTDS canonical names, no other. More...
 
int tds_sys_iconv_close (iconv_t cd)
 
size_t tds_sys_iconv (iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
 

Variables

static const iconv_get_t iconv_gets [16]
 
static const iconv_put_t iconv_puts [16]
 

Detailed Description

This file implements a very simple iconv.

Its purpose is to allow ASCII clients to communicate with Microsoft servers that encode their metadata in Unicode (UTF-16).

It supports ISO-8859-1, ASCII, CP1252, UTF-16, UCS-4 and UTF-8

Definition in file iconv.c.

Macro Definition Documentation

◆ CD

#define CD   ((int) (TDS_INTPTR) cd)

◆ CP1252

#define CP1252 (   i,
 
)    case o: c = i; break;

◆ MASK

#define MASK (   n)    ((0xffffffffu << (n)) & 0xffffffffu)

Function Documentation

◆ get_ascii()

static int get_ascii ( const unsigned char *  p,
size_t  len,
ICONV_CHAR out 
)
static

Definition at line 269 of file iconv.c.

References EILSEQ, and out().

◆ get_err()

static int get_err ( const unsigned char *  p,
size_t  len,
ICONV_CHAR out 
)
static

Definition at line 318 of file iconv.c.

References EILSEQ.

◆ get_iso1()

static int get_iso1 ( const unsigned char *  p,
size_t  len,
ICONV_CHAR out 
)
static

Definition at line 251 of file iconv.c.

References out().

◆ get_ucs4be()

static int get_ucs4be ( const unsigned char *  p,
size_t  len,
ICONV_CHAR out 
)
static

Definition at line 155 of file iconv.c.

References len, out(), and TDS_GET_UA4BE.

◆ get_ucs4le()

static int get_ucs4le ( const unsigned char *  p,
size_t  len,
ICONV_CHAR out 
)
static

Definition at line 137 of file iconv.c.

References len, out(), and TDS_GET_UA4LE.

◆ get_utf16be()

static int get_utf16be ( const unsigned char *  p,
size_t  len,
ICONV_CHAR out 
)
static

Definition at line 212 of file iconv.c.

References len, out(), and TDS_GET_UA2BE.

◆ get_utf16le()

static int get_utf16le ( const unsigned char *  p,
size_t  len,
ICONV_CHAR out 
)
static

Definition at line 173 of file iconv.c.

References len, out(), and TDS_GET_UA2LE.

◆ get_utf8()

static int get_utf8 ( const unsigned char *  p,
size_t  len,
ICONV_CHAR out 
)
static

Definition at line 76 of file iconv.c.

References decode_utf8(), EILSEQ, l(), len, out(), UTF8_ACCEPT, and UTF8_REJECT.

◆ put_ascii()

static int put_ascii ( unsigned char *  buf,
size_t  buf_len,
ICONV_CHAR  c 
)
static

Definition at line 278 of file iconv.c.

References buf, and EILSEQ.

◆ put_err()

static int put_err ( unsigned char *  buf,
size_t  buf_len,
ICONV_CHAR  c 
)
static

Definition at line 324 of file iconv.c.

References EILSEQ.

◆ put_iso1()

static int put_iso1 ( unsigned char *  buf,
size_t  buf_len,
ICONV_CHAR  c 
)
static

Definition at line 258 of file iconv.c.

References buf, and EILSEQ.

◆ put_ucs4be()

static int put_ucs4be ( unsigned char *  buf,
size_t  buf_len,
ICONV_CHAR  c 
)
static

Definition at line 164 of file iconv.c.

References buf, and TDS_PUT_UA4BE.

◆ put_ucs4le()

static int put_ucs4le ( unsigned char *  buf,
size_t  buf_len,
ICONV_CHAR  c 
)
static

Definition at line 146 of file iconv.c.

References buf, and TDS_PUT_UA4LE.

◆ put_utf16be()

static int put_utf16be ( unsigned char *  buf,
size_t  buf_len,
ICONV_CHAR  c 
)
static

Definition at line 233 of file iconv.c.

References buf, EILSEQ, TDS_PUT_UA2BE, and TDS_UNLIKELY.

◆ put_utf16le()

static int put_utf16le ( unsigned char *  buf,
size_t  buf_len,
ICONV_CHAR  c 
)
static

Definition at line 194 of file iconv.c.

References buf, EILSEQ, TDS_PUT_UA2LE, and TDS_UNLIKELY.

◆ put_utf8()

static int put_utf8 ( unsigned char *  buf,
size_t  buf_len,
ICONV_CHAR  c 
)
static

Definition at line 94 of file iconv.c.

References buf, EILSEQ, and MASK.

Modified on Wed Sep 04 15:02:10 2024 by modify_doxy.py rev. 669887