trilogy 2.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of trilogy might be problematic. Click here for more details.

Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +22 -0
  3. data/README.md +74 -0
  4. data/Rakefile +18 -0
  5. data/ext/trilogy-ruby/cast.c +272 -0
  6. data/ext/trilogy-ruby/cext.c +933 -0
  7. data/ext/trilogy-ruby/extconf.rb +16 -0
  8. data/ext/trilogy-ruby/inc/trilogy/blocking.h +163 -0
  9. data/ext/trilogy-ruby/inc/trilogy/buffer.h +64 -0
  10. data/ext/trilogy-ruby/inc/trilogy/builder.h +161 -0
  11. data/ext/trilogy-ruby/inc/trilogy/charset.h +277 -0
  12. data/ext/trilogy-ruby/inc/trilogy/client.h +546 -0
  13. data/ext/trilogy-ruby/inc/trilogy/error.h +43 -0
  14. data/ext/trilogy-ruby/inc/trilogy/packet_parser.h +34 -0
  15. data/ext/trilogy-ruby/inc/trilogy/protocol.h +756 -0
  16. data/ext/trilogy-ruby/inc/trilogy/reader.h +212 -0
  17. data/ext/trilogy-ruby/inc/trilogy/socket.h +111 -0
  18. data/ext/trilogy-ruby/inc/trilogy/vendor/curl_hostcheck.h +29 -0
  19. data/ext/trilogy-ruby/inc/trilogy/vendor/openssl_hostname_validation.h +51 -0
  20. data/ext/trilogy-ruby/inc/trilogy.h +8 -0
  21. data/ext/trilogy-ruby/src/blocking.c +241 -0
  22. data/ext/trilogy-ruby/src/buffer.c +60 -0
  23. data/ext/trilogy-ruby/src/builder.c +198 -0
  24. data/ext/trilogy-ruby/src/charset.c +212 -0
  25. data/ext/trilogy-ruby/src/client.c +728 -0
  26. data/ext/trilogy-ruby/src/error.c +17 -0
  27. data/ext/trilogy-ruby/src/packet_parser.c +140 -0
  28. data/ext/trilogy-ruby/src/protocol.c +676 -0
  29. data/ext/trilogy-ruby/src/reader.c +244 -0
  30. data/ext/trilogy-ruby/src/socket.c +623 -0
  31. data/ext/trilogy-ruby/src/vendor/curl_hostcheck.c +206 -0
  32. data/ext/trilogy-ruby/src/vendor/openssl_hostname_validation.c +175 -0
  33. data/ext/trilogy-ruby/trilogy-ruby.h +36 -0
  34. data/lib/trilogy/version.rb +3 -0
  35. data/lib/trilogy.rb +61 -0
  36. data/trilogy.gemspec +27 -0
  37. metadata +106 -0
@@ -0,0 +1,60 @@
1
+ #include <stdint.h>
2
+ #include <stdlib.h>
3
+
4
+ #include "trilogy/buffer.h"
5
+ #include "trilogy/error.h"
6
+
7
+ int trilogy_buffer_init(trilogy_buffer_t *buffer, size_t initial_capacity)
8
+ {
9
+ buffer->len = 0;
10
+ buffer->cap = initial_capacity;
11
+ buffer->buff = malloc(initial_capacity);
12
+
13
+ if (buffer->buff == NULL) {
14
+ return TRILOGY_SYSERR;
15
+ }
16
+
17
+ return TRILOGY_OK;
18
+ }
19
+
20
+ #define EXPAND_MULTIPLIER 2
21
+
22
+ int trilogy_buffer_expand(trilogy_buffer_t *buffer, size_t needed)
23
+ {
24
+ // expand buffer if necessary
25
+ if (buffer->len + needed > buffer->cap) {
26
+ size_t new_cap = buffer->cap;
27
+
28
+ while (buffer->len + needed > new_cap) {
29
+ // would this next step cause an overflow?
30
+ if (new_cap > SIZE_MAX / EXPAND_MULTIPLIER)
31
+ return TRILOGY_TYPE_OVERFLOW;
32
+
33
+ new_cap *= EXPAND_MULTIPLIER;
34
+ }
35
+
36
+ uint8_t *new_buff = realloc(buffer->buff, new_cap);
37
+ if (new_buff == NULL)
38
+ return TRILOGY_SYSERR;
39
+
40
+ buffer->buff = new_buff;
41
+ buffer->cap = new_cap;
42
+ }
43
+
44
+ return TRILOGY_OK;
45
+ }
46
+
47
+ int trilogy_buffer_putc(trilogy_buffer_t *buffer, uint8_t c)
48
+ {
49
+ int rc = trilogy_buffer_expand(buffer, 1);
50
+
51
+ if (rc) {
52
+ return rc;
53
+ }
54
+
55
+ buffer->buff[buffer->len++] = c;
56
+
57
+ return TRILOGY_OK;
58
+ }
59
+
60
+ void trilogy_buffer_free(trilogy_buffer_t *buffer) { free(buffer->buff); }
@@ -0,0 +1,198 @@
1
+ #include "trilogy/builder.h"
2
+ #include "trilogy/error.h"
3
+ #include "trilogy/packet_parser.h"
4
+
5
+ #include <stdlib.h>
6
+ #include <string.h>
7
+
8
+ static int write_header(trilogy_builder_t *builder)
9
+ {
10
+ int rc = trilogy_buffer_expand(builder->buffer, 4);
11
+
12
+ if (rc < 0) {
13
+ return rc;
14
+ }
15
+
16
+ builder->header_offset = builder->buffer->len;
17
+ builder->fragment_length = 0;
18
+
19
+ builder->buffer->buff[builder->buffer->len++] = 0;
20
+ builder->buffer->buff[builder->buffer->len++] = 0;
21
+ builder->buffer->buff[builder->buffer->len++] = 0;
22
+ builder->buffer->buff[builder->buffer->len++] = builder->seq++;
23
+
24
+ return TRILOGY_OK;
25
+ }
26
+
27
+ static int write_continuation_header(trilogy_builder_t *builder)
28
+ {
29
+ builder->buffer->buff[builder->header_offset] = 0xff;
30
+ builder->buffer->buff[builder->header_offset + 1] = 0xff;
31
+ builder->buffer->buff[builder->header_offset + 2] = 0xff;
32
+
33
+ return write_header(builder);
34
+ }
35
+
36
+ int trilogy_builder_init(trilogy_builder_t *builder, trilogy_buffer_t *buff, uint8_t seq)
37
+ {
38
+ builder->buffer = buff;
39
+ builder->buffer->len = 0;
40
+
41
+ builder->seq = seq;
42
+
43
+ return write_header(builder);
44
+ }
45
+
46
+ void trilogy_builder_finalize(trilogy_builder_t *builder)
47
+ {
48
+ builder->buffer->buff[builder->header_offset + 0] = (builder->fragment_length >> 0) & 0xff;
49
+ builder->buffer->buff[builder->header_offset + 1] = (builder->fragment_length >> 8) & 0xff;
50
+ builder->buffer->buff[builder->header_offset + 2] = (builder->fragment_length >> 16) & 0xff;
51
+ }
52
+
53
+ #define CHECKED(expr) \
54
+ { \
55
+ int rc = (expr); \
56
+ if (rc) { \
57
+ return rc; \
58
+ } \
59
+ }
60
+
61
+ int trilogy_builder_write_uint8(trilogy_builder_t *builder, uint8_t val)
62
+ {
63
+ CHECKED(trilogy_buffer_expand(builder->buffer, 1));
64
+
65
+ builder->buffer->buff[builder->buffer->len++] = val;
66
+ builder->fragment_length++;
67
+
68
+ if (builder->fragment_length == TRILOGY_MAX_PACKET_LEN) {
69
+ CHECKED(write_continuation_header(builder));
70
+ }
71
+
72
+ return TRILOGY_OK;
73
+ }
74
+
75
+ int trilogy_builder_write_uint16(trilogy_builder_t *builder, uint16_t val)
76
+ {
77
+ CHECKED(trilogy_builder_write_uint8(builder, val & 0xff));
78
+ CHECKED(trilogy_builder_write_uint8(builder, (val >> 8) & 0xff));
79
+
80
+ return TRILOGY_OK;
81
+ }
82
+
83
+ int trilogy_builder_write_uint24(trilogy_builder_t *builder, uint32_t val)
84
+ {
85
+ CHECKED(trilogy_builder_write_uint8(builder, val & 0xff));
86
+ CHECKED(trilogy_builder_write_uint8(builder, (val >> 8) & 0xff));
87
+ CHECKED(trilogy_builder_write_uint8(builder, (val >> 16) & 0xff));
88
+
89
+ return TRILOGY_OK;
90
+ }
91
+
92
+ int trilogy_builder_write_uint32(trilogy_builder_t *builder, uint32_t val)
93
+ {
94
+ CHECKED(trilogy_builder_write_uint8(builder, val & 0xff));
95
+ CHECKED(trilogy_builder_write_uint8(builder, (val >> 8) & 0xff));
96
+ CHECKED(trilogy_builder_write_uint8(builder, (val >> 16) & 0xff));
97
+ CHECKED(trilogy_builder_write_uint8(builder, (val >> 24) & 0xff));
98
+
99
+ return TRILOGY_OK;
100
+ }
101
+
102
+ int trilogy_builder_write_uint64(trilogy_builder_t *builder, uint64_t val)
103
+ {
104
+ CHECKED(trilogy_builder_write_uint8(builder, val & 0xff));
105
+ CHECKED(trilogy_builder_write_uint8(builder, (val >> 8) & 0xff));
106
+ CHECKED(trilogy_builder_write_uint8(builder, (val >> 16) & 0xff));
107
+ CHECKED(trilogy_builder_write_uint8(builder, (val >> 24) & 0xff));
108
+ CHECKED(trilogy_builder_write_uint8(builder, (val >> 32) & 0xff));
109
+ CHECKED(trilogy_builder_write_uint8(builder, (val >> 40) & 0xff));
110
+ CHECKED(trilogy_builder_write_uint8(builder, (val >> 48) & 0xff));
111
+ CHECKED(trilogy_builder_write_uint8(builder, (val >> 56) & 0xff));
112
+
113
+ return TRILOGY_OK;
114
+ }
115
+
116
+ int trilogy_builder_write_lenenc(trilogy_builder_t *builder, uint64_t val)
117
+ {
118
+ if (val < 251) {
119
+ CHECKED(trilogy_builder_write_uint8(builder, (uint8_t)val));
120
+ } else if (val <= 0xffff) {
121
+ CHECKED(trilogy_builder_write_uint8(builder, 0xfc));
122
+ CHECKED(trilogy_builder_write_uint16(builder, (uint16_t)val));
123
+ } else if (val <= 0xffffff) {
124
+ CHECKED(trilogy_builder_write_uint8(builder, 0xfd));
125
+ CHECKED(trilogy_builder_write_uint24(builder, (uint32_t)val));
126
+ } else { // val <= 0xffffffffffffffff
127
+ CHECKED(trilogy_builder_write_uint8(builder, 0xfe));
128
+ CHECKED(trilogy_builder_write_uint64(builder, val));
129
+ }
130
+
131
+ return TRILOGY_OK;
132
+ }
133
+
134
+ int trilogy_builder_write_buffer(trilogy_builder_t *builder, const void *data, size_t len)
135
+ {
136
+ const char *ptr = data;
137
+
138
+ size_t fragment_remaining = TRILOGY_MAX_PACKET_LEN - builder->fragment_length;
139
+
140
+ // if this buffer write is not going to straddle a fragment boundary:
141
+ if (len < fragment_remaining) {
142
+ CHECKED(trilogy_buffer_expand(builder->buffer, len));
143
+
144
+ memcpy(builder->buffer->buff + builder->buffer->len, ptr, len);
145
+
146
+ builder->buffer->len += len;
147
+ builder->fragment_length += len;
148
+
149
+ return TRILOGY_OK;
150
+ }
151
+
152
+ // otherwise we're going to need to do this in multiple
153
+ while (len >= fragment_remaining) {
154
+ CHECKED(trilogy_buffer_expand(builder->buffer, fragment_remaining));
155
+
156
+ memcpy(builder->buffer->buff + builder->buffer->len, ptr, fragment_remaining);
157
+
158
+ builder->buffer->len += fragment_remaining;
159
+ builder->fragment_length += fragment_remaining;
160
+
161
+ ptr += fragment_remaining;
162
+ len -= fragment_remaining;
163
+
164
+ CHECKED(write_continuation_header(builder));
165
+ fragment_remaining = TRILOGY_MAX_PACKET_LEN;
166
+ }
167
+
168
+ if (len) {
169
+ CHECKED(trilogy_buffer_expand(builder->buffer, len));
170
+
171
+ memcpy(builder->buffer->buff + builder->buffer->len, ptr, len);
172
+
173
+ builder->buffer->len += len;
174
+ builder->fragment_length += len;
175
+ }
176
+
177
+ return TRILOGY_OK;
178
+ }
179
+
180
+ int trilogy_builder_write_lenenc_buffer(trilogy_builder_t *builder, const void *data, size_t len)
181
+ {
182
+ CHECKED(trilogy_builder_write_lenenc(builder, len));
183
+
184
+ CHECKED(trilogy_builder_write_buffer(builder, data, len));
185
+
186
+ return TRILOGY_OK;
187
+ }
188
+
189
+ int trilogy_builder_write_string(trilogy_builder_t *builder, const char *data)
190
+ {
191
+ CHECKED(trilogy_builder_write_buffer(builder, (void *)data, strlen(data)));
192
+
193
+ CHECKED(trilogy_builder_write_uint8(builder, 0));
194
+
195
+ return TRILOGY_OK;
196
+ }
197
+
198
+ #undef CHECKED
@@ -0,0 +1,212 @@
1
+ #include "trilogy/charset.h"
2
+
3
+ static TRILOGY_ENCODING_t charset_to_encoding_map[] = {
4
+ [TRILOGY_CHARSET_NONE] = TRILOGY_ENCODING_NONE,
5
+ [TRILOGY_CHARSET_BIG5_CHINESE_CI] = TRILOGY_ENCODING_BIG5,
6
+ [TRILOGY_CHARSET_BIG5_BIN] = TRILOGY_ENCODING_BIG5,
7
+ [TRILOGY_CHARSET_LATIN2_CZECH_CS] = TRILOGY_ENCODING_LATIN2,
8
+ [TRILOGY_CHARSET_LATIN2_GENERAL_CI] = TRILOGY_ENCODING_LATIN2,
9
+ [TRILOGY_CHARSET_LATIN2_HUNGARIAN_CI] = TRILOGY_ENCODING_LATIN2,
10
+ [TRILOGY_CHARSET_LATIN2_CROATIAN_CI] = TRILOGY_ENCODING_LATIN2,
11
+ [TRILOGY_CHARSET_LATIN2_BIN] = TRILOGY_ENCODING_LATIN2,
12
+ [TRILOGY_CHARSET_DEC8_SWEDISH_CI] = TRILOGY_ENCODING_DEC8,
13
+ [TRILOGY_CHARSET_DEC8_BIN] = TRILOGY_ENCODING_DEC8,
14
+ [TRILOGY_CHARSET_CP850_GENERAL_CI] = TRILOGY_ENCODING_CP850,
15
+ [TRILOGY_CHARSET_CP850_BIN] = TRILOGY_ENCODING_CP850,
16
+ [TRILOGY_CHARSET_LATIN1_GERMAN1_CI] = TRILOGY_ENCODING_LATIN1,
17
+ [TRILOGY_CHARSET_LATIN1_SWEDISH_CI] = TRILOGY_ENCODING_LATIN1,
18
+ [TRILOGY_CHARSET_LATIN1_DANISH_CI] = TRILOGY_ENCODING_LATIN1,
19
+ [TRILOGY_CHARSET_LATIN1_GERMAN2_CI] = TRILOGY_ENCODING_LATIN1,
20
+ [TRILOGY_CHARSET_LATIN1_BIN] = TRILOGY_ENCODING_LATIN1,
21
+ [TRILOGY_CHARSET_LATIN1_GENERAL_CI] = TRILOGY_ENCODING_LATIN1,
22
+ [TRILOGY_CHARSET_LATIN1_GENERAL_CS] = TRILOGY_ENCODING_LATIN1,
23
+ [TRILOGY_CHARSET_LATIN1_SPANISH_CI] = TRILOGY_ENCODING_LATIN1,
24
+ [TRILOGY_CHARSET_HP8_ENGLISH_CI] = TRILOGY_ENCODING_HP8,
25
+ [TRILOGY_CHARSET_HP8_BIN] = TRILOGY_ENCODING_HP8,
26
+ [TRILOGY_CHARSET_KOI8R_GENERAL_CI] = TRILOGY_ENCODING_KOI8R,
27
+ [TRILOGY_CHARSET_KOI8R_BIN] = TRILOGY_ENCODING_KOI8R,
28
+ [TRILOGY_CHARSET_SWE7_SWEDISH_CI] = TRILOGY_ENCODING_SWE7,
29
+ [TRILOGY_CHARSET_SWE7_BIN] = TRILOGY_ENCODING_SWE7,
30
+ [TRILOGY_CHARSET_ASCII_GENERAL_CI] = TRILOGY_ENCODING_ASCII,
31
+ [TRILOGY_CHARSET_ASCII_BIN] = TRILOGY_ENCODING_ASCII,
32
+ [TRILOGY_CHARSET_UJIS_JAPANESE_CI] = TRILOGY_ENCODING_UJIS,
33
+ [TRILOGY_CHARSET_UJIS_BIN] = TRILOGY_ENCODING_UJIS,
34
+ [TRILOGY_CHARSET_SJIS_JAPANESE_CI] = TRILOGY_ENCODING_SJIS,
35
+ [TRILOGY_CHARSET_SJIS_BIN] = TRILOGY_ENCODING_SJIS,
36
+ [TRILOGY_CHARSET_CP1251_BULGARIAN_CI] = TRILOGY_ENCODING_CP1251,
37
+ [TRILOGY_CHARSET_CP1251_UKRAINIAN_CI] = TRILOGY_ENCODING_CP1251,
38
+ [TRILOGY_CHARSET_CP1251_BIN] = TRILOGY_ENCODING_CP1251,
39
+ [TRILOGY_CHARSET_CP1251_GENERAL_CI] = TRILOGY_ENCODING_CP1251,
40
+ [TRILOGY_CHARSET_CP1251_GENERAL_CS] = TRILOGY_ENCODING_CP1251,
41
+ [TRILOGY_CHARSET_HEBREW_GENERAL_CI] = TRILOGY_ENCODING_HEBREW,
42
+ [TRILOGY_CHARSET_HEBREW_BIN] = TRILOGY_ENCODING_HEBREW,
43
+ [TRILOGY_CHARSET_TIS620_THAI_CI] = TRILOGY_ENCODING_TIS620,
44
+ [TRILOGY_CHARSET_TIS620_BIN] = TRILOGY_ENCODING_TIS620,
45
+ [TRILOGY_CHARSET_EUCKR_KOREAN_CI] = TRILOGY_ENCODING_EUCKR,
46
+ [TRILOGY_CHARSET_EUCKR_BIN] = TRILOGY_ENCODING_EUCKR,
47
+ [TRILOGY_CHARSET_LATIN7_ESTONIAN_CS] = TRILOGY_ENCODING_LATIN7,
48
+ [TRILOGY_CHARSET_LATIN7_GENERAL_CI] = TRILOGY_ENCODING_LATIN7,
49
+ [TRILOGY_CHARSET_LATIN7_GENERAL_CS] = TRILOGY_ENCODING_LATIN7,
50
+ [TRILOGY_CHARSET_LATIN7_BIN] = TRILOGY_ENCODING_LATIN7,
51
+ [TRILOGY_CHARSET_KOI8U_GENERAL_CI] = TRILOGY_ENCODING_KOI8U,
52
+ [TRILOGY_CHARSET_KOI8U_BIN] = TRILOGY_ENCODING_KOI8U,
53
+ [TRILOGY_CHARSET_GB2312_CHINESE_CI] = TRILOGY_ENCODING_GB2312,
54
+ [TRILOGY_CHARSET_GB2312_BIN] = TRILOGY_ENCODING_GB2312,
55
+ [TRILOGY_CHARSET_GREEK_GENERAL_CI] = TRILOGY_ENCODING_GREEK,
56
+ [TRILOGY_CHARSET_GREEK_BIN] = TRILOGY_ENCODING_GREEK,
57
+ [TRILOGY_CHARSET_CP1250_GENERAL_CI] = TRILOGY_ENCODING_CP1250,
58
+ [TRILOGY_CHARSET_CP1250_CZECH_CS] = TRILOGY_ENCODING_CP1250,
59
+ [TRILOGY_CHARSET_CP1250_CROATIAN_CI] = TRILOGY_ENCODING_CP1250,
60
+ [TRILOGY_CHARSET_CP1250_BIN] = TRILOGY_ENCODING_CP1250,
61
+ [TRILOGY_CHARSET_CP1250_POLISH_CI] = TRILOGY_ENCODING_CP1250,
62
+ [TRILOGY_CHARSET_GBK_CHINESE_CI] = TRILOGY_ENCODING_GBK,
63
+ [TRILOGY_CHARSET_GBK_BIN] = TRILOGY_ENCODING_GBK,
64
+ [TRILOGY_CHARSET_GB18030_CHINESE_CI] = TRILOGY_ENCODING_GBK,
65
+ [TRILOGY_CHARSET_GB18030_BIN_CI] = TRILOGY_ENCODING_GBK,
66
+ [TRILOGY_CHARSET_GB18030_UNICODE_520_CI] = TRILOGY_ENCODING_GBK,
67
+ [TRILOGY_CHARSET_CP1257_LITHUANIAN_CI] = TRILOGY_ENCODING_CP1257,
68
+ [TRILOGY_CHARSET_CP1257_BIN] = TRILOGY_ENCODING_CP1257,
69
+ [TRILOGY_CHARSET_CP1257_GENERAL_CI] = TRILOGY_ENCODING_CP1257,
70
+ [TRILOGY_CHARSET_LATIN5_TURKISH_CI] = TRILOGY_ENCODING_LATIN5,
71
+ [TRILOGY_CHARSET_LATIN5_BIN] = TRILOGY_ENCODING_LATIN5,
72
+ [TRILOGY_CHARSET_ARMSCII8_GENERAL_CI] = TRILOGY_ENCODING_ARMSCII8,
73
+ [TRILOGY_CHARSET_ARMSCII8_BIN] = TRILOGY_ENCODING_ARMSCII8,
74
+ [TRILOGY_CHARSET_UTF8_GENERAL_CI] = TRILOGY_ENCODING_UTF8,
75
+ [TRILOGY_CHARSET_UTF8_BIN] = TRILOGY_ENCODING_UTF8,
76
+ [TRILOGY_CHARSET_UTF8_UNICODE_CI] = TRILOGY_ENCODING_UTF8,
77
+ [TRILOGY_CHARSET_UTF8_ICELANDIC_CI] = TRILOGY_ENCODING_UTF8,
78
+ [TRILOGY_CHARSET_UTF8_LATVIAN_CI] = TRILOGY_ENCODING_UTF8,
79
+ [TRILOGY_CHARSET_UTF8_ROMANIAN_CI] = TRILOGY_ENCODING_UTF8,
80
+ [TRILOGY_CHARSET_UTF8_SLOVENIAN_CI] = TRILOGY_ENCODING_UTF8,
81
+ [TRILOGY_CHARSET_UTF8_POLISH_CI] = TRILOGY_ENCODING_UTF8,
82
+ [TRILOGY_CHARSET_UTF8_ESTONIAN_CI] = TRILOGY_ENCODING_UTF8,
83
+ [TRILOGY_CHARSET_UTF8_SPANISH_CI] = TRILOGY_ENCODING_UTF8,
84
+ [TRILOGY_CHARSET_UTF8_SWEDISH_CI] = TRILOGY_ENCODING_UTF8,
85
+ [TRILOGY_CHARSET_UTF8_TURKISH_CI] = TRILOGY_ENCODING_UTF8,
86
+ [TRILOGY_CHARSET_UTF8_CZECH_CI] = TRILOGY_ENCODING_UTF8,
87
+ [TRILOGY_CHARSET_UTF8_DANISH_CI] = TRILOGY_ENCODING_UTF8,
88
+ [TRILOGY_CHARSET_UTF8_LITHUANIAN_CI] = TRILOGY_ENCODING_UTF8,
89
+ [TRILOGY_CHARSET_UTF8_SLOVAK_CI] = TRILOGY_ENCODING_UTF8,
90
+ [TRILOGY_CHARSET_UTF8_SPANISH2_CI] = TRILOGY_ENCODING_UTF8,
91
+ [TRILOGY_CHARSET_UTF8_ROMAN_CI] = TRILOGY_ENCODING_UTF8,
92
+ [TRILOGY_CHARSET_UTF8_PERSIAN_CI] = TRILOGY_ENCODING_UTF8,
93
+ [TRILOGY_CHARSET_UTF8_ESPERANTO_CI] = TRILOGY_ENCODING_UTF8,
94
+ [TRILOGY_CHARSET_UTF8_HUNGARIAN_CI] = TRILOGY_ENCODING_UTF8,
95
+ [TRILOGY_CHARSET_UTF8_SINHALA_CI] = TRILOGY_ENCODING_UTF8,
96
+ [TRILOGY_CHARSET_UTF8_GENERAL_MYSQL500_CI] = TRILOGY_ENCODING_UTF8,
97
+ [TRILOGY_CHARSET_UCS2_GENERAL_CI] = TRILOGY_ENCODING_UCS2,
98
+ [TRILOGY_CHARSET_UCS2_BIN] = TRILOGY_ENCODING_UCS2,
99
+ [TRILOGY_CHARSET_UCS2_UNICODE_CI] = TRILOGY_ENCODING_UCS2,
100
+ [TRILOGY_CHARSET_UCS2_ICELANDIC_CI] = TRILOGY_ENCODING_UCS2,
101
+ [TRILOGY_CHARSET_UCS2_LATVIAN_CI] = TRILOGY_ENCODING_UCS2,
102
+ [TRILOGY_CHARSET_UCS2_ROMANIAN_CI] = TRILOGY_ENCODING_UCS2,
103
+ [TRILOGY_CHARSET_UCS2_SLOVENIAN_CI] = TRILOGY_ENCODING_UCS2,
104
+ [TRILOGY_CHARSET_UCS2_POLISH_CI] = TRILOGY_ENCODING_UCS2,
105
+ [TRILOGY_CHARSET_UCS2_ESTONIAN_CI] = TRILOGY_ENCODING_UCS2,
106
+ [TRILOGY_CHARSET_UCS2_SPANISH_CI] = TRILOGY_ENCODING_UCS2,
107
+ [TRILOGY_CHARSET_UCS2_SWEDISH_CI] = TRILOGY_ENCODING_UCS2,
108
+ [TRILOGY_CHARSET_UCS2_TURKISH_CI] = TRILOGY_ENCODING_UCS2,
109
+ [TRILOGY_CHARSET_UCS2_CZECH_CI] = TRILOGY_ENCODING_UCS2,
110
+ [TRILOGY_CHARSET_UCS2_DANISH_CI] = TRILOGY_ENCODING_UCS2,
111
+ [TRILOGY_CHARSET_UCS2_LITHUANIAN_CI] = TRILOGY_ENCODING_UCS2,
112
+ [TRILOGY_CHARSET_UCS2_SLOVAK_CI] = TRILOGY_ENCODING_UCS2,
113
+ [TRILOGY_CHARSET_UCS2_SPANISH2_CI] = TRILOGY_ENCODING_UCS2,
114
+ [TRILOGY_CHARSET_UCS2_ROMAN_CI] = TRILOGY_ENCODING_UCS2,
115
+ [TRILOGY_CHARSET_UCS2_PERSIAN_CI] = TRILOGY_ENCODING_UCS2,
116
+ [TRILOGY_CHARSET_UCS2_ESPERANTO_CI] = TRILOGY_ENCODING_UCS2,
117
+ [TRILOGY_CHARSET_UCS2_HUNGARIAN_CI] = TRILOGY_ENCODING_UCS2,
118
+ [TRILOGY_CHARSET_UCS2_SINHALA_CI] = TRILOGY_ENCODING_UCS2,
119
+ [TRILOGY_CHARSET_UCS2_GENERAL_MYSQL500_CI] = TRILOGY_ENCODING_UCS2,
120
+ [TRILOGY_CHARSET_CP866_GENERAL_CI] = TRILOGY_ENCODING_CP866,
121
+ [TRILOGY_CHARSET_CP866_BIN] = TRILOGY_ENCODING_CP866,
122
+ [TRILOGY_CHARSET_KEYBCS2_GENERAL_CI] = TRILOGY_ENCODING_KEYBCS2,
123
+ [TRILOGY_CHARSET_KEYBCS2_BIN] = TRILOGY_ENCODING_KEYBCS2,
124
+ [TRILOGY_CHARSET_MACCE_GENERAL_CI] = TRILOGY_ENCODING_MACCE,
125
+ [TRILOGY_CHARSET_MACCE_BIN] = TRILOGY_ENCODING_MACCE,
126
+ [TRILOGY_CHARSET_MACROMAN_GENERAL_CI] = TRILOGY_ENCODING_MACROMAN,
127
+ [TRILOGY_CHARSET_MACROMAN_BIN] = TRILOGY_ENCODING_MACROMAN,
128
+ [TRILOGY_CHARSET_CP852_GENERAL_CI] = TRILOGY_ENCODING_CP852,
129
+ [TRILOGY_CHARSET_CP852_BIN] = TRILOGY_ENCODING_CP852,
130
+ [TRILOGY_CHARSET_UTF8MB4_GENERAL_CI] = TRILOGY_ENCODING_UTF8MB4,
131
+ [TRILOGY_CHARSET_UTF8MB4_BIN] = TRILOGY_ENCODING_UTF8MB4,
132
+ [TRILOGY_CHARSET_UTF8MB4_UNICODE_CI] = TRILOGY_ENCODING_UTF8MB4,
133
+ [TRILOGY_CHARSET_UTF8MB4_ICELANDIC_CI] = TRILOGY_ENCODING_UTF8MB4,
134
+ [TRILOGY_CHARSET_UTF8MB4_LATVIAN_CI] = TRILOGY_ENCODING_UTF8MB4,
135
+ [TRILOGY_CHARSET_UTF8MB4_ROMANIAN_CI] = TRILOGY_ENCODING_UTF8MB4,
136
+ [TRILOGY_CHARSET_UTF8MB4_SLOVENIAN_CI] = TRILOGY_ENCODING_UTF8MB4,
137
+ [TRILOGY_CHARSET_UTF8MB4_POLISH_CI] = TRILOGY_ENCODING_UTF8MB4,
138
+ [TRILOGY_CHARSET_UTF8MB4_ESTONIAN_CI] = TRILOGY_ENCODING_UTF8MB4,
139
+ [TRILOGY_CHARSET_UTF8MB4_SPANISH_CI] = TRILOGY_ENCODING_UTF8MB4,
140
+ [TRILOGY_CHARSET_UTF8MB4_SWEDISH_CI] = TRILOGY_ENCODING_UTF8MB4,
141
+ [TRILOGY_CHARSET_UTF8MB4_TURKISH_CI] = TRILOGY_ENCODING_UTF8MB4,
142
+ [TRILOGY_CHARSET_UTF8MB4_CZECH_CI] = TRILOGY_ENCODING_UTF8MB4,
143
+ [TRILOGY_CHARSET_UTF8MB4_DANISH_CI] = TRILOGY_ENCODING_UTF8MB4,
144
+ [TRILOGY_CHARSET_UTF8MB4_LITHUANIAN_CI] = TRILOGY_ENCODING_UTF8MB4,
145
+ [TRILOGY_CHARSET_UTF8MB4_SLOVAK_CI] = TRILOGY_ENCODING_UTF8MB4,
146
+ [TRILOGY_CHARSET_UTF8MB4_SPANISH2_CI] = TRILOGY_ENCODING_UTF8MB4,
147
+ [TRILOGY_CHARSET_UTF8MB4_ROMAN_CI] = TRILOGY_ENCODING_UTF8MB4,
148
+ [TRILOGY_CHARSET_UTF8MB4_PERSIAN_CI] = TRILOGY_ENCODING_UTF8MB4,
149
+ [TRILOGY_CHARSET_UTF8MB4_ESPERANTO_CI] = TRILOGY_ENCODING_UTF8MB4,
150
+ [TRILOGY_CHARSET_UTF8MB4_HUNGARIAN_CI] = TRILOGY_ENCODING_UTF8MB4,
151
+ [TRILOGY_CHARSET_UTF8MB4_SINHALA_CI] = TRILOGY_ENCODING_UTF8MB4,
152
+ [TRILOGY_CHARSET_UTF8MB4_GERMAN2_CI] = TRILOGY_ENCODING_UTF8MB4,
153
+ [TRILOGY_CHARSET_UTF8MB4_CROATIAN_CI] = TRILOGY_ENCODING_UTF8MB4,
154
+ [TRILOGY_CHARSET_UTF8MB4_UNICODE_520_CI] = TRILOGY_ENCODING_UTF8MB4,
155
+ [TRILOGY_CHARSET_UTF8MB4_VIETNAMESE_CI] = TRILOGY_ENCODING_UTF8MB4,
156
+ [TRILOGY_CHARSET_UTF8MB4_0900_AI_CI] = TRILOGY_ENCODING_UTF8MB4,
157
+ [TRILOGY_CHARSET_UTF16_GENERAL_CI] = TRILOGY_ENCODING_UTF16,
158
+ [TRILOGY_CHARSET_UTF16_BIN] = TRILOGY_ENCODING_UTF16,
159
+ [TRILOGY_CHARSET_UTF16_UNICODE_CI] = TRILOGY_ENCODING_UTF16,
160
+ [TRILOGY_CHARSET_UTF16_ICELANDIC_CI] = TRILOGY_ENCODING_UTF16,
161
+ [TRILOGY_CHARSET_UTF16_LATVIAN_CI] = TRILOGY_ENCODING_UTF16,
162
+ [TRILOGY_CHARSET_UTF16_ROMANIAN_CI] = TRILOGY_ENCODING_UTF16,
163
+ [TRILOGY_CHARSET_UTF16_SLOVENIAN_CI] = TRILOGY_ENCODING_UTF16,
164
+ [TRILOGY_CHARSET_UTF16_POLISH_CI] = TRILOGY_ENCODING_UTF16,
165
+ [TRILOGY_CHARSET_UTF16_ESTONIAN_CI] = TRILOGY_ENCODING_UTF16,
166
+ [TRILOGY_CHARSET_UTF16_SPANISH_CI] = TRILOGY_ENCODING_UTF16,
167
+ [TRILOGY_CHARSET_UTF16_SWEDISH_CI] = TRILOGY_ENCODING_UTF16,
168
+ [TRILOGY_CHARSET_UTF16_TURKISH_CI] = TRILOGY_ENCODING_UTF16,
169
+ [TRILOGY_CHARSET_UTF16_CZECH_CI] = TRILOGY_ENCODING_UTF16,
170
+ [TRILOGY_CHARSET_UTF16_DANISH_CI] = TRILOGY_ENCODING_UTF16,
171
+ [TRILOGY_CHARSET_UTF16_LITHUANIAN_CI] = TRILOGY_ENCODING_UTF16,
172
+ [TRILOGY_CHARSET_UTF16_SLOVAK_CI] = TRILOGY_ENCODING_UTF16,
173
+ [TRILOGY_CHARSET_UTF16_SPANISH2_CI] = TRILOGY_ENCODING_UTF16,
174
+ [TRILOGY_CHARSET_UTF16_ROMAN_CI] = TRILOGY_ENCODING_UTF16,
175
+ [TRILOGY_CHARSET_UTF16_PERSIAN_CI] = TRILOGY_ENCODING_UTF16,
176
+ [TRILOGY_CHARSET_UTF16_ESPERANTO_CI] = TRILOGY_ENCODING_UTF16,
177
+ [TRILOGY_CHARSET_UTF16_HUNGARIAN_CI] = TRILOGY_ENCODING_UTF16,
178
+ [TRILOGY_CHARSET_UTF16_SINHALA_CI] = TRILOGY_ENCODING_UTF16,
179
+ [TRILOGY_CHARSET_CP1256_GENERAL_CI] = TRILOGY_ENCODING_CP1256,
180
+ [TRILOGY_CHARSET_CP1256_BIN] = TRILOGY_ENCODING_CP1256,
181
+ [TRILOGY_CHARSET_UTF32_GENERAL_CI] = TRILOGY_ENCODING_UTF32,
182
+ [TRILOGY_CHARSET_UTF32_BIN] = TRILOGY_ENCODING_UTF32,
183
+ [TRILOGY_CHARSET_UTF32_UNICODE_CI] = TRILOGY_ENCODING_UTF32,
184
+ [TRILOGY_CHARSET_UTF32_ICELANDIC_CI] = TRILOGY_ENCODING_UTF32,
185
+ [TRILOGY_CHARSET_UTF32_LATVIAN_CI] = TRILOGY_ENCODING_UTF32,
186
+ [TRILOGY_CHARSET_UTF32_ROMANIAN_CI] = TRILOGY_ENCODING_UTF32,
187
+ [TRILOGY_CHARSET_UTF32_SLOVENIAN_CI] = TRILOGY_ENCODING_UTF32,
188
+ [TRILOGY_CHARSET_UTF32_POLISH_CI] = TRILOGY_ENCODING_UTF32,
189
+ [TRILOGY_CHARSET_UTF32_ESTONIAN_CI] = TRILOGY_ENCODING_UTF32,
190
+ [TRILOGY_CHARSET_UTF32_SPANISH_CI] = TRILOGY_ENCODING_UTF32,
191
+ [TRILOGY_CHARSET_UTF32_SWEDISH_CI] = TRILOGY_ENCODING_UTF32,
192
+ [TRILOGY_CHARSET_UTF32_TURKISH_CI] = TRILOGY_ENCODING_UTF32,
193
+ [TRILOGY_CHARSET_UTF32_CZECH_CI] = TRILOGY_ENCODING_UTF32,
194
+ [TRILOGY_CHARSET_UTF32_DANISH_CI] = TRILOGY_ENCODING_UTF32,
195
+ [TRILOGY_CHARSET_UTF32_LITHUANIAN_CI] = TRILOGY_ENCODING_UTF32,
196
+ [TRILOGY_CHARSET_UTF32_SLOVAK_CI] = TRILOGY_ENCODING_UTF32,
197
+ [TRILOGY_CHARSET_UTF32_SPANISH2_CI] = TRILOGY_ENCODING_UTF32,
198
+ [TRILOGY_CHARSET_UTF32_ROMAN_CI] = TRILOGY_ENCODING_UTF32,
199
+ [TRILOGY_CHARSET_UTF32_PERSIAN_CI] = TRILOGY_ENCODING_UTF32,
200
+ [TRILOGY_CHARSET_UTF32_ESPERANTO_CI] = TRILOGY_ENCODING_UTF32,
201
+ [TRILOGY_CHARSET_UTF32_HUNGARIAN_CI] = TRILOGY_ENCODING_UTF32,
202
+ [TRILOGY_CHARSET_UTF32_SINHALA_CI] = TRILOGY_ENCODING_UTF32,
203
+ [TRILOGY_CHARSET_BINARY] = TRILOGY_ENCODING_BINARY,
204
+ [TRILOGY_CHARSET_GEOSTD8_GENERAL_CI] = TRILOGY_ENCODING_GEOSTD8,
205
+ [TRILOGY_CHARSET_GEOSTD8_BIN] = TRILOGY_ENCODING_GEOSTD8,
206
+ [TRILOGY_CHARSET_CP932_JAPANESE_CI] = TRILOGY_ENCODING_CP932,
207
+ [TRILOGY_CHARSET_CP932_BIN] = TRILOGY_ENCODING_CP932,
208
+ [TRILOGY_CHARSET_EUCJPMS_JAPANESE_CI] = TRILOGY_ENCODING_EUCJPMS,
209
+ [TRILOGY_CHARSET_EUCJPMS_BIN] = TRILOGY_ENCODING_EUCJPMS,
210
+ };
211
+
212
+ TRILOGY_ENCODING_t trilogy_encoding_from_charset(TRILOGY_CHARSET_t charset) { return charset_to_encoding_map[charset]; }