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

1.1     ! root        1: #include "copyright.h"
        !             2: 
        !             3: /* $Header: XFontNames.c,v 11.17 87/09/11 08:03:23 toddb Exp $ */
        !             4: /* Copyright    Massachusetts Institute of Technology    1986  */
        !             5: #define NEED_REPLIES
        !             6: #include "Xlibint.h"
        !             7: 
        !             8: char **XListFonts(dpy, pattern, maxNames, actualCount)
        !             9: register Display *dpy;
        !            10: char *pattern;  /* null-terminated */
        !            11: int maxNames;
        !            12: int *actualCount;      /* RETURN */
        !            13: {       
        !            14:     register long nbytes;
        !            15:     register int i;
        !            16:     register int length;
        !            17:     char **flist;
        !            18:     char *ch;
        !            19:     xListFontsReply rep;
        !            20:     register xListFontsReq *req;
        !            21: 
        !            22:     LockDisplay(dpy);
        !            23:     GetReq(ListFonts, req);
        !            24:     req->maxNames = maxNames;
        !            25:     nbytes = req->nbytes = strlen (pattern);;
        !            26:     req->length += (nbytes + 3) >> 2;
        !            27:     _XSend (dpy, pattern, nbytes);
        !            28:        /* use _XSend instead of Data, since following _XReply will flush buffer */
        !            29: 
        !            30:     (void) _XReply (dpy, (xReply *)&rep, 0, xFalse);
        !            31:     *actualCount = rep.nFonts;
        !            32:     if (*actualCount) {
        !            33:            flist = (char **)Xmalloc ((unsigned)rep.nFonts * sizeof(char *));
        !            34:            ch = (char *) Xmalloc((unsigned)(rep.length * 4) + 1);
        !            35:                /* +1 to leave room for last null-terminator */
        !            36:            _XReadPad (dpy, ch, (long)(rep.length * 4));
        !            37:            /*
        !            38:             * unpack into null terminated strings.
        !            39:             */
        !            40:            length = *ch;
        !            41:            for (i = 0; i < rep.nFonts; i++) {
        !            42:                flist[i] = ch + 1;  /* skip over length */
        !            43:                ch += length + 1;  /* find next length ... */
        !            44:                length = *ch;
        !            45:                *ch = '\0';  /* and replace with null-termination */
        !            46:            }
        !            47:        }
        !            48:     else flist = NULL;
        !            49:     UnlockDisplay(dpy);
        !            50:     SyncHandle();
        !            51:     return (flist);
        !            52: }
        !            53: 
        !            54: XFreeFontNames(list)
        !            55: char **list;
        !            56: {       
        !            57:        if (list != NULL) {
        !            58:                Xfree (list[0]-1);
        !            59:                Xfree ((char *)list);
        !            60:        }
        !            61: }

unix.superglobalmegacorp.com

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