00001
00018
00019
00020
00021 #include "name2char.h"
00022 #include "matchdefs.h"
00023 #include "danerror.h"
00024 #include <string.h>
00025
00026 #define ILLEGALCHARNAME 6001
00027
00028
00029
00030
00035 static const char *NameList[]={
00036 "!bang",
00037 "\"doubleq",
00038 "#hash",
00039 "$dollar",
00040 "%percent",
00041 "&and",
00042 "'quote",
00043 "(lround",
00044 ")rround",
00045 "*asterisk",
00046 "+plus",
00047 ",comma",
00048 "-minus",
00049 ".dot",
00050 "/slash",
00051 ":colon",
00052 ";semic",
00053 "<less",
00054 "=equal",
00055 ">greater",
00056 "?question",
00057 "@at",
00058 "[lsquare",
00059 "\\backsl",
00060 "]rsquare",
00061 "^uparr",
00062 "_unders",
00063 "`grave",
00064 "{lbrace",
00065 "|bar",
00066 "}rbrace",
00067 "~tilde",
00068 "AcA",
00069 "BcB",
00070 "CcC",
00071 "DcD",
00072 "EcE",
00073 "FcF",
00074 "GcG",
00075 "HcH",
00076 "IcI",
00077 "JcJ",
00078 "KcK",
00079 "LcL",
00080 "McM",
00081 "NcN",
00082 "OcO",
00083 "PcP",
00084 "QcQ",
00085 "RcR",
00086 "ScS",
00087 "TcT",
00088 "UcU",
00089 "VcV",
00090 "WcW",
00091 "XcX",
00092 "YcY",
00093 "ZcZ",
00094 NULL
00095 };
00096
00097
00098
00099
00100
00101
00102
00112 CLASS_ID NameToChar (
00113 char CharName[])
00114 {
00115 int i;
00116
00117
00118 for ( i = 0; NameList[i] != NULL; i++ )
00119 if ( strcmp (CharName, &NameList[i][1]) == 0)
00120 return (NameList[i][0]);
00121 if ( strlen (CharName) == 1 )
00122 return (CharName[0]);
00123 else
00124 {
00125 DoError (ILLEGALCHARNAME, "Illegal character name");
00126 return 0;
00127 }
00128 }
00129
00130
00131
00144 void CharToName (
00145 CLASS_ID Char,
00146 char CharName[])
00147 {
00148 int i;
00149
00150
00151 for ( i = 0; NameList[i] != NULL; i++ )
00152 if ( Char == NameList[i][0] )
00153 {
00154 strcpy ( CharName, &NameList[i][1] );
00155 return;
00156 }
00157
00158
00159 CharName[0] = Char;
00160 CharName[1] = 0;
00161
00162 }