3 Copyright 1986, 1998 The Open Group
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
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
34 register Display *dpy,
39 _Xconst XChar2b *string,
43 register xPolyText16Req *req;
50 GetReq (PolyText16, req);
57 Datalength += SIZEOF(xTextElt) * ((length + 253) / 254) + (length << 1);
60 req->length += (Datalength + 3)>>2; /* convert to number of 32-bit words */
64 * If the entire request does not fit into the remaining space in the
65 * buffer, flush the buffer first. If the request does fit into the
66 * empty buffer, then we won't have to flush it at the end to keep
67 * the buffer 32-bit aligned.
70 if (dpy->bufptr + Datalength > dpy->bufmax)
75 int PartialNChars = length;
76 register xTextElt *elt;
77 XChar2b *CharacterOffset = (XChar2b *)string;
79 while(PartialNChars > 254)
81 nbytes = 254 * 2 + SIZEOF(xTextElt);
82 BufAlloc (xTextElt *, elt, nbytes);
85 #if defined(MUSTCOPY) || defined(MUSTCOPY2B)
88 register unsigned char *cp;
89 for (i = 0, cp = ((unsigned char *)elt) + 2; i < 254; i++) {
90 *cp++ = CharacterOffset[i].byte1;
91 *cp++ = CharacterOffset[i].byte2;
95 memcpy (((char *) elt) + 2, (char *)CharacterOffset, 254 * 2);
97 PartialNChars = PartialNChars - 254;
98 CharacterOffset += 254;
103 nbytes = PartialNChars * 2 + SIZEOF(xTextElt);
104 BufAlloc (xTextElt *, elt, nbytes);
106 elt->len = PartialNChars;
107 #if defined(MUSTCOPY) || defined(MUSTCOPY2B)
110 register unsigned char *cp;
111 for (i = 0, cp = ((unsigned char *)elt) + 2; i < PartialNChars;
113 *cp++ = CharacterOffset[i].byte1;
114 *cp++ = CharacterOffset[i].byte2;
118 memcpy(((char *)elt) + 2, (char *)CharacterOffset, PartialNChars * 2);
123 /* Pad request out to a 32-bit boundary */
125 if (Datalength &= 3) {
128 * BufAlloc is a macro that uses its last argument more than
129 * once, otherwise I'd write "BufAlloc (char *, pad, 4-length)"
131 length = 4 - Datalength;
132 BufAlloc (char *, pad, length);
134 * if there are 3 bytes of padding, the first byte MUST be 0
135 * so the pad bytes aren't mistaken for a final xTextElt
141 * If the buffer pointer is not now pointing to a 32-bit boundary,
142 * we must flush the buffer so that it does point to a 32-bit boundary
143 * at the end of this routine.
146 if ((dpy->bufptr - dpy->buffer) & 3)