| 1 |
|
| 2 |
. |
| 3 |
. |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#define ASCII "ASCII" |
| 21 |
|
| 22 |
|
| 23 |
#include "config.h" |
| 24 |
#include "common.h" |
| 25 |
#include "decsteps.h" |
| 26 |
|
| 27 |
static unsigned char const ascii_to_ebcdic[256] = |
| 28 |
{ |
| 29 |
0, 1, 2, 3, 55, 45, 46, 47, |
| 30 |
22, 5, 37, 11, 12, 13, 14, 15, |
| 31 |
16, 17, 18, 19, 60, 61, 50, 38, |
| 32 |
24, 25, 63, 39, 28, 29, 30, 31, |
| 33 |
64, 79, 127, 123, 91, 108, 80, 125, |
| 34 |
77, 93, 92, 78, 107, 96, 75, 97, |
| 35 |
240, 241, 242, 243, 244, 245, 246, 247, |
| 36 |
248, 249, 122, 94, 76, 126, 110, 111, |
| 37 |
124, 193, 194, 195, 196, 197, 198, 199, |
| 38 |
200, 201, 209, 210, 211, 212, 213, 214, |
| 39 |
215, 216, 217, 226, 227, 228, 229, 230, |
| 40 |
231, 232, 233, 74, 224, 90, 95, 109, |
| 41 |
121, 129, 130, 131, 132, 133, 134, 135, |
| 42 |
136, 137, 145, 146, 147, 148, 149, 150, |
| 43 |
151, 152, 153, 162, 163, 164, 165, 166, |
| 44 |
167, 168, 169, 192, 106, 208, 161, 7, |
| 45 |
32, 33, 34, 35, 36, 21, 6, 23, |
| 46 |
40, 41, 42, 43, 44, 9, 10, 27, |
| 47 |
48, 49, 26, 51, 52, 53, 54, 8, |
| 48 |
56, 57, 58, 59, 4, 20, 62, 225, |
| 49 |
65, 66, 67, 68, 69, 70, 71, 72, |
| 50 |
73, 81, 82, 83, 84, 85, 86, 87, |
| 51 |
88, 89, 98, 99, 100, 101, 102, 103, |
| 52 |
104, 105, 112, 113, 114, 115, 116, 117, |
| 53 |
118, 119, 120, 128, 138, 139, 140, 141, |
| 54 |
142, 143, 144, 154, 155, 156, 157, 158, |
| 55 |
159, 160, 170, 171, 172, 173, 174, 175, |
| 56 |
176, 177, 178, 179, 180, 181, 182, 183, |
| 57 |
184, 185, 186, 187, 188, 189, 190, 191, |
| 58 |
202, 203, 204, 205, 206, 207, 218, 219, |
| 59 |
220, 221, 222, 223, 234, 235, 236, 237, |
| 60 |
238, 239, 250, 251, 252, 253, 254, 255, |
| 61 |
}; |
| 62 |
|
| 63 |
static unsigned char const ascii_to_ebcdic_ccc[256] = |
| 64 |
{ |
| 65 |
0, 1, 2, 3, 55, 45, 46, 47, |
| 66 |
22, 5, 37, 11, 12, 13, 14, 15, |
| 67 |
16, 17, 18, 19, 60, 61, 50, 38, |
| 68 |
24, 25, 63, 39, 28, 29, 30, 31, |
| 69 |
64, 90, 127, 123, 91, 108, 80, 125, |
| 70 |
77, 93, 92, 78, 107, 96, 75, 97, |
| 71 |
240, 241, 242, 243, 244, 245, 246, 247, |
| 72 |
248, 249, 122, 94, 76, 126, 110, 111, |
| 73 |
124, 193, 194, 195, 196, 197, 198, 199, |
| 74 |
200, 201, 209, 210, 211, 212, 213, 214, |
| 75 |
215, 216, 217, 226, 227, 228, 229, 230, |
| 76 |
231, 232, 233, 74, 224, 79, 95, 109, |
| 77 |
121, 129, 130, 131, 132, 133, 134, 135, |
| 78 |
136, 137, 145, 146, 147, 148, 149, 150, |
| 79 |
151, 152, 153, 162, 163, 164, 165, 166, |
| 80 |
167, 168, 169, 192, 106, 208, 161, 7, |
| 81 |
4, 6, 8, 9, 10, 20, 21, 23, |
| 82 |
26, 27, 138, 139, 140, 141, 142, 143, |
| 83 |
32, 33, 34, 35, 36, 40, 41, 42, |
| 84 |
43, 44, 154, 155, 156, 157, 158, 159, |
| 85 |
48, 49, 51, 52, 53, 54, 56, 57, |
| 86 |
58, 59, 170, 171, 172, 173, 174, 175, |
| 87 |
176, 177, 178, 179, 180, 181, 182, 183, |
| 88 |
184, 185, 186, 187, 188, 189, 190, 191, |
| 89 |
128, 65, 66, 67, 68, 69, 70, 71, |
| 90 |
72, 73, 202, 203, 204, 205, 206, 207, |
| 91 |
144, 81, 82, 83, 84, 85, 86, 87, |
| 92 |
88, 89, 218, 219, 220, 221, 222, 223, |
| 93 |
160, 225, 98, 99, 100, 101, 102, 103, |
| 94 |
104, 105, 234, 235, 236, 237, 238, 239, |
| 95 |
112, 113, 114, 115, 116, 117, 118, 119, |
| 96 |
120, 62, 250, 251, 252, 253, 254, 255, |
| 97 |
}; |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
static unsigned char const ascii_to_ebcdic_ibm[256] = |
| 105 |
{ |
| 106 |
0, 1, 2, 3, 55, 45, 46, 47, |
| 107 |
22, 5, 37, 11, 12, 13, 14, 15, |
| 108 |
16, 17, 18, 19, 60, 61, 50, 38, |
| 109 |
24, 25, 63, 39, 28, 29, 30, 31, |
| 110 |
64, 90, 127, 123, 91, 108, 80, 125, |
| 111 |
77, 93, 92, 78, 107, 96, 75, 97, |
| 112 |
240, 241, 242, 243, 244, 245, 246, 247, |
| 113 |
248, 249, 122, 94, 76, 126, 110, 111, |
| 114 |
124, 193, 194, 195, 196, 197, 198, 199, |
| 115 |
200, 201, 209, 210, 211, 212, 213, 214, |
| 116 |
215, 216, 217, 226, 227, 228, 229, 230, |
| 117 |
231, 232, 233, 173, 224, 189, 95, 109, |
| 118 |
121, 129, 130, 131, 132, 133, 134, 135, |
| 119 |
136, 137, 145, 146, 147, 148, 149, 150, |
| 120 |
151, 152, 153, 162, 163, 164, 165, 166, |
| 121 |
167, 168, 169, 192, 79, 208, 161, 7, |
| 122 |
32, 33, 34, 35, 36, 21, 6, 23, |
| 123 |
40, 41, 42, 43, 44, 9, 10, 27, |
| 124 |
48, 49, 26, 51, 52, 53, 54, 8, |
| 125 |
56, 57, 58, 59, 4, 20, 62, 225, |
| 126 |
65, 66, 67, 68, 69, 70, 71, 72, |
| 127 |
73, 81, 82, 83, 84, 85, 86, 87, |
| 128 |
88, 89, 98, 99, 100, 101, 102, 103, |
| 129 |
104, 105, 112, 113, 114, 115, 116, 117, |
| 130 |
118, 119, 120, 128, 138, 139, 140, 141, |
| 131 |
142, 143, 144, 154, 155, 156, 157, 158, |
| 132 |
159, 160, 170, 171, 172, 74, 174, 175, |
| 133 |
176, 177, 178, 179, 180, 181, 182, 183, |
| 134 |
184, 185, 186, 187, 188, 106, 190, 191, |
| 135 |
202, 203, 204, 205, 206, 207, 218, 219, |
| 136 |
220, 221, 222, 223, 234, 235, 236, 237, |
| 137 |
238, 239, 250, 251, 252, 253, 254, 255, |
| 138 |
}; |
| 139 |
|
| 140 |
static bool |
| 141 |
init_ascii_ebcdic (RECODE_STEP step, |
| 142 |
RECODE_CONST_REQUEST request _GL_UNUSED, |
| 143 |
RECODE_CONST_OPTION_LIST before_options, |
| 144 |
RECODE_CONST_OPTION_LIST after_options) |
| 145 |
{ |
| 146 |
if (before_options || after_options) |
| 147 |
return false; |
| 148 |
|
| 149 |
step->step_type = RECODE_BYTE_TO_BYTE; |
| 150 |
|
| 151 |
step->step_table = (void *) ascii_to_ebcdic; |
| 152 |
return true; |
| 153 |
} |
| 154 |
|
| 155 |
static bool |
| 156 |
init_ebcdic_ascii (RECODE_STEP step, |
| 157 |
RECODE_CONST_REQUEST request, |
| 158 |
RECODE_CONST_OPTION_LIST before_options, |
| 159 |
RECODE_CONST_OPTION_LIST after_options) |
| 160 |
{ |
| 161 |
if (before_options || after_options) |
| 162 |
return false; |
| 163 |
|
| 164 |
if (step->step_table = recode_invert_table (request->outer, ascii_to_ebcdic), |
| 165 |
step->step_table) |
| 166 |
{ |
| 167 |
step->step_type = RECODE_BYTE_TO_BYTE; |
| 168 |
step->step_table_term_routine = free; |
| 169 |
return true; |
| 170 |
} |
| 171 |
else |
| 172 |
return false; |
| 173 |
} |
| 174 |
|
| 175 |
static bool |
| 176 |
init_ascii_ebcdic_ccc (RECODE_STEP step, |
| 177 |
RECODE_CONST_REQUEST request _GL_UNUSED, |
| 178 |
RECODE_CONST_OPTION_LIST before_options, |
| 179 |
RECODE_CONST_OPTION_LIST after_options) |
| 180 |
{ |
| 181 |
if (before_options || after_options) |
| 182 |
return false; |
| 183 |
|
| 184 |
step->step_type = RECODE_BYTE_TO_BYTE; |
| 185 |
|
| 186 |
step->step_table = (void *) ascii_to_ebcdic_ccc; |
| 187 |
return true; |
| 188 |
} |
| 189 |
|
| 190 |
static bool |
| 191 |
init_ebcdic_ccc_ascii (RECODE_STEP step, |
| 192 |
RECODE_CONST_REQUEST request, |
| 193 |
RECODE_CONST_OPTION_LIST before_options, |
| 194 |
RECODE_CONST_OPTION_LIST after_options) |
| 195 |
|
| 196 |
{ |
| 197 |
if (before_options || after_options) |
| 198 |
return false; |
| 199 |
|
| 200 |
if (step->step_table = recode_invert_table (request->outer, ascii_to_ebcdic_ccc), |
| 201 |
step->step_table) |
| 202 |
{ |
| 203 |
step->step_type = RECODE_BYTE_TO_BYTE; |
| 204 |
step->step_table_term_routine = free; |
| 205 |
return true; |
| 206 |
} |
| 207 |
else |
| 208 |
return false; |
| 209 |
} |
| 210 |
|
| 211 |
static bool |
| 212 |
init_ascii_ebcdic_ibm (RECODE_STEP step, |
| 213 |
RECODE_CONST_REQUEST request _GL_UNUSED, |
| 214 |
RECODE_CONST_OPTION_LIST before_options, |
| 215 |
RECODE_CONST_OPTION_LIST after_options) |
| 216 |
{ |
| 217 |
if (before_options || after_options) |
| 218 |
return false; |
| 219 |
|
| 220 |
step->step_type = RECODE_BYTE_TO_BYTE; |
| 221 |
|
| 222 |
step->step_table = (void *) ascii_to_ebcdic_ibm; |
| 223 |
return true; |
| 224 |
} |
| 225 |
|
| 226 |
static bool |
| 227 |
init_ebcdic_ibm_ascii (RECODE_STEP step, |
| 228 |
RECODE_CONST_REQUEST request, |
| 229 |
RECODE_CONST_OPTION_LIST before_options, |
| 230 |
RECODE_CONST_OPTION_LIST after_options) |
| 231 |
{ |
| 232 |
if (before_options || after_options) |
| 233 |
return false; |
| 234 |
|
| 235 |
if (step->step_table = recode_invert_table (request->outer, ascii_to_ebcdic_ibm), |
| 236 |
step->step_table) |
| 237 |
{ |
| 238 |
step->step_type = RECODE_BYTE_TO_BYTE; |
| 239 |
step->step_table_term_routine = free; |
| 240 |
return true; |
| 241 |
} |
| 242 |
else |
| 243 |
return false; |
| 244 |
} |
| 245 |
|
| 246 |
bool |
| 247 |
module_ebcdic (RECODE_OUTER outer) |
| 248 |
{ |
| 249 |
return |
| 250 |
recode_declare_single (outer, ASCII, "EBCDIC", |
| 251 |
outer->quality_byte_reversible, |
| 252 |
init_ascii_ebcdic, recode_transform_byte_to_byte) |
| 253 |
&& recode_declare_single (outer, "EBCDIC", ASCII, |
| 254 |
outer->quality_byte_reversible, |
| 255 |
init_ebcdic_ascii, recode_transform_byte_to_byte) |
| 256 |
&& recode_declare_single (outer, ASCII, "EBCDIC-CCC", |
| 257 |
outer->quality_byte_reversible, |
| 258 |
init_ascii_ebcdic_ccc, recode_transform_byte_to_byte) |
| 259 |
&& recode_declare_single (outer, "EBCDIC-CCC", ASCII, |
| 260 |
outer->quality_byte_reversible, |
| 261 |
init_ebcdic_ccc_ascii, recode_transform_byte_to_byte) |
| 262 |
&& recode_declare_single (outer, ASCII, "EBCDIC-IBM", |
| 263 |
outer->quality_byte_reversible, |
| 264 |
init_ascii_ebcdic_ibm, recode_transform_byte_to_byte) |
| 265 |
&& recode_declare_single (outer, "EBCDIC-IBM", ASCII, |
| 266 |
outer->quality_byte_reversible, |
| 267 |
init_ebcdic_ibm_ascii, recode_transform_byte_to_byte); |
| 268 |
} |
| 269 |
|
| 270 |
void |
| 271 |
delmodule_ebcdic (_GL_UNUSED RECODE_OUTER outer) |
| 272 |
{ |
| 273 |
} |