Sync to HEAD
[bpt/emacs.git] / src / ccl.h
1 /* Header for CCL (Code Conversion Language) interpreter.
2 Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
3 Licensed to the Free Software Foundation.
4 Copyright (C) 2003
5 National Institute of Advanced Industrial Science and Technology (AIST)
6 Registration Number H13PRO009
7
8 This file is part of GNU Emacs.
9
10 GNU Emacs is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
13 any later version.
14
15 GNU Emacs is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with GNU Emacs; see the file COPYING. If not, write to
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
24
25 #ifndef EMACS_CCL_H
26 #define EMACS_CCL_H
27
28 /* Macros for exit status of CCL program. */
29 #define CCL_STAT_SUCCESS 0 /* Terminated successfully. */
30 #define CCL_STAT_SUSPEND_BY_SRC 1 /* Terminated by empty input. */
31 #define CCL_STAT_SUSPEND_BY_DST 2 /* Terminated by output buffer full. */
32 #define CCL_STAT_INVALID_CMD 3 /* Terminated because of invalid
33 command. */
34 #define CCL_STAT_QUIT 4 /* Terminated because of quit. */
35
36 /* Structure to hold information about running CCL code. Read
37 comments in the file ccl.c for the detail of each field. */
38 struct ccl_program {
39 int size; /* Size of the compiled code. */
40 Lisp_Object *prog; /* Pointer into the compiled code. */
41 int ic; /* Instruction Counter (index for PROG). */
42 int eof_ic; /* Instruction Counter for end-of-file
43 processing code. */
44 int reg[8]; /* CCL registers, reg[7] is used for
45 condition flag of relational
46 operations. */
47 int private_state; /* CCL instruction may use this
48 for private use, mainly for saving
49 internal states on suspending.
50 This variable is set to 0 when ccl is
51 set up. */
52 int last_block; /* Set to 1 while processing the last
53 block. */
54 int status; /* Exit status of the CCL program. */
55 int buf_magnification; /* Output buffer magnification. How
56 many times bigger the output buffer
57 should be than the input buffer. */
58 int stack_idx; /* How deep the call of CCL_Call is nested. */
59 int src_multibyte; /* 1 if the input buffer is multibyte. */
60 int dst_multibyte; /* 1 if the output buffer is multibyte. */
61 int cr_consumed; /* Flag for encoding DOS-like EOL
62 format when the CCL program is used
63 for encoding by a coding
64 system. */
65 int consumed;
66 int produced;
67 int suppress_error; /* If nonzero, don't insert error
68 message in the output. */
69 int eight_bit_control; /* If nonzero, ccl_driver counts all
70 eight-bit-control bytes written by
71 CCL_WRITE_CHAR. After execution,
72 if no such byte is written, set
73 this value to zero. */
74 };
75
76 /* This data type is used for the spec field of the structure
77 coding_system. */
78
79 struct ccl_spec {
80 struct ccl_program ccl;
81 int cr_carryover; /* CR carryover flag. */
82 unsigned char eight_bit_carryover[MAX_MULTIBYTE_LENGTH];
83 };
84
85 #define CODING_SPEC_CCL_PROGRAM(coding) ((coding)->spec.ccl.ccl)
86
87 /* Alist of fontname patterns vs corresponding CCL program. */
88 extern Lisp_Object Vfont_ccl_encoder_alist;
89
90 /* Setup fields of the structure pointed by CCL appropriately for the
91 execution of ccl program CCL_PROG (symbol or vector). */
92 extern int setup_ccl_program P_ ((struct ccl_program *, Lisp_Object));
93
94 extern void ccl_driver P_ ((struct ccl_program *, int *, int *, int, int,
95 Lisp_Object));
96
97 /* Vector of CCL program names vs corresponding program data. */
98 extern Lisp_Object Vccl_program_table;
99
100 /* Symbols of ccl program have this property, a value of the property
101 is an index for Vccl_protram_table. */
102 extern Lisp_Object Qccl_program_idx;
103
104 extern Lisp_Object Qccl, Qcclp;
105
106 EXFUN (Fccl_program_p, 1);
107
108 #define CHECK_CCL_PROGRAM(x) \
109 do { \
110 if (NILP (Fccl_program_p (x))) \
111 x = wrong_type_argument (Qcclp, (x)); \
112 } while (0);
113
114 #endif /* EMACS_CCL_H */
115
116 /* arch-tag: 14681df7-876d-43de-bc71-6b78e23a4e3c
117 (do not change this comment) */