home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / c-kermit / ckmxla.c < prev    next >
C/C++ Source or Header  |  2020-01-01  |  37KB  |  790 lines

  1. /* $Id: ckmxla.c,v 1.6 91/12/15 23:18:06 rick Exp $
  2.  * $Source: /uw/mackermit/RCS/ckmxla.c,v $
  3.  *------------------------------------------------------------------
  4.  * $Log:    ckmxla.c,v $
  5.  * Revision 1.6  91/12/15  23:18:06  rick
  6.  * ut9
  7.  * 
  8.  * Revision 1.5  91/10/22  11:56:16  rick
  9.  * Fixup includes.
  10.  * 
  11.  * Revision 1.4  91/10/21  21:43:58  fdc
  12.  * Make sure all sources lines are < 80.
  13.  * Update with a year's worth of changes from Unix version,
  14.  * but use only three character sets.  Fix the tables, functions,
  15.  * and tables of functions.  And the comments.  Etc etc.
  16.  * 
  17.  * Revision 1.3  91/10/03  12:43:03  rick
  18.  * UT(5)
  19.  * 
  20.  *------------------------------------------------------------------
  21.  * $Endlog$
  22.  */
  23. char *xlav = "Macintosh Character Set Translation 5A(011), 25 Dec 91";
  24.  
  25. /*  C K M X L A  */
  26.  
  27. /*  C-Kermit tables and functions supporting character set translation.  */
  28. /*  Macintosh-only version */
  29. /*
  30.   Author: Frank da Cruz (fdc@columbia.edu, FDCCU@CUVMA.BITNET),
  31.   Columbia University Center for Computing Activities.
  32.   Copyright (C) 1985, 1992, Trustees of Columbia University in the City of New
  33.   York.  Permission is granted to any individual or institution to use this
  34.   software as long as it is not sold for profit.  This copyright notice must be
  35.   retained.  This software may not be included in commercial products without
  36.   written permission of Columbia University.
  37. */
  38.  
  39. #include "ckcdeb.h"            /* Includes... */
  40. #include "ckcker.h"
  41. #include "ckucmd.h"            /* Needed for struct keytab */
  42. #include "ckmdef.h"
  43. #include "ckmptp.h"            /* ckm* Prototypes */
  44. #include "ckcxla.h"
  45. #include "ckmxla.h"
  46.  
  47. #ifndef NULL
  48. #define NULL 0
  49. #endif
  50.  
  51. /* Character set translation data and functions */
  52.  
  53. extern int zincnt;
  54. extern char *zinptr;
  55. extern int zoutcnt;
  56. extern char *zoutptr;
  57.  
  58. int tslevel  = TS_L0;            /* Transfer syntax level (0,1,2) */
  59. int tcharset = TC_TRANSP;        /* Transfer syntax character set */
  60. int fcharset = FC_APPQD;        /* Local file character set */
  61. int tcsr     = FC_USASCII;        /* Remote terminal character set */
  62. int tcsl     = FC_APPQD;        /* Local terminal character set */
  63. int language = L_USASCII;        /* Language */
  64.  
  65. /* This list is indexed by the transfer character set number. */
  66. struct csinfo tcsinfo[] = {              /* Transfer character-set info */
  67. /*  Name              size code      designator alphabet keyword            */
  68.   "TRANSPARENT",       256,TC_TRANSP, "",      AL_UNK,  "transparent", /* 0 */
  69.   "ASCII",             128,TC_USASCII,"",      AL_ROMAN,"ascii",       /* 1 */
  70.   "LATIN1, ISO 8859-1",256,TC_1LATIN, "I6/100",AL_ROMAN,"latin1-iso",  /* 2 */
  71. };
  72. int ntcsets = (sizeof(tcsinfo) / sizeof(struct csinfo));
  73.  
  74. struct keytab tcstab[] = {        /* Keyword table for */
  75.     "ascii",         TC_USASCII, 0,    /* SET TRANSFER CHARACTER-SET */
  76.     "latin1-iso",    TC_1LATIN,  0,
  77.     "transparent",   TC_TRANSP,  0
  78. };
  79. int ntcs = (sizeof(tcstab) / sizeof(struct keytab));
  80.  
  81. /* Grrr... Had to back off on moving this to ckmxla.h because that file */
  82. /* is included by more than one module, so link complains about multiple */
  83. /* definitions of _fcsinfo, _fcstab, etc. */
  84.  
  85. /* File character set information structure, indexed by character set code, */
  86. /* as defined in ckmxla.h.  This table must be in order of file character */
  87. /* set number! */ 
  88.  
  89. struct csinfo fcsinfo[] = { /* File character set information... */
  90.   /* Descriptive Name              Size  Designator */
  91.   "US ASCII",                     128, FC_USASCII, NULL, AL_ROMAN, "ascii",
  92.   "ISO 8859-1 Latin-1",           256, FC_1LATIN,  NULL, AL_ROMAN,"latin1-iso",
  93.   "Macintosh Latin",              256, FC_APPQD,   NULL, AL_ROMAN,"macintosh-latin"
  94. };    
  95.  
  96. /* Local file character sets */
  97.  
  98. struct keytab fcstab[] = { /* Keyword table for 'set file character-set' */
  99.  
  100. /* Keyword             Value       Flags */
  101.     "apple-quickdraw",  FC_APPQD,   CM_INV,    /* Macintosh Quickraw */
  102.     "ascii",            FC_USASCII, 0,        /* ASCII */
  103.     "latin1-iso",       FC_1LATIN,  0,        /* ISO Latin Alphabet 1 */
  104.     "macintosh-latin",  FC_APPQD,   0,        /* "Extended Mac Latin */
  105.  
  106. };
  107. int nfilc = (sizeof(fcstab) / sizeof(struct keytab)); /* size of this table */
  108.  
  109. /*
  110.  Languages:
  111.  
  112.  This table allows C-Kermit to have a SET LANGUAGE command to apply special
  113.  language-specific rules when translating from a character set that contains
  114.  national characters into plain ASCII, like German umlaut-a becomes ae.
  115.  
  116.  Originally, I thought it would be a good idea to let SET LANGUAGE also select
  117.  an appropriate FILE CHARACTER-SET and TRANSFER CHARACTER-SET automatically,
  118.  and these are included in the langinfo structure.  Later I realized that this
  119.  was a bad idea.  Users are confused by unexpected side effects.  If this
  120.  functionality is desired, it's better to define a macro to do it.
  121. */
  122.  
  123. struct langinfo langs[] = {
  124. /*  Language code   File Charset Xfer Charset Name */
  125.     L_USASCII,      FC_USASCII,  TC_USASCII,  "ASCII (American English)",
  126.     L_DANISH,       FC_APPQD,  TC_1LATIN,   "Danish",
  127.     L_DUTCH,        FC_APPQD,  TC_1LATIN,   "Dutch",
  128.     L_FINNISH,      FC_APPQD,  TC_1LATIN,   "Finnish",
  129.     L_FRENCH,       FC_APPQD,  TC_1LATIN,   "French",
  130.     L_GERMAN,       FC_APPQD,  TC_1LATIN,   "German",
  131.     L_HUNGARIAN,    FC_APPQD,  TC_1LATIN,   "Hungarian",
  132.     L_ICELANDIC,    FC_APPQD,  TC_1LATIN,   "Icelandic",
  133.     L_ITALIAN,      FC_APPQD,  TC_1LATIN,   "Italian",
  134.     L_NORWEGIAN,    FC_APPQD,  TC_1LATIN,   "Norwegian",
  135.     L_PORTUGUESE,   FC_APPQD,  TC_1LATIN,   "Portuguese",
  136.     L_SPANISH,      FC_APPQD,  TC_1LATIN,   "Spanish",
  137.     L_SWEDISH,      FC_APPQD,  TC_1LATIN,   "Swedish",
  138.     L_SWISS,        FC_APPQD,  TC_1LATIN,   "Swiss"
  139. };
  140. int nlangs = (sizeof(langs) / sizeof(struct langinfo));
  141.  
  142.  
  143. /*
  144.   Keyword table for the SET LANGUAGE command.
  145.   Only a few of these (German, Scandinavian, etc) actually do anything.
  146.   The language is used to invoke special translation rules when converting
  147.   from an 8-bit character set to ASCII; for example, German u-diaeresis
  148.   becomes "ue", Dutch y-diaeresis becomes "ij".  Languages without associated
  149.   rules are invisible (CM_INV).
  150. */
  151. struct keytab lngtab[] = {
  152.     "ascii",            L_USASCII,    CM_INV,
  153.     "danish",           L_DANISH,     0,
  154.     "dutch",            L_DUTCH,      0,
  155.     "english",          L_USASCII,    CM_INV,
  156.     "finnish",          L_FINNISH,    0,
  157.     "french",           L_FRENCH,     0,
  158.     "german",           L_GERMAN,     0,
  159. #ifdef HEBREW
  160.     "hebrew",           L_HEBREW,     CM_INV,
  161. #endif /* HEBREW */    
  162.     "hungarian",        L_HUNGARIAN,  CM_INV,
  163.     "icelandic",        L_ICELANDIC,  0,
  164.     "italian",          L_ITALIAN,    CM_INV,
  165. #ifdef KANJI
  166.     "japanese",         L_JAPANESE,   CM_INV,
  167. #endif /* KANJI */
  168.     "norwegian",        L_NORWEGIAN,  0,
  169.     "none",             L_USASCII,    0,
  170.     "portuguese",       L_PORTUGUESE, CM_INV,
  171. #ifdef CYRILLIC
  172.     "russian",          L_RUSSIAN,    0,
  173. #endif /* CYRILLIC */
  174.     "spanish",          L_SPANISH,    CM_INV,
  175.     "swedish",          L_SWEDISH,    0
  176. #ifdef CYRILLIC
  177. ,   "ukrainian",        L_RUSSIAN,    0
  178. #endif /* CYRILLIC */
  179. };
  180. int nlng = (sizeof(lngtab) / sizeof(struct keytab)); /* how many languages */
  181.  
  182. /* Translation tables ... */
  183.  
  184. /*
  185.   Note, many more can and should be added, space permitting!  Presently we
  186.   have only ASCII and Latin-1 as transfer character sets and ASCII, Latin-1,
  187.   and the Adobe-extended-Macintosh set as file character sets.  For each pair
  188.   of (file,transfer) character sets, we need two translation functions, one
  189.   for sending, one for receiving.  It is recommended that functions and tables
  190.   for all computers be included in this file, perhaps within #ifdef's, so that
  191.   corrections need be made only in one place.
  192. */
  193.  
  194. /* Here is the first table, fully annotated... */
  195.  
  196. CHAR
  197. yl1as[] =  {  /* ISO 8859-1 Latin Alphabet 1 to US ASCII */
  198.       /*  Source character    Description               => Translation */
  199.       /*  Dec row/col Set                                           */
  200.   0,  /*  000  00/00  C0 NUL  Ctrl-@                    =>  (self)  */
  201.   1,  /*  001  00/01  C0 SOH  Ctrl-A                    =>  (self)  */
  202.   2,  /*  002  00/02  C0 STX  Ctrl-B                    =>  (self)  */
  203.   3,  /*  003  00/03  C0 ETX  Ctrl-C                    =>  (self)  */
  204.   4,  /*  004  00/04  C0 EOT  Ctrl-D                    =>  (self)  */
  205.   5,  /*  005  00/05  C0 ENQ  Ctrl-E                    =>  (self)  */
  206.   6,  /*  006  00/06  C0 ACK  Ctrl-F                    =>  (self)  */
  207.   7,  /*  007  00/07  C0 BEL  Ctrl-G                    =>  (self)  */
  208.   8,  /*  008  00/08  C0 BS   Ctrl-H                    =>  (self)  */
  209.   9,  /*  009  00/09  C0 HT   Ctrl-I                    =>  (self)  */
  210.  10,  /*  010  00/10  C0 LF   Ctrl-J                    =>  (self)  */
  211.  11,  /*  011  00/11  C0 VT   Ctrl-K                    =>  (self)  */
  212.  12,  /*  012  00/12  C0 FF   Ctrl-L                    =>  (self)  */
  213.  13,  /*  013  00/13  C0 CR   Ctrl-M                    =>  (self)  */
  214.  14,  /*  014  00/14  C0 SO   Ctrl-N                    =>  (self)  */
  215.  15,  /*  015  00/15  C0 SI   Ctrl-O                    =>  (self)  */
  216.  16,  /*  016  01/00  C0 DLE  Ctrl-P                    =>  (self)  */
  217.  17,  /*  017  01/01  C0 DC1  Ctrl-Q                    =>  (self)  */
  218.  18,  /*  018  01/02  C0 DC2  Ctrl-R                    =>  (self)  */
  219.  19,  /*  019  01/03  C0 DC3  Ctrl-S                    =>  (self)  */
  220.  20,  /*  020  01/04  C0 DC4  Ctrl-T                    =>  (self)  */
  221.  21,  /*  021  01/05  C0 NAK  Ctrl-U                    =>  (self)  */
  222.  22,  /*  022  01/06  C0 SYN  Ctrl-V                    =>  (self)  */
  223.  23,  /*  023  01/07  C0 ETB  Ctrl-W                    =>  (self)  */
  224.  24,  /*  024  01/08  C0 CAN  Ctrl-X                    =>  (self)  */
  225.  25,  /*  025  01/09  C0 EM   Ctrl-Y                    =>  (self)  */
  226.  26,  /*  026  01/10  C0 SUB  Ctrl-Z                    =>  (self)  */
  227.  27,  /*  027  01/11  C0 ESC  Ctrl-[                    =>  (self)  */
  228.  28,  /*  028  01/12  C0 FS   Ctrl-\                    =>  (self)  */
  229.  29,  /*  029  01/13  C0 GS   Ctrl-]                    =>  (self)  */
  230.  30,  /*  030  01/14  C0 RS   Ctrl-^                    =>  (self)  */
  231.  31,  /*  031  01/15  C0 US   Ctrl-_                    =>  (self)  */
  232.  32,  /*  032  02/00     SP   Space                     =>  (self)  */
  233.  33,  /*  033  02/01  G0 !    Exclamation mark          =>  (self)  */
  234.  34,  /*  034  02/02  G0 "    Doublequote               =>  (self)  */
  235.  35,  /*  035  02/03  G0 #    Number sign               =>  (self)  */
  236.  36,  /*  036  02/04  G0 $    Dollar sign               =>  (self)  */
  237.  37,  /*  037  02/05  G0 %    Percent sign              =>  (self)  */
  238.  38,  /*  038  02/06  G0 &    Ampersand                 =>  (self)  */
  239.  39,  /*  039  02/07  G0 '    Apostrophe                =>  (self)  */
  240.  40,  /*  040  02/08  G0 (    Left parenthesis          =>  (self)  */
  241.  41,  /*  041  02/09  G0 )    Right parenthesis         =>  (self)  */
  242.  42,  /*  042  02/10  G0 *    Asterisk                  =>  (self)  */
  243.  43,  /*  043  02/11  G0 +    Plus sign                 =>  (self)  */
  244.  44,  /*  044  02/12  G0 ,    Comma                     =>  (self)  */
  245.  45,  /*  045  02/13  G0 -    Hyphen, minus sign        =>  (self)  */
  246.  46,  /*  046  02/14  G0 .    Period, full stop         =>  (self)  */
  247.  47,  /*  047  02/15  G0 /    Slash, solidus            =>  (self)  */
  248.  48,  /*  048  03/00  G0 0    Digit 0                   =>  (self)  */
  249.  49,  /*  049  03/01  G0 1    Digit 1                   =>  (self)  */
  250.  50,  /*  050  03/02  G0 2    Digit 2                   =>  (self)  */
  251.  51,  /*  051  03/03  G0 3    Digit 3                   =>  (self)  */
  252.  52,  /*  052  03/04  G0 4    Digit 4                   =>  (self)  */
  253.  53,  /*  053  03/05  G0 5    Digit 5                   =>  (self)  */
  254.  54,  /*  054  03/06  G0 6    Digit 6                   =>  (self)  */
  255.  55,  /*  055  03/07  G0 7    Digit 7                   =>  (self)  */
  256.  56,  /*  056  03/08  G0 8    Digit 8                   =>  (self)  */
  257.  57,  /*  057  03/09  G0 9    Digit 9                   =>  (self)  */
  258.  58,  /*  058  03/10  G0 :    Colon                     =>  (self)  */
  259.  59,  /*  059  03/11  G0 ;    Semicolon                 =>  (self)  */
  260.  60,  /*  060  03/12  G0 <    Less-than sign            =>  (self)  */
  261.  61,  /*  061  03/13  G0 =    Equals sign               =>  (self)  */
  262.  62,  /*  062  03/14  G0 >    Greater-than sign         =>  (self)  */
  263.  63,  /*  063  03/15  G0 ?    Question mark             =>  (self)  */
  264.  64,  /*  064  04/00  G0 @    Commercial at sign        =>  (self)  */
  265.  65,  /*  065  04/01  G0 A    Letter A                  =>  (self)  */
  266.  66,  /*  066  04/02  G0 B    Letter B                  =>  (self)  */
  267.  67,  /*  067  04/03  G0 C    Letter C                  =>  (self)  */
  268.  68,  /*  068  04/04  G0 D    Letter D                  =>  (self)  */
  269.  69,  /*  069  04/05  G0 E    Letter E                  =>  (self)  */
  270.  70,  /*  070  04/06  G0 F    Letter F                  =>  (self)  */
  271.  71,  /*  071  04/07  G0 G    Letter G                  =>  (self)  */
  272.  72,  /*  072  04/08  G0 H    Letter H                  =>  (self)  */
  273.  73,  /*  073  04/09  G0 I    Letter I                  =>  (self)  */
  274.  74,  /*  074  04/10  G0 J    Letter J                  =>  (self)  */
  275.  75,  /*  075  04/11  G0 K    Letter K                  =>  (self)  */
  276.  76,  /*  076  04/12  G0 L    Letter L                  =>  (self)  */
  277.  77,  /*  077  04/13  G0 M    Letter M                  =>  (self)  */
  278.  78,  /*  078  04/14  G0 N    Letter N                  =>  (self)  */
  279.  79,  /*  079  04/15  G0 O    Letter O                  =>  (self)  */
  280.  80,  /*  080  05/00  G0 P    Letter P                  =>  (self)  */
  281.  81,  /*  081  05/01  G0 Q    Letter Q                  =>  (self)  */
  282.  82,  /*  082  05/02  G0 R    Letter R                  =>  (self)  */
  283.  83,  /*  083  05/03  G0 S    Letter S                  =>  (self)  */
  284.  84,  /*  084  05/04  G0 T    Letter T                  =>  (self)  */
  285.  85,  /*  085  05/05  G0 U    Letter U                  =>  (self)  */
  286.  86,  /*  086  05/06  G0 V    Letter V                  =>  (self)  */
  287.  87,  /*  087  05/07  G0 W    Letter W                  =>  (self)  */
  288.  88,  /*  088  05/08  G0 X    Letter X                  =>  (self)  */
  289.  89,  /*  089  05/09  G0 Y    Letter Y                  =>  (self)  */
  290.  90,  /*  090  05/10  G0 Z    Letter Z                  =>  (self)  */
  291.  91,  /*  091  05/11  G0 [    Left square bracket       =>  (self)  */
  292.  92,  /*  092  05/12  G0 \    Reverse slash             =>  (self)  */
  293.  93,  /*  093  05/13  G0 ]    Right square bracket      =>  (self)  */
  294.  94,  /*  094  05/14  G0 ^    Circumflex accent         =>  (self)  */
  295.  95,  /*  095  05/15  G0 _    Underline, low line       =>  (self)  */
  296.  96,  /*  096  06/00  G0 `    Grave accent              =>  (self)  */
  297.  97,  /*  097  06/01  G0 a    Letter a                  =>  (self)  */
  298.  98,  /*  098  06/02  G0 b    Letter b                  =>  (self)  */
  299.  99,  /*  099  06/03  G0 c    Letter c                  =>  (self)  */
  300. 100,  /*  100  06/04  G0 d    Letter d                  =>  (self)  */
  301. 101,  /*  101  06/05  G0 e    Letter e                  =>  (self)  */
  302. 102,  /*  102  06/06  G0 f    Letter f                  =>  (self)  */
  303. 103,  /*  103  06/07  G0 g    Letter g                  =>  (self)  */
  304. 104,  /*  104  06/08  G0 h    Letter h                  =>  (self)  */
  305. 105,  /*  105  06/09  G0 i    Letter i                  =>  (self)  */
  306. 106,  /*  106  06/10  G0 j    Letter j                  =>  (self)  */
  307. 107,  /*  107  06/11  G0 k    Letter k                  =>  (self)  */
  308. 108,  /*  108  06/12  G0 l    Letter l                  =>  (self)  */
  309. 109,  /*  109  06/13  G0 m    Letter m                  =>  (self)  */
  310. 110,  /*  110  06/14  G0 n    Letter n                  =>  (self)  */
  311. 111,  /*  111  06/15  G0 o    Letter o                  =>  (self)  */
  312. 112,  /*  112  07/00  G0 p    Letter p                  =>  (self)  */
  313. 113,  /*  113  07/01  G0 q    Letter q                  =>  (self)  */
  314. 114,  /*  114  07/02  G0 r    Letter r                  =>  (self)  */
  315. 115,  /*  115  07/03  G0 s    Letter s                  =>  (self)  */
  316. 116,  /*  116  07/04  G0 t    Letter t                  =>  (self)  */
  317. 117,  /*  117  07/05  G0 u    Letter u                  =>  (self)  */
  318. 118,  /*  118  07/06  G0 v    Letter v                  =>  (self)  */
  319. 119,  /*  119  07/07  G0 w    Letter w                  =>  (self)  */
  320. 120,  /*  120  07/08  G0 x    Letter x                  =>  (self)  */
  321. 121,  /*  121  07/09  G0 y    Letter y                  =>  (self)  */
  322. 122,  /*  122  07/10  G0 z    Letter z                  =>  (self)  */
  323. 123,  /*  123  07/11  G0 {    Left curly bracket        =>  (self)  */
  324. 124,  /*  124  07/12  G0 |    Vertical bar              =>  (self)  */
  325. 125,  /*  125  07/13  G0 }    Right curly bracket       =>  (self)  */
  326. 126,  /*  126  07/14  G0 ~    Tilde                     =>  (self)  */
  327. 127,  /*  127  07/15     DEL  Delete, Rubout            =>  (self)  */
  328. UNK,  /*  128  08/00  C1                                =>  UNK     */
  329. UNK,  /*  129  08/01  C1                                =>  UNK     */
  330. UNK,  /*  130  08/02  C1                                =>  UNK     */
  331. UNK,  /*  131  08/03  C1                                =>  UNK     */
  332. UNK,  /*  132  08/04  C1 IND                            =>  UNK     */
  333. UNK,  /*  133  08/05  C1 NEL                            =>  UNK     */
  334. UNK,  /*  134  08/06  C1 SSA                            =>  UNK     */
  335. UNK,  /*  135  08/07  C1 ESA                            =>  UNK     */
  336. UNK,  /*  136  08/08  C1 HTS                            =>  UNK     */
  337. UNK,  /*  137  08/09  C1                                =>  UNK     */
  338. UNK,  /*  138  08/10  C1                                =>  UNK     */
  339. UNK,  /*  139  08/11  C1                                =>  UNK     */
  340. UNK,  /*  140  08/12  C1                                =>  UNK     */
  341. UNK,  /*  141  08/13  C1 RI                             =>  UNK     */
  342. UNK,  /*  142  08/14  C1 SS2                            =>  UNK     */
  343. UNK,  /*  143  08/15  C1 SS3                            =>  UNK     */
  344. UNK,  /*  144  09/00  C1 DCS                            =>  UNK     */
  345. UNK,  /*  145  09/01  C1                                =>  UNK     */
  346. UNK,  /*  146  09/02  C1                                =>  UNK     */
  347. UNK,  /*  147  09/03  C1 STS                            =>  UNK     */
  348. UNK,  /*  148  09/04  C1                                =>  UNK     */
  349. UNK,  /*  149  09/05  C1                                =>  UNK     */
  350. UNK,  /*  150  09/06  C1 SPA                            =>  UNK     */
  351. UNK,  /*  151  09/07  C1 EPA                            =>  UNK     */
  352. UNK,  /*  152  09/08  C1                                =>  UNK     */
  353. UNK,  /*  153  09/09  C1                                =>  UNK     */
  354. UNK,  /*  154  09/10  C1                                =>  UNK     */
  355. UNK,  /*  155  09/11  C1 CSI                            =>  UNK     */
  356. UNK,  /*  156  09/12  C1 ST                             =>  UNK     */
  357. UNK,  /*  157  09/13  C1 OSC                            =>  UNK     */
  358. UNK,  /*  158  09/14  C1 PM                             =>  UNK     */
  359. UNK,  /*  159  09/15  C1 APC                            =>  UNK     */
  360.  32,  /*  160  10/00  G1      No-break space            =>  SP      */
  361.  33,  /*  161  10/01  G1      Inverted exclamation      =>  !       */
  362.  99,  /*  162  10/02  G1      Cent sign                 =>  c       */
  363.  35,  /*  163  10/03  G1      Pound sign                =>  #       */
  364.  36,  /*  164  10/04  G1      Currency sign             =>  $       */
  365.  89,  /*  165  10/05  G1      Yen sign                  =>  Y       */
  366. 124,  /*  166  10/06  G1      Broken bar                =>  |       */
  367.  80,  /*  167  10/07  G1      Paragraph sign            =>  P       */
  368.  34,  /*  168  10/08  G1      Diaeresis                 =>  "       */
  369.  67,  /*  169  10/09  G1      Copyright sign            =>  C       */
  370.  97,  /*  170  10/10  G1      Feminine ordinal          =>  a       */
  371.  34,  /*  171  10/11  G1      Left angle quotation      =>  "       */
  372. 126,  /*  172  10/12  G1      Not sign                  =>  ~       */
  373.  45,  /*  173  10/13  G1      Soft hyphen               =>  -       */
  374.  82,  /*  174  10/14  G1      Registered trade mark     =>  R       */
  375.  95,  /*  175  10/15  G1      Macron                    =>  _       */
  376. 111,  /*  176  11/00  G1      Degree sign, ring above   =>  o       */
  377. UNK,  /*  177  11/01  G1      Plus-minus sign           =>  UNK     */
  378.  50,  /*  178  11/02  G1      Superscript two           =>  2       */
  379.  51,  /*  179  11/03  G1      Superscript three         =>  3       */
  380.  39,  /*  180  11/04  G1      Acute accent              =>  '       */
  381. 117,  /*  181  11/05  G1      Micro sign                =>  u       */
  382.  45,  /*  182  11/06  G1      Pilcrow sign              =>  -       */
  383.  45,  /*  183  11/07  G1      Middle dot                =>  -       */
  384.  44,  /*  184  11/08  G1      Cedilla                   =>  ,       */
  385.  49,  /*  185  11/09  G1      Superscript one           =>  1       */
  386. 111,  /*  186  11/10  G1      Masculine ordinal         =>  o       */
  387.  34,  /*  187  11/11  G1      Right angle quotation     =>  "       */
  388. UNK,  /*  188  11/12  G1      One quarter               =>  UNK     */
  389. UNK,  /*  189  11/13  G1      One half                  =>  UNK     */
  390. UNK,  /*  190  11/14  G1      Three quarters            =>  UNK     */
  391.  63,  /*  191  11/15  G1      Inverted question mark    =>  ?       */
  392.  65,  /*  192  12/00  G1      A grave                   =>  A       */
  393.  65,  /*  193  12/01  G1      A acute                   =>  A       */
  394.  65,  /*  194  12/02  G1      A circumflex              =>  A       */
  395.  65,  /*  195  12/03  G1      A tilde                   =>  A       */
  396.  65,  /*  196  12/04  G1      A diaeresis               =>  A       */
  397.  65,  /*  197  12/05  G1      A ring above              =>  A       */
  398.  65,  /*  198  12/06  G1      A with E                  =>  A       */
  399.  67,  /*  199  12/07  G1      C Cedilla                 =>  C       */
  400.  69,  /*  200  12/08  G1      E grave                   =>  E       */
  401.  69,  /*  201  12/09  G1      E acute                   =>  E       */
  402.  69,  /*  202  12/10  G1      E circumflex              =>  E       */
  403.  69,  /*  203  12/11  G1      E diaeresis               =>  E       */
  404.  73,  /*  204  12/12  G1      I grave                   =>  I       */
  405.  73,  /*  205  12/13  G1      I acute                   =>  I       */
  406.  73,  /*  206  12/14  G1      I circumflex              =>  I       */
  407.  73,  /*  207  12/15  G1      I diaeresis               =>  I       */
  408.  68,  /*  208  13/00  G1      Icelandic Eth             =>  D       */
  409.  78,  /*  209  13/01  G1      N tilde                   =>  N       */
  410.  79,  /*  210  13/02  G1      O grave                   =>  O       */
  411.  79,  /*  211  13/03  G1      O acute                   =>  O       */
  412.  79,  /*  212  13/04  G1      O circumflex              =>  O       */
  413.  79,  /*  213  13/05  G1      O tilde                   =>  O       */
  414.  79,  /*  214  13/06  G1      O diaeresis               =>  O       */
  415. 120,  /*  215  13/07  G1      Multiplication sign       =>  x       */
  416.  79,  /*  216  13/08  G1      O oblique stroke          =>  O       */
  417.  85,  /*  217  13/09  G1      U grave                   =>  U       */
  418.  85,  /*  218  13/10  G1      U acute                   =>  U       */
  419.  85,  /*  219  13/11  G1      U circumflex              =>  U       */
  420.  85,  /*  220  13/12  G1      U diaeresis               =>  U       */
  421.  89,  /*  221  13/13  G1      Y acute                   =>  Y       */
  422.  84,  /*  222  13/14  G1      Icelandic Thorn           =>  T       */
  423. 115,  /*  223  13/15  G1      German sharp s            =>  s       */
  424.  97,  /*  224  14/00  G1      a grave                   =>  a       */
  425.  97,  /*  225  14/01  G1      a acute                   =>  a       */
  426.  97,  /*  226  14/02  G1      a circumflex              =>  a       */
  427.  97,  /*  227  14/03  G1      a tilde                   =>  a       */
  428.  97,  /*  228  14/04  G1      a diaeresis               =>  a       */
  429.  97,  /*  229  14/05  G1      a ring above              =>  a       */
  430.  97,  /*  230  14/06  G1      a with e                  =>  a       */
  431.  99,  /*  231  14/07  G1      c cedilla                 =>  c       */
  432. 101,  /*  232  14/08  G1      e grave                   =>  e       */
  433. 101,  /*  233  14/09  G1      e acute                   =>  e       */
  434. 101,  /*  234  14/10  G1      e circumflex              =>  e       */
  435. 101,  /*  235  14/11  G1      e diaeresis               =>  e       */
  436. 105,  /*  236  14/12  G1      i grave                   =>  i       */
  437. 105,  /*  237  14/13  G1      i acute                   =>  i       */
  438. 105,  /*  238  14/14  G1      i circumflex              =>  i       */
  439. 105,  /*  239  14/15  G1      i diaeresis               =>  i       */
  440. 100,  /*  240  15/00  G1      Icelandic eth             =>  d       */
  441. 110,  /*  241  15/01  G1      n tilde                   =>  n       */
  442. 111,  /*  242  15/02  G1      o grave                   =>  o       */
  443. 111,  /*  243  15/03  G1      o acute                   =>  o       */
  444. 111,  /*  244  15/04  G1      o circumflex              =>  o       */
  445. 111,  /*  245  15/05  G1      o tilde                   =>  o       */
  446. 111,  /*  246  15/06  G1      o diaeresis               =>  o       */
  447.  47,  /*  247  15/07  G1      Division sign             =>  /       */
  448. 111,  /*  248  15/08  G1      o oblique stroke          =>  o       */
  449. 117,  /*  249  15/09  G1      u grave                   =>  u       */
  450. 117,  /*  250  15/10  G1      u acute                   =>  u       */
  451. 117,  /*  251  15/11  G1      u circumflex              =>  u       */
  452. 117,  /*  252  15/12  G1      u diaeresis               =>  u       */
  453. 121,  /*  253  15/13  G1      y acute                   =>  y       */
  454. 116,  /*  254  15/14  G1      Icelandic thorn           =>  t       */
  455. 121   /*  255  15/15  G1      y diaeresis               =>  y       */
  456. }
  457. ;
  458.  
  459. /* Translation tables for ISO Latin Alphabet 1 to local file character sets */
  460.  
  461. CHAR
  462. yl1aq[] = {  /* Latin-1 to Extended Mac Latin (based on Apple QuickDraw) */
  463.   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,
  464.  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,
  465.  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,  45,  46,  47,
  466.  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,  60,  61,  62,  63,
  467.  64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,
  468.  80,  81,  82,  83,  84,  85,  86,  87,  88,  89,  90,  91,  92,  93,  94,  95,
  469.  96,  97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
  470. 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
  471. 182, 183, 184, 185, 189, 196, 197, 198, 206, 207, 210, 211, 217, 218, 195, 212,
  472. 209, 215, 213, 226, 227, 228, 240, 245, 246, 247, 249, 250, 251, 253, 254, 255,
  473. 202, 193, 162, 163, 219, 180, 201, 164, 172, 169, 187, 199, 194, 208, 168, 248,
  474. 161, 177, 170, 173, 171, 181, 166, 225, 252, 176, 188, 200, 178, 179, 186, 192,
  475. 203, 231, 229, 204, 128, 129, 174, 130, 233, 131, 230, 232, 237, 234, 235, 236,
  476. 220, 132, 241, 238, 239, 205, 133, 165, 175, 244, 242, 243, 134, 160, 222, 167,
  477. 136, 135, 137, 139, 138, 140, 190, 141, 143, 142, 144, 145, 147, 146, 148, 149,
  478. 221, 150, 152, 151, 153, 155, 154, 214, 191, 157, 156, 158, 159, 224, 223, 216
  479. };
  480.  
  481. /* Local file character sets to ISO Latin Alphabet 1 */
  482.  
  483. #ifdef COMMENT
  484. CHAR
  485. yasl1[] = {  /* ASCII to Latin-1 */
  486.   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,
  487.  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,
  488.  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,  45,  46,  47,
  489.  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,  60,  61,  62,  63,
  490.  64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,
  491.  80,  81,  82,  83,  84,  85,  86,  87,  88,  89,  90,  91,  92,  93,  94,  95,
  492.  96,  97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
  493. 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127
  494. };
  495. #endif /* COMMENT */
  496.  
  497. CHAR
  498. yaql1[] = {  /* Extended Mac Latin (based on Apple Quickdraw) to Latin-1 */
  499.   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,
  500.  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,
  501.  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,  45,  46,  47,
  502.  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,  60,  61,  62,  63,
  503.  64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,
  504.  80,  81,  82,  83,  84,  85,  86,  87,  88,  89,  90,  91,  92,  93,  94,  95,
  505.  96,  97,  98,  99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
  506. 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
  507. 196, 197, 199, 201, 209, 214, 220, 225, 224, 226, 228, 227, 229, 231, 233, 232,
  508. 234, 235, 237, 236, 238, 239, 241, 243, 242, 244, 246, 245, 250, 249, 251, 252,
  509. 221, 176, 162, 163, 167, 215, 182, 223, 174, 169, 178, 180, 168, 179, 198, 216,
  510. 185, 177, 188, 189, 165, 181, 128, 129, 130, 131, 190, 170, 186, 132, 230, 248,
  511. 191, 161, 172, 142, 133, 134, 135, 171, 187, 166, 160, 192, 195, 213, 136, 137,
  512. 173, 144, 138, 139, 143, 146, 247, 145, 255, 140, 141, 164, 208, 240, 222, 254,
  513. 253, 183, 147, 148, 149, 194, 202, 193, 203, 200, 205, 206, 207, 204, 211, 212,
  514. 150, 210, 218, 219, 217, 151, 152, 153, 175, 154, 155, 156, 184, 157, 158, 159
  515. };
  516.  
  517. /* Translation functions ... */
  518.  
  519. #ifdef COMMENT
  520. /*
  521.   Not needed...
  522. */
  523. CHAR                /* The identity translation function */
  524. ident(c) CHAR c; {
  525.     return(c);
  526. }
  527. #endif /* COMMENT */
  528.  
  529. /* Latin-1 to US ASCII... */
  530. CHAR
  531. #ifdef CK_ANSIC
  532. xl1as(CHAR c) 
  533. #else
  534. xl1as(c) CHAR c; 
  535. #endif /* CK_ANSIC */
  536. { /* xl1as */
  537.     switch(langs[language].id) {
  538.  
  539.       case L_DUTCH:
  540.     if (c == 255) {            /* Dutch umlaut-y */
  541.         zmstuff('j');        /* becomes ij */
  542.         return('i');
  543.     } else return(yl1as[c]);    /* all others by the book */
  544.  
  545.       case L_GERMAN:
  546.     switch (c) {            /* German, special rules. */
  547.       case 196:            /* umlaut-A -> Ae */
  548.         zmstuff('e');
  549.         return('A');
  550.       case 214:            /* umlaut-O -> Oe */
  551.         zmstuff('e');
  552.         return('O');
  553.       case 220:            /* umlaut-U -> Ue */
  554.         zmstuff('e');
  555.         return('U');
  556.       case 228:            /* umlaut-a -> ae */
  557.         zmstuff('e');
  558.         return('a');
  559.       case 246:            /* umlaut-o -> oe */
  560.         zmstuff('e');
  561.         return('o');
  562.       case 252:            /* umlaut-u -> ue */
  563.         zmstuff('e');
  564.         return('u');
  565.       case 223:            /* ess-zet -> ss */
  566.         zmstuff('s');
  567.         return('s');
  568.       default: return(yl1as[c]);    /* all others by the book */
  569.     }
  570.       case L_DANISH:
  571.       case L_FINNISH:
  572.       case L_NORWEGIAN:
  573.       case L_SWEDISH:
  574.     switch (c) {            /* Scandanavian languages. */
  575.       case 196:            /* umlaut-A -> Ae */
  576.           case 198:            /* AE ligature also -> Ae */
  577.         zmstuff('e');
  578.         return('A');
  579.       case 214:            /* umlaut-O -> Oe */
  580.       case 216:            /* O-slash -> Oe */
  581.         zmstuff('e');
  582.         return('O');
  583.       case 220:            /* umlaut-U -> Ue */
  584.       /*  return('Y'); replaced by "Ue" by popular demand. */
  585.           /*  Y for Umlaut-U is only used in German names. */
  586.         zmstuff('e');
  587.         return('U');
  588.       case 228:            /* umlaut-a -> ae */
  589.           case 230:            /* ditto for ae ligature */
  590.         zmstuff('e');
  591.         return('a');
  592.       case 246:            /* umlaut-o -> oe */
  593.       case 248:            /* o-slash -> oe */
  594.         zmstuff('e');
  595.         return('o');
  596.       case 252:            /* umlaut-u -> ue */
  597.       /*  return('y'); replaced by "ue" by popular demand. */
  598.         zmstuff('e');
  599.         return('u');
  600.       case 197:            /* A-ring -> Aa */
  601.         zmstuff('a');
  602.         return('A');
  603.           case 229:            /* a-ring -> aa */
  604.         zmstuff('a');
  605.         return('a');
  606.       default: return(yl1as[c]);    /* All others by the book */
  607.     }
  608.       case L_ICELANDIC:            /* Icelandic. */
  609.     switch (c) {    
  610.       case 198:            /* uppercase AE -> AE */
  611.         zmstuff('e');
  612.         return('A');
  613.       case 208:            /* uppercase Eth -> D */
  614.         return('D');
  615.       case 222:            /* uppercase Thorn -> Th */
  616.         zmstuff('h');
  617.         return('T');
  618.       case 230:            /* lowercase ae -> ae */
  619.         zmstuff('e');
  620.         return('a');
  621.       case 240:            /* lowercase Eth -> d */
  622.         return('d');
  623.       case 254:            /* lowercase Thorn -> th */
  624.         zmstuff('h');
  625.         return('t');
  626.       default: return(yl1as[c]);    /* All others by the book */
  627.     }
  628.       default:
  629.     return(yl1as[c]);        /* None of the above, by the table. */
  630.     }
  631. }
  632.  
  633. /* Translation functions for receiving files and translating them into ASCII */
  634.  
  635. CHAR
  636. zl1as(CHAR c) {
  637.     switch(langs[language].id) {
  638.  
  639.       case L_DUTCH:
  640.     if (c == 255) {            /* Dutch umlaut-y */
  641.         zdstuff('j');        /* becomes ij */
  642.         return('i');
  643.     } else return(yl1as[c]);    /* all others by the book */
  644.  
  645.       case L_GERMAN:
  646.     switch (c) {            /* German, special rules. */
  647.       case 196:            /* umlaut-A -> Ae */
  648.         zdstuff('e');
  649.         return('A');
  650.       case 214:            /* umlaut-O -> Oe */
  651.         zdstuff('e');
  652.         return('O');
  653.       case 220:            /* umlaut-U -> Ue */
  654.         zdstuff('e');
  655.         return('U');
  656.       case 228:            /* umlaut-a -> ae */
  657.         zdstuff('e');
  658.         return('a');
  659.       case 246:            /* umlaut-o -> oe */
  660.         zdstuff('e');
  661.         return('o');
  662.       case 252:            /* umlaut-u -> ue */
  663.         zdstuff('e');
  664.         return('u');
  665.       case 223:            /* ess-zet -> ss */
  666.         zdstuff('s');
  667.         return('s');
  668.       default: return(yl1as[c]);    /* all others by the book */
  669.     }
  670.       case L_DANISH:
  671.       case L_FINNISH:
  672.       case L_NORWEGIAN:
  673.       case L_SWEDISH:
  674.     switch (c) {            /* Scandanavian languages. */
  675.       case 196:            /* umlaut-A -> Ae */
  676.         zdstuff('e');
  677.         return('A');
  678.       case 214:            /* umlaut-O -> Oe */
  679.       case 216:            /* O-slash -> Oe */
  680.         zdstuff('e');
  681.         return('O');
  682.       case 220:            /* umlaut-U -> Y */
  683.         /* return('Y'); */
  684.         zdstuff('e');
  685.         return('U');
  686.       case 228:            /* umlaut-a -> ae */
  687.         zdstuff('e');
  688.         return('a');
  689.       case 246:            /* umlaut-o -> oe */
  690.       case 248:            /* o-slash -> oe */
  691.         zdstuff('e');
  692.         return('o');
  693.       case 252:            /* umlaut-u -> y */
  694.         /* return('y'); */
  695.         zdstuff('e');
  696.         return('u');
  697.       case 197:            /* A-ring -> Aa */
  698.         zdstuff('a');
  699.         return('A');
  700.           case 229:            /* a-ring -> aa */
  701.         zdstuff('a');
  702.         return('a');
  703.       default: return(yl1as[c]);    /* All others by the book */
  704.     }
  705.       default:
  706.     return(yl1as[c]);        /* Not German, by the table. */
  707.     }
  708. }
  709.  
  710. /* Apple Mac to ASCII */
  711. CHAR
  712. #ifdef CK_ANSIC
  713. xaqas(CHAR c) 
  714. #else
  715. xaqas(c) CHAR c; 
  716. #endif /* CK_ANSIC */
  717. { /* xaqas */
  718.     c = yaql1[c];            /* Translate to Latin-1 */
  719.     return(xl1as(c));            /* then to ASCII. */
  720. }
  721.  
  722. CHAR
  723. #ifdef CK_ANSIC
  724. xl1aq(CHAR c) 
  725. #else
  726. xl1aq(c) CHAR c; 
  727. #endif /* CK_ANSIC */
  728. { /* xl1aq */    /* Latin-1 to Apple Macintosh Character Set */
  729.     return(yl1aq[c]);
  730. }
  731.  
  732. /* Apple Macintosh Character Set to Latin-1 */
  733. CHAR
  734. #ifdef CK_ANSIC
  735. xaql1(CHAR c) 
  736. #else
  737. xaql1(c) CHAR c; 
  738. #endif /* CK_ANSIC */
  739. { /* xaql1 */
  740.     return(yaql1[c]);
  741. }
  742.  
  743. /*
  744.   Table of translation functions for receiving files.
  745.   Array of pointers to functions for translating from the transfer
  746.   syntax to the local file character set.  The first index is the
  747.   transfer syntax character set number, the second index is the file 
  748.   character set number.
  749. */
  750. #ifdef CK_ANSIC
  751. CHAR (*xlr[MAXTCSETS+1][MAXFCSETS+1])(CHAR) =
  752. #else
  753. CHAR (*xlr[MAXTCSETS+1][MAXFCSETS+1])() =
  754. #endif /* CK_ANSIC */
  755. {
  756.     NULL,            /* 0,0 transparent to us ascii */
  757.     NULL,            /* 0,1 transparent to latin-1 */
  758.     NULL,            /* 0,2 transparent to Apple Quickdraw */
  759.     NULL,            /* 1,0 ascii to us ascii */
  760.     NULL,            /* 1,2 ascii to latin-1 */
  761.     NULL,            /* 1,3 ascii to Apple Quickdraw */
  762.     zl1as,            /* 2,0 latin-1 to us ascii */
  763.     NULL,            /* 2,1 latin-1 to latin-1 */
  764.     xl1aq            /* 2,2 latin-1 to Apple Quickdraw */
  765. };
  766.  
  767. /*
  768.   Translation functions for sending files.
  769.   Array of pointers to functions for translating from the local file
  770.   character set to the transfer syntax character set.  Indexed in the same
  771.   way as the xlr array above.
  772. */
  773. #ifdef CK_ANSIC
  774. CHAR (*xls[MAXTCSETS+1][MAXFCSETS+1])(CHAR) =
  775. #else
  776. CHAR (*xls[MAXTCSETS+1][MAXFCSETS+1])() =
  777. #endif /* CK_ANSIC */
  778. {
  779.  
  780.     NULL,            /* 0,0 us ascii to transparent */
  781.     NULL,            /* 0,1 latin-1 to transparent */
  782.     NULL,            /* 0,2 Apple Quickdraw to transparent */
  783.     NULL,            /* 1,0 ascii to ascii */
  784.     xl1as,            /* 1,2 latin-1 to ascii */
  785.     xaqas,            /* 1,3 Apple Quickdraw to ascii */
  786.     NULL,            /* 2,0 ascii to latin-1  */
  787.     NULL,            /* 2,1 latin-1 to latin-1 */
  788.     xaql1            /* 2,2 Apple Quickdraw to latin-1 */
  789. };
  790.