⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xfontnames.c

📁 早期freebsd实现
💻 C
字号:
/* $XConsortium: XFontNames.c,v 11.26 92/03/03 14:21:22 rws Exp $ *//* Copyright    Massachusetts Institute of Technology    1986	*//*Permission to use, copy, modify, distribute, and sell this software and itsdocumentation for any purpose is hereby granted without fee, provided thatthe above copyright notice appear in all copies and that both thatcopyright notice and this permission notice appear in supportingdocumentation, and that the name of M.I.T. not be used in advertising orpublicity pertaining to distribution of the software without specific,written prior permission.  M.I.T. makes no representations about thesuitability of this software for any purpose.  It is provided "as is"without express or implied warranty.*/#define NEED_REPLIES#include "Xlibint.h"#if NeedFunctionPrototypeschar **XListFonts(register Display *dpy,_Xconst char *pattern,  /* null-terminated */int maxNames,int *actualCount)	/* RETURN */#elsechar **XListFonts(dpy, pattern, maxNames, actualCount)register Display *dpy;char *pattern;  /* null-terminated */int maxNames;int *actualCount;	/* RETURN */#endif{           register long nbytes;    register unsigned i;    register int length;    char **flist;    char *ch;    xListFontsReply rep;    register xListFontsReq *req;    register long rlen;    LockDisplay(dpy);    GetReq(ListFonts, req);    req->maxNames = maxNames;    nbytes = req->nbytes = pattern ? strlen (pattern) : 0;    req->length += (nbytes + 3) >> 2;    _XSend (dpy, pattern, nbytes);    /* use _XSend instead of Data, since following _XReply will flush buffer */    (void) _XReply (dpy, (xReply *)&rep, 0, xFalse);    if (rep.nFonts) {	flist = (char **)Xmalloc ((unsigned)rep.nFonts * sizeof(char *));	rlen = rep.length << 2;	ch = (char *) Xmalloc((unsigned) (rlen + 1));	    /* +1 to leave room for last null-terminator */	if ((! flist) || (! ch)) {	    if (flist) Xfree((char *) flist);	    if (ch) Xfree(ch);	    _XEatData(dpy, (unsigned long) rlen);	    UnlockDisplay(dpy);	    SyncHandle();	    return (char **) NULL;	}	_XReadPad (dpy, ch, rlen);	/*	 * unpack into null terminated strings.	 */	length = *(unsigned char *)ch;	*ch = 1; /* make sure it is non-zero for XFreeFontNames */	for (i = 0; i < rep.nFonts; i++) {	    flist[i] = ch + 1;  /* skip over length */	    ch += length + 1;  /* find next length ... */	    length = *(unsigned char *)ch;	    *ch = '\0';  /* and replace with null-termination */	}    }    else flist = (char **) NULL;    *actualCount = rep.nFonts;    UnlockDisplay(dpy);    SyncHandle();    return (flist);}XFreeFontNames(list)char **list;{       	if (list) {		if (!*(list[0]-1)) { /* from ListFontsWithInfo */			register char **names;			for (names = list+1; *names; names++)				Xfree (*names);		}		Xfree (list[0]-1);		Xfree ((char *)list);	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -