~sbeattie/ubuntu/lucid/vnc4/lp556147

« back to all changes in this revision

Viewing changes to unix/xc/extras/X-TrueType/KOI8/main.c

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2006-05-15 20:35:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515203517-l4lre1ku942mn26k
Tags: 4.1.1+X4.3.0-10
* Correction of critical security issue. Thanks to Martin Kogler
  <e9925248@student.tuwien.ac.at> that informed me about the issue,
  and provided the patch.
  This flaw was originally found by Steve Wiseman of intelliadmin.com.
* Applied patch from Javier Kohen <jkohen@users.sourceforge.net> that
  inform the user that only 8 first characters of the password will
  actually be used when typing more than 8 characters, closes:
  #355619.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ===EmacsMode: -*- Mode: C; tab-width:4; c-basic-offset: 4; -*- === */
 
2
/* ===FileName: ===
 
3
   Copyright (c) 1998 Takuya SHIOZAKI, All Rights reserved.
 
4
   Copyright (c) 1998 X-TrueType Server Project, All rights reserved. 
 
5
   
 
6
===Notice
 
7
   Redistribution and use in source and binary forms, with or without
 
8
   modification, are permitted provided that the following conditions
 
9
   are met:
 
10
   1. Redistributions of source code must retain the above copyright
 
11
      notice, this list of conditions and the following disclaimer.
 
12
   2. Redistributions in binary form must reproduce the above copyright
 
13
      notice, this list of conditions and the following disclaimer in the
 
14
      documentation and/or other materials provided with the distribution.
 
15
 
 
16
   THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 
17
   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
18
   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
19
   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 
20
   FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
21
   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 
22
   OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
23
   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 
24
   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 
25
   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 
26
   SUCH DAMAGE.
 
27
 
 
28
   Major Release ID: X-TrueType Server Version 1.3 [Aoi MATSUBARA Release 3]
 
29
 
 
30
Notice===
 
31
 */
 
32
 
 
33
#include "xttversion.h"
 
34
 
 
35
static char const * const releaseID =
 
36
    _XTT_RELEASE_NAME;
 
37
 
 
38
#include "xttcommon.h"
 
39
#include "xttcap.h"
 
40
#include "xttcconv.h"
 
41
#include "xttcconvP.h"
 
42
 
 
43
 
 
44
typedef enum
 
45
{
 
46
    KOI8_R,
 
47
    KOI8_U,
 
48
    KOI8_RU,
 
49
    KOI8_UNI
 
50
} CharSetMagic;
 
51
 
 
52
static CharSetRelation const charSetRelations[] = {
 
53
    { "koi8",   NULL, "1",   KOI8_R,   { 0x20, 0xff, 0,    0,    0x20 } },
 
54
    { "koi8",   NULL, "r",   KOI8_R,   { 0x20, 0xff, 0,    0,    0x20 } },
 
55
    { "koi8",   NULL, "u",   KOI8_U,   { 0x20, 0xff, 0,    0,    0x20 } },
 
56
    { "koi8",   NULL, "ru",  KOI8_RU,  { 0x20, 0xff, 0,    0,    0x20 } },
 
57
    { "koi8",   NULL, "uni", KOI8_UNI, { 0x20, 0xff, 0,    0,    0x20 } },
 
58
    { NULL, NULL, NULL, 0, { 0, 0, 0, 0, 0 } }
 
59
};
 
60
 
 
61
 
 
62
CODECONV_TEMPLATE(cc_koi8_r_to_ucs2);
 
63
CODECONV_TEMPLATE(cc_koi8_u_to_ucs2);
 
64
CODECONV_TEMPLATE(cc_koi8_ru_to_ucs2);
 
65
CODECONV_TEMPLATE(cc_koi8_uni_to_ucs2);
 
66
static MapIDRelation const mapIDRelations[] = {
 
67
    { KOI8_R,       EPlfmISO,     EEncISO10646,
 
68
                                  cc_koi8_r_to_ucs2,                   NULL },
 
69
    { KOI8_R,       EPlfmUnicode, EEncAny,
 
70
                                  cc_koi8_r_to_ucs2,                   NULL },
 
71
    { KOI8_R,       EPlfmMS,      EEncMSUnicode,
 
72
                                  cc_koi8_r_to_ucs2,                   NULL },
 
73
    { KOI8_U,       EPlfmISO,     EEncISO10646,
 
74
                                  cc_koi8_u_to_ucs2,                   NULL },
 
75
    { KOI8_U,       EPlfmUnicode, EEncAny,
 
76
                                  cc_koi8_u_to_ucs2,                   NULL },
 
77
    { KOI8_U,       EPlfmMS,      EEncMSUnicode,
 
78
                                  cc_koi8_u_to_ucs2,                   NULL },
 
79
    { KOI8_RU,      EPlfmISO,     EEncISO10646,
 
80
                                  cc_koi8_ru_to_ucs2,                  NULL },
 
81
    { KOI8_RU,      EPlfmUnicode, EEncAny,
 
82
                                  cc_koi8_ru_to_ucs2,                  NULL },
 
83
    { KOI8_RU,      EPlfmMS,      EEncMSUnicode,
 
84
                                  cc_koi8_ru_to_ucs2,                  NULL },
 
85
    { KOI8_UNI,     EPlfmISO,     EEncISO10646,
 
86
                                  cc_koi8_uni_to_ucs2,                 NULL },
 
87
    { KOI8_UNI,     EPlfmUnicode, EEncAny,
 
88
                                  cc_koi8_uni_to_ucs2,                 NULL },
 
89
    { KOI8_UNI,     EPlfmMS,      EEncMSUnicode,
 
90
                                  cc_koi8_uni_to_ucs2,                 NULL },
 
91
    { -1, 0, 0, NULL, NULL }
 
92
};
 
93
 
 
94
STD_ENTRYFUNC_TEMPLATE(KOI8_entrypoint)
 
95
 
 
96
/*
 
97
  koi-* -> UCS2
 
98
 
 
99
  This  from xfsft:
 
100
    Copyright (c) 1997 by Mark Leisher
 
101
    Copyright (c) 1998 by Juliusz Chroboczek
 
102
 
 
103
 */
 
104
 
 
105
ucs2_t
 
106
cc_koi8_u_to_ucs2(ft_char_code_t codeSrc)
 
107
{
 
108
    ucs2_t codeDst;
 
109
 
 
110
    switch(codeSrc) {
 
111
    case 0xA4: codeDst = 0x0454; break;
 
112
    case 0xA6: codeDst = 0x0456; break;
 
113
    case 0xA7: codeDst = 0x0457; break;
 
114
    case 0xAD: codeDst = 0x0491; break;
 
115
    case 0xB4: codeDst = 0x0403; break;
 
116
    case 0xB6: codeDst = 0x0406; break;
 
117
    case 0xB7: codeDst = 0x0407; break;
 
118
    case 0xBD: codeDst = 0x0490; break;
 
119
    default:   codeDst = cc_koi8_r_to_ucs2(codeSrc);
 
120
    }
 
121
 
 
122
    return codeDst;
 
123
}
 
124
 
 
125
ucs2_t
 
126
cc_koi8_ru_to_ucs2(ft_char_code_t codeSrc)
 
127
{
 
128
    ucs2_t codeDst;
 
129
 
 
130
    switch(codeSrc) {
 
131
    case 0x93: codeDst = 0x201C; break;
 
132
    case 0x96: codeDst = 0x201D; break;
 
133
    case 0x97: codeDst = 0x2014; break;
 
134
    case 0x98: codeDst = 0x2116; break;
 
135
    case 0x99: codeDst = 0x2122; break;
 
136
    case 0x9B: codeDst = 0x00BB; break;
 
137
    case 0x9C: codeDst = 0x00AE; break;
 
138
    case 0x9D: codeDst = 0x00AB; break;
 
139
    case 0x9F: codeDst = 0x00A4; break;
 
140
    case 0xA4: codeDst = 0x0454; break;
 
141
    case 0xA6: codeDst = 0x0456; break;
 
142
    case 0xA7: codeDst = 0x0457; break;
 
143
    case 0xAD: codeDst = 0x0491; break;
 
144
    case 0xAE: codeDst = 0x045E; break;
 
145
    case 0xB4: codeDst = 0x0404; break;
 
146
    case 0xB6: codeDst = 0x0406; break;
 
147
    case 0xB7: codeDst = 0x0407; break;
 
148
    case 0xBD: codeDst = 0x0490; break;
 
149
    case 0xBE: codeDst = 0x040E; break;
 
150
    default:   codeDst = cc_koi8_r_to_ucs2(codeSrc);
 
151
    }
 
152
 
 
153
    return codeDst;
 
154
}
 
155
 
 
156
/* end of file */