1 /*
   2  * Copyright (c) 1992, 1993, 1994 Henry Spencer.
   3  * Copyright (c) 1992, 1993, 1994
   4  *      The Regents of the University of California.  All rights reserved.
   5  *
   6  * This code is derived from software contributed to Berkeley by
   7  * Henry Spencer.
   8  *
   9  * Redistribution and use in source and binary forms, with or without
  10  * modification, are permitted provided that the following conditions
  11  * are met:
  12  * 1. Redistributions of source code must retain the above copyright
  13  *    notice, this list of conditions and the following disclaimer.
  14  * 2. Redistributions in binary form must reproduce the above copyright
  15  *    notice, this list of conditions and the following disclaimer in the
  16  *    documentation and/or other materials provided with the distribution.
  17  * 3. Neither the name of the University nor the names of its contributors
  18  *    may be used to endorse or promote products derived from this software
  19  *    without specific prior written permission.
  20  *
  21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31  * SUCH DAMAGE.
  32  */
  33 
  34 /* character-name table */
  35 static const struct cname {
  36         const wchar_t *name;
  37         wchar_t code;
  38 } cnames[] = {
  39         {L"",                           (wchar_t)-1}, /* sentinel */
  40         {L"ACK",                        L'\006'},
  41         {L"BEL",                        L'\007'},
  42         {L"BS",                         L'\010'},
  43         {L"CAN",                        L'\030'},
  44         {L"CR",                         L'\015'},
  45         {L"DC1",                        L'\021'},
  46         {L"DC2",                        L'\022'},
  47         {L"DC3",                        L'\023'},
  48         {L"DC4",                        L'\024'},
  49         {L"DEL",                        L'\177'},
  50         {L"DLE",                        L'\020'},
  51         {L"EM",                         L'\031'},
  52         {L"ENQ",                        L'\005'},
  53         {L"EOT",                        L'\004'},
  54         {L"ESC",                        L'\033'},
  55         {L"ETB",                        L'\027'},
  56         {L"ETX",                        L'\003'},
  57         {L"FF",                         L'\014'},
  58         {L"FS",                         L'\034'},
  59         {L"GS",                         L'\035'},
  60         {L"HT",                         L'\011'},
  61         {L"IS1",                        L'\037'},
  62         {L"IS2",                        L'\036'},
  63         {L"IS3",                        L'\035'},
  64         {L"IS4",                        L'\034'},
  65         {L"LF",                         L'\012'},
  66         {L"NAK",                        L'\025'},
  67         {L"NUL",                        L'\0'},
  68         {L"RS",                         L'\036'},
  69         {L"SI",                         L'\017'},
  70         {L"SO",                         L'\016'},
  71         {L"SOH",                        L'\001'},
  72         {L"STX",                        L'\002'},
  73         {L"SUB",                        L'\032'},
  74         {L"SYN",                        L'\026'},
  75         {L"US",                         L'\037'},
  76         {L"VT",                         L'\013'},
  77         {L"alert",                      L'\007'},
  78         {L"ampersand",                  L'&'},
  79         {L"apostrophe",                 L'\''},
  80         {L"asterisk",                   L'*'},
  81         {L"backslash",                  L'\\'},
  82         {L"backspace",                  L'\b'},
  83         {L"carriage-return",            L'\r'},
  84         {L"circumflex",                 L'^'},
  85         {L"circumflex-accent",          L'^'},
  86         {L"colon",                      L':'},
  87         {L"comma",                      L','},
  88         {L"commercial-at",              L'@'},
  89         {L"dollar-sign",                L'$'},
  90         {L"eight",                      L'8'},
  91         {L"equals-sign",                L'='},
  92         {L"exclamation-mark",           L'!'},
  93         {L"five",                       L'5'},
  94         {L"form-feed",                  L'\f'},
  95         {L"four",                       L'4'},
  96         {L"full-stop",                  L'.'},
  97         {L"grave-accent",               L'`'},
  98         {L"greater-than-sign",          L'>'},
  99         {L"hyphen",                     L'-'},
 100         {L"hyphen-minus",               L'-'},
 101         {L"left-brace",                 L'{'},
 102         {L"left-curly-bracket",         L'{'},
 103         {L"left-parenthesis",           L'('},
 104         {L"left-square-bracket",        L'['},
 105         {L"less-than-sign",             L'<'},
 106         {L"low-line",                   L'_'},
 107         {L"newline",                    L'\n'},
 108         {L"nine",                       L'9'},
 109         {L"number-sign",                L'#'},
 110         {L"one",                        L'1'},
 111         {L"percent-sign",               L'%'},
 112         {L"period",                     L'.'},
 113         {L"plus-sign",                  L'+'},
 114         {L"question-mark",              L'?'},
 115         {L"quotation-mark",             L'"'},
 116         {L"reverse-solidus",            L'\\'},
 117         {L"right-brace",                L'}'},
 118         {L"right-curly-bracket",        L'}'},
 119         {L"right-parenthesis",          L')'},
 120         {L"right-square-bracket",       L']'},
 121         {L"semicolon",                  L';'},
 122         {L"seven",                      L'7'},
 123         {L"six",                        L'6'},
 124         {L"slash",                      L'/'},
 125         {L"solidus",                    L'/'},
 126         {L"space",                      L' '},
 127         {L"tab",                        L'\t'},
 128         {L"three",                      L'3'},
 129         {L"tilde",                      L'~'},
 130         {L"two",                        L'2'},
 131         {L"underscore",                 L'_'},
 132         {L"vertical-line",              L'|'},
 133         {L"vertical-tab",               L'\v'},
 134         {L"zero",                       L'0'},
 135 };
 136 
 137 #define NCNAMES         (sizeof (cnames)/sizeof (*cnames))