#include <stdlib.h>
#include <string.h>
#include "xftint.h"
#include <fontconfig/fcprivate.h>
XftPattern *
XftPatternCreate (void)
{
return FcPatternCreate ();
}
void
XftValueDestroy (XftValue v)
{
FcValueDestroy (v);
}
void
XftPatternDestroy (XftPattern *p)
{
FcPatternDestroy (p);
}
Bool
XftPatternAdd (XftPattern *p, const char *object, XftValue value, Bool append)
{
return FcPatternAdd (p, object, value, append);
}
Bool
XftPatternDel (XftPattern *p, const char *object)
{
return FcPatternDel (p, object);
}
Bool
XftPatternAddInteger (XftPattern *p, const char *object, int i)
{
XftValue v;
v.type = XftTypeInteger;
v.u.i = i;
return XftPatternAdd (p, object, v, True);
}
Bool
XftPatternAddDouble (XftPattern *p, const char *object, double d)
{
XftValue v;
v.type = XftTypeDouble;
v.u.d = d;
return XftPatternAdd (p, object, v, True);
}
Bool
XftPatternAddString (XftPattern *p, const char *object, const char *s)
{
XftValue v;
v.type = XftTypeString;
v.u.s = (FcChar8 *) s;
return XftPatternAdd (p, object, v, True);
}
Bool
XftPatternAddMatrix (XftPattern *p, const char *object, const XftMatrix *s)
{
XftValue v;
v.type = XftTypeMatrix;
v.u.m = (XftMatrix *) s;
return XftPatternAdd (p, object, v, True);
}
Bool
XftPatternAddBool (XftPattern *p, const char *object, Bool b)
{
XftValue v;
v.type = XftTypeBool;
v.u.b = b;
return XftPatternAdd (p, object, v, True);
}
XftResult
XftPatternGet (XftPattern *p, const char *object, int id, XftValue *v)
{
return FcPatternGet (p, object, id, v);
}
XftResult
XftPatternGetInteger (XftPattern *p, const char *object, int id, int *i)
{
XftValue v;
XftResult r;
r = XftPatternGet (p, object, id, &v);
if (r != XftResultMatch)
return r;
switch (v.type) {
case XftTypeDouble:
*i = (int) v.u.d;
break;
case XftTypeInteger:
*i = v.u.i;
break;
default:
return XftResultTypeMismatch;
}
return XftResultMatch;
}
XftResult
XftPatternGetDouble (XftPattern *p, const char *object, int id, double *d)
{
XftValue v;
XftResult r;
r = XftPatternGet (p, object, id, &v);
if (r != XftResultMatch)
return r;
switch (v.type) {
case XftTypeDouble:
*d = v.u.d;
break;
case XftTypeInteger:
*d = (double) v.u.i;
break;
default:
return XftResultTypeMismatch;
}
return XftResultMatch;
}
XftResult
XftPatternGetString (XftPattern *p, const char *object, int id, char **s)
{
XftValue v;
XftResult r;
r = XftPatternGet (p, object, id, &v);
if (r != XftResultMatch)
return r;
if (v.type != XftTypeString)
return XftResultTypeMismatch;
*s = (char *) v.u.s;
return XftResultMatch;
}
XftResult
XftPatternGetMatrix (XftPattern *p, const char *object, int id, XftMatrix **m)
{
XftValue v;
XftResult r;
r = XftPatternGet (p, object, id, &v);
if (r != XftResultMatch)
return r;
if (v.type != XftTypeMatrix)
return XftResultTypeMismatch;
*m = (XftMatrix *) v.u.m;
return XftResultMatch;
}
XftResult
XftPatternGetBool (XftPattern *p, const char *object, int id, Bool *b)
{
XftValue v;
XftResult r;
r = XftPatternGet (p, object, id, &v);
if (r != XftResultMatch)
return r;
if (v.type != XftTypeBool)
return XftResultTypeMismatch;
*b = v.u.b;
return XftResultMatch;
}
XftPatternElt *
XftPatternFind (XftPattern *p, const char *object, FcBool insert)
{
if (insert)
return FcPatternInsertElt (p, object);
else
return FcPatternFindElt (p, object);
}
XftPattern *
XftPatternDuplicate (XftPattern *orig)
{
return FcPatternDuplicate (orig);
}
XftPattern *
XftPatternVaBuild (XftPattern *orig, va_list va)
{
XftPattern *ret;
FcPatternVapBuild (ret, orig, va);
return ret;
}
XftPattern *
XftPatternBuild (XftPattern *orig, ...)
{
va_list va;
va_start (va, orig);
FcPatternVapBuild (orig, orig, va);
va_end (va);
return orig;
}