]> git.wh0rd.org - fontconfig.git/blobdiff - src/fcint.h
[int] Define MIN/MAX/ABS macros
[fontconfig.git] / src / fcint.h
index 25fb00ffd3561799c702ed9353a716bf6db54401..81cde21d5e80bf1d9dded764b0a8c50f29d6c055 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $RCSId: xc/lib/fontconfig/src/fcint.h,v 1.27 2002/08/31 22:17:32 keithp Exp $
+ * fontconfig/src/fcint.h
  *
  * Copyright © 2000 Keith Packard
  *
@@ -13,9 +13,9 @@
  * representations about the suitability of this software for any purpose.  It
  * is provided "as is" without express or implied warranty.
  *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 #include <ctype.h>
 #include <errno.h>
 #include <unistd.h>
+#include <stddef.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <time.h>
 #include <fontconfig/fontconfig.h>
-#include <fontconfig/fcfreetype.h>
+#include <fontconfig/fcprivate.h>
+#include "fcdeprecate.h"
 
 #ifndef FC_CONFIG_PATH
 #define FC_CONFIG_PATH "fonts.conf"
 #define FC_BANK_FIRST 1
 #define FC_BANK_LANGS      0xfcfcfcfc
 
+#define FC_MIN(a,b) ((a) < (b) ? (a) : (b))
+#define FC_MAX(a,b) ((a) > (b) ? (a) : (b))
+#define FC_ABS(a)   ((a) < 0 ? -(a) : (a))
+
 /* slim_internal.h */
 #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__) && !defined(__sun)
 #define FcPrivate              __attribute__((__visibility__("hidden")))
@@ -245,6 +251,15 @@ typedef struct _FcExpr {
     } u;
 } FcExpr;
 
+typedef struct _FcExprPage FcExprPage;
+
+struct _FcExprPage {
+  FcExprPage *next_page;
+  FcExpr *next;
+  FcExpr exprs[(1024 - 2/* two pointers */ - 2/* malloc overhead */) * sizeof (void *) / sizeof (FcExpr)];
+  FcExpr end[0];
+};
+
 typedef enum _FcQual {
     FcQualAny, FcQualAll, FcQualFirst, FcQualNotFirst
 } FcQual;
@@ -311,6 +326,7 @@ typedef struct _FcStrBuf {
     FcBool  failed;
     int            len;
     int            size;
+    FcChar8 buf_static[16 * sizeof (void *)];
 } FcStrBuf;
 
 struct _FcCache {
@@ -339,6 +355,14 @@ struct _FcCache {
 
 #define FC_SERIALIZE_HASH_SIZE 8191
 
+typedef union _FcAlign {
+    double     d;
+    int                i;
+    intptr_t   ip;
+    FcBool     b;
+    void       *p;
+} FcAlign;
+
 typedef struct _FcSerializeBucket {
     struct _FcSerializeBucket *next;
     const void *object;
@@ -481,6 +505,10 @@ struct _FcConfig {
      */
     time_t     rescanTime;         /* last time information was scanned */
     int                rescanInterval;     /* interval between scans */
+
+    int                ref;                /* reference count */
+
+    FcExprPage *expr_pool;         /* pool of FcExpr's */
 };
  
 extern FcPrivate FcConfig      *_fcConfig;
@@ -495,100 +523,6 @@ typedef struct _FcCharMap FcCharMap;
 /* watch out; assumes that v is void * -PL */
 #define ALIGN(v,type) ((void *)(((uintptr_t)(v) + fc_alignof(type) - 1) & ~(fc_alignof(type) - 1)))
 
-/*
- * I tried this with functions that took va_list* arguments
- * but portability concerns made me change these functions
- * into macros (sigh).
- */
-
-#define FcPatternVapBuild(result, orig, va)                        \
-{                                                                  \
-    FcPattern  *__p__ = (orig);                                    \
-    const char *__o__;                                             \
-    FcValue    __v__;                                              \
-                                                                   \
-    if (!__p__)                                                            \
-    {                                                              \
-       __p__ = FcPatternCreate ();                                 \
-       if (!__p__)                                                 \
-           goto _FcPatternVapBuild_bail0;                          \
-    }                                                              \
-    for (;;)                                                       \
-    {                                                              \
-       __o__ = va_arg (va, const char *);                          \
-       if (!__o__)                                                 \
-           break;                                                  \
-       __v__.type = va_arg (va, FcType);                           \
-       switch (__v__.type) {                                       \
-       case FcTypeVoid:                                            \
-           goto _FcPatternVapBuild_bail1;                          \
-       case FcTypeInteger:                                         \
-           __v__.u.i = va_arg (va, int);                           \
-           break;                                                  \
-       case FcTypeDouble:                                          \
-           __v__.u.d = va_arg (va, double);                        \
-           break;                                                  \
-       case FcTypeString:                                          \
-           __v__.u.s = va_arg (va, const FcChar8 *);               \
-           break;                                                  \
-       case FcTypeBool:                                            \
-           __v__.u.b = va_arg (va, FcBool);                        \
-           break;                                                  \
-       case FcTypeMatrix:                                          \
-           __v__.u.m = va_arg (va, const FcMatrix *);              \
-           break;                                                  \
-       case FcTypeCharSet:                                         \
-           __v__.u.c = va_arg (va, const FcCharSet *);             \
-           break;                                                  \
-       case FcTypeFTFace:                                          \
-           __v__.u.f = va_arg (va, FT_Face);                       \
-           break;                                                  \
-       case FcTypeLangSet:                                         \
-           __v__.u.l = va_arg (va, const FcLangSet *);             \
-           break;                                                  \
-       }                                                           \
-       if (!FcPatternAdd (__p__, __o__, __v__, FcTrue))            \
-           goto _FcPatternVapBuild_bail1;                          \
-    }                                                              \
-    result = __p__;                                                \
-    goto _FcPatternVapBuild_return;                                \
-                                                                   \
-_FcPatternVapBuild_bail1:                                          \
-    if (!orig)                                                     \
-       FcPatternDestroy (__p__);                                   \
-_FcPatternVapBuild_bail0:                                          \
-    result = (void*)0;                                             \
-                                                                   \
-_FcPatternVapBuild_return:                                         \
-    ;                                                              \
-}
-
-
-#define FcObjectSetVapBuild(__ret__, __first__, __va__)                \
-{                                                                      \
-    FcObjectSet    *__os__;                                            \
-    const char     *__ob__;                                            \
-                                                                       \
-    __ret__ = 0;                                                       \
-    __os__ = FcObjectSetCreate ();                                     \
-    if (!__os__)                                                       \
-       goto _FcObjectSetVapBuild_bail0;                                \
-    __ob__ = __first__;                                                        \
-    while (__ob__)                                                     \
-    {                                                                  \
-       if (!FcObjectSetAdd (__os__, __ob__))                           \
-           goto _FcObjectSetVapBuild_bail1;                            \
-       __ob__ = va_arg (__va__, const char *);                         \
-    }                                                                  \
-    __ret__ = __os__;                                                  \
-                                                                       \
-_FcObjectSetVapBuild_bail1:                                            \
-    if (!__ret__ && __os__)                                            \
-       FcObjectSetDestroy (__os__);                                    \
-_FcObjectSetVapBuild_bail0:                                            \
-    ;                                                                  \
-}
-
 /* fcblanks.c */
 
 /* fccache.c */
@@ -614,8 +548,18 @@ FcCacheFini (void);
 FcPrivate void
 FcDirCacheReference (FcCache *cache, int nref);
 
+#ifdef _WIN32
+FcPrivate int
+FcStat (const char *file, struct stat *statb);
+#else
+#define FcStat stat
+#endif
+
 /* fccfg.c */
 
+FcPrivate FcExpr *
+FcConfigAllocExpr (FcConfig *config);
+
 FcPrivate FcBool
 FcConfigAddConfigDir (FcConfig     *config,
                      const FcChar8 *d);
@@ -728,6 +672,16 @@ FcNameUnparseCharSet (FcStrBuf *buf, const FcCharSet *c);
 FcPrivate FcCharSet *
 FcNameParseCharSet (FcChar8 *string);
 
+FcPrivate FcBool
+FcNameUnparseValue (FcStrBuf    *buf,
+                    FcValue     *v0,
+                   FcChar8     *escape);
+
+FcPrivate FcBool
+FcNameUnparseValueList (FcStrBuf       *buf,
+                       FcValueListPtr  v,
+                       FcChar8         *escape);
+
 FcPrivate FcCharLeaf *
 FcCharSetFindLeafCreate (FcCharSet *fcs, FcChar32 ucs4);
 
@@ -796,23 +750,7 @@ FcDirScanConfig (FcFontSet *set,
 /* fcfont.c */
 FcPrivate int
 FcFontDebug (void);
-    
-/* fcfreetype.c */
-FcPrivate FcBool
-FcFreeTypeIsExclusiveLang (const FcChar8  *lang);
 
-FcPrivate FcBool
-FcFreeTypeHasLang (FcPattern *pattern, const FcChar8 *lang);
-
-FcPrivate FcChar32
-FcFreeTypeUcs4ToPrivate (FcChar32 ucs4, const FcCharMap *map);
-
-FcPrivate FcChar32
-FcFreeTypePrivateToUcs4 (FcChar32 private, const FcCharMap *map);
-
-FcPrivate const FcCharMap *
-FcFreeTypeGetPrivateMap (FT_Encoding encoding);
-    
 /* fcfs.c */
 
 FcPrivate FcBool
@@ -820,53 +758,11 @@ FcFontSetSerializeAlloc (FcSerialize *serialize, const FcFontSet *s);
 
 FcPrivate FcFontSet *
 FcFontSetSerialize (FcSerialize *serialize, const FcFontSet * s);
-    
-/* fcgram.y */
-FcPrivate int
-FcConfigparse (void);
-
-FcPrivate int
-FcConfigwrap (void);
-    
-FcPrivate void
-FcConfigerror (char *fmt, ...);
-    
-FcPrivate char *
-FcConfigSaveField (const char *field);
 
+/* fcxml.c */
 FcPrivate void
 FcTestDestroy (FcTest *test);
 
-FcPrivate FcExpr *
-FcExprCreateInteger (int i);
-
-FcPrivate FcExpr *
-FcExprCreateDouble (double d);
-
-FcPrivate FcExpr *
-FcExprCreateString (const FcChar8 *s);
-
-FcPrivate FcExpr *
-FcExprCreateMatrix (const FcMatrix *m);
-
-FcPrivate FcExpr *
-FcExprCreateBool (FcBool b);
-
-FcPrivate FcExpr *
-FcExprCreateNil (void);
-
-FcPrivate FcExpr *
-FcExprCreateField (const char *field);
-
-FcPrivate FcExpr *
-FcExprCreateConst (const FcChar8 *constant);
-
-FcPrivate FcExpr *
-FcExprCreateOp (FcExpr *left, FcOp op, FcExpr *right);
-
-FcPrivate void
-FcExprDestroy (FcExpr *e);
-
 FcPrivate void
 FcEditDestroy (FcEdit *e);
 
@@ -889,9 +785,6 @@ FcFreeTypeLangSet (const FcCharSet  *charset,
 FcPrivate FcLangResult
 FcLangCompare (const FcChar8 *s1, const FcChar8 *s2);
     
-FcPrivate const FcCharSet *
-FcCharSetForLang (const FcChar8 *lang);
-
 FcPrivate FcLangSet *
 FcLangSetPromote (const FcChar8 *lang);
 
@@ -959,7 +852,8 @@ FcListPatternMatchAny (const FcPattern *p,
 #define FC_EMBOLDEN_OBJECT     38
 #define FC_EMBEDDED_BITMAP_OBJECT      39
 #define FC_DECORATIVE_OBJECT   40
-#define FC_MAX_BASE_OBJECT     FC_DECORATIVE_OBJECT
+#define FC_LCD_FILTER_OBJECT   41
+#define FC_MAX_BASE_OBJECT     FC_LCD_FILTER_OBJECT
 
 FcPrivate FcBool
 FcNameBool (const FcChar8 *v, FcBool *result);
@@ -973,6 +867,9 @@ FcObjectFromName (const char * name);
 FcPrivate const char *
 FcObjectName (FcObject object);
 
+FcPrivate FcObjectSet *
+FcObjectGetSet (void);
+
 FcPrivate FcBool
 FcObjectInit (void);
 
@@ -1105,6 +1002,9 @@ FcStrBufDestroy (FcStrBuf *buf);
 FcPrivate FcChar8 *
 FcStrBufDone (FcStrBuf *buf);
 
+FcPrivate FcChar8 *
+FcStrBufDoneStatic (FcStrBuf *buf);
+
 FcPrivate FcBool
 FcStrBufChar (FcStrBuf *buf, FcChar8 c);