44 #include <freetds/tds.h>
45 #include <freetds/bytes.h>
46 #include <freetds/iconv.h>
61 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
62 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
63 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
64 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
65 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
66 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
67 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
68 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
69 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
70 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
71 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
72 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
73 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
74 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
75 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
76 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 0, 0,
80 0, 0x7f, 0x1f, 0x0f, 0x07, 0x03, 0x01
109 uc = (uc << 6) | (*p++ & 0x3f);
117 #define MASK(n) ((0xffffffffu << (n)) & 0xffffffffu)
120 if ((c &
MASK(7)) == 0) {
123 *
buf = (
unsigned char) c;
129 if ((c &
MASK(11)) == 0)
132 if ((c &
MASK(16)) == 0)
135 if ((c &
MASK(21)) == 0)
138 if ((c &
MASK(26)) == 0)
141 if ((c &
MASK(31)) != 0)
150 *--
buf = 0x80 | (c & 0x3f);
153 *--
buf = (0xff00u >> o_len) | c;
201 if ((c & 0xfc00) == 0xd800) {
205 if ((c2 & 0xfc00) != 0xdc00)
207 *
out = (c << 10) + c2 - ((0xd800 << 10) + 0xdc00 - 0x10000);
241 if ((c & 0xfc00) == 0xd800) {
245 if ((c2 & 0xfc00) != 0xdc00)
247 *
out = (c << 10) + c2 - ((0xd800 << 10) + 0xdc00 - 0x10000);
287 buf[0] = (
unsigned char) c;
307 buf[0] = (
unsigned char) c;
341 const char *enc_name;
342 unsigned char encodings[2];
344 static char first_time = 1;
353 for (
i=0;
i < 2; ++
i) {
354 unsigned char encoding;
356 if (
strcmp(enc_name,
"ISO-8859-1") == 0)
358 else if (
strcmp(enc_name,
"US-ASCII") == 0)
360 else if (
strcmp(enc_name,
"UCS-2LE") == 0 ||
strcmp(enc_name,
"UTF-16LE") == 0)
362 else if (
strcmp(enc_name,
"UCS-2BE") == 0 ||
strcmp(enc_name,
"UTF-16BE") == 0)
364 else if (
strcmp(enc_name,
"UCS-4LE") == 0)
366 else if (
strcmp(enc_name,
"UCS-4BE") == 0)
368 else if (
strcmp(enc_name,
"UTF-8") == 0)
374 encodings[
i] = encoding;
379 fromto = (encodings[0] << 4) | (encodings[1] & 0x0F);
382 if (encodings[0] == encodings[1]) {
398 const unsigned char *ib;
404 #define CD ((int) (TDS_INTPTR) cd)
421 ib = (
const unsigned char*) *
inbuf;
422 ob = (
unsigned char*) *
outbuf;
425 size_t copybytes = (il < ol)? il : ol;
427 memcpy(ob, ib, copybytes);
432 }
else if (
CD & ~0x77) {
433 local_errno = EINVAL;
440 int readed = get_func(ib, il, &out_c), written;
444 local_errno = -readed;
448 written = put_func(ob, ol, out_c);
451 local_errno = -written;
464 *
inbuf = (
const char*) ib;
467 if (il && !local_errno)
std::ofstream out("events_result.xml")
main entry point for tests
#define TDS_PUT_A4LE(ptr, val)
#define TDS_GET_A2BE(ptr)
#define TDS_GET_A2LE(ptr)
#define TDS_GET_A4LE(ptr)
#define TDS_GET_A4BE(ptr)
#define TDS_PUT_A2LE(ptr, val)
#define TDS_PUT_A2BE(ptr, val)
#define TDS_PUT_A4BE(ptr, val)
#define TDS_EXTRA_CHECK(stmt)
tds_sysdep_intptr_type TDS_INTPTR
tds_sysdep_uint32_type TDS_UINT
static int put_ascii(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 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_utf16be(const unsigned char *p, size_t len, ICONV_CHAR *out)
static const iconv_get_t iconv_gets[8]
static int get_err(const unsigned char *p, size_t len, ICONV_CHAR *out)
size_t tds_sys_iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
static const unsigned char utf8_masks[7]
static const unsigned char utf8_lengths[256]
static int put_err(unsigned char *buf, size_t buf_len, ICONV_CHAR c)
static int get_ascii(const unsigned char *p, size_t len, ICONV_CHAR *out)
iconv_t tds_sys_iconv_open(const char *tocode, const char *fromcode)
Inputs are FreeTDS canonical names, no other.
static int get_ucs4be(const unsigned char *p, size_t len, ICONV_CHAR *out)
int(* iconv_put_t)(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_ucs4le(unsigned char *buf, size_t buf_len, ICONV_CHAR c)
static int put_ucs4be(unsigned char *buf, size_t buf_len, ICONV_CHAR c)
static int put_iso1(unsigned char *buf, size_t buf_len, ICONV_CHAR c)
static int put_utf16be(unsigned char *buf, size_t buf_len, ICONV_CHAR c)
static const iconv_put_t iconv_puts[8]
static int get_ucs4le(const unsigned char *p, size_t len, ICONV_CHAR *out)
int tds_sys_iconv_close(iconv_t cd)
static int put_utf16le(unsigned char *buf, size_t buf_len, ICONV_CHAR c)
int(* iconv_get_t)(const unsigned char *p, size_t len, ICONV_CHAR *out)
unsigned int
A callback function used to compare two keys in a database.
int strcmp(const char *str1, const char *str2)
static SLJIT_INLINE sljit_ins l(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
uchar outbuf[(1000000+1000000)]