+#define COMPOSING_P(coding) ((int) coding->composing > (int) COMPOSITION_NO)
+
+#define COMPOSITION_DATA_SIZE 4080
+#define COMPOSITION_DATA_MAX_BUNCH_LENGTH (4 + MAX_COMPOSITION_COMPONENTS*2)
+
+/* Data structure to hold information about compositions of text that
+ is being decoded or encode. ISO 2022 base code conversion routines
+ handle special ESC sequences for composition specification. But,
+ they can't get/put such information directly from/to a buffer in
+ the deepest place. So, they store or retrieve the information
+ through this structure.
+
+ The encoder stores the information in this structure when it meets
+ ESC sequences for composition while encoding codes, then, after all
+ text codes are encoded, puts `composition' properties on the text
+ by referring to the structure.
+
+ The decoder at first stores the information of a text to be
+ decoded, then, while decoding codes, generates ESC sequences for
+ composition at proper places by referring to the structure. */
+
+struct composition_data
+{
+ /* The character position of the first character to be encoded or
+ decoded. START and END (see below) are relative to this
+ position. */
+ int char_offset;
+
+ /* The composition data. These elements are repeated for each
+ composition:
+ LENGTH START END METHOD [ COMPONENT ... ]
+ where,
+ LENGTH is the number of elements for this composition.
+
+ START and END are starting and ending character positions of
+ the composition relative to `char_offset'.
+
+ METHOD is one of `enum composing_status' specifying the way of
+ composition.
+
+ COMPONENT is a character or an encoded composition rule. */
+ int data[COMPOSITION_DATA_SIZE];
+
+ /* The number of elements in `data' currently used. */
+ int used;
+
+ /* Pointers to the previous and next structures. When `data' is
+ filled up, another structure is allocated and linked in `next'.
+ The new structure has backward link to this structure in `prev'.
+ The number of chained structures depends on how many compositions
+ the text being encoded or decoded contains. */
+ struct composition_data *prev, *next;
+};
+
+/* Macros used for the member `result' of the struct
+ coding_system. */
+#define CODING_FINISH_NORMAL 0
+#define CODING_FINISH_INSUFFICIENT_SRC 1
+#define CODING_FINISH_INSUFFICIENT_DST 2
+#define CODING_FINISH_INCONSISTENT_EOL 3
+#define CODING_FINISH_INSUFFICIENT_CMP 4
+#define CODING_FINISH_INTERRUPT 5
+
+/* Macros used for the member `mode' of the struct coding_system. */
+
+/* If set, recover the original CR or LF of the already decoded text
+ when the decoding routine encounters an inconsistent eol format. */
+#define CODING_MODE_INHIBIT_INCONSISTENT_EOL 0x01
+
+/* If set, the decoding/encoding routines treat the current data as
+ the last block of the whole text to be converted, and do
+ appropriate finishing job. */
+#define CODING_MODE_LAST_BLOCK 0x02
+
+/* If set, it means that the current source text is in a buffer which
+ enables selective display. */
+#define CODING_MODE_SELECTIVE_DISPLAY 0x04
+
+/* If set, replace unencodabae characters by `?' on encoding. */
+#define CODING_MODE_INHIBIT_UNENCODABLE_CHAR 0x08
+
+/* This flag is used by the decoding/encoding routines on the fly. If
+ set, it means that right-to-left text is being processed. */
+#define CODING_MODE_DIRECTION 0x10