]> git.wh0rd.org - fontconfig.git/blobdiff - src/fcint.h
Patrick Lam <plam@mit.edu>
[fontconfig.git] / src / fcint.h
index 4b01d91f6df74b7615d0ee46e9b03ec7b1f3f603..84df88de225986bb96803ffc527b63e6dd0b13a3 100644 (file)
 
 #include <stdlib.h>
 #include <stdio.h>
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#else
 #include <stdint.h>
+#endif
 #include <string.h>
 #include <ctype.h>
 #include <errno.h>
@@ -48,6 +52,7 @@
 
 #define FC_FONT_FILE_INVALID   ((FcChar8 *) ".")
 #define FC_FONT_FILE_DIR       ((FcChar8 *) ".dir")
+#define FC_GLOBAL_MAGIC_COOKIE "GLOBAL"
 
 #ifdef _WIN32
 #define FC_SEARCH_PATH_SEPARATOR ';'
@@ -250,7 +255,7 @@ typedef struct _FcStrBuf {
 } FcStrBuf;
 
 typedef struct _FcCache {
-    int            magic;              /* 0xFC02FC02 */
+    int            magic;              /* FC_CACHE_MAGIC */
     int            count;              /* number of bytes of data in block */
     int     bank;               /* bank ID */
     int     pattern_count;      /* number of FcPatterns */
@@ -323,16 +328,21 @@ typedef struct _FcCaseFold {
  * cache which is then rewritten to the users home directory
  */
 
-#define FC_CACHE_MAGIC 0xFC02FC02
+#define FC_CACHE_MAGIC 0xFC02FC03
 
 typedef struct _FcGlobalCacheDir FcGlobalCacheDir;
 
+enum FcGCDirState {
+       FcGCDirDisabled, FcGCDirFileRead, FcGCDirConsumed, FcGCDirUpdated
+};
 struct _FcGlobalCacheDir {
     struct _FcGlobalCacheDir   *next;
     char                       *name;
     FcCache                    metadata;
     off_t                      offset;
+    FcStrSet                   *subdirs;
     void                       *ent;
+    enum FcGCDirState          state;
 };
 
 typedef struct _FcGlobalCache {
@@ -446,12 +456,15 @@ FcGlobalCacheLoad (FcGlobalCache    *cache,
 
 FcBool
 FcGlobalCacheUpdate (FcGlobalCache  *cache,
+                    FcStrSet       *dirs,
                     const char     *file,
-                    FcFontSet      *set);
+                    FcFontSet      *set,
+                    FcConfig       *config);
 
 FcBool
 FcGlobalCacheSave (FcGlobalCache    *cache,
-                  const FcChar8    *cache_file);
+                  const FcChar8    *cache_file,
+                  FcConfig         *config);
 
 FcFontSet *
 FcCacheRead (FcConfig *config, FcGlobalCache * cache);
@@ -460,10 +473,17 @@ FcBool
 FcDirCacheWrite (FcFontSet *set, FcStrSet * dirs, const FcChar8 *dir);
 
 FcBool
-FcDirCacheRead (FcFontSet * set, FcStrSet * dirs, const FcChar8 *dir);
+FcDirCacheRead (FcFontSet * set, FcStrSet * dirs, const FcChar8 *dir, FcConfig *config);
 
+extern int *_fcBankId, *_fcBankIdx;
 int
-FcCacheBankToIndex (int bank);
+FcCacheBankToIndexMTF (int bank);
+
+static __inline__ int
+FcCacheBankToIndex (int bank)
+{
+    return (_fcBankId[*_fcBankIdx] == bank) ? *_fcBankIdx : FcCacheBankToIndexMTF(bank);
+}
 
 const char *
 FcCacheFindBankDir (int bank);
@@ -871,8 +891,8 @@ FcPatternDistributeBytes (FcCache * metadata, void * block_ptr);
 
 /* please don't access these outside of fcpat.c! only visible so that
  * *PtrU can be inlined. */
-extern FcValueList ** fcvaluelists;
-extern FcPatternElt ** fcpatternelts;
+extern FcValueList ** _fcValueLists;
+extern FcPatternElt ** _fcPatternElts;
 
 static __inline__ FcValueList * 
 FcValueListPtrU (FcValueListPtr pi)
@@ -880,7 +900,7 @@ FcValueListPtrU (FcValueListPtr pi)
     if (pi.bank == FC_BANK_DYNAMIC)
         return pi.u.dyn;
 
-    return &fcvaluelists[FcCacheBankToIndex(pi.bank)][pi.u.stat];
+    return &_fcValueLists[FcCacheBankToIndex(pi.bank)][pi.u.stat];
 }
 
 static __inline__ FcPatternElt *
@@ -889,12 +909,9 @@ FcPatternEltU (FcPatternEltPtr pei)
     if (pei.bank == FC_BANK_DYNAMIC)
        return pei.u.dyn;
 
-    return &fcpatternelts[FcCacheBankToIndex(pei.bank)][pei.u.stat];
+    return &_fcPatternElts[FcCacheBankToIndex(pei.bank)][pei.u.stat];
 }
 
-FcPatternElt *
-FcPatternEltU (FcPatternEltPtr pei);
-
 FcValueListPtr
 FcValueListPtrCreateDynamic(FcValueList * p);