Improve the performance issue on rescanning directories
[platform/upstream/fontconfig.git] / src / fcint.h
index 4eac610..cdf2dab 100644 (file)
@@ -37,6 +37,7 @@
 #include <ctype.h>
 #include <assert.h>
 #include <errno.h>
+#include <limits.h>
 #include <unistd.h>
 #include <stddef.h>
 #include <sys/types.h>
@@ -85,7 +86,7 @@ extern pfnSHGetFolderPathA pSHGetFolderPathA;
 #define FC_DBG_CONFIG  1024
 #define FC_DBG_LANGSET 2048
 
-#define _FC_ASSERT_STATIC1(_line, _cond) typedef int _static_assert_on_line_##_line##_failed[(_cond)?1:-1]
+#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))
 
@@ -107,7 +108,9 @@ extern pfnSHGetFolderPathA pSHGetFolderPathA;
 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)))
@@ -171,6 +174,12 @@ typedef struct _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;
 
 /*
@@ -271,7 +280,6 @@ typedef enum _FcQual {
 #define FcMatchDefault ((FcMatchKind) -1)
 
 typedef struct _FcTest {
-    struct _FcTest     *next;
     FcMatchKind                kind;
     FcQual             qual;
     FcObject           object;
@@ -280,17 +288,28 @@ 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 {
@@ -501,7 +520,9 @@ struct _FcConfig {
 
     FcRef      ref;                /* reference count */
 
-    FcExprPage *expr_pool;         /* pool of FcExpr's */
+    FcExprPage  *expr_pool;        /* pool of FcExpr's */
+
+    FcChar8     *sysRoot;          /* override the system root directory */
 };
 
 typedef struct _FcFileTime {
@@ -546,6 +567,9 @@ 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);
 
@@ -608,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
@@ -621,7 +644,7 @@ FcConfigSetFonts (FcConfig  *config,
 
 FcPrivate FcBool
 FcConfigCompareValue (const FcValue *m,
-                     FcOp          op,
+                     unsigned int   op_,
                      const FcValue *v);
 
 FcPrivate FcBool
@@ -728,6 +751,9 @@ FcMakeTempfile (char *template);
 FcPrivate int32_t
 FcRandom (void);
 
+FcPrivate FcBool
+FcMakeDirectory (const FcChar8 *dir);
+
 /* fcdbg.c */
 
 FcPrivate void
@@ -786,6 +812,9 @@ FcPrivate FcBool
 FcFileIsLink (const FcChar8 *file);
 
 FcPrivate FcBool
+FcFileIsFile (const FcChar8 *file);
+
+FcPrivate FcBool
 FcFileScanConfig (FcFontSet    *set,
                  FcStrSet      *dirs,
                  FcBlanks      *blanks,
@@ -812,13 +841,28 @@ FcFontSetSerializeAlloc (FcSerialize *serialize, const FcFontSet *s);
 FcPrivate FcFontSet *
 FcFontSetSerialize (FcSerialize *serialize, const FcFontSet * s);
 
+FcPrivate FcFontSet *
+FcFontSetDeserialize (const FcFontSet *set);
+
 /* fchash.c */
 FcPrivate FcChar8 *
 FcHashGetSHA256Digest (const FcChar8 *input_strings,
                       size_t         len);
+
 FcPrivate FcChar8 *
 FcHashGetSHA256DigestFromFile (const FcChar8 *filename);
 
+FcPrivate FcChar8 *
+FcHashGetSHA256DigestFromMemory (const char *fontdata,
+                                size_t      length);
+
+/* fcinit.c */
+FcPrivate FcConfig *
+FcInitLoadOwnConfig (FcConfig *config);
+
+FcPrivate FcConfig *
+FcInitLoadOwnConfigAndFonts (FcConfig *config);
+
 /* fcxml.c */
 FcPrivate void
 FcTestDestroy (FcTest *test);
@@ -826,6 +870,9 @@ FcTestDestroy (FcTest *test);
 FcPrivate void
 FcEditDestroy (FcEdit *e);
 
+void
+FcRuleDestroy (FcRule *rule);
+
 /* fclang.c */
 FcPrivate FcLangSet *
 FcFreeTypeLangSet (const FcCharSet  *charset,
@@ -1054,6 +1101,9 @@ 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);
 
@@ -1069,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