1
/* $Xorg: KeysymStr.c,v 1.5 2001/02/09 02:03:34 xorgcvs Exp $ */
5
Copyright 1990, 1998 The Open Group
7
Permission to use, copy, modify, distribute, and sell this software and its
8
documentation for any purpose is hereby granted without fee, provided that
9
the above copyright notice appear in all copies and that both that
10
copyright notice and this permission notice appear in supporting
13
The above copyright notice and this permission notice shall be included in
14
all copies or substantial portions of the Software.
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
Except as contained in this notice, the name of The Open Group shall not be
24
used in advertising or otherwise to promote the sale, use or other dealings
25
in this Software without prior written authorization from The Open Group.
28
/* $XFree86: xc/lib/X11/KeysymStr.c,v 3.8 2001/12/14 19:54:02 dawes Exp $ */
31
#include <X11/Xresource.h>
32
#include <X11/keysymdef.h>
34
#include <stdio.h> /* sprintf */
36
typedef unsigned long Signature;
39
#include "ks_tables.h"
41
extern XrmDatabase _XInitKeysymDB();
42
extern const unsigned char _XkeyTable[];
45
typedef struct _GRNData {
47
XrmRepresentation type;
51
#if NeedFunctionPrototypes
53
static Bool SameValue(
55
XrmBindingList bindings,
57
XrmRepresentation* type,
62
static Bool SameValue(db, bindings, quarks, type, value, data)
64
XrmBindingList bindings;
66
XrmRepresentation *type;
71
GRNData *gd = (GRNData *)data;
73
if ((*type == gd->type) && (value->size == gd->value->size) &&
74
!strncmp((char *)value->addr, (char *)gd->value->addr, value->size))
76
gd->name = XrmQuarkToString(*quarks); /* XXX */
82
char *XKeysymToString(ks)
88
const unsigned char *entry;
89
unsigned char val1, val2;
92
if (!ks || (ks & ((unsigned long) ~0x1fffffff)) != 0)
93
return ((char *)NULL);
94
if (ks == XK_VoidSymbol)
103
while ((idx = hashKeysym[i]))
105
entry = &_XkeyTable[idx];
106
if ((entry[0] == val1) && (entry[1] == val2))
107
return ((char *)entry + 2);
116
if ((keysymdb = _XInitKeysymDB()))
120
XrmQuark empty = NULLQUARK;
123
sprintf(buf, "%lX", ks);
124
resval.addr = (XPointer)buf;
125
resval.size = strlen(buf) + 1;
126
data.name = (char *)NULL;
127
data.type = XrmPermStringToQuark("String");
128
data.value = &resval;
129
(void)XrmEnumerateDatabase(keysymdb, &empty, &empty, XrmEnumAllLevels,
130
SameValue, (XPointer)&data);
134
if ((ks & 0xff000000) == 0x01000000){
135
KeySym val = ks & 0xffffff;
153
s[i] = 'A'+ val1 - 10;
158
return ((char *) NULL);