| 1 |
/****************************************************************** |
| 2 |
|
| 3 |
Copyright 1993, 1994 by FUJITSU LIMITED |
| 4 |
|
| 5 |
Permission to use, copy, modify, distribute, and sell this software |
| 6 |
and its documentation for any purpose is hereby granted without fee, |
| 7 |
provided that the above copyright notice appear in all copies and |
| 8 |
that both that copyright notice and this permission notice appear |
| 9 |
in supporting documentation, and that the name of FUJITSU LIMITED |
| 10 |
not be used in advertising or publicity pertaining to distribution |
| 11 |
of the software without specific, written prior permission. |
| 12 |
FUJITSU LIMITED makes no representations about the suitability of |
| 13 |
this software for any purpose. |
| 14 |
It is provided "as is" without express or implied warranty. |
| 15 |
|
| 16 |
FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, |
| 17 |
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO |
| 18 |
EVENT SHALL FUJITSU LIMITED BE LIABLE FOR ANY SPECIAL, INDIRECT OR |
| 19 |
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF |
| 20 |
USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR |
| 21 |
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 22 |
PERFORMANCE OF THIS SOFTWARE. |
| 23 |
|
| 24 |
Author: Takashi Fujiwara FUJITSU LIMITED |
| 25 |
[email protected] |
| 26 |
|
| 27 |
******************************************************************/ |
| 28 |
|
| 29 |
#ifdef HAVE_CONFIG_H |
| 30 |
#include <config.h> |
| 31 |
#endif |
| 32 |
#include <nx-X11/Xlib.h> |
| 33 |
#include "Xlibint.h" |
| 34 |
#include "Xutil.h" |
| 35 |
#include "Xlcint.h" |
| 36 |
#include "Ximint.h" |
| 37 |
|
| 38 |
|
| 39 |
Bool |
| 40 |
_XimRegProtoIntrCallback( |
| 41 |
Xim im, |
| 42 |
CARD16 major_code, |
| 43 |
CARD16 minor_code, |
| 44 |
Bool (*proc)( |
| 45 |
Xim, INT16, XPointer, XPointer |
| 46 |
), |
| 47 |
|
| 48 |
XPointer call_data) |
| 49 |
{ |
| 50 |
XimProtoIntrRec *rec; |
| 51 |
|
| 52 |
if (!(rec = Xmalloc(sizeof(XimProtoIntrRec)))) |
| 53 |
return False; |
| 54 |
rec->func = proc; |
| 55 |
rec->major_code = major_code; |
| 56 |
rec->minor_code = minor_code; |
| 57 |
rec->call_data = call_data; |
| 58 |
rec->next = im->private.proto.intrproto; |
| 59 |
im->private.proto.intrproto = rec; |
| 60 |
return True; |
| 61 |
} |
| 62 |
|
| 63 |
void |
| 64 |
_XimFreeProtoIntrCallback(Xim im) |
| 65 |
{ |
| 66 |
register XimProtoIntrRec *rec, *next; |
| 67 |
|
| 68 |
for (rec = im->private.proto.intrproto; rec;) { |
| 69 |
next = rec->next; |
| 70 |
Xfree(rec); |
| 71 |
rec = next; |
| 72 |
} |
| 73 |
im->private.proto.intrproto = NULL; |
| 74 |
return; |
| 75 |
} |
| 76 |
|
| 77 |
static Bool |
| 78 |
_XimTransportIntr( |
| 79 |
Xim im, |
| 80 |
INT16 len, |
| 81 |
XPointer data, |
| 82 |
XPointer call_data) |
| 83 |
{ |
| 84 |
Xim call_im = (Xim)call_data; |
| 85 |
XimProtoIntrRec *rec = call_im->private.proto.intrproto; |
| 86 |
CARD8 major_opcode = *((CARD8 *)data); |
| 87 |
CARD8 minor_opcode = *((CARD8 *)data + 1); |
| 88 |
|
| 89 |
for (; rec; rec = rec->next) { |
| 90 |
if ((major_opcode == (CARD8)rec->major_code) |
| 91 |
&& (minor_opcode == (CARD8)rec->minor_code)) |
| 92 |
if ((*rec->func)(call_im, len, data, rec->call_data)) |
| 93 |
return True; |
| 94 |
} |
| 95 |
return False; |
| 96 |
} |
| 97 |
|
| 98 |
Bool |
| 99 |
_XimDispatchInit(Xim im) |
| 100 |
{ |
| 101 |
if (_XimRegisterDispatcher(im, _XimTransportIntr, (XPointer)im)) |
| 102 |
return True; |
| 103 |
return False; |
| 104 |
} |