imDispch.c revision b4ee4795
1/****************************************************************** 2 3 Copyright 1993, 1994 by FUJITSU LIMITED 4 5Permission to use, copy, modify, distribute, and sell this software 6and its documentation for any purpose is hereby granted without fee, 7provided that the above copyright notice appear in all copies and 8that both that copyright notice and this permission notice appear 9in supporting documentation, and that the name of FUJITSU LIMITED 10not be used in advertising or publicity pertaining to distribution 11of the software without specific, written prior permission. 12FUJITSU LIMITED makes no representations about the suitability of 13this software for any purpose. 14It is provided "as is" without express or implied warranty. 15 16FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 17INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 18EVENT SHALL FUJITSU LIMITED BE LIABLE FOR ANY SPECIAL, INDIRECT OR 19CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 20USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 21OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 22PERFORMANCE OF THIS SOFTWARE. 23 24 Author: Takashi Fujiwara FUJITSU LIMITED 25 fujiwara@a80.tech.yk.fujitsu.co.jp 26 27******************************************************************/ 28 29#ifdef HAVE_CONFIG_H 30#include <config.h> 31#endif 32#include <X11/Xlib.h> 33#include "Xlibint.h" 34#include "Xutil.h" 35#include "Xlcint.h" 36#include "Ximint.h" 37 38 39Public 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 = (XimProtoIntrRec *)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 63Public 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 77Private 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 98Public Bool 99_XimDispatchInit(Xim im) 100{ 101 if (_XimRegisterDispatcher(im, _XimTransportIntr, (XPointer)im)) 102 return True; 103 return False; 104} 105