Annotation of researchv9/X11/src/X.V11R1/lib/X/XText16.c, revision 1.1

1.1     ! root        1: #include "copyright.h"
        !             2: 
        !             3: /* $Header: XText16.c,v 11.15 87/08/29 13:46:55 newman Locked $ */
        !             4: /* Copyright    Massachusetts Institute of Technology    1986  */
        !             5: 
        !             6: #include "Xlibint.h"
        !             7: 
        !             8: XDrawString16(dpy, d, gc, x, y, string, length)
        !             9:     register Display *dpy;
        !            10:     Drawable d;
        !            11:     GC gc;
        !            12:     int x, y;
        !            13:     XChar2b *string;
        !            14:     int length;
        !            15: {   
        !            16:     int Datalength = 0;
        !            17:     register xPolyText16Req *req;
        !            18: 
        !            19:     if (length <= 0)
        !            20:        return;
        !            21: 
        !            22:     LockDisplay(dpy);
        !            23:     FlushGC(dpy, gc);
        !            24:     GetReq (PolyText16, req);
        !            25:     req->drawable = d;
        !            26:     req->gc = gc->gid;
        !            27:     req->x = x;
        !            28:     req->y = y;
        !            29: 
        !            30: 
        !            31:     Datalength += sizeof(xTextElt) * ((length + 253) / 254) + (length << 1);
        !            32: 
        !            33: 
        !            34:     req->length += (Datalength + 3)>>2;  /* convert to number of 32-bit words */
        !            35: 
        !            36: 
        !            37:     /* 
        !            38:      * If the entire request does not fit into the remaining space in the
        !            39:      * buffer, flush the buffer first.   If the request does fit into the
        !            40:      * empty buffer, then we won't have to flush it at the end to keep
        !            41:      * the buffer 32-bit aligned. 
        !            42:      */
        !            43: 
        !            44:     if (dpy->bufptr + Datalength > dpy->bufmax)
        !            45:        _XFlush (dpy);
        !            46: 
        !            47:     {
        !            48:        int nbytes;
        !            49:        int PartialNChars = length;
        !            50:         register xTextElt *elt;
        !            51:        XChar2b *CharacterOffset = string;
        !            52: 
        !            53:        while(PartialNChars > 254)
        !            54:         {
        !            55:            nbytes = 254 * 2 + sizeof(xTextElt);
        !            56:            BufAlloc (xTextElt *, elt, nbytes);
        !            57:            elt->delta = 0;
        !            58:            elt->len = 254;
        !            59:             bcopy ((char *)CharacterOffset, (char *) (elt + 1), 254 * 2);
        !            60:            PartialNChars = PartialNChars - 254;
        !            61:            CharacterOffset += 254;
        !            62:        }
        !            63:            
        !            64:         if (PartialNChars)
        !            65:         {
        !            66:            nbytes = PartialNChars * 2  + sizeof(xTextElt);
        !            67:            BufAlloc (xTextElt *, elt, nbytes); 
        !            68:            elt->delta = 0;
        !            69:            elt->len = PartialNChars;
        !            70:             bcopy ((char *)CharacterOffset, (char *) (elt + 1), PartialNChars * 2);
        !            71:         }
        !            72:     }
        !            73: 
        !            74:     /* Pad request out to a 32-bit boundary */
        !            75: 
        !            76:     if (Datalength &= 3) {
        !            77:        char *pad;
        !            78:        /* 
        !            79:         * BufAlloc is a macro that uses its last argument more than
        !            80:         * once, otherwise I'd write "BufAlloc (char *, pad, 4-length)" 
        !            81:         */
        !            82:        length = 4 - Datalength;
        !            83:        BufAlloc (char *, pad, length);
        !            84:        /* 
        !            85:         * if there are 3 bytes of padding, the first byte MUST be 0
        !            86:         * so the pad bytes aren't mistaken for a final xTextElt 
        !            87:         */
        !            88:        *pad = 0;
        !            89:         }
        !            90: 
        !            91:     /* 
        !            92:      * If the buffer pointer is not now pointing to a 32-bit boundary,
        !            93:      * we must flush the buffer so that it does point to a 32-bit boundary
        !            94:      * at the end of this routine. 
        !            95:      */
        !            96: 
        !            97:     if ((dpy->bufptr - dpy->buffer) & 3)
        !            98:        _XFlush (dpy);
        !            99:     UnlockDisplay(dpy);
        !           100:     SyncHandle();
        !           101:     return;
        !           102: }
        !           103: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.