summaryrefslogtreecommitdiff
path: root/xc/lib/X11/XKBCvt.c
diff options
context:
space:
mode:
Diffstat (limited to 'xc/lib/X11/XKBCvt.c')
-rw-r--r--xc/lib/X11/XKBCvt.c363
1 files changed, 27 insertions, 336 deletions
diff --git a/xc/lib/X11/XKBCvt.c b/xc/lib/X11/XKBCvt.c
index fbf7d079f..7a68151cc 100644
--- a/xc/lib/X11/XKBCvt.c
+++ b/xc/lib/X11/XKBCvt.c
@@ -22,7 +22,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
-/* $XFree86: xc/lib/X11/XKBCvt.c,v 3.20 1999/06/06 14:05:52 dawes Exp $ */
+/* $XFree86: xc/lib/X11/XKBCvt.c,v 3.25 2000/02/18 12:18:50 tsi Exp $ */
#include <stdio.h>
#include <sys/types.h>
@@ -64,59 +64,6 @@ extern char *getenv();
#define RConst /**/
#endif
-/* bit (1<<i) means character is in codeset i at the same codepoint */
-extern unsigned int _Xlatin1[];
-
-/* bit (1<<i) means character is in codeset i at the same codepoint */
-extern unsigned int _Xlatin2[];
-
-/* maps Cyrillic keysyms to KOI8-R */
-extern unsigned char _Xkoi8_r[];
-
-/* maps Cyrillic keysyms to KOI8-U */
-extern unsigned char _Xkoi8_u[];
-
-extern unsigned short _Xkoi8_size;
-
-#define sLatin1 0
-#define sLatin2 1
-#define sLatin3 2
-#define sLatin4 3
-#define sKana 4
-#define sX0201 0x01000004
-#define sArabic 5
-#define sCyrillic 6
-#define sGreek 7
-#define sAPL 11
-#define sHebrew 12
-#define sThai 13
-#define sKorean 14
-#define sLatin5 15
-#define sLatin6 16
-#define sLatin7 17
-#define sLatin8 18
-#define sLatin9 19
-#define sArmenian 20
-#define sGeorgian 21
-#define sCurrency 32
-
-
-static unsigned long WantLatin1 = sLatin1;
-static unsigned long WantLatin2 = sLatin2;
-static unsigned long WantLatin3 = sLatin3;
-static unsigned long WantLatin4 = sLatin4;
-static unsigned long WantLatin5 = sLatin5;
-static unsigned long WantLatin6 = sLatin6;
-static unsigned long WantKana = sKana;
-static unsigned long WantX0201 = sX0201;
-static unsigned long WantArabic = sArabic;
-static unsigned long WantCyrillic = sCyrillic;
-static unsigned long WantGreek = sGreek;
-static unsigned long WantAPL = sAPL;
-static unsigned long WantHebrew = sHebrew;
-static unsigned long WantArmenian = sArmenian;
-static unsigned long WantGeorgian = sGeorgian;
-
static int
#if NeedFunctionPrototypes
_XkbHandleSpecialSym(KeySym keysym, char *buffer, int nbytes, int *extra_rtrn)
@@ -154,14 +101,25 @@ _XkbHandleSpecialSym(keysym, buffer, nbytes, extra_rtrn)
}
extern int
-_XGetCharCode (
+_XimGetCharCode (
+#if NeedFunctionPrototypes
+ unsigned long /* locale_code */,
+ KeySym /* keysym */,
+ unsigned char* /* buf */,
+ int /* nbytes */
+#endif
+);
+
+extern unsigned long Const*
+_XimGetLocaleCode (
#if NeedFunctionPrototypes
- unsigned long, KeySym, char*, int
+ _Xconst char* /* encoding_name */,
+ XPointer* /* pass NULL here */
#endif
);
/*ARGSUSED*/
-int
+static int
#if NeedFunctionPrototypes
_XkbKSToKnownSet ( XPointer priv,
KeySym keysym,
@@ -177,15 +135,13 @@ _XkbKSToKnownSet (priv, keysym, buffer, nbytes, extra_rtrn)
int *extra_rtrn;
#endif
{
- unsigned long kset,keysymSet;
- int count,isLatin1;
+ unsigned long keysymSet;
char tbuf[8],*buf;
if (extra_rtrn)
*extra_rtrn= 0;
- keysymSet = *((unsigned long *)priv);
- kset = keysymSet&0xffffff;
+ keysymSet = *((unsigned long Const *)priv);
/* convert "dead" diacriticals for dumb applications */
if ( (keysym&0xffffff00)== 0xfe00 ) {
@@ -211,16 +167,13 @@ _XkbKSToKnownSet (priv, keysym, buffer, nbytes, extra_rtrn)
}
}
- isLatin1 = ((keysym&0xffffff00)==0);
- count = 0;
-
if (nbytes<1) buf= tbuf;
else buf= buffer;
if ((keysym&0xffffff00)==0xff00) {
return _XkbHandleSpecialSym(keysym, buf, nbytes, extra_rtrn);
}
- return _XGetCharCode (keysymSet, keysym, buf, nbytes);
+ return _XimGetCharCode (keysymSet, keysym, (unsigned char *)buf, nbytes);
}
typedef struct _XkbToKS {
@@ -255,62 +208,6 @@ _XkbKnownSetToKS(priv,buffer,nbytes,status)
return NoSymbol;
}
-/*ARGSUSED*/
-int
-#if NeedFunctionPrototypes
-_XkbKSToThai ( XPointer priv,
- KeySym keysym,
- char * buffer,
- int nbytes,
- int * extra_rtrn)
-#else
-_XkbKSToThai (priv, keysym, buffer, nbytes, extra_rtrn)
- XPointer priv;
- KeySym keysym;
- char *buffer;
- int nbytes;
- int *extra_rtrn;
-#endif
-{
-
- if ((keysym&0xffffff00)==0xff00) {
- return _XkbHandleSpecialSym(keysym, buffer, nbytes, extra_rtrn);
- }
- else if (((keysym&0xffffff80)==0xd80)||((keysym&0xffffff80)==0)) {
- if (nbytes>0) {
- buffer[0]= (char)(keysym&0xff);
- if (nbytes>1)
- buffer[1]= '\0';
- return 1;
- }
- if (extra_rtrn)
- *extra_rtrn= 1;
- }
- return 0;
-}
-
-/*ARGSUSED*/
-static KeySym
-#if NeedFunctionPrototypes
-_XkbThaiToKS(XPointer priv,char *buffer,int nbytes,Status *status)
-#else
-_XkbThaiToKS(priv,buffer,nbytes,status)
- XPointer priv;
- char *buffer;
- int nbytes;
- Status *status;
-#endif
-{
- if (nbytes!=1)
- return NoSymbol;
- if (((buffer[0]&0x80)==0)&&(buffer[0]>=32))
- return buffer[0];
- else if ((buffer[0]&0x7f)>=32) {
- return 0xd00|buffer[0];
- }
- return NoSymbol;
-}
-
static KeySym
#if NeedFunctionPrototypes
__XkbDefaultToUpper(KeySym sym)
@@ -325,170 +222,7 @@ __XkbDefaultToUpper(sym)
return upper;
}
-static int
-_XkbKSToKoi8_r (priv, keysym, buffer, nbytes, status)
- XPointer priv;
- KeySym keysym;
- char *buffer;
- int nbytes;
- Status *status;
-{
- if ((keysym&0xffffff00)==0xff00) {
- return _XkbHandleSpecialSym(keysym, buffer, nbytes, status);
- }
- else if (((keysym&0xffffff80)==0x680)||((keysym&0xffffff80)==0)) {
- if (nbytes>0) {
- if ( (keysym&0x80)==0 )
- buffer[0] = keysym&0x7f;
- else buffer[0] = _Xkoi8_r[keysym & 0x7f];
- if (nbytes>1)
- buffer[1]= '\0';
- return 1;
- }
- }
- return 0;
-}
-
-static KeySym
-_XkbKoi8_rToKS(priv,buffer,nbytes,status)
- XPointer priv;
- char *buffer;
- int nbytes;
- Status *status;
-{
- if (nbytes!=1)
- return NoSymbol;
- if (((buffer[0]&0x80)==0)&&(buffer[0]>=32))
- return buffer[0];
- else if ((buffer[0]&0x7f)>=32) {
- register int i;
- for (i=0;i<_Xkoi8_size;i++) {
- if (_Xkoi8_r[i]==buffer[0])
- return 0x680|i;
- }
- }
- return NoSymbol;
-}
-
-/***========================KOI8-U======================================***/
-static int _XkbKSToKoi8_u (priv, keysym, buffer, nbytes, status)
- XPointer priv;
- KeySym keysym;
- char *buffer;
- int nbytes;
- Status *status;
-{
- if ((keysym&0xffffff00)==0xff00) {
- return _XkbHandleSpecialSym(keysym, buffer, nbytes, status);
- }
- else if (((keysym&0xffffff80)==0x680)||((keysym&0xffffff80)==0)) {
- if (nbytes>0) {
- if ( (keysym&0x80)==0 )
- buffer[0] = keysym&0x7f;
- else buffer[0] = _Xkoi8_u[keysym & 0x7f];
- if (nbytes>1)
- buffer[1]= '\0';
- return 1;
- }
- }
- return 0;
-}
-
-static KeySym
-_XkbKoi8_uToKS(priv,buffer,nbytes,status)
- XPointer priv;
- char *buffer;
- int nbytes;
- Status *status;
-{
- if (nbytes!=1)
- return NoSymbol;
- if (((buffer[0]&0x80)==0)&&(buffer[0]>=32))
- return buffer[0];
- else if ((buffer[0]&0x7f)>=32) {
- register int i;
- for (i=0;i<_Xkoi8_size;i++) {
- if (_Xkoi8_u[i]==buffer[0])
- return 0x680|i;
- }
- }
- return NoSymbol;
-}
-
-
-
-
-/***====================================================================***/
-
-
-static XkbConverters RConst cvt_ascii = {
- _XkbKSToKnownSet,(XPointer)&WantLatin1,_XkbKnownSetToKS,NULL,__XkbDefaultToUpper
-};
-
-static XkbConverters RConst cvt_latin1 = {
- _XkbKSToKnownSet,(XPointer)&WantLatin1,_XkbKnownSetToKS,NULL,NULL
-};
-
-static XkbConverters RConst cvt_latin2 = {
- _XkbKSToKnownSet,(XPointer)&WantLatin2,_XkbKnownSetToKS,NULL,NULL
-};
-
-static XkbConverters RConst cvt_latin3 = {
- _XkbKSToKnownSet,(XPointer)&WantLatin3,_XkbKnownSetToKS,NULL,NULL
-};
-
-static XkbConverters RConst cvt_latin4 = {
- _XkbKSToKnownSet,(XPointer)&WantLatin4,_XkbKnownSetToKS,NULL,NULL
-};
-
-static XkbConverters RConst cvt_latin5 = {
- _XkbKSToKnownSet,(XPointer)&WantLatin5,_XkbKnownSetToKS,NULL,NULL
-};
-
-static XkbConverters RConst cvt_latin6 = {
- _XkbKSToKnownSet,(XPointer)&WantLatin6,_XkbKnownSetToKS,NULL,NULL
-};
-
-static XkbConverters RConst cvt_kana = {
- _XkbKSToKnownSet,(XPointer)&WantKana,_XkbKnownSetToKS,NULL,NULL
-};
-
-static XkbConverters RConst cvt_X0201 = {
- _XkbKSToKnownSet,(XPointer)&WantX0201,_XkbKnownSetToKS,NULL,NULL
-};
-
-static XkbConverters RConst cvt_Arabic = {
- _XkbKSToKnownSet,(XPointer)&WantArabic,_XkbKnownSetToKS,NULL,NULL
-};
-
-static XkbConverters RConst cvt_Cyrillic = {
- _XkbKSToKnownSet,(XPointer)&WantCyrillic,_XkbKnownSetToKS,NULL,NULL
-};
-
-static XkbConverters RConst cvt_Greek = {
- _XkbKSToKnownSet,(XPointer)&WantGreek,_XkbKnownSetToKS,NULL,NULL
-};
-
-static XkbConverters RConst cvt_APL = {
- _XkbKSToKnownSet,(XPointer)&WantAPL,_XkbKnownSetToKS,NULL,NULL
-};
-
-static XkbConverters RConst cvt_Hebrew = {
- _XkbKSToKnownSet,(XPointer)&WantHebrew,_XkbKnownSetToKS,NULL,NULL
-};
-
-static XkbConverters cvt_Thai = {
- _XkbKSToThai, NULL, _XkbThaiToKS, NULL, NULL
-};
-
-static XkbConverters cvt_Koi8_r = {
- _XkbKSToKoi8_r, NULL, _XkbKoi8_rToKS, NULL, NULL
-};
-
-static XkbConverters cvt_Koi8_u = {
- _XkbKSToKoi8_u, NULL, _XkbKoi8_uToKS, NULL, NULL
-};
-
+#ifdef XKB_EXTEND_LOOKUP_STRING
static int
#if NeedFunctionPrototypes
Strcmp(char *str1, char *str2)
@@ -515,6 +249,7 @@ Strcmp(str1, str2)
*s = '\0';
return (strcmp(str, str2));
}
+#endif
int
#if NeedFunctionPrototypes
@@ -525,57 +260,13 @@ _XkbGetConverters(encoding_name, cvt_rtrn)
XkbConverters *cvt_rtrn;
#endif
{
- if ( cvt_rtrn ) {
- if ( (encoding_name==NULL) ||
- (Strcmp(encoding_name,"ascii")==0) ||
- (Strcmp(encoding_name,"string")==0) )
- *cvt_rtrn = cvt_ascii;
- else if (Strcmp(encoding_name,"iso8859-1")==0)
- *cvt_rtrn = cvt_latin1;
- else if (Strcmp(encoding_name, "iso8859-2")==0)
- *cvt_rtrn = cvt_latin2;
- else if (Strcmp(encoding_name, "iso8859-3")==0)
- *cvt_rtrn = cvt_latin3;
- else if (Strcmp(encoding_name, "iso8859-4")==0)
- *cvt_rtrn = cvt_latin4;
- else if (Strcmp(encoding_name, "iso8859-5")==0)
- *cvt_rtrn = cvt_Cyrillic;
- else if (Strcmp(encoding_name, "iso8859-6")==0)
- *cvt_rtrn = cvt_Arabic;
- else if (Strcmp(encoding_name, "iso8859-7")==0)
- *cvt_rtrn = cvt_Greek;
- else if (Strcmp(encoding_name, "iso8859-8")==0)
- *cvt_rtrn = cvt_Hebrew;
- else if (Strcmp(encoding_name, "iso8859-9")==0)
- *cvt_rtrn = cvt_latin5;
- else if (Strcmp(encoding_name, "iso8859-10")==0)
- *cvt_rtrn = cvt_latin6;
- else if (Strcmp(encoding_name, "apl")==0)
- *cvt_rtrn = cvt_APL;
-#if 0
- else if (Strcmp(encoding_name, "ja.euc")==0)
- *cvt_rtrn = ???;
- else if (Strcmp(encoding_name, "ja.jis")==0)
- *cvt_rtrn = ???;
- else if (Strcmp(encoding_name, "ja.sjis")==0)
- *cvt_rtrn = ???;
-#endif
- else if (Strcmp(encoding_name, "jisx0201")==0) /* ??? */
- *cvt_rtrn = cvt_X0201;
- else if (Strcmp(encoding_name, "kana")==0) /* ??? */
- *cvt_rtrn = cvt_kana;
- else if ((Strcmp(encoding_name, "tactis")==0) ||
- (Strcmp(encoding_name, "tis620.2533-1")==0))
- *cvt_rtrn = cvt_Thai;
- else if (Strcmp(encoding_name, "koi8-r")==0)
- *cvt_rtrn = cvt_Koi8_r;
- else if (Strcmp(encoding_name, "koi8-u")==0)
- *cvt_rtrn = cvt_Koi8_u;
- /* other codesets go here */
- else *cvt_rtrn = cvt_latin1;
- return 1;
- }
- *cvt_rtrn= cvt_latin1;
+ if ( !cvt_rtrn ) return 0;
+
+ cvt_rtrn->KSToMB = _XkbKSToKnownSet;
+ cvt_rtrn->KSToMBPriv = (XPointer) _XimGetLocaleCode(encoding_name, NULL);
+ cvt_rtrn->MBToKS = _XkbKnownSetToKS;
+ cvt_rtrn->MBToKSPriv = NULL;
+ cvt_rtrn->KSToUpper = __XkbDefaultToUpper;
return 1;
}