Re: XIM_STR_CONVERSION_REPLY message is strange

David Dawes <[email protected]>
Newsgroups gmane.comp.xfree86.internationalization
Message-ID <[email protected]>
On Sat, Dec 27, 2003 at 01:10:31AM +0900, Choe Hwanjin wrote:
>Hello,
>
>I have a question about XIM_STR_CONVERSION_REPLY message.
>On XIM spec, XIM_STR_CONVERSION_REPLY is defined as:
>
>    2  CARD16            input-method-ID
>    2  CARD16            input-context-ID
>    4  CARD32            XIMStringConversionFeedback
>       XIMSTRCONVTEXT    XIMStringConversionText

XIMSTRCONVTEXT is defined to include a CARD16 XIMStringConversionFeedback
too, so the separate field above looks redundant.

>but xfree86 source does not conform to this.
>xc/lib/X11/imCallbk.c:394 is :
>
>        _XimSetHeader((XPointer)buf, XIM_STR_CONVERSION_REPLY, 0, &buf_len);
>        buf_len -= XIM_HEADER_SIZE; /* added by _XimSetHeader (HACK) */
>        p = XIM_HEADER_SIZE;
>        *(CARD16*)&buf[p] = (CARD16)im->private.proto.imid; p += sz_CARD16;
>        *(CARD16*)&buf[p] = (CARD16)ic->private.proto.icid; p += sz_CARD16;
>        *(CARD16*)&buf[p] = (CARD16)cbrec.text->length; p += sz_CARD16;
>        ~~~~~~~~~~~~~~~~~
>               +----> this is not XIMStringConversionFeedback
>
>        memcpy(&buf[p],&cbrec.text->string.mbs,length_in_bytes);
>        p += length_in_bytes;
>        *(CARD16*)&buf[p] = (CARD16)(sz_CARD32*cbrec.text->length);
>        p += XIM_PAD(2);
>        for (i = 0; i < (int)cbrec.text->length; i++) {
>            *(CARD32*)&buf[p] = (CARD32)cbrec.text->feedback[i];
>            p += sz_CARD32;
>        }

I'm not sure if the buffer length is calculated correctly either.

>On the other hand, IMdkit comform to XIM spec, it define structure for 
>XIM_STR_CONVERSION_REPLY as:
>
>xim_externaldef XimFrameRec str_conversion_reply_fr[] =
>{
>    _FRAME(BIT16),              /* input-method-ID */
>    _FRAME(BIT16),              /* input-context-ID */
>    _FRAME(BIT32),              /* XIMStringConversionFeedback */
>    _FRAME(BIT16),              /* length of the retrieved string */
>    _FRAME(BARRAY),             /* retrieved string */
>    _PAD4(2),
>    _BYTE_COUNTER(BIT16, 2),    /* number of feedback array */
>    _PAD4(1),
>    _FRAME(ITER),               /* feedback array */
>    _FRAME(BIT32),
>    _FRAME(EOL),
>};
>
>Which is right?

That's a good question.  What do working XIM servers expect?

David
-- 
David Dawes                                     X-Oz Technologies
www.XFree86.org/~dawes                          www.x-oz.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.