CursorName.c revision 6c321187
1/* $Xorg: CursorName.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */
2
3/*
4
5Copyright 1989, 1998  The Open Group
6
7Permission to use, copy, modify, distribute, and sell this software and its
8documentation for any purpose is hereby granted without fee, provided that
9the above copyright notice appear in all copies and that both that
10copyright notice and this permission notice appear in supporting
11documentation.
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
19OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23Except as contained in this notice, the name of The Open Group shall not be
24used in advertising or otherwise to promote the sale, use or other dealings
25in this Software without prior written authorization from The Open Group.
26
27*/
28/* $XFree86: xc/lib/Xmu/CursorName.c,v 3.7tsi Exp $ */
29
30#ifdef HAVE_CONFIG_H
31#include <config.h>
32#endif
33#include <X11/Xmu/CharSet.h>
34#include <X11/Xmu/CurUtil.h>
35#include <X11/cursorfont.h>
36#include <string.h>
37
38int
39XmuCursorNameToIndex(_Xconst char *name)
40{
41    static _Xconst struct _CursorName {
42	_Xconst char	*name;
43	unsigned int	shape;
44    } cursor_names[] = {
45			{"x_cursor",		XC_X_cursor},
46			{"arrow",		XC_arrow},
47			{"based_arrow_down",	XC_based_arrow_down},
48			{"based_arrow_up",	XC_based_arrow_up},
49			{"boat",		XC_boat},
50			{"bogosity",		XC_bogosity},
51			{"bottom_left_corner",	XC_bottom_left_corner},
52			{"bottom_right_corner",	XC_bottom_right_corner},
53			{"bottom_side",		XC_bottom_side},
54			{"bottom_tee",		XC_bottom_tee},
55			{"box_spiral",		XC_box_spiral},
56			{"center_ptr",		XC_center_ptr},
57			{"circle",		XC_circle},
58			{"clock",		XC_clock},
59			{"coffee_mug",		XC_coffee_mug},
60			{"cross",		XC_cross},
61			{"cross_reverse",	XC_cross_reverse},
62			{"crosshair",		XC_crosshair},
63			{"diamond_cross",	XC_diamond_cross},
64			{"dot",			XC_dot},
65			{"dotbox",		XC_dotbox},
66			{"double_arrow",	XC_double_arrow},
67			{"draft_large",		XC_draft_large},
68			{"draft_small",		XC_draft_small},
69			{"draped_box",		XC_draped_box},
70			{"exchange",		XC_exchange},
71			{"fleur",		XC_fleur},
72			{"gobbler",		XC_gobbler},
73			{"gumby",		XC_gumby},
74			{"hand1",		XC_hand1},
75			{"hand2",		XC_hand2},
76			{"heart",		XC_heart},
77			{"icon",		XC_icon},
78			{"iron_cross",		XC_iron_cross},
79			{"left_ptr",		XC_left_ptr},
80			{"left_side",		XC_left_side},
81			{"left_tee",		XC_left_tee},
82			{"leftbutton",		XC_leftbutton},
83			{"ll_angle",		XC_ll_angle},
84			{"lr_angle",		XC_lr_angle},
85			{"man",			XC_man},
86			{"middlebutton",	XC_middlebutton},
87			{"mouse",		XC_mouse},
88			{"pencil",		XC_pencil},
89			{"pirate",		XC_pirate},
90			{"plus",		XC_plus},
91			{"question_arrow",	XC_question_arrow},
92			{"right_ptr",		XC_right_ptr},
93			{"right_side",		XC_right_side},
94			{"right_tee",		XC_right_tee},
95			{"rightbutton",		XC_rightbutton},
96			{"rtl_logo",		XC_rtl_logo},
97			{"sailboat",		XC_sailboat},
98			{"sb_down_arrow",	XC_sb_down_arrow},
99			{"sb_h_double_arrow",	XC_sb_h_double_arrow},
100			{"sb_left_arrow",	XC_sb_left_arrow},
101			{"sb_right_arrow",	XC_sb_right_arrow},
102			{"sb_up_arrow",		XC_sb_up_arrow},
103			{"sb_v_double_arrow",	XC_sb_v_double_arrow},
104			{"shuttle",		XC_shuttle},
105			{"sizing",		XC_sizing},
106			{"spider",		XC_spider},
107			{"spraycan",		XC_spraycan},
108			{"star",		XC_star},
109			{"target",		XC_target},
110			{"tcross",		XC_tcross},
111			{"top_left_arrow",	XC_top_left_arrow},
112			{"top_left_corner",	XC_top_left_corner},
113			{"top_right_corner",	XC_top_right_corner},
114			{"top_side",		XC_top_side},
115			{"top_tee",		XC_top_tee},
116			{"trek",		XC_trek},
117			{"ul_angle",		XC_ul_angle},
118			{"umbrella",		XC_umbrella},
119			{"ur_angle",		XC_ur_angle},
120			{"watch",		XC_watch},
121			{"xterm",		XC_xterm},
122    };
123#define NUM_CURSOR_NAMES    (sizeof (cursor_names) / sizeof (cursor_names[0]))
124    register _Xconst struct _CursorName *table;
125    register int i;
126    char tmp[40];
127
128    if (strlen (name) >= sizeof tmp) return -1;
129    XmuCopyISOLatin1Lowered (tmp, name);
130
131    for (i=0, table=cursor_names; i < NUM_CURSOR_NAMES; i++, table++ ) {
132	if (strcmp(tmp, table->name) == 0) return table->shape;
133    }
134
135    return -1;
136}
137
138
139
140
141
142