| 1 |
/* |
| 2 |
* Copyright 1991 by the Open Software Foundation |
| 3 |
* Copyright 1993, 1994 by the Sony Corporation |
| 4 |
* |
| 5 |
* Permission to use, copy, modify, distribute, and sell this software and its |
| 6 |
* documentation for any purpose is hereby granted without fee, provided that |
| 7 |
* the above copyright notice appear in all copies and that both that |
| 8 |
* copyright notice and this permission notice appear in supporting |
| 9 |
* documentation, and that the names of Open Software Foundation and |
| 10 |
* Sony Corporation not be used in advertising or publicity pertaining to |
| 11 |
* distribution of the software without specific, written prior permission. |
| 12 |
* Open Software Foundation and Sony Corporation make no |
| 13 |
* representations about the suitability of this software for any purpose. |
| 14 |
* It is provided "as is" without express or implied warranty. |
| 15 |
* |
| 16 |
* OPEN SOFTWARE FOUNDATION AND SONY CORPORATION DISCLAIM ALL |
| 17 |
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED |
| 18 |
* WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL OPEN |
| 19 |
* SOFTWARE FOUNDATIONN OR SONY CORPORATION BE LIABLE FOR ANY SPECIAL, |
| 20 |
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM |
| 21 |
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE |
| 22 |
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 23 |
* PERFORMANCE OF THIS SOFTWARE. |
| 24 |
* |
| 25 |
* M. Collins OSF |
| 26 |
* Makoto Wakamatsu Sony Corporation |
| 27 |
*/ |
| 28 |
/* |
| 29 |
|
| 30 |
Copyright 1991, 1998 The Open Group |
| 31 |
|
| 32 |
Permission to use, copy, modify, distribute, and sell this software and its |
| 33 |
documentation for any purpose is hereby granted without fee, provided that |
| 34 |
the above copyright notice appear in all copies and that both that |
| 35 |
copyright notice and this permission notice appear in supporting |
| 36 |
documentation. |
| 37 |
|
| 38 |
The above copyright notice and this permission notice shall be included |
| 39 |
in all copies or substantial portions of the Software. |
| 40 |
|
| 41 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 42 |
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 43 |
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 44 |
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 45 |
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 46 |
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 47 |
OTHER DEALINGS IN THE SOFTWARE. |
| 48 |
|
| 49 |
Except as contained in this notice, the name of The Open Group shall |
| 50 |
not be used in advertising or otherwise to promote the sale, use or |
| 51 |
other dealings in this Software without prior written authorization |
| 52 |
from The Open Group. |
| 53 |
|
| 54 |
*/ |
| 55 |
|
| 56 |
|
| 57 |
#ifdef HAVE_CONFIG_H |
| 58 |
#include <config.h> |
| 59 |
#endif |
| 60 |
#include "Xlibint.h" |
| 61 |
#include "Xlcint.h" |
| 62 |
|
| 63 |
/* |
| 64 |
* Compile the resource name. (resource_name ---> xrm_name) |
| 65 |
*/ |
| 66 |
void |
| 67 |
_XIMCompileResourceList(XIMResourceList res, unsigned int num_res) |
| 68 |
{ |
| 69 |
register unsigned int count; |
| 70 |
|
| 71 |
for (count = 0; count < num_res; res++, count++) { |
| 72 |
res->xrm_name = XrmStringToQuark(res->resource_name); |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
void |
| 77 |
_XCopyToArg(XPointer src, XPointer *dst, unsigned int size) |
| 78 |
{ |
| 79 |
if (!*dst) { |
| 80 |
union { |
| 81 |
long longval; |
| 82 |
#ifdef LONG64 |
| 83 |
int intval; |
| 84 |
#endif |
| 85 |
short shortval; |
| 86 |
char charval; |
| 87 |
char* charptr; |
| 88 |
XPointer ptr; |
| 89 |
} u; |
| 90 |
if (size <= sizeof(XPointer)) { |
| 91 |
memcpy((char *)&u, (char *)src, (int)size); |
| 92 |
if (size == sizeof(long)) *dst = (XPointer)u.longval; |
| 93 |
#ifdef LONG64 |
| 94 |
else if (size == sizeof(int)) *dst = (XPointer)(long)u.intval; |
| 95 |
#endif |
| 96 |
else if (size == sizeof(short)) *dst = (XPointer)(long)u.shortval; |
| 97 |
else if (size == sizeof(char)) *dst = (XPointer)(long)u.charval; |
| 98 |
else if (size == sizeof(char*)) *dst = (XPointer)u.charptr; |
| 99 |
else if (size == sizeof(XPointer)) *dst = (XPointer)u.ptr; |
| 100 |
else memcpy( (char*)dst, (char*)src, (int)size ); |
| 101 |
} else { |
| 102 |
memcpy( (char*)dst, (char*)src, (int)size ); |
| 103 |
} |
| 104 |
} else { |
| 105 |
memcpy( (char*)*dst, (char*)src, (int)size ); |
| 106 |
} |
| 107 |
} |
| 108 |
|
| 109 |
/* |
| 110 |
* Connects to an input method matching current locale specification, creates |
| 111 |
* a XIM object and return a pointer the newly created XIM back to the caller. |
| 112 |
*/ |
| 113 |
|
| 114 |
XIM |
| 115 |
XOpenIM(Display *display, XrmDatabase rdb, char *res_name, char *res_class) |
| 116 |
{ |
| 117 |
XLCd lcd = _XOpenLC( (char *)NULL ); |
| 118 |
|
| 119 |
if( !lcd ) |
| 120 |
return( (XIM)NULL ); |
| 121 |
return (*lcd->methods->open_im) (lcd, display, rdb, res_name, res_class); |
| 122 |
} |
| 123 |
|
| 124 |
/* |
| 125 |
* Close the connection to the input manager, and free the XIM structure |
| 126 |
*/ |
| 127 |
Status |
| 128 |
XCloseIM(XIM im) |
| 129 |
{ |
| 130 |
Status s; |
| 131 |
XIC ic; |
| 132 |
XLCd lcd = im->core.lcd; |
| 133 |
|
| 134 |
s = (im->methods->close) (im); |
| 135 |
for (ic = im->core.ic_chain; ic; ic = ic->core.next) |
| 136 |
ic->core.im = (XIM)NULL; |
| 137 |
Xfree (im); |
| 138 |
_XCloseLC (lcd); |
| 139 |
return (s); |
| 140 |
} |
| 141 |
|
| 142 |
/* |
| 143 |
* Return the Display associated with the input method. |
| 144 |
*/ |
| 145 |
Display * |
| 146 |
XDisplayOfIM(XIM im) |
| 147 |
{ |
| 148 |
return im->core.display; |
| 149 |
} |
| 150 |
|
| 151 |
/* |
| 152 |
* Return the Locale associated with the input method. |
| 153 |
*/ |
| 154 |
char * |
| 155 |
XLocaleOfIM(XIM im) |
| 156 |
{ |
| 157 |
return im->core.lcd->core->name; |
| 158 |
} |
| 159 |
|
| 160 |
/* |
| 161 |
* Register to a input method instantiation callback to prepare the |
| 162 |
* on-demand input method instantiation. |
| 163 |
*/ |
| 164 |
Bool |
| 165 |
XRegisterIMInstantiateCallback( |
| 166 |
Display *display, |
| 167 |
XrmDatabase rdb, |
| 168 |
char *res_name, |
| 169 |
char *res_class, |
| 170 |
XIDProc callback, |
| 171 |
XPointer client_data) |
| 172 |
{ |
| 173 |
XLCd lcd = _XOpenLC( (char *)NULL ); |
| 174 |
|
| 175 |
if( !lcd ) |
| 176 |
return( False ); |
| 177 |
return( (*lcd->methods->register_callback)( lcd, display, rdb, res_name, |
| 178 |
res_class, callback, |
| 179 |
client_data ) ); |
| 180 |
} |
| 181 |
|
| 182 |
/* |
| 183 |
* Unregister to a input method instantiation callback. |
| 184 |
*/ |
| 185 |
Bool |
| 186 |
XUnregisterIMInstantiateCallback( |
| 187 |
Display *display, |
| 188 |
XrmDatabase rdb, |
| 189 |
char *res_name, |
| 190 |
char *res_class, |
| 191 |
XIDProc callback, |
| 192 |
XPointer client_data) |
| 193 |
{ |
| 194 |
XLCd lcd = _XlcCurrentLC(); |
| 195 |
|
| 196 |
if( !lcd ) |
| 197 |
return( False ); |
| 198 |
if( lcd->methods->unregister_callback == NULL ) |
| 199 |
return( False ); |
| 200 |
return( (*lcd->methods->unregister_callback)( lcd, display, rdb, res_name, |
| 201 |
res_class, callback, |
| 202 |
client_data ) ); |
| 203 |
} |
| 204 |
|