From 3562e78743202e43aec8727005182a2558117eca Mon Sep 17 00:00:00 2001 From: marha Date: Sun, 28 Jun 2009 22:07:26 +0000 Subject: Checked in the following released items: xkeyboard-config-1.4.tar.gz ttf-bitstream-vera-1.10.tar.gz font-alias-1.0.1.tar.gz font-sun-misc-1.0.0.tar.gz font-sun-misc-1.0.0.tar.gz font-sony-misc-1.0.0.tar.gz font-schumacher-misc-1.0.0.tar.gz font-mutt-misc-1.0.0.tar.gz font-misc-misc-1.0.0.tar.gz font-misc-meltho-1.0.0.tar.gz font-micro-misc-1.0.0.tar.gz font-jis-misc-1.0.0.tar.gz font-isas-misc-1.0.0.tar.gz font-dec-misc-1.0.0.tar.gz font-daewoo-misc-1.0.0.tar.gz font-cursor-misc-1.0.0.tar.gz font-arabic-misc-1.0.0.tar.gz font-winitzki-cyrillic-1.0.0.tar.gz font-misc-cyrillic-1.0.0.tar.gz font-cronyx-cyrillic-1.0.0.tar.gz font-screen-cyrillic-1.0.1.tar.gz font-xfree86-type1-1.0.1.tar.gz font-adobe-utopia-type1-1.0.1.tar.gz font-ibm-type1-1.0.0.tar.gz font-bitstream-type1-1.0.0.tar.gz font-bitstream-speedo-1.0.0.tar.gz font-bh-ttf-1.0.0.tar.gz font-bh-type1-1.0.0.tar.gz font-bitstream-100dpi-1.0.0.tar.gz font-bh-lucidatypewriter-100dpi-1.0.0.tar.gz font-bh-100dpi-1.0.0.tar.gz font-adobe-utopia-100dpi-1.0.1.tar.gz font-adobe-100dpi-1.0.0.tar.gz font-util-1.0.1.tar.gz font-bitstream-75dpi-1.0.0.tar.gz font-bh-lucidatypewriter-75dpi-1.0.0.tar.gz font-adobe-utopia-75dpi-1.0.1.tar.gz font-bh-75dpi-1.0.0.tar.gz bdftopcf-1.0.1.tar.gz font-adobe-75dpi-1.0.0.tar.gz mkfontscale-1.0.6.tar.gz openssl-0.9.8k.tar.gz bigreqsproto-1.0.2.tar.gz xtrans-1.2.2.tar.gz resourceproto-1.0.2.tar.gz inputproto-1.4.4.tar.gz compositeproto-0.4.tar.gz damageproto-1.1.0.tar.gz zlib-1.2.3.tar.gz xkbcomp-1.0.5.tar.gz freetype-2.3.9.tar.gz pthreads-w32-2-8-0-release.tar.gz pixman-0.12.0.tar.gz kbproto-1.0.3.tar.gz evieext-1.0.2.tar.gz fixesproto-4.0.tar.gz recordproto-1.13.2.tar.gz randrproto-1.2.2.tar.gz scrnsaverproto-1.1.0.tar.gz renderproto-0.9.3.tar.gz xcmiscproto-1.1.2.tar.gz fontsproto-2.0.2.tar.gz xextproto-7.0.3.tar.gz xproto-7.0.14.tar.gz libXdmcp-1.0.2.tar.gz libxkbfile-1.0.5.tar.gz libfontenc-1.0.4.tar.gz libXfont-1.3.4.tar.gz libX11-1.1.5.tar.gz libXau-1.0.4.tar.gz libxcb-1.1.tar.gz xorg-server-1.5.3.tar.gz --- libX11/modules/im/ximcp/imTransR.c | 304 +++++++++++++++++++++++++++++++++++++ 1 file changed, 304 insertions(+) create mode 100644 libX11/modules/im/ximcp/imTransR.c (limited to 'libX11/modules/im/ximcp/imTransR.c') diff --git a/libX11/modules/im/ximcp/imTransR.c b/libX11/modules/im/ximcp/imTransR.c new file mode 100644 index 000000000..5ca4a39c0 --- /dev/null +++ b/libX11/modules/im/ximcp/imTransR.c @@ -0,0 +1,304 @@ +/* $Xorg: imTransR.c,v 1.4 2000/08/17 19:45:16 cpqbld Exp $ */ +/****************************************************************** + + Copyright 1992 by Sun Microsystems, Inc. + Copyright 1992, 1993, 1994 by FUJITSU LIMITED + +Permission to use, copy, modify, distribute, and sell this software +and its documentation for any purpose is hereby granted without fee, +provided that the above copyright notice appear in all copies and +that both that copyright notice and this permission notice appear +in supporting documentation, and that the name of Sun Microsystems, Inc. +and FUJITSU LIMITED not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior permission. +Sun Microsystems, Inc. and FUJITSU LIMITED makes no representations about +the suitability of this software for any purpose. +It is provided "as is" without express or implied warranty. + +Sun Microsystems Inc. AND FUJITSU LIMITED DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS, IN NO EVENT SHALL Sun Microsystems, Inc. AND FUJITSU LIMITED +BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + + Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc. + Takashi Fujiwara FUJITSU LIMITED + fujiwara@a80.tech.yk.fujitsu.co.jp + +******************************************************************/ +/* $XFree86: xc/lib/X11/imTransR.c,v 3.6 2003/04/17 02:39:56 dawes Exp $ */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include "Xlibint.h" +#include "Xlcint.h" +#include "XimTrInt.h" +#include "Ximint.h" + +Public TransportSW _XimTransportRec[] = { + { "X", _XimXConf }, /* 1st entry must be X. + This will be a fallback */ +#ifdef TCPCONN + { "tcp", _XimTransConf }, /* use X transport lib */ +#endif /* TCPCONN */ +#if defined(UNIXCONN) || defined(LOCALCONN) + { "local", _XimTransConf }, /* use X transport lib */ +#endif /* UNIXCONN */ +#ifdef DNETCONN + { "dnet", _XimTransConf }, /* use X transport lib */ +#endif /* DNETCONN */ +#ifdef STREAMSCONN + { "streams", _XimTransConf }, /* use X transport lib */ +#endif /* STREAMSCONN */ + { (char *)NULL, (Bool (*)(Xim, char *))NULL }, +}; + +Public Bool +_XimConnect(im) + Xim im; +{ + return im->private.proto.connect(im); +} + +Public Bool +_XimShutdown(im) + Xim im; +{ + return im->private.proto.shutdown(im); +} + +Public Bool +_XimWrite(Xim im, INT16 len, XPointer data) +{ + return im->private.proto.write(im, len, data); +} + +Private int +_CheckProtocolData( + Xim im, + char *recv_buf) +{ + int data_len; + + data_len = (int)(((*((CARD16 *)recv_buf + 1)) * 4) + XIM_HEADER_SIZE); + return data_len; +} + +Private int +_XimReadData( + Xim im, + INT16 *len, + XPointer buf, + int buf_size) +{ + char *hold_buf; + char *tmp; + int data_len; + int packet_size; + int ret_len; + register int i; + + if (buf_size < XIM_HEADER_SIZE) { + *len = (INT16)XIM_HEADER_SIZE; + return XIM_OVERFLOW; + } + + bzero(buf, buf_size); + packet_size = 0; + data_len = 0; + + if ((hold_buf = im->private.proto.hold_data)) { + data_len = im->private.proto.hold_data_len; + if (data_len >= XIM_HEADER_SIZE) { + packet_size = _CheckProtocolData(im, hold_buf); + if (packet_size > buf_size) { + *len = (INT16)packet_size; + return XIM_OVERFLOW; + } + if (packet_size <= data_len) { + memcpy(buf, hold_buf, packet_size); + for (i = packet_size; i < data_len; i++) { + if (hold_buf[i]) + break; + } + data_len -= i; + + if (data_len) { + if (!(tmp = (char *)Xmalloc(data_len))) { + return XIM_FALSE; + } + memcpy(tmp, &hold_buf[i], data_len); + im->private.proto.hold_data = tmp; + im->private.proto.hold_data_len = data_len; + } else { + im->private.proto.hold_data = 0; + im->private.proto.hold_data_len = 0; + } + Xfree(hold_buf); + *len = (INT16)packet_size; + return XIM_TRUE; + } + } + memcpy(buf, hold_buf, data_len); + buf_size -= data_len; + Xfree(hold_buf); + im->private.proto.hold_data = 0; + im->private.proto.hold_data_len = 0; + } + + if (!packet_size) { + while (data_len < XIM_HEADER_SIZE) { + if (!(im->private.proto.read(im, + (XPointer)&buf[data_len], buf_size, &ret_len))) { + return XIM_FALSE; + } + data_len += ret_len; + buf_size -= ret_len; + } + packet_size = _CheckProtocolData(im, buf); + } + + if (packet_size > buf_size) { + if (!(tmp = (char *)Xmalloc(data_len))) { + return XIM_FALSE; + } + memcpy(tmp, buf, data_len); + bzero(buf, data_len); + im->private.proto.hold_data = tmp; + im->private.proto.hold_data_len = data_len; + *len = (INT16)packet_size; + return XIM_OVERFLOW; + } + + while (data_len < packet_size) { + if (!(im->private.proto.read(im, + (XPointer)&buf[data_len], buf_size, &ret_len))) { + return XIM_FALSE; + } + data_len += ret_len; + buf_size -= ret_len; + } + + for (i = packet_size; i < data_len; i++) { + if (buf[i]) + break; + } + data_len -= i; + + if (data_len) { + if (!(tmp = (char *)Xmalloc(data_len))) { + return XIM_FALSE; + } + memcpy(tmp, &buf[i], data_len); + bzero(&buf[i], data_len); + im->private.proto.hold_data = tmp; + im->private.proto.hold_data_len = data_len; + } else { + im->private.proto.hold_data = 0; + im->private.proto.hold_data_len = 0; + } + *len = (INT16)packet_size; + return XIM_TRUE; +} + +Private Bool +_XimCallDispatcher( + Xim im, + INT16 len, + XPointer data) +{ + return im->private.proto.call_dispatcher(im, len, data); +} + +Public int +_XimRead(im, len, buf, buf_size, predicate, arg) + Xim im; + INT16 *len; + XPointer buf; + int buf_size; + Bool (*predicate)( + Xim, INT16, XPointer, XPointer + ); + XPointer arg; +{ + INT16 read_len; + int ret_code; + + for (;;) { + ret_code = _XimReadData(im, &read_len, buf, buf_size); + if(ret_code != XIM_TRUE) { + return ret_code; + } + if ((*predicate)(im, read_len, buf, arg)) + break; + if (_XimCallDispatcher(im, read_len, buf)) + continue; + _XimError(im, 0, XIM_BadProtocol, (INT16)0, (CARD16)0, (char *)NULL); + } + *len = read_len; + return True; +} + +Public Bool +_XimRegisterDispatcher( + Xim im, + Bool (*callback)( + Xim, INT16, XPointer, XPointer + ), + XPointer call_data) +{ + return im->private.proto.register_dispatcher(im, callback, call_data); +} + +Public void +_XimFlush(im) + Xim im; +{ + im->private.proto.flush(im); + return; +} + +Public Bool +_XimFilterWaitEvent(im) + Xim im; +{ + INT16 read_len; + CARD32 reply32[BUFSIZE/4]; + char *reply = (char *)reply32; + XPointer preply; + int buf_size; + int ret_code; + + buf_size = BUFSIZE; + ret_code = _XimReadData(im, &read_len, (XPointer)reply, buf_size); + if(ret_code == XIM_TRUE) { + preply = reply; + } else if(ret_code == XIM_OVERFLOW) { + if(read_len <= 0) { + preply = reply; + } else { + buf_size = (int)read_len; + preply = (XPointer)Xmalloc(buf_size); + ret_code = _XimReadData(im, &read_len, preply, buf_size); + if(ret_code != XIM_TRUE) { + if (preply != reply) + Xfree(preply); + return False; + } + } + } else { + return False; + } + if (_XimCallDispatcher(im, read_len, preply)) { + if(reply != preply) + Xfree(preply); + return True; + } + _XimError(im, 0, XIM_BadProtocol, (INT16)0, (CARD16)0, (char *)NULL); + if(reply != preply) + Xfree(preply); + return True; +} -- cgit v1.2.3