Improve the performance issue on rescanning directories
[platform/upstream/fontconfig.git] / src / fcint.h
index 329092d..cdf2dab 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
  *
@@ -7,15 +7,15 @@
  * documentation for any purpose is hereby granted without fee, provided that
  * the above copyright notice appear in all copies and that both that
  * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
+ * documentation, and that the name of the author(s) not be used in
  * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
+ * specific, written prior permission.  The authors make no
  * 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 <config.h>
 #endif
 
+#include "fcstdint.h"
+
 #include <stdlib.h>
 #include <stdio.h>
-#ifdef HAVE_INTTYPES_H
-#include <inttypes.h>
-#elif defined(HAVE_STDINT_H)
-#include <stdint.h>
-#else
-#error missing C99 integer data types
-#endif
 #include <string.h>
 #include <ctype.h>
+#include <assert.h>
 #include <errno.h>
+#include <limits.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"
+#include "fcmutex.h"
+#include "fcatomic.h"
 
 #ifndef FC_CONFIG_PATH
 #define FC_CONFIG_PATH "fonts.conf"
 #endif
 
 #ifdef _WIN32
-#define FC_SEARCH_PATH_SEPARATOR ';'
+#  include "fcwindows.h"
+typedef UINT (WINAPI *pfnGetSystemWindowsDirectory)(LPSTR, UINT);
+typedef HRESULT (WINAPI *pfnSHGetFolderPathA)(HWND, int, HANDLE, DWORD, LPSTR);
+extern pfnGetSystemWindowsDirectory pGetSystemWindowsDirectory;
+extern pfnSHGetFolderPathA pSHGetFolderPathA;
+#  define FC_SEARCH_PATH_SEPARATOR ';'
+#  define FC_DIR_SEPARATOR         '\\'
+#  define FC_DIR_SEPARATOR_S       "\\"
+#else
+#  define FC_SEARCH_PATH_SEPARATOR ':'
+#  define FC_DIR_SEPARATOR         '/'
+#  define FC_DIR_SEPARATOR_S       "/"
+#endif
+
+#if __GNUC__ >= 4
+#define FC_UNUSED      __attribute__((unused))
 #else
-#define FC_SEARCH_PATH_SEPARATOR ':'
+#define FC_UNUSED
 #endif
 
 #define FC_DBG_MATCH   1
 #define FC_DBG_PARSE   64
 #define FC_DBG_SCAN    128
 #define FC_DBG_SCANV   256
-#define FC_DBG_MEMORY  512
 #define FC_DBG_CONFIG  1024
 #define FC_DBG_LANGSET 2048
-#define FC_DBG_OBJTYPES        4096
-
-#define FC_MEM_CHARSET     0
-#define FC_MEM_CHARLEAF            1
-#define FC_MEM_FONTSET     2
-#define FC_MEM_FONTPTR     3
-#define FC_MEM_OBJECTSET    4
-#define FC_MEM_OBJECTPTR    5
-#define FC_MEM_MATRIX      6
-#define FC_MEM_PATTERN     7
-#define FC_MEM_PATELT      8
-#define FC_MEM_VALLIST     9
-#define FC_MEM_SUBSTATE            10
-#define FC_MEM_STRING      11
-#define FC_MEM_LISTBUCK            12
-#define FC_MEM_STRSET      13
-#define FC_MEM_STRLIST     14
-#define FC_MEM_CONFIG      15
-#define FC_MEM_LANGSET     16
-#define FC_MEM_ATOMIC      17
-#define FC_MEM_BLANKS      18
-#define FC_MEM_CACHE       19
-#define FC_MEM_STRBUF      20
-#define FC_MEM_SUBST       21
-#define FC_MEM_OBJECTTYPE   22
-#define FC_MEM_CONSTANT            23
-#define FC_MEM_TEST        24
-#define FC_MEM_EXPR        25
-#define FC_MEM_VSTACK      26
-#define FC_MEM_ATTR        27
-#define FC_MEM_PSTACK      28
-#define FC_MEM_STATICSTR    29
-
-#define FC_MEM_NUM         30
-
-#define FC_BANK_DYNAMIC 0
-#define FC_BANK_FIRST 1
-#define FC_BANK_LANGS      0xfcfcfcfc
+
+#define _FC_ASSERT_STATIC1(_line, _cond) typedef int _static_assert_on_line_##_line##_failed[(_cond)?1:-1] FC_UNUSED
+#define _FC_ASSERT_STATIC0(_line, _cond) _FC_ASSERT_STATIC1 (_line, (_cond))
+#define FC_ASSERT_STATIC(_cond) _FC_ASSERT_STATIC0 (__LINE__, (_cond))
+
+#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
 #endif
 
+FC_ASSERT_STATIC (sizeof (FcRef) == sizeof (int));
+
 typedef enum _FcValueBinding {
-    FcValueBindingWeak, FcValueBindingStrong, FcValueBindingSame
+    FcValueBindingWeak, FcValueBindingStrong, FcValueBindingSame,
+    /* to make sure sizeof (FcValueBinding) == 4 even with -fshort-enums */
+    FcValueBindingEnd = INT_MAX
 } FcValueBinding;
 
+#define FcStrdup(s) ((FcChar8 *) strdup ((const char *) (s)))
+#define FcFree(s) (free ((FcChar8 *) (s)))
+
 /*
  * Serialized data structures use only offsets instead of pointers
  * A low bit of 1 indicates an offset.
  */
+
 /* Is the provided pointer actually an offset? */
 #define FcIsEncodedOffset(p)   ((((intptr_t) (p)) & 1) != 0)
 
@@ -180,13 +171,19 @@ typedef struct _FcValueList {
 } FcValueList;
 
 #define FcValueListNext(vl)    FcPointerMember(vl,next,FcValueList)
-                            
+                       
 typedef int FcObject;
 
+/* The 1024 is to leave some room for future added internal objects, such
+ * that caches from newer fontconfig can still be used with older fontconfig
+ * without getting confused. */
+#define FC_EXT_OBJ_INDEX       1024
+#define FC_OBJ_ID(_n_) ((_n_) & (~FC_EXT_OBJ_INDEX))
+
 typedef struct _FcPatternElt *FcPatternEltPtr;
 
 /*
- * Pattern elts are stuck in a structure connected to the pattern, 
+ * Pattern elts are stuck in a structure connected to the pattern,
  * so they get moved around when the pattern is resized. Hence, the
  * values field must be a pointer/offset instead of just an offset
  */
@@ -201,7 +198,7 @@ struct _FcPattern {
     int                    num;
     int                    size;
     intptr_t       elts_offset;
-    int                    ref;
+    FcRef          ref;
 };
 
 #define FcPatternElts(p)       FcOffsetMember(p,elts_offset,FcPatternElt)
@@ -215,13 +212,14 @@ struct _FcPattern {
                                 fs->fonts[i])
                                                
 typedef enum _FcOp {
-    FcOpInteger, FcOpDouble, FcOpString, FcOpMatrix, FcOpBool, FcOpCharSet, 
+    FcOpInteger, FcOpDouble, FcOpString, FcOpMatrix, FcOpRange, FcOpBool, FcOpCharSet, FcOpLangSet,
     FcOpNil,
     FcOpField, FcOpConst,
-    FcOpAssign, FcOpAssignReplace, 
+    FcOpAssign, FcOpAssignReplace,
     FcOpPrependFirst, FcOpPrepend, FcOpAppend, FcOpAppendLast,
+    FcOpDelete, FcOpDeleteAll,
     FcOpQuest,
-    FcOpOr, FcOpAnd, FcOpEqual, FcOpNotEqual, 
+    FcOpOr, FcOpAnd, FcOpEqual, FcOpNotEqual,
     FcOpContains, FcOpListing, FcOpNotContains,
     FcOpLess, FcOpLessEqual, FcOpMore, FcOpMoreEqual,
     FcOpPlus, FcOpMinus, FcOpTimes, FcOpDivide,
@@ -229,23 +227,52 @@ typedef enum _FcOp {
     FcOpInvalid
 } FcOp;
 
+typedef enum _FcOpFlags {
+       FcOpFlagIgnoreBlanks = 1 << 0
+} FcOpFlags;
+
+#define FC_OP_GET_OP(_x_)      ((_x_) & 0xffff)
+#define FC_OP_GET_FLAGS(_x_)   (((_x_) & 0xffff0000) >> 16)
+#define FC_OP(_x_,_f_)         (FC_OP_GET_OP (_x_) | ((_f_) << 16))
+
+typedef struct _FcExprMatrix {
+  struct _FcExpr *xx, *xy, *yx, *yy;
+} FcExprMatrix;
+
+typedef struct _FcExprName {
+  FcObject     object;
+  FcMatchKind  kind;
+} FcExprName;
+
+
 typedef struct _FcExpr {
     FcOp   op;
     union {
        int         ival;
        double      dval;
-       FcChar8     *sval;
-       FcMatrix    *mval;
+       const FcChar8       *sval;
+       FcExprMatrix *mexpr;
        FcBool      bval;
        FcCharSet   *cval;
-       FcObject    object;
-       FcChar8     *constant;
+       FcLangSet   *lval;
+
+       FcExprName  name;
+       const FcChar8       *constant;
        struct {
            struct _FcExpr *left, *right;
        } tree;
     } 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[FLEXIBLE_ARRAY_MEMBER];
+};
+
 typedef enum _FcQual {
     FcQualAny, FcQualAll, FcQualFirst, FcQualNotFirst
 } FcQual;
@@ -253,7 +280,6 @@ typedef enum _FcQual {
 #define FcMatchDefault ((FcMatchKind) -1)
 
 typedef struct _FcTest {
-    struct _FcTest     *next;
     FcMatchKind                kind;
     FcQual             qual;
     FcObject           object;
@@ -262,27 +288,36 @@ typedef struct _FcTest {
 } FcTest;
 
 typedef struct _FcEdit {
-    struct _FcEdit *next;
     FcObject       object;
     FcOp           op;
     FcExpr         *expr;
     FcValueBinding  binding;
 } FcEdit;
 
+typedef enum _FcRuleType {
+    FcRuleUnknown, FcRuleTest, FcRuleEdit
+} FcRuleType;
+
+typedef struct _FcRule {
+    struct _FcRule *next;
+    FcRuleType      type;
+    union {
+       FcTest *test;
+       FcEdit *edit;
+    } u;
+} FcRule;
+
 typedef struct _FcSubst {
     struct _FcSubst    *next;
-    FcTest             *test;
-    FcEdit             *edit;
+    FcRule             *rule;
 } FcSubst;
 
 typedef struct _FcCharLeaf {
     FcChar32   map[256/32];
 } FcCharLeaf;
 
-#define FC_REF_CONSTANT            -1
-
 struct _FcCharSet {
-    int                    ref;        /* reference count */
+    FcRef          ref;        /* reference count */
     int                    num;        /* size of leaves and numbers arrays */
     intptr_t       leaves_offset;
     intptr_t       numbers_offset;
@@ -295,7 +330,7 @@ struct _FcCharSet {
 #define FcCharSetNumbers(c)    FcOffsetMember(c,numbers_offset,FcChar16)
 
 struct _FcStrSet {
-    int                    ref;        /* reference count */
+    FcRef          ref;        /* reference count */
     int                    num;
     int                    size;
     FcChar8        **strs;
@@ -312,17 +347,18 @@ typedef struct _FcStrBuf {
     FcBool  failed;
     int            len;
     int            size;
+    FcChar8 buf_static[16 * sizeof (void *)];
 } FcStrBuf;
 
 struct _FcCache {
-    int                magic;              /* FC_CACHE_MAGIC_MMAP or FC_CACHE_ALLOC */
+    unsigned int magic;              /* FC_CACHE_MAGIC_MMAP or FC_CACHE_ALLOC */
     int                version;            /* FC_CACHE_CONTENT_VERSION */
     intptr_t   size;               /* size of file */
     intptr_t   dir;                /* offset to dir name */
     intptr_t   dirs;               /* offset to subdirs */
     int                dirs_count;         /* number of subdir strings */
     intptr_t   set;                /* offset to font set */
-    int                mtime;              /* low bits of directory mtime */
+    int                checksum;           /* checksum of directory state */
 };
 
 #undef FcCacheDir
@@ -340,6 +376,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;
@@ -354,7 +398,7 @@ typedef struct _FcSerialize {
     void               *linear;
     FcSerializeBucket  *buckets[FC_SERIALIZE_HASH_SIZE];
 } FcSerialize;
-    
+
 /*
  * To map adobe glyph names to unicode values, a precomputed hash
  * table is used
@@ -368,14 +412,14 @@ typedef struct _FcGlyphName {
 /*
  * To perform case-insensitive string comparisons, a table
  * is used which holds three different kinds of folding data.
- * 
+ *
  * The first is a range of upper case values mapping to a range
  * of their lower case equivalents.  Within each range, the offset
  * between upper and lower case is constant.
  *
  * The second is a range of upper case values which are interleaved
  * with their lower case equivalents.
- * 
+ *
  * The third is a set of raw unicode values mapping to a list
  * of unicode values for comparison purposes.  This allows conversion
  * of ß to "ss" so that SS, ss and ß all match.  A separate array
@@ -398,18 +442,9 @@ typedef struct _FcCaseFold {
 
 #define FC_MAX_FILE_LEN            4096
 
-/* XXX remove these when we're ready */
-
-#define fc_value_string(v)     FcValueString(v)
-#define fc_value_charset(v)    FcValueCharSet(v)
-#define fc_value_langset(v)    FcValueLangSet(v)
-#define fc_storage_type(v)     ((v)->type)
-
-#define fc_alignof(type) offsetof (struct { char c; type member; }, member)
-
 #define FC_CACHE_MAGIC_MMAP        0xFC02FC04
 #define FC_CACHE_MAGIC_ALLOC       0xFC02FC05
-#define FC_CACHE_CONTENT_VERSION    2
+#define FC_CACHE_CONTENT_VERSION    4
 
 struct _FcAtomic {
     FcChar8    *file;          /* original file name */
@@ -438,7 +473,7 @@ struct _FcConfig {
     FcBlanks   *blanks;
     /*
      * List of directories containing fonts,
-     * built by recursively scanning the set 
+     * built by recursively scanning the set
      * of configured directories
      */
     FcStrSet   *fontDirs;
@@ -482,9 +517,13 @@ struct _FcConfig {
      */
     time_t     rescanTime;         /* last time information was scanned */
     int                rescanInterval;     /* interval between scans */
+
+    FcRef      ref;                /* reference count */
+
+    FcExprPage  *expr_pool;        /* pool of FcExpr's */
+
+    FcChar8     *sysRoot;          /* override the system root directory */
 };
-extern FcPrivate FcConfig      *_fcConfig;
 
 typedef struct _FcFileTime {
     time_t  time;
@@ -493,102 +532,30 @@ typedef struct _FcFileTime {
 
 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)))
+typedef struct _FcRange            FcRange;
 
-/*
- * I tried this with functions that took va_list* arguments
- * but portability concerns made me change these functions
- * into macros (sigh).
- */
+struct _FcRange {
+    FcChar32 begin;
+    FcChar32 end;
+};
+
+typedef struct _FcStatFS    FcStatFS;
+
+struct _FcStatFS {
+    FcBool is_remote_fs;
+    FcBool is_mtime_broken;
+};
 
-#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:                                            \
-    ;                                                                  \
-}
+typedef struct _FcValuePromotionBuffer FcValuePromotionBuffer;
+
+struct _FcValuePromotionBuffer {
+  union {
+    double d;
+    int i;
+    long l;
+    char c[256]; /* Enlarge as needed */
+  } u;
+};
 
 /* fcblanks.c */
 
@@ -600,9 +567,15 @@ FcDirCacheScan (const FcChar8 *dir, FcConfig *config);
 FcPrivate FcCache *
 FcDirCacheBuild (FcFontSet *set, const FcChar8 *dir, struct stat *dir_stat, FcStrSet *dirs);
 
+FcPrivate FcCache *
+FcDirCacheRebuild (FcCache *cache, struct stat *dir_stat, FcStrSet *dirs);
+
 FcPrivate FcBool
 FcDirCacheWrite (FcCache *cache, FcConfig *config);
-    
+
+FcPrivate FcBool
+FcDirCacheCreateTagFile (const FcChar8 *cache_dir);
+
 FcPrivate void
 FcCacheObjectReference (void *object);
 
@@ -611,13 +584,31 @@ FcCacheObjectDereference (void *object);
 
 FcPrivate void
 FcCacheFini (void);
-    
+
 FcPrivate void
 FcDirCacheReference (FcCache *cache, int nref);
 
 /* fccfg.c */
 
 FcPrivate FcBool
+FcConfigInit (void);
+
+FcPrivate void
+FcConfigFini (void);
+
+FcPrivate FcChar8 *
+FcConfigXdgCacheHome (void);
+
+FcPrivate FcChar8 *
+FcConfigXdgConfigHome (void);
+
+FcPrivate FcChar8 *
+FcConfigXdgDataHome (void);
+
+FcPrivate FcExpr *
+FcConfigAllocExpr (FcConfig *config);
+
+FcPrivate FcBool
 FcConfigAddConfigDir (FcConfig     *config,
                      const FcChar8 *d);
 
@@ -641,10 +632,9 @@ FcPrivate FcBool
 FcConfigAddBlank (FcConfig     *config,
                  FcChar32      blank);
 
-FcPrivate FcBool
-FcConfigAddEdit (FcConfig      *config,
-                FcTest         *test,
-                FcEdit         *edit,
+FcBool
+FcConfigAddRule (FcConfig      *config,
+                FcRule         *rule,
                 FcMatchKind    kind);
 
 FcPrivate void
@@ -654,7 +644,7 @@ FcConfigSetFonts (FcConfig  *config,
 
 FcPrivate FcBool
 FcConfigCompareValue (const FcValue *m,
-                     FcOp          op,
+                     unsigned int   op_,
                      const FcValue *v);
 
 FcPrivate FcBool
@@ -679,13 +669,13 @@ FcPrivate FcFileTime
 FcConfigModifiedTime (FcConfig *config);
 
 FcPrivate FcBool
-FcConfigAddCache (FcConfig *config, FcCache *cache, 
+FcConfigAddCache (FcConfig *config, FcCache *cache,
                  FcSetName set, FcStrSet *dirSet);
 
 /* fcserialize.c */
 FcPrivate intptr_t
 FcAlignSize (intptr_t size);
-    
+
 FcPrivate FcSerialize *
 FcSerializeCreate (void);
 
@@ -729,6 +719,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);
 
@@ -741,9 +741,32 @@ FcCharSetSerialize(FcSerialize *serialize, const FcCharSet *cs);
 FcPrivate FcChar16 *
 FcCharSetGetNumbers(const FcCharSet *c);
 
+/* fccompat.c */
+FcPrivate int
+FcOpen(const char *pathname, int flags, ...);
+
+FcPrivate int
+FcMakeTempfile (char *template);
+
+FcPrivate int32_t
+FcRandom (void);
+
+FcPrivate FcBool
+FcMakeDirectory (const FcChar8 *dir);
+
 /* fcdbg.c */
+
+FcPrivate void
+FcValuePrintFile (FILE *f, const FcValue v);
+
+FcPrivate void
+FcValuePrintWithPosition (const FcValue v, FcBool show_pos_mark);
+
+FcPrivate void
+FcValueListPrintWithPosition (FcValueListPtr l, const FcValueListPtr pos);
+
 FcPrivate void
-FcValueListPrint (const FcValueListPtr l);
+FcValueListPrint (FcValueListPtr l);
 
 FcPrivate void
 FcLangSetPrint (const FcLangSet *ls);
@@ -765,7 +788,7 @@ FcSubstPrint (const FcSubst *subst);
 
 FcPrivate void
 FcCharSetPrint (const FcCharSet *c);
-    
+
 extern FcPrivate int FcDebugVal;
 
 #define FcDebug() (FcDebugVal)
@@ -777,9 +800,21 @@ FcInitDebug (void);
 FcPrivate FcChar8 *
 FcGetDefaultLang (void);
 
+FcPrivate FcChar8 *
+FcGetPrgname (void);
+
+FcPrivate void
+FcDefaultFini (void);
+
 /* fcdir.c */
 
 FcPrivate FcBool
+FcFileIsLink (const FcChar8 *file);
+
+FcPrivate FcBool
+FcFileIsFile (const FcChar8 *file);
+
+FcPrivate FcBool
 FcFileScanConfig (FcFontSet    *set,
                  FcStrSet      *dirs,
                  FcBlanks      *blanks,
@@ -797,23 +832,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
@@ -821,80 +840,49 @@ 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);
-
-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 FcFontSet *
+FcFontSetDeserialize (const FcFontSet *set);
 
-FcPrivate FcExpr *
-FcExprCreateBool (FcBool b);
+/* fchash.c */
+FcPrivate FcChar8 *
+FcHashGetSHA256Digest (const FcChar8 *input_strings,
+                      size_t         len);
 
-FcPrivate FcExpr *
-FcExprCreateNil (void);
+FcPrivate FcChar8 *
+FcHashGetSHA256DigestFromFile (const FcChar8 *filename);
 
-FcPrivate FcExpr *
-FcExprCreateField (const char *field);
+FcPrivate FcChar8 *
+FcHashGetSHA256DigestFromMemory (const char *fontdata,
+                                size_t      length);
 
-FcPrivate FcExpr *
-FcExprCreateConst (const FcChar8 *constant);
+/* fcinit.c */
+FcPrivate FcConfig *
+FcInitLoadOwnConfig (FcConfig *config);
 
-FcPrivate FcExpr *
-FcExprCreateOp (FcExpr *left, FcOp op, FcExpr *right);
+FcPrivate FcConfig *
+FcInitLoadOwnConfigAndFonts (FcConfig *config);
 
+/* fcxml.c */
 FcPrivate void
-FcExprDestroy (FcExpr *e);
+FcTestDestroy (FcTest *test);
 
 FcPrivate void
 FcEditDestroy (FcEdit *e);
 
-/* fcinit.c */
-
-FcPrivate void
-FcMemReport (void);
-
-FcPrivate void
-FcMemAlloc (int kind, int size);
-
-FcPrivate void
-FcMemFree (int kind, int size);
+void
+FcRuleDestroy (FcRule *rule);
 
 /* fclang.c */
 FcPrivate FcLangSet *
-FcFreeTypeLangSet (const FcCharSet  *charset, 
+FcFreeTypeLangSet (const FcCharSet  *charset,
                   const FcChar8    *exclusiveLang);
 
 FcPrivate FcLangResult
 FcLangCompare (const FcChar8 *s1, const FcChar8 *s2);
-    
-FcPrivate const FcCharSet *
-FcCharSetForLang (const FcChar8 *lang);
 
 FcPrivate FcLangSet *
-FcLangSetPromote (const FcChar8 *lang);
+FcLangSetPromote (const FcChar8 *lang, FcValuePromotionBuffer *buf);
 
 FcPrivate FcLangSet *
 FcNameParseLangSet (const FcChar8 *string);
@@ -915,52 +903,14 @@ FcListPatternMatchAny (const FcPattern *p,
 
 /* fcname.c */
 
-/*
- * NOTE -- this ordering is part of the cache file format.
- * It must also match the ordering in fcname.c
- */
-
-#define FC_FAMILY_OBJECT       1
-#define FC_FAMILYLANG_OBJECT   2
-#define FC_STYLE_OBJECT                3
-#define FC_STYLELANG_OBJECT    4
-#define FC_FULLNAME_OBJECT     5
-#define FC_FULLNAMELANG_OBJECT 6
-#define FC_SLANT_OBJECT                7
-#define FC_WEIGHT_OBJECT       8
-#define FC_WIDTH_OBJECT                9
-#define FC_SIZE_OBJECT         10
-#define FC_ASPECT_OBJECT       11
-#define FC_PIXEL_SIZE_OBJECT   12
-#define FC_SPACING_OBJECT      13
-#define FC_FOUNDRY_OBJECT      14
-#define FC_ANTIALIAS_OBJECT    15
-#define FC_HINT_STYLE_OBJECT   16
-#define FC_HINTING_OBJECT      17
-#define FC_VERTICAL_LAYOUT_OBJECT      18
-#define FC_AUTOHINT_OBJECT     19
-#define FC_GLOBAL_ADVANCE_OBJECT       20
-#define FC_FILE_OBJECT         21
-#define FC_INDEX_OBJECT                22
-#define FC_RASTERIZER_OBJECT   23
-#define FC_OUTLINE_OBJECT      24
-#define FC_SCALABLE_OBJECT     25
-#define FC_DPI_OBJECT          26
-#define FC_RGBA_OBJECT         27
-#define FC_SCALE_OBJECT                28
-#define FC_MINSPACE_OBJECT     29
-#define FC_CHAR_WIDTH_OBJECT   30
-#define FC_CHAR_HEIGHT_OBJECT  31
-#define FC_MATRIX_OBJECT       32
-#define FC_CHARSET_OBJECT      33
-#define FC_LANG_OBJECT         34
-#define FC_FONTVERSION_OBJECT  35
-#define FC_CAPABILITY_OBJECT   36
-#define FC_FONTFORMAT_OBJECT   37
-#define FC_EMBOLDEN_OBJECT     38
-#define FC_EMBEDDED_BITMAP_OBJECT      39
-#define FC_DECORATIVE_OBJECT   40
-#define FC_MAX_BASE_OBJECT     FC_DECORATIVE_OBJECT
+enum {
+  FC_INVALID_OBJECT = 0,
+#define FC_OBJECT(NAME, Type, Cmp) FC_##NAME##_OBJECT,
+#include "fcobjs.h"
+#undef FC_OBJECT
+  FC_ONE_AFTER_MAX_BASE_OBJECT
+#define FC_MAX_BASE_OBJECT (FC_ONE_AFTER_MAX_BASE_OBJECT - 1)
+};
 
 FcPrivate FcBool
 FcNameBool (const FcChar8 *v, FcBool *result);
@@ -974,11 +924,8 @@ FcObjectFromName (const char * name);
 FcPrivate const char *
 FcObjectName (FcObject object);
 
-FcPrivate FcBool
-FcObjectInit (void);
-
-FcPrivate void
-FcObjectFini (void);
+FcPrivate FcObjectSet *
+FcObjectGetSet (void);
 
 #define FcObjectCompare(a, b)  ((int) a - (int) b)
 
@@ -987,9 +934,25 @@ FcObjectFini (void);
 FcPrivate FcValue
 FcValueCanonicalize (const FcValue *v);
 
+FcPrivate FcValueListPtr
+FcValueListCreate (void);
+
 FcPrivate void
 FcValueListDestroy (FcValueListPtr l);
 
+FcPrivate FcValueListPtr
+FcValueListPrepend (FcValueListPtr vallist,
+                   FcValue        value,
+                   FcValueBinding binding);
+
+FcPrivate FcValueListPtr
+FcValueListAppend (FcValueListPtr vallist,
+                  FcValue        value,
+                  FcValueBinding binding);
+
+FcPrivate FcValueListPtr
+FcValueListDuplicate(FcValueListPtr orig);
+
 FcPrivate FcPatternElt *
 FcPatternObjectFindElt (const FcPattern *p, FcObject object);
 
@@ -997,6 +960,12 @@ FcPrivate FcPatternElt *
 FcPatternObjectInsertElt (FcPattern *p, FcObject object);
 
 FcPrivate FcBool
+FcPatternObjectListAdd (FcPattern      *p,
+                       FcObject        object,
+                       FcValueListPtr  list,
+                       FcBool          append);
+
+FcPrivate FcBool
 FcPatternObjectAddWithBinding  (FcPattern      *p,
                                FcObject        object,
                                FcValue         value,
@@ -1005,13 +974,13 @@ FcPatternObjectAddWithBinding  (FcPattern        *p,
 
 FcPrivate FcBool
 FcPatternObjectAdd (FcPattern *p, FcObject object, FcValue value, FcBool append);
-    
+
 FcPrivate FcBool
 FcPatternObjectAddWeak (FcPattern *p, FcObject object, FcValue value, FcBool append);
-    
+
 FcPrivate FcResult
 FcPatternObjectGet (const FcPattern *p, FcObject object, int id, FcValue *v);
-    
+
 FcPrivate FcBool
 FcPatternObjectDel (FcPattern *p, FcObject object);
 
@@ -1060,15 +1029,9 @@ FcPatternObjectGetBool (const FcPattern *p, FcObject object, int n, FcBool *b);
 FcPrivate FcResult
 FcPatternObjectGetLangSet (const FcPattern *p, FcObject object, int n, FcLangSet **ls);
 
-FcPrivate void
-FcPatternFini (void);
-
 FcPrivate FcBool
 FcPatternAppend (FcPattern *p, FcPattern *s);
 
-FcPrivate const FcChar8 *
-FcStrStaticName (const FcChar8 *name);
-
 FcPrivate FcChar32
 FcStringHash (const FcChar8 *s);
 
@@ -1093,7 +1056,24 @@ extern FcPrivate const FcMatrix    FcIdentityMatrix;
 FcPrivate void
 FcMatrixFree (FcMatrix *mat);
 
+/* fcstat.c */
+
+FcPrivate int
+FcStat (const FcChar8 *file, struct stat *statb);
+
+FcPrivate int
+FcStatChecksum (const FcChar8 *file, struct stat *statb);
+
+FcPrivate FcBool
+FcIsFsMmapSafe (int fd);
+
+FcPrivate FcBool
+FcIsFsMtimeBroken (const FcChar8 *dir);
+
 /* fcstr.c */
+FcPrivate FcBool
+FcStrSetAddLangs (FcStrSet *strs, const char *languages);
+
 FcPrivate void
 FcStrSetSort (FcStrSet * set);
 
@@ -1106,6 +1086,9 @@ FcStrBufDestroy (FcStrBuf *buf);
 FcPrivate FcChar8 *
 FcStrBufDone (FcStrBuf *buf);
 
+FcPrivate FcChar8 *
+FcStrBufDoneStatic (FcStrBuf *buf);
+
 FcPrivate FcBool
 FcStrBufChar (FcStrBuf *buf, FcChar8 c);
 
@@ -1118,6 +1101,15 @@ FcStrBufData (FcStrBuf *buf, const FcChar8 *s, int len);
 FcPrivate int
 FcStrCmpIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2);
 
+FcPrivate int
+FcStrCmpIgnoreCaseAndDelims (const FcChar8 *s1, const FcChar8 *s2, const FcChar8 *delims);
+
+FcPrivate FcBool
+FcStrRegexCmp (const FcChar8 *s, const FcChar8 *regex);
+
+FcPrivate FcBool
+FcStrRegexCmpIgnoreCase (const FcChar8 *s, const FcChar8 *regex);
+
 FcPrivate const FcChar8 *
 FcStrContainsIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2);
 
@@ -1127,10 +1119,21 @@ FcStrContainsIgnoreCase (const FcChar8 *s1, const FcChar8 *s2);
 FcPrivate const FcChar8 *
 FcStrContainsWord (const FcChar8 *s1, const FcChar8 *s2);
 
+FcPrivate int
+FcStrMatchIgnoreCaseAndDelims (const FcChar8 *s1, const FcChar8 *s2, const FcChar8 *delims);
+
+FcPrivate FcBool
+FcStrGlobMatch (const FcChar8 *glob,
+               const FcChar8 *string);
+
 FcPrivate FcBool
 FcStrUsesHome (const FcChar8 *s);
 
 FcPrivate FcChar8 *
+FcStrBuildFilename (const FcChar8 *path,
+                   ...);
+
+FcPrivate FcChar8 *
 FcStrLastSlash (const FcChar8  *path);
 
 FcPrivate FcChar32
@@ -1145,4 +1148,21 @@ FcStrSerializeAlloc (FcSerialize *serialize, const FcChar8 *str);
 FcPrivate FcChar8 *
 FcStrSerialize (FcSerialize *serialize, const FcChar8 *str);
 
+/* fcobjs.c */
+
+FcPrivate FcObject
+FcObjectLookupIdByName (const char *str);
+
+FcPrivate FcObject
+FcObjectLookupBuiltinIdByName (const char *str);
+
+FcPrivate const char *
+FcObjectLookupOtherNameById (FcObject id);
+
+FcPrivate const FcObjectType *
+FcObjectLookupOtherTypeById (FcObject id);
+
+FcPrivate const FcObjectType *
+FcObjectLookupOtherTypeByName (const char *str);
+
 #endif /* _FC_INT_H_ */