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