home *** CD-ROM | disk | FTP | other *** search
/ Mega Top 1 / os2_top1.zip / os2_top1 / APPS / TEKST / GRECODE / RECODE.H < prev    next >
C/C++ Source or Header  |  1993-12-20  |  5KB  |  156 lines

  1. /* Conversion of files between different charsets and usages.
  2.    Copyright (C) 1990 Free Software Foundation, Inc.
  3.    Francois Pinard <pinard@iro.umontreal.ca>, 1988.
  4.  
  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 2, or (at your option)
  8.    any later version.
  9.  
  10.    This program is distributed in the hope that it will be useful, but
  11.    WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.    General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU General Public License
  16.    along with this program; if not, write to the Free Software
  17.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20. #ifdef HAVE_CONFIG_H
  21. #if defined (CONFIG_BROKETS)
  22. /* We use <config.h> instead of "config.h" so that a compilation
  23.    using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
  24.    (which it would do because it found this file in $srcdir).  */
  25. #include <config.h>
  26. #else
  27. #include "config.h"
  28. #endif
  29. #endif
  30.  
  31. #include <stdio.h>
  32.  
  33. #ifdef STDC_HEADERS
  34. #include <stdlib.h>
  35. #endif
  36.  
  37. /* Some systems do not define EXIT_*, even with STDC_HEADERS.  */
  38. #ifndef EXIT_SUCCESS
  39. #define EXIT_SUCCESS 0
  40. #endif
  41. #ifndef EXIT_FAILURE
  42. #define EXIT_FAILURE 1
  43. #endif
  44.  
  45. #ifdef __STDC__
  46. #define _(Args) Args
  47. #else
  48. #define _(Args) ()
  49. #endif
  50.  
  51. void *xmalloc _((int));
  52. char *xstrdup _((const char *));
  53. int argmatch _((const char *, const char *const *));
  54.  
  55. /* Description of a charset.  */
  56.  
  57. typedef const char* DOUBLE_TABLE[8];
  58.  
  59. typedef struct charset CHARSET;
  60.  
  61. struct charset
  62.   {
  63.     const char *name;        /* main name */
  64.     int ignore;            /* non zero if should be ignored */
  65.     DOUBLE_TABLE *table;    /* double table for RFC 1345 */
  66.     int size;            /* size of each DOUBLE_TABLE entry */
  67.   };
  68.  
  69. /* Description of a single step of recoding.  */
  70.  
  71. typedef enum quality QUALITY;
  72.  
  73. enum quality
  74.   {
  75.     REVERSIBLE,            /* reversible one to one recoding */
  76.     ONE_TO_ONE,            /* simple one to one recoding */
  77.     MANY_TO_ONE,        /* many characters to one recoding */
  78.     ONE_TO_MANY,        /* one to many characters recoding */
  79.     MANY_TO_MANY        /* many to many characters recoding */
  80.   };
  81.  
  82. typedef struct step STEP;
  83.  
  84. struct step
  85.   {
  86.     CHARSET *before;        /* charset before conversion */
  87.     CHARSET *after;        /* charset after conversion */
  88.     QUALITY quality;        /* recoding quality */
  89.     void (*init_recode) _((STEP *));
  90.     void (*file_recode) _((const STEP *, FILE *, FILE *));
  91.     const unsigned char *one_to_one; /* recoding array of 256 chars */
  92.     const char *const *one_to_many; /* recoding array of 256 strings */
  93.     int conversion_cost;    /* cost for this single step only */
  94.   };
  95.  
  96. typedef struct known_pair KNOWN_PAIR;
  97.  
  98. struct known_pair
  99.   {
  100.     unsigned char left;        /* first character in pair */
  101.     unsigned char right;    /* second character in pair */
  102.   };
  103.  
  104. /* Description of list formats.  */
  105.  
  106. enum list_format
  107.   {
  108.     NO_FORMAT,            /* format not decided yet */
  109.     DECIMAL_FORMAT,        /* concise tabular list using decimal */
  110.     OCTAL_FORMAT,        /* concise tabular list using octal */
  111.     HEXADECIMAL_FORMAT,        /* concise tabular list using hexadecimal */
  112.     FULL_FORMAT            /* full list, one character per line */
  113.   };
  114.  
  115. /* recode.c.  */
  116.  
  117. extern int ascii_graphics;
  118. extern char diaeresis_char;
  119. extern int diacritics_only;
  120. extern int strict_mapping;
  121. extern enum list_format list_format;
  122.  
  123. extern int decoding_charset_flag;
  124. extern const unsigned char *one_to_same;
  125. extern CHARSET *rfc1345;
  126.  
  127. void usage _((int));
  128. const char *quality_to_string _((QUALITY));
  129. QUALITY merge_qualities _((QUALITY, QUALITY));
  130. void declare_step _((const char *, const char *, QUALITY, void (*) (STEP *),
  131.              void (*) (const STEP *, FILE *, FILE *)));
  132. void declare_double_step _((DOUBLE_TABLE *, const char *, int));
  133. unsigned char *invert_table _((const unsigned char *));
  134. void complete_pairs _((STEP *, int, const KNOWN_PAIR *, int, int));
  135. void file_one_to_one _((const STEP *, FILE *, FILE *));
  136. void file_one_to_many _((const STEP *, FILE *, FILE *));
  137.  
  138. /* charname.c.  */
  139.  
  140. char *symbol_to_charname _((const char *));
  141.  
  142. /* charset.c.  */
  143.  
  144. extern CHARSET charset_array[];
  145. extern int number_of_charsets;
  146.  
  147. void prepare_charset_initialization _((void));
  148. CHARSET *find_charset _((const char *));
  149. void declare_alias _((const char *, const char *));
  150. void make_argmatch_array _((void));
  151. const char *clean_charset_name _((const char *));
  152.  
  153. void list_all_charsets _((void));
  154. void list_full_charset _((CHARSET *));
  155. void list_concise_charset _((CHARSET *));
  156.