| 171 | | /* A revision number to be specified for each charset on encoding. |
|---|
| 172 | | The value 255 means no revision number for the corresponding |
|---|
| 173 | | charset. */ |
|---|
| 174 | | unsigned char charset_revision_number[MAX_CHARSET + 1]; |
|---|
| | 164 | /* Table of expected character sets for this coding system. If the |
|---|
| | 165 | Nth element is 0, the charset of ID N is not an expected |
|---|
| | 166 | character set. Such a character set is not encoded when |
|---|
| | 167 | CODING_ISO_FLAG_SAFE is set. */ |
|---|
| | 168 | unsigned char expected_charsets[MAX_CHARSET + 1]; |
|---|
| 279 | | /* Macros used for the member finish_status of the struct |
|---|
| 280 | | coding_system. */ |
|---|
| 281 | | #define CODING_FINISH_NORMAL 0 |
|---|
| 282 | | #define CODING_FINISH_INSUFFICIENT_SRC 1 |
|---|
| 283 | | #define CODING_FINISH_INSUFFICIENT_DST 2 |
|---|
| 284 | | #define CODING_FINISH_INCONSISTENT_EOL 3 |
|---|
| 285 | | |
|---|
| 286 | | /* Macros used for the member `mode' of the struct coding_system. */ |
|---|
| 287 | | |
|---|
| 288 | | /* If set, recover the original CR or LF of the already decoded text |
|---|
| 289 | | when the decoding routine encounters an inconsistent eol format. */ |
|---|
| 290 | | #define CODING_MODE_INHIBIT_INCONSISTENT_EOL 0x01 |
|---|
| 291 | | |
|---|
| 292 | | /* If set, the decoding/encoding routines treat the current data as |
|---|
| 293 | | the last block of the whole text to be converted, and do |
|---|
| 294 | | appropriate fisishing job. */ |
|---|
| 295 | | #define CODING_MODE_LAST_BLOCK 0x02 |
|---|
| 296 | | |
|---|
| 297 | | /* If set, it means that the current source text is in a buffer which |
|---|
| 298 | | enables selective display. */ |
|---|
| 299 | | #define CODING_MODE_SELECTIVE_DISPLAY 0x04 |
|---|
| 300 | | |
|---|
| 301 | | /* This flag is used by the decoding/encoding routines on the fly. If |
|---|
| 302 | | set, it means that right-to-left text is being processed. */ |
|---|
| 303 | | #define CODING_MODE_DIRECTION 0x08 |
|---|
| 304 | | |
|---|
| 321 | | /* Mode bits of the coding system. See the comments of the macros |
|---|
| 322 | | CODING_MODE_XXX. */ |
|---|
| 323 | | unsigned int mode; |
|---|
| 324 | | |
|---|
| 325 | | /* Table of safe character sets for this coding system. If the Nth |
|---|
| 326 | | element is 0, the charset of ID N is not a safe character set. |
|---|
| 327 | | Such a character set is not encoded when CODING_ISO_FLAG_SAFE is |
|---|
| 328 | | set. */ |
|---|
| 329 | | unsigned char safe_charsets[MAX_CHARSET + 1]; |
|---|
| | 286 | /* Type of end-of-line format (LF, CRLF, or CR) of the coding system. */ |
|---|
| | 287 | int eol_type; |
|---|
| | 288 | |
|---|
| | 289 | /* Non-zero means that the current source text is the last block of the |
|---|
| | 290 | whole text to be converted. */ |
|---|
| | 291 | int last_block; |
|---|
| 343 | | /* Index number of coding category of the coding system. */ |
|---|
| 344 | | int category_idx; |
|---|
| 345 | | |
|---|
| 346 | | /* How may heading bytes we can skip for decoding. This is set to |
|---|
| 347 | | -1 in setup_coding_system, and updated by detect_coding. So, |
|---|
| 348 | | when this is equal to the byte length of the text being |
|---|
| 349 | | converted, we can skip the actual conversion process. */ |
|---|
| 350 | | int heading_ascii; |
|---|
| 351 | | |
|---|
| 352 | | /* The following members are set by encoding/decoding routine. */ |
|---|
| 353 | | int produced, produced_char, consumed, consumed_char; |
|---|
| 354 | | |
|---|
| 355 | | /* Encoding routines set this to 1 when they produce a byte sequence |
|---|
| 356 | | which can be parsed as a multibyte character. Decoding routines |
|---|
| 357 | | set this to 1 when they encounter an invalid code and, as the |
|---|
| 358 | | result, produce an unexpected multibyte character. */ |
|---|
| 359 | | int fake_multibyte; |
|---|
| 360 | | |
|---|
| 361 | | /* The following members are all Lisp symbols. We don't have to |
|---|
| 362 | | protect them from GC because the current garbage collection |
|---|
| 363 | | doesn't relocate Lisp symbols. But, when it is changed, we must |
|---|
| 364 | | find a way to protect them. */ |
|---|
| 365 | | |
|---|
| 377 | | /* Character translation tables to look up, or nil. */ |
|---|
| 378 | | Lisp_Object translation_table_for_decode; |
|---|
| 379 | | Lisp_Object translation_table_for_encode; |
|---|
| | 324 | /* Character unification tables to look up, or nil. */ |
|---|
| | 325 | Lisp_Object character_unification_table_for_decode; |
|---|
| | 326 | Lisp_Object character_unification_table_for_encode; |
|---|
| | 327 | |
|---|
| | 328 | /* Carryover yielded by decoding/encoding incomplete source. No |
|---|
| | 329 | coding-system yields more than 7-byte of carryover. This does |
|---|
| | 330 | not include a text which is not processed because of short of |
|---|
| | 331 | output buffer. */ |
|---|
| | 332 | char carryover[8]; |
|---|
| | 333 | |
|---|
| | 334 | /* Actual data length in the above array. */ |
|---|
| | 335 | int carryover_size; |
|---|
| 382 | | #define CODING_REQUIRE_FLUSHING_MASK 1 |
|---|
| 383 | | #define CODING_REQUIRE_DECODING_MASK 2 |
|---|
| 384 | | #define CODING_REQUIRE_ENCODING_MASK 4 |
|---|
| 385 | | #define CODING_REQUIRE_DETECTION_MASK 8 |
|---|
| 386 | | |
|---|
| 387 | | /* Return 1 if the coding system CODING requires specific code to be |
|---|
| 388 | | attached at the tail of converted text. */ |
|---|
| 389 | | #define CODING_REQUIRE_FLUSHING(coding) \ |
|---|
| 390 | | ((coding)->common_flags & CODING_REQUIRE_FLUSHING_MASK) |
|---|
| 391 | | |
|---|
| 392 | | /* Return 1 if the coding system CODING requires code conversion on |
|---|
| 393 | | decoding. */ |
|---|
| 394 | | #define CODING_REQUIRE_DECODING(coding) \ |
|---|
| 395 | | ((coding)->common_flags & CODING_REQUIRE_DECODING_MASK) |
|---|
| 396 | | |
|---|
| 397 | | /* Return 1 if the coding system CODING requires code conversion on |
|---|
| 398 | | encoding. */ |
|---|
| 399 | | #define CODING_REQUIRE_ENCODING(coding) \ |
|---|
| 400 | | ((coding)->common_flags & CODING_REQUIRE_ENCODING_MASK) |
|---|
| 401 | | |
|---|
| 402 | | /* Return 1 if the coding system CODING requires some kind of code |
|---|
| 403 | | detection. */ |
|---|
| 404 | | #define CODING_REQUIRE_DETECTION(coding) \ |
|---|
| 405 | | ((coding)->common_flags & CODING_REQUIRE_DETECTION_MASK) |
|---|
| 406 | | |
|---|
| 407 | | #define CODING_MAY_REQUIRE_DECODING(coding) \ |
|---|
| 408 | | ((coding)->common_flags \ |
|---|
| 409 | | & (CODING_REQUIRE_DETECTION_MASK | CODING_REQUIRE_DECODING_MASK)) |
|---|
| | 338 | /* Return 1 if coding system CODING never requires any code conversion. */ |
|---|
| | 339 | #define CODING_REQUIRE_NO_CONVERSION(coding) \ |
|---|
| | 340 | ((coding)->type == coding_type_no_conversion \ |
|---|
| | 341 | || (((coding)->type == coding_type_emacs_mule \ |
|---|
| | 342 | || (coding)->type == coding_type_raw_text) \ |
|---|
| | 343 | && (coding)->eol_type == CODING_EOL_LF)) |
|---|
| | 344 | |
|---|
| | 345 | /* Return 1 if coding system CODING may not require code conversion. */ |
|---|
| | 346 | #define CODING_MAY_REQUIRE_NO_CONVERSION(coding) \ |
|---|
| | 347 | ((coding)->type == coding_type_no_conversion \ |
|---|
| | 348 | || (((coding)->type == coding_type_emacs_mule \ |
|---|
| | 349 | || (coding)->type == coding_type_undecided \ |
|---|
| | 350 | || (coding)->type == coding_type_raw_text) \ |
|---|
| | 351 | && ((coding)->eol_type == CODING_EOL_LF \ |
|---|
| | 352 | || (coding)->eol_type == CODING_EOL_UNDECIDED))) |
|---|
| 415 | | #define CODING_CATEGORY_IDX_ISO_7_TIGHT 3 |
|---|
| 416 | | #define CODING_CATEGORY_IDX_ISO_8_1 4 |
|---|
| 417 | | #define CODING_CATEGORY_IDX_ISO_8_2 5 |
|---|
| 418 | | #define CODING_CATEGORY_IDX_ISO_7_ELSE 6 |
|---|
| 419 | | #define CODING_CATEGORY_IDX_ISO_8_ELSE 7 |
|---|
| 420 | | #define CODING_CATEGORY_IDX_CCL 8 |
|---|
| 421 | | #define CODING_CATEGORY_IDX_BIG5 9 |
|---|
| 422 | | #define CODING_CATEGORY_IDX_RAW_TEXT 10 |
|---|
| 423 | | #define CODING_CATEGORY_IDX_BINARY 11 |
|---|
| 424 | | #define CODING_CATEGORY_IDX_MAX 12 |
|---|
| | 358 | #define CODING_CATEGORY_IDX_ISO_8_1 3 |
|---|
| | 359 | #define CODING_CATEGORY_IDX_ISO_8_2 4 |
|---|
| | 360 | #define CODING_CATEGORY_IDX_ISO_7_ELSE 5 |
|---|
| | 361 | #define CODING_CATEGORY_IDX_ISO_8_ELSE 6 |
|---|
| | 362 | #define CODING_CATEGORY_IDX_BIG5 7 |
|---|
| | 363 | #define CODING_CATEGORY_IDX_RAW_TEXT 8 |
|---|
| | 364 | #define CODING_CATEGORY_IDX_BINARY 9 |
|---|
| | 365 | #define CODING_CATEGORY_IDX_MAX 10 |
|---|
| 454 | | |
|---|
| 455 | | #define CODING_CATEGORY_MASK_ISO_7BIT \ |
|---|
| 456 | | (CODING_CATEGORY_MASK_ISO_7 | CODING_CATEGORY_MASK_ISO_7_TIGHT) |
|---|
| 457 | | |
|---|
| 458 | | #define CODING_CATEGORY_MASK_ISO_8BIT \ |
|---|
| 459 | | (CODING_CATEGORY_MASK_ISO_8_1 | CODING_CATEGORY_MASK_ISO_8_2) |
|---|
| 460 | | |
|---|
| 461 | | #define CODING_CATEGORY_MASK_ISO_SHIFT \ |
|---|
| 462 | | (CODING_CATEGORY_MASK_ISO_7_ELSE | CODING_CATEGORY_MASK_ISO_8_ELSE) |
|---|
| 463 | | |
|---|
| 464 | | #define CODING_CATEGORY_MASK_ISO \ |
|---|
| 465 | | ( CODING_CATEGORY_MASK_ISO_7BIT \ |
|---|
| 466 | | | CODING_CATEGORY_MASK_ISO_SHIFT \ |
|---|
| 467 | | | CODING_CATEGORY_MASK_ISO_8BIT) |
|---|
| 494 | | /* Encode the file name NAME using the specified coding system |
|---|
| 495 | | for file names, if any. */ |
|---|
| 496 | | #define ENCODE_FILE(name) \ |
|---|
| 497 | | (! NILP (Vfile_name_coding_system) \ |
|---|
| 498 | | && XFASTINT (Vfile_name_coding_system) != 0 \ |
|---|
| 499 | | ? code_convert_string_norecord (name, Vfile_name_coding_system, 1) \ |
|---|
| 500 | | : (! NILP (Vdefault_file_name_coding_system) \ |
|---|
| 501 | | && XFASTINT (Vdefault_file_name_coding_system) != 0 \ |
|---|
| 502 | | ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 1) \ |
|---|
| 503 | | : name)) |
|---|
| 504 | | |
|---|
| 505 | | /* Decode the file name NAME using the specified coding system |
|---|
| 506 | | for file names, if any. */ |
|---|
| 507 | | #define DECODE_FILE(name) \ |
|---|
| 508 | | (! NILP (Vfile_name_coding_system) \ |
|---|
| 509 | | && XFASTINT (Vfile_name_coding_system) != 0 \ |
|---|
| 510 | | ? code_convert_string_norecord (name, Vfile_name_coding_system, 0) \ |
|---|
| 511 | | : (! NILP (Vdefault_file_name_coding_system) \ |
|---|
| 512 | | && XFASTINT (Vdefault_file_name_coding_system) != 0 \ |
|---|
| 513 | | ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 0) \ |
|---|
| 514 | | : name)) |
|---|
| 515 | | |
|---|
| 517 | | extern int decode_coding P_ ((struct coding_system *, unsigned char *, |
|---|
| 518 | | unsigned char *, int, int)); |
|---|
| 519 | | extern int encode_coding P_ ((struct coding_system *, unsigned char *, |
|---|
| 520 | | unsigned char *, int, int)); |
|---|
| 521 | | extern int code_convert_region P_ ((int, int, int, int, struct coding_system *, |
|---|
| 522 | | int, int)); |
|---|
| 523 | | extern int decoding_buffer_size P_ ((struct coding_system *, int)); |
|---|
| 524 | | extern int encoding_buffer_size P_ ((struct coding_system *, int)); |
|---|
| 525 | | extern void detect_coding P_ ((struct coding_system *, unsigned char *, int)); |
|---|
| 526 | | extern void detect_eol P_ ((struct coding_system *, unsigned char *, int)); |
|---|
| | 418 | extern int decode_coding (), encode_coding (); |
|---|
| | 419 | extern int decoding_buffer_size (), encoding_buffer_size (); |
|---|