1 /******************************************************************
3 Copyright 1994, 1995 by Sun Microsystems, Inc.
4 Copyright 1993, 1994 by Hewlett-Packard Company
6 Permission to use, copy, modify, distribute, and sell this software
7 and its documentation for any purpose is hereby granted without fee,
8 provided that the above copyright notice appear in all copies and
9 that both that copyright notice and this permission notice appear
10 in supporting documentation, and that the name of Sun Microsystems, Inc.
11 and Hewlett-Packard not be used in advertising or publicity pertaining to
12 distribution of the software without specific, written prior permission.
13 Sun Microsystems, Inc. and Hewlett-Packard make no representations about
14 the suitability of this software for any purpose. It is provided "as is"
15 without express or implied warranty.
17 SUN MICROSYSTEMS INC. AND HEWLETT-PACKARD COMPANY DISCLAIMS ALL
18 WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
20 SUN MICROSYSTEMS, INC. AND HEWLETT-PACKARD COMPANY BE LIABLE FOR ANY
21 SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
22 RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
23 CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
24 IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
26 Author: Hidetoshi Tajima(tajima@Eng.Sun.COM) Sun Microsystems, Inc.
28 This version tidied and debugged by Steve Underwood May 1999
30 ******************************************************************/
38 #define Va_start(a,b) va_start(a,b)
40 static void _IMCountVaList(va_list var, int *total_count)
46 for (attr = va_arg (var, char*); attr; attr = va_arg (var, char*))
48 (void)va_arg (var, XIMArg *);
54 static void _IMVaToNestedList(va_list var, int max_count, XIMArg **args_return)
61 *args_return = (XIMArg *) NULL;
66 args = (XIMArg *) malloc ((unsigned) (max_count + 1)*sizeof (XIMArg));
72 for (attr = va_arg (var, char*); attr; attr = va_arg (var, char *))
75 args->value = va_arg (var, XPointer);
79 args->name = (char*)NULL;
82 static char *_FindModifiers (XIMArg *args)
88 if (strcmp (args->name, IMModifiers) == 0)
90 modifiers = args->value;
103 XIMS _GetIMS (char *modifiers)
106 extern IMMethodsRec Xi18n_im_methods;
108 if ((ims = (XIMS) malloc (sizeof (XIMProtocolRec))) == (XIMS) NULL)
109 return ((XIMS) NULL);
111 memset ((void *) ims, 0, sizeof (XIMProtocolRec));
113 if (modifiers == NULL
117 strcmp (modifiers, "Xi18n") == 0)
119 ims->methods = &Xi18n_im_methods;
127 XIMS IMOpenIM (Display *display, ...)
136 Va_start (var, display);
137 _IMCountVaList (var, &total_count);
140 Va_start (var, display);
141 _IMVaToNestedList (var, total_count, &args);
144 modifiers = _FindModifiers (args);
146 ims = _GetIMS (modifiers);
147 if (ims == (XIMS) NULL)
151 ims->core.display = display;
153 ims->protocol = (*ims->methods->setup) (display, args);
155 if (ims->protocol == (void *) NULL)
161 ret = (ims->methods->openIM) (ims);
171 Status IMCloseIM (XIMS ims)
173 (ims->methods->closeIM) (ims);