"Fossies" - the Fresh Open Source Software Archive

Member "recode-3.7.12/src/recodext.h" (15 Feb 2022, 24579 Bytes) of package /linux/misc/recode-3.7.12.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "recodext.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 3.7.11_vs_3.7.12.

    1 /* Conversion of files between different charsets and surfaces.
    2    Copyright © 1990, 93, 94, 96-99, 2000, 2001 Free Software Foundation, Inc.
    3    Contributed by François Pinard <pinard@iro.umontreal.ca>, 1988.
    4 
    5    This library is free software; you can redistribute it and/or
    6    modify it under the terms of the GNU Library General Public License
    7    as published by the Free Software Foundation; either version 3 of the
    8    License, or (at your option) any later version.
    9 
   10    This library is distributed in the hope that it will be
   11    useful, but WITHOUT ANY WARRANTY; without even the implied warranty
   12    of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   13    Library General Public License for more details.
   14 
   15    You should have received a copy of the GNU Library General Public
   16    License along with the Recode Library; see the file `COPYING.LIB'.
   17    If not, see <https://www.gnu.org/licenses/>.
   18 */
   19 
   20 /* Extended definitions, for externally written steps.  */
   21 
   22 #include "recode.h"
   23 
   24 /* Internal typedefs, to supplement those in "recode.h".  */
   25 
   26 typedef struct recode_symbol *          RECODE_SYMBOL;
   27 typedef struct recode_option_list *     RECODE_OPTION_LIST;
   28 typedef struct recode_single *          RECODE_SINGLE;
   29 typedef struct recode_step *            RECODE_STEP;
   30 typedef struct recode_alias *           RECODE_ALIAS;
   31 typedef struct recode_subtask *         RECODE_SUBTASK;
   32 
   33 typedef const struct recode_option_list *   RECODE_CONST_OPTION_LIST;
   34 typedef const struct recode_outer *     RECODE_CONST_OUTER;
   35 typedef const struct recode_step *      RECODE_CONST_STEP;
   36 typedef const struct recode_alias *     RECODE_CONST_ALIAS;
   37 typedef const struct recode_task *      RECODE_CONST_TASK;
   38 
   39 /*--------------------------------------------------------------------------.
   40 | Return from SUBTASK, with `false' if the failure level has been reached.  |
   41 `--------------------------------------------------------------------------*/
   42 
   43 #define SUBTASK_RETURN(Subtask) \
   44   return (Subtask)->task->error_so_far < (Subtask)->task->fail_level
   45 
   46 /*-------------------------------------------------------------------------.
   47 | Maintain maximum of ERROR and current error in SUBTASK.  If the abort    |
   48 | level has been reached, then return immediately as with SUBTASK_RETURN.  |
   49 `-------------------------------------------------------------------------*/
   50 
   51 #define RETURN_IF_NOGO(Error, Subtask) \
   52   do {                              \
   53     if (recode_if_nogo (Error, Subtask))            \
   54        SUBTASK_RETURN (Subtask);                \
   55   } while (false)
   56 
   57 /* Various structure declarations.  */
   58 
   59 /*-----------------------------------------.
   60 | Outer variables for the recode library.  |
   61 `-----------------------------------------*/
   62 
   63 /* Error codes, in increasing severity.  */
   64 
   65 enum recode_error
   66   {
   67     RECODE_NO_ERROR,        /* no error so far */
   68     RECODE_NOT_CANONICAL,   /* input is not exact, but equivalent */
   69     RECODE_AMBIGUOUS_OUTPUT,    /* output will be misleading */
   70     RECODE_UNTRANSLATABLE,  /* input is getting lost, while valid */
   71     RECODE_INVALID_INPUT,   /* input is getting lost, but was invalid */
   72     RECODE_SYSTEM_ERROR,    /* system returned input/output failure */
   73     RECODE_USER_ERROR,      /* library is being misused */
   74     RECODE_INTERNAL_ERROR,  /* programming botch in the library */
   75     RECODE_MAXIMUM_ERROR    /* impossible value (should be kept last) */
   76   };
   77 
   78 /* Structure for relating alias names to charsets and surfaces.  */
   79 
   80 struct recode_alias
   81   {
   82     const char *name;       /* charset, surface or alias name */
   83     RECODE_SYMBOL symbol;   /* associated symbol */
   84     /* If a charset, list of surfaces usually applied by default.  */
   85     struct recode_surface_list *implied_surfaces;
   86   };
   87 
   88 /* The sole purpose of qualities is for later attributing step costs.  */
   89 
   90 enum recode_size
   91   {
   92     RECODE_1,           /* roughly one byte per character */
   93     RECODE_2,           /* roughly two bytes per character */
   94     RECODE_4,           /* roughly four bytes per character */
   95     RECODE_N            /* variable number of bytes per character */
   96   };
   97 
   98 struct recode_quality
   99   {
  100     enum recode_size in_size : 3; /* rough byte size of input characters */
  101     enum recode_size out_size : 3; /* rough byte size of output characters */
  102     bool reversible : 1;    /* transformation is known to be reversible */
  103     bool slower : 1;        /* transformation is slower than average */
  104     bool faster : 1;        /* transformation is faster than average */
  105   };
  106 
  107 /* Main variables of the initialised library.  */
  108 
  109 struct recode_outer
  110   {
  111     /* This flag asks the library to diagnose and abort itself if errors.  */
  112     bool auto_abort;
  113 
  114     /* If the external `iconv' library should be initialized and used.  */
  115     bool use_iconv;
  116 
  117     /* If we should discard untranslatable input and return an error,
  118        unless 'force' is set (see below).  */
  119     bool strict_mapping;
  120 
  121     /* If we should ignore untranslatable input altogether.  */
  122     bool force;
  123 
  124     /* charset.c */
  125     /* --------- */
  126 
  127     /* Known pairs (for restricting listing).  */
  128     struct recode_known_pair *pair_restriction;
  129     unsigned pair_restrictions;
  130 
  131     /* Opaque Hash_table pointer giving access to the single table holding all
  132        names and aliases for charsets, surfaces and fallback methods.  */
  133     void *alias_table;
  134 
  135     /* Unique symbols are linked into a list and counted.  */
  136     RECODE_SYMBOL symbol_list;
  137     unsigned number_of_symbols;
  138 
  139     /* Arrays of strings ready for argmatch.  */
  140     char const **argmatch_charset_array;
  141     char const **argmatch_surface_array;
  142     const char **realname_charset_array;
  143     const char **realname_surface_array;
  144 
  145     /* recode.c */
  146     /* -------- */
  147 
  148     /* Known single steps.  */
  149     struct recode_single *single_list;
  150     unsigned number_of_singles;
  151 
  152     /* Identity recoding table.  */
  153     const unsigned char *one_to_same;
  154 
  155     /* Preset charsets and surfaces.  */
  156     RECODE_SYMBOL data_symbol;/* special charset defining surfaces */
  157     RECODE_SYMBOL ucs2_charset; /* UCS-2 */
  158     RECODE_SYMBOL iconv_pivot; /* `iconv' internal UCS */
  159     RECODE_SYMBOL crlf_surface; /* for IBM PC machines */
  160     RECODE_SYMBOL cr_surface;   /* for Macintosh machines */
  161 
  162     /* Preset qualities, to make step initialisation simpler.  */
  163     struct recode_quality quality_byte_reversible;
  164     struct recode_quality quality_byte_to_byte;
  165     struct recode_quality quality_byte_to_ucs2;
  166     struct recode_quality quality_byte_to_variable;
  167     struct recode_quality quality_ucs2_to_byte;
  168     struct recode_quality quality_ucs2_to_variable;
  169     struct recode_quality quality_variable_to_byte;
  170     struct recode_quality quality_variable_to_ucs2;
  171     struct recode_quality quality_variable_to_variable;
  172   };
  173 
  174 /*--------------------------.
  175 | Description of a symbol.  |
  176 `--------------------------*/
  177 
  178 enum recode_symbol_type
  179   {
  180     RECODE_NO_SYMBOL_TYPE,  /* missing value */
  181     RECODE_CHARSET,     /* visible in the space of charsets */
  182     RECODE_DATA_SURFACE     /* this is a mere data surface */
  183   };
  184 
  185 enum recode_data_type
  186   {
  187     RECODE_NO_CHARSET_DATA, /* the charset_table field is unused */
  188     RECODE_STRIP_DATA,      /* pool pointer and array of strips */
  189     RECODE_EXPLODE_DATA     /* explode variable length data */
  190   };
  191 
  192 struct recode_symbol
  193   {
  194     /* Chaining of all known symbols (charsets and surfaces).  */
  195     RECODE_SYMBOL next;
  196 
  197     /* Unique ordinal for this symbol, counted from zero.  */
  198     unsigned ordinal;
  199 
  200     /* Main name.  */
  201     const char *name;
  202 
  203     /* Name to use for the iconv library, or NULL.  */
  204     const char *iconv_name;
  205 
  206     /* Type of table.  */
  207     enum recode_data_type data_type;
  208 
  209     /* Recoding table.  */
  210     void *data;
  211 
  212     /* Step for data..CHARSET transformation, if any, or NULL.  */
  213     struct recode_single *resurfacer;
  214 
  215     /* Step for CHARSET..data transformation, if any, or NULL.  */
  216     struct recode_single *unsurfacer;
  217 
  218     /* Non zero if this is an acceptable charset (not only a surface).  */
  219     enum recode_symbol_type type : 3;
  220 
  221     /* Non zero if this one should be ignored.  */
  222     bool ignore : 1;
  223   };
  224 
  225 struct recode_surface_list
  226   {
  227     RECODE_CONST_SYMBOL surface;
  228     struct recode_surface_list *next;
  229   };
  230 
  231 /*-------------------------------------------.
  232 | Description of a single step of recoding.  |
  233 `-------------------------------------------*/
  234 
  235 extern bool recode_interrupted;
  236 
  237 typedef bool (*Recode_init) (RECODE_STEP, RECODE_CONST_REQUEST,
  238                              RECODE_CONST_OPTION_LIST,
  239                              RECODE_CONST_OPTION_LIST);
  240 typedef bool (*Recode_term) (RECODE_STEP);
  241 typedef bool (*Recode_transform) (RECODE_SUBTASK);
  242 typedef bool (*Recode_fallback) (RECODE_SUBTASK, unsigned);
  243 
  244 /* The `single' structure holds data needed to decide of sequences, and is
  245    invariant over actual requests.  The `step' structure holds data needed for
  246    task execution, it may take care of fallback and option variance.  */
  247 
  248 struct recode_single
  249   {
  250     /* Chaining of all known single steps.  */
  251     struct recode_single *next;
  252 
  253     /* Charset before conversion.  */
  254     RECODE_SYMBOL before;
  255 
  256     /* Charset after conversion.  */
  257     RECODE_SYMBOL after;
  258 
  259     /* Cost for this single step only.  */
  260     short conversion_cost;
  261 
  262     /* Initial value for step_table.  */
  263     void *initial_step_table;
  264 
  265     /* Recoding quality.  */
  266     struct recode_quality quality;
  267 
  268     /* Initialisation handler, to be called before step optimisation.  */
  269     Recode_init init_routine;
  270 
  271     /* Transformation handler, for doing the actual recoding work.  */
  272     Recode_transform transform_routine;
  273 
  274     /* Default fallback for the step.  Merely to implement `-s' option.  */
  275     Recode_fallback fallback_routine;
  276   };
  277 
  278 enum recode_step_type
  279   {
  280     RECODE_NO_STEP_TABLE,   /* the step_table field is unused */
  281     RECODE_BYTE_TO_BYTE,    /* array of 256 bytes */
  282     RECODE_BYTE_TO_STRING,  /* array of 256 strings */
  283     RECODE_UCS2_TO_BYTE,    /* hash from ucs2 to byte */
  284     RECODE_UCS2_TO_STRING,  /* hash from ucs2 to string */
  285     RECODE_STRING_TO_UCS2,  /* hash from ucs2 to string, reversed */
  286     RECODE_COMBINE_EXPLODE, /* raw data for combining or exploding */
  287     RECODE_COMBINE_STEP,    /* special hash for combining */
  288     RECODE_EXPLODE_STEP     /* special hash for exploding */
  289   };
  290 
  291 struct recode_step
  292   {
  293     /* Charset before conversion.  */
  294     RECODE_SYMBOL before;
  295 
  296     /* Charset after conversion.  */
  297     RECODE_SYMBOL after;
  298 
  299     /* Recoding quality.  */
  300     struct recode_quality quality;
  301 
  302     /* Type of table.  */
  303     enum recode_step_type step_type;
  304 
  305     /* Recoding table.  */
  306     void *step_table;
  307     void (*step_table_term_routine)(void *);
  308 
  309     /* Step specific variables.  */
  310     void *local;
  311 
  312     /* Transformation handler, for doing the actual recoding work.  */
  313     Recode_transform transform_routine;
  314 
  315     /* Fallback for the step.  */
  316     Recode_fallback fallback_routine;
  317 
  318     /* Cleanup handler, to be called after the recoding is done.  */
  319     Recode_term term_routine;
  320   };
  321 
  322 struct recode_option_list
  323   {
  324     const char *option;
  325     RECODE_OPTION_LIST next;
  326   };
  327 
  328 /*------------------------------------------------------------------------.
  329 | A recoding request holds, among other things, a selected path among the |
  330 | available recoding steps, it so represents a kind of recoding plan.     |
  331 `------------------------------------------------------------------------*/
  332 
  333 struct recode_request
  334   {
  335     /* A request is always associated with a recoding system.  */
  336     RECODE_OUTER outer;
  337 
  338     /* By setting the following flag, the program will echo to stderr the
  339        sequence of elementary recoding steps needed to achieve the requested
  340        recoding.  */
  341     bool verbose_flag : 1;
  342 
  343     /* In `texte' charset, some countries use double quotes to mark diaeresis,
  344        while some other prefer colons.  This field contains the diaeresis
  345        character for `texte' charset.  Nominally set to a double quote, it can
  346        be forced to a colon.  Those are the only two acceptable values.  */
  347     char diaeresis_char;
  348 
  349     /* If producing a recoding table in source form, there will be no actual
  350        recoding done, and consequently, the optimisation of step sequence can
  351        be attempted more aggressively.  If the step sequence cannot be reduced
  352        to a single step, table production will fail.  */
  353     bool make_header_flag : 1;
  354 
  355     /* For `latex/bibtex' charsets, it is often convenient to recode the diacritics
  356        only, while letting other LaTeX code using backslashes unrecoded.  In
  357        the other charset, one can edit text as well as LaTeX directives.  */
  358     bool diacritics_only : 1;
  359 
  360     /* For `ibmpc' charset, characters 176 to 223 are use to draw boxes.  If
  361        this field is set, while getting out of `ibmpc', ASCII characters are
  362        selected so to approximate these boxes.  */
  363     bool ascii_graphics : 1;
  364 
  365     /* Array stating the sequence of conversions.  */
  366     RECODE_STEP sequence_array;
  367     size_t sequence_allocated;
  368     short sequence_length;
  369 
  370     /* Internal variables used while scanning request text.  */
  371     char *work_string;      /* buffer space for generated work strings */
  372     size_t work_string_length;  /* length of work_string */
  373     size_t work_string_allocated; /* allocated length of work_string */
  374     const char *scan_cursor;    /* next character to be seen */
  375     char *scanned_string;   /* buffer space to scan strings */
  376   };
  377 
  378 /*--------------------------------------------------------------------.
  379 | A recoding text is either an external file or an in memory buffer.  |
  380 `--------------------------------------------------------------------*/
  381 
  382 /* While the recoding is going on, FILE being non-NULL has precedence over
  383    BUFFER.  Moreover, if NAME is not NULL at start of recoding, this is
  384    interpreted as a request for the library to open the named file, either
  385    in read or write mode, and also to close it afterwards.  Standard input
  386    or output is denoted by NAME being an empty string.
  387 
  388    If FILE is NULL in input mode, the in-memory read-only text extends from
  389    BUFFER to LIMIT.  There is no clue about if the buffer has been allocated
  390    bigger.  When CURSOR reaches LIMIT, there is no more data to get.  If
  391    FILE is NULL in output mode, the in-memory text extends from BUFFER to
  392    CURSOR, but the buffer has been allocated until LIMIT.  When CURSOR
  393    reaches LIMIT, the buffer should be reallocated bigger, as needed.  */
  394 
  395 struct recode_read_only_text
  396   {
  397     const char *name;
  398     FILE *file;
  399     const char *buffer;
  400     const char *cursor;
  401     const char *limit;
  402   };
  403 
  404 struct recode_read_write_text
  405   {
  406     const char *name;
  407     FILE *file;
  408     char *buffer;
  409     char *cursor;
  410     char *limit;
  411   };
  412 
  413 /* Tells how to swap the incoming pair of bytes, while reading UCS-2.  */
  414 
  415 enum recode_swap_input
  416   {
  417     RECODE_SWAP_UNDECIDED,  /* the text has not been read yet */
  418     RECODE_SWAP_NO,     /* no need to swap pair of bytes */
  419     RECODE_SWAP_YES     /* should swap incoming pair of bytes */
  420   };
  421 
  422 /*--------------------------------------------------------------------------.
  423 | A recoding subtask associates a particular recoding step to a given input |
  424 | text, for producing a corresponding output text.  It also holds error     |
  425 | related statistics for the execution of that step.                        |
  426 `--------------------------------------------------------------------------*/
  427 
  428 struct recode_subtask
  429   {
  430     /* Task for which this subtask is an element.  */
  431     RECODE_TASK task;
  432 
  433     /* Step being executed by this subtask.  */
  434     RECODE_CONST_STEP step;
  435 
  436     /* Current input and output.  */
  437     struct recode_read_only_text input;
  438     struct recode_read_write_text output;
  439 
  440     /* Line count and character count in last line, both zero-based.  */
  441     unsigned newline_count;
  442     unsigned character_count;
  443   };
  444 
  445 #define GOT_CHARACTER(Subtask) \
  446   ((Subtask)->character_count++)
  447 
  448 #define GOT_NEWLINE(Subtask) \
  449   ((Subtask)->newline_count++, (Subtask)->character_count = 0)
  450 
  451 /*--------------------------------------------------------------------------.
  452 | A recoding task associates a sequence of steps to a given input text, for |
  453 | producing a corresponding output text.  It holds an array of subtasks.    |
  454 `--------------------------------------------------------------------------*/
  455 
  456 struct recode_task
  457   {
  458     /* Associated request.  */
  459     RECODE_CONST_REQUEST request;
  460 
  461     /* Initial input and final output.  */
  462     struct recode_read_only_text input;
  463     struct recode_read_write_text output;
  464 
  465     /* Produce a byte order mark on UCS-2 output, insist for it on input.  */
  466     bool byte_order_mark : 1;
  467 
  468     /* The input UCS-2 stream might have bytes swapped (status variable).  */
  469     enum recode_swap_input swap_input : 3;
  470 
  471     /* Error processing.  */
  472     /* -----------------  */
  473 
  474     /* At this level, there will be failure.  */
  475     enum recode_error fail_level : 5;
  476 
  477     /* At this level, task should be interrupted.  */
  478     enum recode_error abort_level : 5;
  479 
  480     /* Maximum error level met so far (status variable).  */
  481     enum recode_error error_so_far : 5;
  482 
  483     /* Step being executed when error_so_far was last set.  */
  484     RECODE_CONST_STEP error_at_step;
  485   };
  486 
  487 /* Specialities for some function arguments.  */
  488 
  489 /* For restricting charset lists.  */
  490 
  491 struct recode_known_pair
  492   {
  493     unsigned char left;     /* first character in pair */
  494     unsigned char right;    /* second character in pair */
  495   };
  496 
  497 /*----------------------.
  498 | Various definitions.  |
  499 `----------------------*/
  500 
  501 typedef unsigned short recode_ucs2;
  502 
  503 /* Double tables are generated as arrays of indices into a pool of strips,
  504    each strip holds STRIP_SIZE UCS-2 characters.  Some memory is saved by
  505    not allowing duplicate strips in the pool.  A smaller strip size yields
  506    more duplicates and so, a smaller pool, but then, tables get longer
  507    because more strip indices are needed for each table.  It is difficult to
  508    predict the optimal strip size.  Tests made on 1997-09-22 showed that a
  509    strip size of 4 needs 27808 bytes total, 8 needs 22656, 16 needs 23584
  510    and 32 needs 25568, so we decided to stick to a strip size of 8.  Change
  511    $STRIP_SIZE in `doc/tables.pl' if you change the value here.  */
  512 
  513 /* "Are we speaking slips, strips or bars?" (of gold-pressed latinum :-) */
  514 #define STRIP_SIZE 8
  515 
  516 /* An struct strip_data is a pointer to a pool of strips, and an array
  517    of 256/STRIP_SIZE offsets for the start of strips into the pool, each strip
  518    describes STRIP_SIZE UCS-2 characters.  A missing character in a strip is
  519    indicated by all 16 bits set.  */
  520 struct strip_data
  521   {
  522     const recode_ucs2 *pool;
  523     const short offset[256 / STRIP_SIZE];
  524   };
  525 
  526 struct ucs2_to_string
  527   {
  528     recode_ucs2 code;       /* UCS-2 value */
  529     unsigned short flags;   /* various flags */
  530     const char *string;     /* corresponding string */
  531   };
  532 
  533 /* Per module declarations.  */
  534 
  535 #ifdef __cplusplus
  536 extern "C" {
  537 #endif
  538 
  539 /* recode.c.  */
  540 
  541 #define ALLOC_SIZE(Variable, Size, Type) \
  542   (Variable = (Type *) recode_malloc (outer, (Size)))
  543 
  544 #define ALLOC(Variable, Count, Type) \
  545   ALLOC_SIZE (Variable, (Count) * sizeof (Type), Type)
  546 
  547 #define REALLOC(Variable, Count, Type) \
  548   (Variable = (Type *) recode_realloc (outer, Variable,     \
  549                        (Count) * sizeof(Type)), \
  550    Variable)
  551 
  552 void recode_error (RECODE_OUTER, const char *, ...);
  553 void recode_perror (RECODE_OUTER, const char *, ...);
  554 void *recode_malloc (RECODE_OUTER, size_t);
  555 void *recode_realloc (RECODE_OUTER, void *, size_t);
  556 
  557 unsigned char *invert_table (RECODE_OUTER, const unsigned char *);
  558 bool complete_pairs (RECODE_OUTER, RECODE_STEP,
  559                      const struct recode_known_pair *, unsigned,
  560                      bool, bool);
  561 bool transform_byte_to_ucs2 (RECODE_SUBTASK);
  562 bool init_ucs2_to_byte (RECODE_STEP, RECODE_CONST_REQUEST,
  563                         RECODE_CONST_OPTION_LIST,
  564                         RECODE_CONST_OPTION_LIST);
  565 bool transform_ucs2_to_byte (RECODE_SUBTASK);
  566 
  567 /* charname.c and fr-charname.c.  */
  568 
  569 const char *ucs2_to_charname (int);
  570 const char *ucs2_to_french_charname (int);
  571 
  572 /* charset.c.  */
  573 
  574 enum alias_find_type
  575 {
  576   SYMBOL_CREATE_CHARSET,    /* charset as given, create as needed */
  577   SYMBOL_CREATE_DATA_SURFACE,   /* data surface as given, create as needed */
  578   ALIAS_FIND_AS_CHARSET,    /* disambiguate only as a charset */
  579   ALIAS_FIND_AS_SURFACE,    /* disambiguate only as a surface */
  580   ALIAS_FIND_AS_EITHER      /* disambiguate as a charset or a surface */
  581 };
  582 
  583 int code_to_ucs2 (RECODE_CONST_SYMBOL, unsigned);
  584 bool prepare_for_aliases (RECODE_OUTER);
  585 RECODE_ALIAS declare_alias (RECODE_OUTER,
  586                             const char *, const char *);
  587 bool declare_implied_surface (RECODE_OUTER, RECODE_ALIAS,
  588                               RECODE_CONST_SYMBOL);
  589 bool make_argmatch_arrays (RECODE_OUTER);
  590 void delete_alias (RECODE_ALIAS alias);
  591 RECODE_ALIAS find_alias (RECODE_OUTER, const char *,
  592                          enum alias_find_type);
  593 bool find_and_report_subsets (RECODE_OUTER);
  594 bool decode_known_pairs (RECODE_OUTER, const char *);
  595 
  596 /* combine.c.  */
  597 
  598 #define DONE NOT_A_CHARACTER
  599 #define ELSE BYTE_ORDER_MARK_SWAPPED
  600 
  601 bool init_explode (RECODE_STEP, RECODE_CONST_REQUEST,
  602                    RECODE_CONST_OPTION_LIST,
  603                    RECODE_CONST_OPTION_LIST);
  604 bool explode_byte_byte (RECODE_SUBTASK);
  605 bool explode_ucs2_byte (RECODE_SUBTASK);
  606 bool explode_byte_ucs2 (RECODE_SUBTASK);
  607 bool explode_ucs2_ucs2 (RECODE_SUBTASK);
  608 
  609 bool init_combine (RECODE_STEP, RECODE_CONST_REQUEST,
  610                    RECODE_CONST_OPTION_LIST,
  611                    RECODE_CONST_OPTION_LIST);
  612 bool combine_byte_byte (RECODE_SUBTASK);
  613 bool combine_ucs2_byte (RECODE_SUBTASK);
  614 bool combine_byte_ucs2 (RECODE_SUBTASK);
  615 bool combine_ucs2_ucs2 (RECODE_SUBTASK);
  616 
  617 /* freeze.c.  */
  618 
  619 void recode_freeze_tables (RECODE_OUTER);
  620 
  621 /* iconv.c.  */
  622 
  623 bool transform_with_iconv (RECODE_SUBTASK);
  624 bool module_iconv (struct recode_outer *);
  625 void delmodule_iconv (struct recode_outer *);
  626 
  627 /* names.c.  */
  628 
  629 bool should_prefer_french (void);
  630 
  631 /* mixed.c.  */
  632 
  633 bool transform_c_source (RECODE_TASK);
  634 bool transform_po_source (RECODE_TASK);
  635 
  636 /* outer.c.  */
  637 
  638 bool reversibility (RECODE_SUBTASK, unsigned);
  639 RECODE_SINGLE declare_single
  640   (RECODE_OUTER, const char *, const char *,
  641    struct recode_quality,
  642    bool (*) (RECODE_STEP, RECODE_CONST_REQUEST,
  643              RECODE_CONST_OPTION_LIST, RECODE_CONST_OPTION_LIST),
  644    bool (*) (RECODE_SUBTASK));
  645 bool declare_iconv (RECODE_OUTER, const char *, const char *);
  646 bool declare_explode_data (RECODE_OUTER, const unsigned short *,
  647                            const char *, const char *);
  648 bool declare_strip_data (RECODE_OUTER, struct strip_data *,
  649                          const char *);
  650 
  651 /* pool.c.  */
  652 
  653 extern const recode_ucs2 ucs2_data_pool[];
  654 
  655 /* request.c.  */
  656 
  657 char *edit_sequence (RECODE_REQUEST, bool);
  658 
  659 /* rfc1345.c.  */
  660 
  661 const char *ucs2_to_rfc1345 (recode_ucs2);
  662 
  663 /* task.c.  */
  664 
  665 int get_byte (RECODE_SUBTASK);
  666 size_t get_bytes (RECODE_SUBTASK, char *, size_t);
  667 void put_byte (char, RECODE_SUBTASK);
  668 void put_bytes (const char *, size_t, RECODE_SUBTASK);
  669 bool recode_if_nogo (enum recode_error, RECODE_SUBTASK);
  670 bool transform_byte_to_byte (RECODE_SUBTASK);
  671 bool transform_byte_to_variable (RECODE_SUBTASK);
  672 
  673 /* ucs.c.  */
  674 
  675 /* Replacement character for when correctly formed character has no
  676    equivalent.  It is not used for ill-formed characters, however.  */
  677 #define REPLACEMENT_CHARACTER 0xFFFD
  678 
  679 /* Device for detecting if bytes are swapped.  This value should appear first
  680    in UCS-2 files.  */
  681 #define BYTE_ORDER_MARK 0xFEFF
  682 #define BYTE_ORDER_MARK_SWAPPED 0xFFFE
  683 
  684 /* Never an UCS-2 character.  */
  685 #define NOT_A_CHARACTER 0xFFFF
  686 
  687 bool get_ucs2 (unsigned *, RECODE_SUBTASK);
  688 bool get_ucs4 (unsigned *, RECODE_SUBTASK);
  689 bool put_ucs2 (unsigned, RECODE_SUBTASK);
  690 bool put_ucs4 (unsigned, RECODE_SUBTASK);
  691 
  692 #ifdef __cplusplus
  693 }
  694 #endif
  695 
  696 /* Global macros specifically for Recode.  */
  697 
  698 /* Giving a name to the ASCII character assigned to position 0.  */
  699 #define NUL '\0'
  700 
  701 #ifdef FLEX_SCANNER
  702 
  703 # define PUT_NON_DIACRITIC_BYTE(Byte, Subtask) \
  704     if (request->diacritics_only)               \
  705       ECHO;                         \
  706     else                            \
  707       put_byte ((Byte), (Subtask))
  708 
  709 /* ECHO may not have a (Subtask) argument, because some ECHO without argument
  710    is generated by Flex -- yet Vern tells me it won't happen if I inhibit
  711    the rule about default copying.  Happily enough, within Flex, Subtask is
  712    `subtask' quite systematically, so it may be used as a constant, here.  */
  713 # define ECHO \
  714     do {                            \
  715       const char *cursor = librecode_yytext;            \
  716       int counter = librecode_yyleng;               \
  717       for (; counter > 0; cursor++, counter--)          \
  718     put_byte (*cursor, subtask);                \
  719     } while (false)
  720 
  721 #endif /* FLEX_SCANNER */