Path: blob/master/thirdparty/linuxbsd_headers/fontconfig/fcprivate.h
9904 views
/*1* fontconfig/fontconfig/fcprivate.h2*3* Copyright © 2001 Keith Packard4*5* Permission to use, copy, modify, distribute, and sell this software and its6* documentation for any purpose is hereby granted without fee, provided that7* the above copyright notice appear in all copies and that both that8* copyright notice and this permission notice appear in supporting9* documentation, and that the name of the author(s) not be used in10* advertising or publicity pertaining to distribution of the software without11* specific, written prior permission. The authors make no12* representations about the suitability of this software for any purpose. It13* is provided "as is" without express or implied warranty.14*15* THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,16* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO17* EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR18* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,19* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER20* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR21* PERFORMANCE OF THIS SOFTWARE.22*/2324#ifndef _FCPRIVATE_H_25#define _FCPRIVATE_H_2627/*28* I tried this with functions that took va_list* arguments29* but portability concerns made me change these functions30* into macros (sigh).31*/3233#define FcPatternVapBuild(result, orig, va) \34{ \35FcPattern *__p__ = (orig); \36const char *__o__; \37FcValue __v__; \38\39if (!__p__) \40{ \41__p__ = FcPatternCreate (); \42if (!__p__) \43goto _FcPatternVapBuild_bail0; \44} \45for (;;) \46{ \47__o__ = va_arg (va, const char *); \48if (!__o__) \49break; \50__v__.type = va_arg (va, int); \51switch (__v__.type) { \52case FcTypeUnknown: \53case FcTypeVoid: \54goto _FcPatternVapBuild_bail1; \55case FcTypeInteger: \56__v__.u.i = va_arg (va, int); \57break; \58case FcTypeDouble: \59__v__.u.d = va_arg (va, double); \60break; \61case FcTypeString: \62__v__.u.s = va_arg (va, const FcChar8 *); \63break; \64case FcTypeBool: \65__v__.u.b = va_arg (va, FcBool); \66break; \67case FcTypeMatrix: \68__v__.u.m = va_arg (va, const FcMatrix *); \69break; \70case FcTypeCharSet: \71__v__.u.c = va_arg (va, const FcCharSet *); \72break; \73case FcTypeFTFace: \74__v__.u.f = va_arg (va, FT_Face); \75break; \76case FcTypeLangSet: \77__v__.u.l = va_arg (va, const FcLangSet *); \78break; \79case FcTypeRange: \80__v__.u.r = va_arg (va, const FcRange *); \81break; \82} \83if (!FcPatternAdd (__p__, __o__, __v__, FcTrue)) \84goto _FcPatternVapBuild_bail1; \85} \86result = __p__; \87goto _FcPatternVapBuild_return; \88\89_FcPatternVapBuild_bail1: \90if (!orig) \91FcPatternDestroy (__p__); \92_FcPatternVapBuild_bail0: \93result = (void*)0; \94\95_FcPatternVapBuild_return: \96; \97}9899100#define FcObjectSetVapBuild(__ret__, __first__, __va__) \101{ \102FcObjectSet *__os__; \103const char *__ob__; \104\105__ret__ = 0; \106__os__ = FcObjectSetCreate (); \107if (!__os__) \108goto _FcObjectSetVapBuild_bail0; \109__ob__ = __first__; \110while (__ob__) \111{ \112if (!FcObjectSetAdd (__os__, __ob__)) \113goto _FcObjectSetVapBuild_bail1; \114__ob__ = va_arg (__va__, const char *); \115} \116__ret__ = __os__; \117\118_FcObjectSetVapBuild_bail1: \119if (!__ret__ && __os__) \120FcObjectSetDestroy (__os__); \121_FcObjectSetVapBuild_bail0: \122; \123}124125#endif /* _FCPRIVATE_H_ */126127128129