#define NEED_EVENTS
#define NEED_REPLIES
#include <X11/Xlibint.h>
#include <X11/extensions/fontcachstr.h>
#include <X11/extensions/Xext.h>
#include <X11/extensions/extutil.h>
static XExtensionInfo _fontcache_info_data;
static XExtensionInfo *fontcache_info = &_fontcache_info_data;
static char *fontcache_extension_name = FONTCACHENAME;
#define FontCacheCheckExtension(dpy,i,val) \
XextCheckExtension (dpy, i, fontcache_extension_name, val)
static int close_display(Display *, XExtCodes *);
static XExtensionHooks fontcache_extension_hooks = {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
close_display,
NULL,
NULL,
NULL,
NULL,
};
static XEXT_GENERATE_FIND_DISPLAY (find_display, fontcache_info,
fontcache_extension_name,
&fontcache_extension_hooks,
0, NULL)
static XEXT_GENERATE_CLOSE_DISPLAY (close_display, fontcache_info)
Bool
FontCacheQueryExtension(Display *dpy, int *event_basep, int *error_basep)
{
XExtDisplayInfo *info = find_display (dpy);
if (XextHasExtension(info)) {
*event_basep = info->codes->first_event;
*error_basep = info->codes->first_error;
return True;
} else {
return False;
}
}
Bool
FontCacheQueryVersion(Display *dpy, int *majorVersion, int *minorVersion)
{
XExtDisplayInfo *info = find_display (dpy);
xFontCacheQueryVersionReply rep;
xFontCacheQueryVersionReq *req;
FontCacheCheckExtension (dpy, info, False);
LockDisplay(dpy);
GetReq(FontCacheQueryVersion, req);
req->reqType = info->codes->major_opcode;
req->fontcacheReqType = X_FontCacheQueryVersion;
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
}
*majorVersion = rep.majorVersion;
*minorVersion = rep.minorVersion;
UnlockDisplay(dpy);
SyncHandle();
return True;
}
Bool
FontCacheGetCacheSettings(Display *dpy, FontCacheSettings *cacheinfo)
{
XExtDisplayInfo *info = find_display (dpy);
xFontCacheGetCacheSettingsReply rep;
xFontCacheGetCacheSettingsReq *req;
FontCacheCheckExtension (dpy, info, False);
LockDisplay(dpy);
GetReq(FontCacheGetCacheSettings, req);
req->reqType = info->codes->major_opcode;
req->fontcacheReqType = X_FontCacheGetCacheSettings;
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
}
cacheinfo->himark = rep.himark;
cacheinfo->lowmark = rep.lowmark;
cacheinfo->balance = rep.balance;
UnlockDisplay(dpy);
SyncHandle();
return True;
}
Bool
FontCacheChangeCacheSettings(Display *dpy, FontCacheSettings *cacheinfo)
{
XExtDisplayInfo *info = find_display (dpy);
xFontCacheChangeCacheSettingsReq *req;
FontCacheCheckExtension (dpy, info, False);
LockDisplay(dpy);
GetReq(FontCacheChangeCacheSettings, req);
req->reqType = info->codes->major_opcode;
req->fontcacheReqType = X_FontCacheChangeCacheSettings;
req->himark = cacheinfo->himark;
req->lowmark = cacheinfo->lowmark;
req->balance = cacheinfo->balance;
UnlockDisplay(dpy);
SyncHandle();
return True;
}
Bool
FontCacheGetCacheStatistics(Display *dpy, FontCacheStatistics *cachestats)
{
XExtDisplayInfo *info = find_display (dpy);
xFontCacheGetCacheStatisticsReply rep;
xFontCacheGetCacheStatisticsReq *req;
FontCacheCheckExtension (dpy, info, False);
LockDisplay(dpy);
GetReq(FontCacheGetCacheStatistics, req);
req->reqType = info->codes->major_opcode;
req->fontcacheReqType = X_FontCacheGetCacheStatistics;
if (!_XReply(dpy, (xReply *)&rep,
(SIZEOF(xFontCacheGetCacheStatisticsReply)-SIZEOF(xReply))>>2,
xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
}
cachestats->purge_runs = rep.purge_runs;
cachestats->purge_stat = rep.purge_stat;
cachestats->balance = rep.balance;
cachestats->f.hits = rep.f_hits;
cachestats->f.misshits = rep.f_misshits;
cachestats->f.purged = rep.f_purged;
cachestats->f.usage = rep.f_usage;
cachestats->v.hits = rep.v_hits;
cachestats->v.misshits = rep.v_misshits;
cachestats->v.purged = rep.v_purged;
cachestats->v.usage = rep.v_usage;
UnlockDisplay(dpy);
SyncHandle();
return True;
}