Make FcGetDefaultLang and FcGetDefaultLangs thread-safe
[platform/upstream/fontconfig.git] / src / fcint.h
1 /*
2  * fontconfig/src/fcint.h
3  *
4  * Copyright © 2000 Keith Packard
5  *
6  * Permission to use, copy, modify, distribute, and sell this software and its
7  * documentation for any purpose is hereby granted without fee, provided that
8  * the above copyright notice appear in all copies and that both that
9  * copyright notice and this permission notice appear in supporting
10  * documentation, and that the name of the author(s) not be used in
11  * advertising or publicity pertaining to distribution of the software without
12  * specific, written prior permission.  The authors make no
13  * representations about the suitability of this software for any purpose.  It
14  * is provided "as is" without express or implied warranty.
15  *
16  * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18  * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22  * PERFORMANCE OF THIS SOFTWARE.
23  */
24
25 #ifndef _FCINT_H_
26 #define _FCINT_H_
27
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31
32 #include "fcstdint.h"
33
34 #include <stdlib.h>
35 #include <stdio.h>
36 #include <string.h>
37 #include <ctype.h>
38 #include <assert.h>
39 #include <errno.h>
40 #include <unistd.h>
41 #include <stddef.h>
42 #include <sys/types.h>
43 #include <sys/stat.h>
44 #include <time.h>
45 #include <fontconfig/fontconfig.h>
46 #include <fontconfig/fcprivate.h>
47 #include "fcdeprecate.h"
48 #include "fcmutex.h"
49 #include "fcatomic.h"
50
51 #ifndef FC_CONFIG_PATH
52 #define FC_CONFIG_PATH "fonts.conf"
53 #endif
54
55 #ifdef _WIN32
56 #  ifndef _WIN32_WINNT
57 #    define _WIN32_WINNT 0x0500
58 #  endif
59 #  define WIN32_LEAN_AND_MEAN
60 #  define STRICT
61 #  include <windows.h>
62 typedef UINT (WINAPI *pfnGetSystemWindowsDirectory)(LPSTR, UINT);
63 typedef HRESULT (WINAPI *pfnSHGetFolderPathA)(HWND, int, HANDLE, DWORD, LPSTR);
64 extern pfnGetSystemWindowsDirectory pGetSystemWindowsDirectory;
65 extern pfnSHGetFolderPathA pSHGetFolderPathA;
66 #  define FC_SEARCH_PATH_SEPARATOR ';'
67 #  define FC_DIR_SEPARATOR         '\\'
68 #  define FC_DIR_SEPARATOR_S       "\\"
69 #else
70 #  define FC_SEARCH_PATH_SEPARATOR ':'
71 #  define FC_DIR_SEPARATOR         '/'
72 #  define FC_DIR_SEPARATOR_S       "/"
73 #endif
74
75 #if __GNUC__ >= 4
76 #define FC_UNUSED       __attribute__((unused))
77 #else
78 #define FC_UNUSED
79 #endif
80
81 #define FC_DBG_MATCH    1
82 #define FC_DBG_MATCHV   2
83 #define FC_DBG_EDIT     4
84 #define FC_DBG_FONTSET  8
85 #define FC_DBG_CACHE    16
86 #define FC_DBG_CACHEV   32
87 #define FC_DBG_PARSE    64
88 #define FC_DBG_SCAN     128
89 #define FC_DBG_SCANV    256
90 #define FC_DBG_CONFIG   1024
91 #define FC_DBG_LANGSET  2048
92
93 #define _FC_ASSERT_STATIC1(_line, _cond) typedef int _static_assert_on_line_##_line##_failed[(_cond)?1:-1]
94 #define _FC_ASSERT_STATIC0(_line, _cond) _FC_ASSERT_STATIC1 (_line, (_cond))
95 #define FC_ASSERT_STATIC(_cond) _FC_ASSERT_STATIC0 (__LINE__, (_cond))
96
97 #define FC_MIN(a,b) ((a) < (b) ? (a) : (b))
98 #define FC_MAX(a,b) ((a) > (b) ? (a) : (b))
99 #define FC_ABS(a)   ((a) < 0 ? -(a) : (a))
100
101 /* slim_internal.h */
102 #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__) && !defined(__sun)
103 #define FcPrivate               __attribute__((__visibility__("hidden")))
104 #define HAVE_GNUC_ATTRIBUTE 1
105 #include "fcalias.h"
106 #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
107 #define FcPrivate               __hidden
108 #else /* not gcc >= 3.3 and not Sun Studio >= 8 */
109 #define FcPrivate
110 #endif
111
112 FC_ASSERT_STATIC (sizeof (FcRef) == sizeof (int));
113
114 typedef enum _FcValueBinding {
115     FcValueBindingWeak, FcValueBindingStrong, FcValueBindingSame
116 } FcValueBinding;
117
118 /*
119  * Serialized data structures use only offsets instead of pointers
120  * A low bit of 1 indicates an offset.
121  */
122
123 /* Is the provided pointer actually an offset? */
124 #define FcIsEncodedOffset(p)    ((((intptr_t) (p)) & 1) != 0)
125
126 /* Encode offset in a pointer of type t */
127 #define FcOffsetEncode(o,t)     ((t *) ((o) | 1))
128
129 /* Decode a pointer into an offset */
130 #define FcOffsetDecode(p)       (((intptr_t) (p)) & ~1)
131
132 /* Compute pointer offset */
133 #define FcPtrToOffset(b,p)      ((intptr_t) (p) - (intptr_t) (b))
134
135 /* Given base address, offset and type, return a pointer */
136 #define FcOffsetToPtr(b,o,t)    ((t *) ((intptr_t) (b) + (o)))
137
138 /* Given base address, encoded offset and type, return a pointer */
139 #define FcEncodedOffsetToPtr(b,p,t) FcOffsetToPtr(b,FcOffsetDecode(p),t)
140
141 /* Given base address, pointer and type, return an encoded offset */
142 #define FcPtrToEncodedOffset(b,p,t) FcOffsetEncode(FcPtrToOffset(b,p),t)
143
144 /* Given a structure, offset member and type, return pointer */
145 #define FcOffsetMember(s,m,t)       FcOffsetToPtr(s,(s)->m,t)
146
147 /* Given a structure, encoded offset member and type, return pointer to member */
148 #define FcEncodedOffsetMember(s,m,t) FcOffsetToPtr(s,FcOffsetDecode((s)->m), t)
149
150 /* Given a structure, member and type, convert the member to a pointer */
151 #define FcPointerMember(s,m,t)  (FcIsEncodedOffset((s)->m) ? \
152                                  FcEncodedOffsetMember (s,m,t) : \
153                                  (s)->m)
154
155 /*
156  * Serialized values may hold strings, charsets and langsets as pointers,
157  * unfortunately FcValue is an exposed type so we can't just always use
158  * offsets
159  */
160 #define FcValueString(v)        FcPointerMember(v,u.s,FcChar8)
161 #define FcValueCharSet(v)       FcPointerMember(v,u.c,const FcCharSet)
162 #define FcValueLangSet(v)       FcPointerMember(v,u.l,const FcLangSet)
163
164 typedef struct _FcValueList *FcValueListPtr;
165
166 typedef struct _FcValueList {
167     struct _FcValueList *next;
168     FcValue             value;
169     FcValueBinding      binding;
170 } FcValueList;
171
172 #define FcValueListNext(vl)     FcPointerMember(vl,next,FcValueList)
173                         
174 typedef int FcObject;
175
176 typedef struct _FcPatternElt *FcPatternEltPtr;
177
178 /*
179  * Pattern elts are stuck in a structure connected to the pattern,
180  * so they get moved around when the pattern is resized. Hence, the
181  * values field must be a pointer/offset instead of just an offset
182  */
183 typedef struct _FcPatternElt {
184     FcObject            object;
185     FcValueList         *values;
186 } FcPatternElt;
187
188 #define FcPatternEltValues(pe)  FcPointerMember(pe,values,FcValueList)
189
190 struct _FcPattern {
191     int             num;
192     int             size;
193     intptr_t        elts_offset;
194     FcRef           ref;
195 };
196
197 #define FcPatternElts(p)        FcOffsetMember(p,elts_offset,FcPatternElt)
198
199 #define FcFontSetFonts(fs)      FcPointerMember(fs,fonts,FcPattern *)
200
201 #define FcFontSetFont(fs,i)     (FcIsEncodedOffset((fs)->fonts) ? \
202                                  FcEncodedOffsetToPtr(fs, \
203                                                       FcFontSetFonts(fs)[i], \
204                                                       FcPattern) : \
205                                  fs->fonts[i])
206                                                 
207 typedef enum _FcOp {
208     FcOpInteger, FcOpDouble, FcOpString, FcOpMatrix, FcOpRange, FcOpBool, FcOpCharSet, FcOpLangSet,
209     FcOpNil,
210     FcOpField, FcOpConst,
211     FcOpAssign, FcOpAssignReplace,
212     FcOpPrependFirst, FcOpPrepend, FcOpAppend, FcOpAppendLast,
213     FcOpQuest,
214     FcOpOr, FcOpAnd, FcOpEqual, FcOpNotEqual,
215     FcOpContains, FcOpListing, FcOpNotContains,
216     FcOpLess, FcOpLessEqual, FcOpMore, FcOpMoreEqual,
217     FcOpPlus, FcOpMinus, FcOpTimes, FcOpDivide,
218     FcOpNot, FcOpComma, FcOpFloor, FcOpCeil, FcOpRound, FcOpTrunc,
219     FcOpInvalid
220 } FcOp;
221
222 typedef enum _FcOpFlags {
223         FcOpFlagIgnoreBlanks = 1 << 0
224 } FcOpFlags;
225
226 #define FC_OP_GET_OP(_x_)       ((_x_) & 0xffff)
227 #define FC_OP_GET_FLAGS(_x_)    (((_x_) & 0xffff0000) >> 16)
228 #define FC_OP(_x_,_f_)          (FC_OP_GET_OP (_x_) | ((_f_) << 16))
229
230 typedef struct _FcExprMatrix {
231   struct _FcExpr *xx, *xy, *yx, *yy;
232 } FcExprMatrix;
233
234 typedef struct _FcExprName {
235   FcObject      object;
236   FcMatchKind   kind;
237 } FcExprName;
238
239
240 typedef struct _FcExpr {
241     FcOp   op;
242     union {
243         int         ival;
244         double      dval;
245         const FcChar8       *sval;
246         FcExprMatrix *mexpr;
247         FcBool      bval;
248         FcCharSet   *cval;
249         FcLangSet   *lval;
250
251         FcExprName  name;
252         const FcChar8       *constant;
253         struct {
254             struct _FcExpr *left, *right;
255         } tree;
256     } u;
257 } FcExpr;
258
259 typedef struct _FcExprPage FcExprPage;
260
261 struct _FcExprPage {
262   FcExprPage *next_page;
263   FcExpr *next;
264   FcExpr exprs[(1024 - 2/* two pointers */ - 2/* malloc overhead */) * sizeof (void *) / sizeof (FcExpr)];
265   FcExpr end[FLEXIBLE_ARRAY_MEMBER];
266 };
267
268 typedef enum _FcQual {
269     FcQualAny, FcQualAll, FcQualFirst, FcQualNotFirst
270 } FcQual;
271
272 #define FcMatchDefault  ((FcMatchKind) -1)
273
274 typedef struct _FcTest {
275     struct _FcTest      *next;
276     FcMatchKind         kind;
277     FcQual              qual;
278     FcObject            object;
279     FcOp                op;
280     FcExpr              *expr;
281 } FcTest;
282
283 typedef struct _FcEdit {
284     struct _FcEdit *next;
285     FcObject        object;
286     FcOp            op;
287     FcExpr          *expr;
288     FcValueBinding  binding;
289 } FcEdit;
290
291 typedef struct _FcSubst {
292     struct _FcSubst     *next;
293     FcTest              *test;
294     FcEdit              *edit;
295 } FcSubst;
296
297 typedef struct _FcCharLeaf {
298     FcChar32    map[256/32];
299 } FcCharLeaf;
300
301 struct _FcCharSet {
302     FcRef           ref;        /* reference count */
303     int             num;        /* size of leaves and numbers arrays */
304     intptr_t        leaves_offset;
305     intptr_t        numbers_offset;
306 };
307
308 #define FcCharSetLeaves(c)      FcOffsetMember(c,leaves_offset,intptr_t)
309 #define FcCharSetLeaf(c,i)      (FcOffsetToPtr(FcCharSetLeaves(c), \
310                                                FcCharSetLeaves(c)[i], \
311                                                FcCharLeaf))
312 #define FcCharSetNumbers(c)     FcOffsetMember(c,numbers_offset,FcChar16)
313
314 struct _FcStrSet {
315     FcRef           ref;        /* reference count */
316     int             num;
317     int             size;
318     FcChar8         **strs;
319 };
320
321 struct _FcStrList {
322     FcStrSet        *set;
323     int             n;
324 };
325
326 typedef struct _FcStrBuf {
327     FcChar8 *buf;
328     FcBool  allocated;
329     FcBool  failed;
330     int     len;
331     int     size;
332     FcChar8 buf_static[16 * sizeof (void *)];
333 } FcStrBuf;
334
335 struct _FcCache {
336     unsigned int magic;              /* FC_CACHE_MAGIC_MMAP or FC_CACHE_ALLOC */
337     int         version;            /* FC_CACHE_CONTENT_VERSION */
338     intptr_t    size;               /* size of file */
339     intptr_t    dir;                /* offset to dir name */
340     intptr_t    dirs;               /* offset to subdirs */
341     int         dirs_count;         /* number of subdir strings */
342     intptr_t    set;                /* offset to font set */
343     int         checksum;           /* checksum of directory state */
344 };
345
346 #undef FcCacheDir
347 #undef FcCacheSubdir
348 #define FcCacheDir(c)   FcOffsetMember(c,dir,FcChar8)
349 #define FcCacheDirs(c)  FcOffsetMember(c,dirs,intptr_t)
350 #define FcCacheSet(c)   FcOffsetMember(c,set,FcFontSet)
351 #define FcCacheSubdir(c,i)  FcOffsetToPtr (FcCacheDirs(c),\
352                                            FcCacheDirs(c)[i], \
353                                            FcChar8)
354
355 /*
356  * Used while constructing a directory cache object
357  */
358
359 #define FC_SERIALIZE_HASH_SIZE  8191
360
361 typedef union _FcAlign {
362     double      d;
363     int         i;
364     intptr_t    ip;
365     FcBool      b;
366     void        *p;
367 } FcAlign;
368
369 typedef struct _FcSerializeBucket {
370     struct _FcSerializeBucket *next;
371     const void  *object;
372     intptr_t    offset;
373 } FcSerializeBucket;
374
375 typedef struct _FcCharSetFreezer FcCharSetFreezer;
376
377 typedef struct _FcSerialize {
378     intptr_t            size;
379     FcCharSetFreezer    *cs_freezer;
380     void                *linear;
381     FcSerializeBucket   *buckets[FC_SERIALIZE_HASH_SIZE];
382 } FcSerialize;
383
384 /*
385  * To map adobe glyph names to unicode values, a precomputed hash
386  * table is used
387  */
388
389 typedef struct _FcGlyphName {
390     FcChar32    ucs;            /* unicode value */
391     FcChar8     name[1];        /* name extends beyond struct */
392 } FcGlyphName;
393
394 /*
395  * To perform case-insensitive string comparisons, a table
396  * is used which holds three different kinds of folding data.
397  *
398  * The first is a range of upper case values mapping to a range
399  * of their lower case equivalents.  Within each range, the offset
400  * between upper and lower case is constant.
401  *
402  * The second is a range of upper case values which are interleaved
403  * with their lower case equivalents.
404  *
405  * The third is a set of raw unicode values mapping to a list
406  * of unicode values for comparison purposes.  This allows conversion
407  * of ß to "ss" so that SS, ss and ß all match.  A separate array
408  * holds the list of unicode values for each entry.
409  *
410  * These are packed into a single table.  Using a binary search,
411  * the appropriate entry can be located.
412  */
413
414 #define FC_CASE_FOLD_RANGE          0
415 #define FC_CASE_FOLD_EVEN_ODD       1
416 #define FC_CASE_FOLD_FULL           2
417
418 typedef struct _FcCaseFold {
419     FcChar32    upper;
420     FcChar16    method : 2;
421     FcChar16    count : 14;
422     short       offset;     /* lower - upper for RANGE, table id for FULL */
423 } FcCaseFold;
424
425 #define FC_MAX_FILE_LEN     4096
426
427 #define FC_CACHE_MAGIC_MMAP         0xFC02FC04
428 #define FC_CACHE_MAGIC_ALLOC        0xFC02FC05
429 #define FC_CACHE_CONTENT_VERSION    3
430
431 struct _FcAtomic {
432     FcChar8     *file;          /* original file name */
433     FcChar8     *new;           /* temp file name -- write data here */
434     FcChar8     *lck;           /* lockfile name (used for locking) */
435     FcChar8     *tmp;           /* tmpfile name (used for locking) */
436 };
437
438 struct _FcBlanks {
439     int         nblank;
440     int         sblank;
441     FcChar32    *blanks;
442 };
443
444 struct _FcConfig {
445     /*
446      * File names loaded from the configuration -- saved here as the
447      * cache file must be consulted before the directories are scanned,
448      * and those directives may occur in any order
449      */
450     FcStrSet    *configDirs;        /* directories to scan for fonts */
451     /*
452      * Set of allowed blank chars -- used to
453      * trim fonts of bogus glyphs
454      */
455     FcBlanks    *blanks;
456     /*
457      * List of directories containing fonts,
458      * built by recursively scanning the set
459      * of configured directories
460      */
461     FcStrSet    *fontDirs;
462     /*
463      * List of directories containing cache files.
464      */
465     FcStrSet    *cacheDirs;
466     /*
467      * Names of all of the configuration files used
468      * to create this configuration
469      */
470     FcStrSet    *configFiles;       /* config files loaded */
471     /*
472      * Substitution instructions for patterns and fonts;
473      * maxObjects is used to allocate appropriate intermediate storage
474      * while performing a whole set of substitutions
475      */
476     FcSubst     *substPattern;      /* substitutions for patterns */
477     FcSubst     *substFont;         /* substitutions for fonts */
478     FcSubst     *substScan;         /* substitutions for scanned fonts */
479     int         maxObjects;         /* maximum number of tests in all substs */
480     /*
481      * List of patterns used to control font file selection
482      */
483     FcStrSet    *acceptGlobs;
484     FcStrSet    *rejectGlobs;
485     FcFontSet   *acceptPatterns;
486     FcFontSet   *rejectPatterns;
487     /*
488      * The set of fonts loaded from the listed directories; the
489      * order within the set does not determine the font selection,
490      * except in the case of identical matches in which case earlier fonts
491      * match preferrentially
492      */
493     FcFontSet   *fonts[FcSetApplication + 1];
494     /*
495      * Fontconfig can periodically rescan the system configuration
496      * and font directories.  This rescanning occurs when font
497      * listing requests are made, but no more often than rescanInterval
498      * seconds apart.
499      */
500     time_t      rescanTime;         /* last time information was scanned */
501     int         rescanInterval;     /* interval between scans */
502
503     FcRef       ref;                /* reference count */
504
505     FcExprPage *expr_pool;          /* pool of FcExpr's */
506 };
507
508 extern FcPrivate FcConfig       *_fcConfig;
509
510 typedef struct _FcFileTime {
511     time_t  time;
512     FcBool  set;
513 } FcFileTime;
514
515 typedef struct _FcCharMap FcCharMap;
516
517 typedef struct _FcRange     FcRange;
518
519 struct _FcRange {
520     FcChar32 begin;
521     FcChar32 end;
522 };
523
524 typedef struct _FcStatFS    FcStatFS;
525
526 struct _FcStatFS {
527     FcBool is_remote_fs;
528     FcBool is_mtime_broken;
529 };
530
531 typedef struct _FcValuePromotionBuffer FcValuePromotionBuffer;
532
533 struct _FcValuePromotionBuffer {
534   union {
535     double d;
536     int i;
537     long l;
538     char c[256]; /* Enlarge as needed */
539   } u;
540 };
541
542 /* fcblanks.c */
543
544 /* fccache.c */
545
546 FcPrivate FcCache *
547 FcDirCacheScan (const FcChar8 *dir, FcConfig *config);
548
549 FcPrivate FcCache *
550 FcDirCacheBuild (FcFontSet *set, const FcChar8 *dir, struct stat *dir_stat, FcStrSet *dirs);
551
552 FcPrivate FcBool
553 FcDirCacheWrite (FcCache *cache, FcConfig *config);
554
555 FcPrivate FcBool
556 FcDirCacheCreateTagFile (const FcChar8 *cache_dir);
557
558 FcPrivate void
559 FcCacheObjectReference (void *object);
560
561 FcPrivate void
562 FcCacheObjectDereference (void *object);
563
564 FcPrivate void
565 FcCacheFini (void);
566
567 FcPrivate void
568 FcDirCacheReference (FcCache *cache, int nref);
569
570 /* fccfg.c */
571
572 FcPrivate FcChar8 *
573 FcConfigXdgCacheHome (void);
574
575 FcPrivate FcChar8 *
576 FcConfigXdgConfigHome (void);
577
578 FcPrivate FcChar8 *
579 FcConfigXdgDataHome (void);
580
581 FcPrivate FcExpr *
582 FcConfigAllocExpr (FcConfig *config);
583
584 FcPrivate FcBool
585 FcConfigAddConfigDir (FcConfig      *config,
586                       const FcChar8 *d);
587
588 FcPrivate FcBool
589 FcConfigAddFontDir (FcConfig        *config,
590                     const FcChar8   *d);
591
592 FcPrivate FcBool
593 FcConfigAddDir (FcConfig        *config,
594                 const FcChar8   *d);
595
596 FcPrivate FcBool
597 FcConfigAddCacheDir (FcConfig       *config,
598                      const FcChar8  *d);
599
600 FcPrivate FcBool
601 FcConfigAddConfigFile (FcConfig         *config,
602                        const FcChar8    *f);
603
604 FcPrivate FcBool
605 FcConfigAddBlank (FcConfig      *config,
606                   FcChar32      blank);
607
608 FcPrivate FcBool
609 FcConfigAddEdit (FcConfig       *config,
610                  FcTest         *test,
611                  FcEdit         *edit,
612                  FcMatchKind    kind);
613
614 FcPrivate void
615 FcConfigSetFonts (FcConfig      *config,
616                   FcFontSet     *fonts,
617                   FcSetName     set);
618
619 FcPrivate FcBool
620 FcConfigCompareValue (const FcValue *m,
621                       FcOp          op,
622                       const FcValue *v);
623
624 FcPrivate FcBool
625 FcConfigGlobAdd (FcConfig       *config,
626                  const FcChar8  *glob,
627                  FcBool         accept);
628
629 FcPrivate FcBool
630 FcConfigAcceptFilename (FcConfig        *config,
631                         const FcChar8   *filename);
632
633 FcPrivate FcBool
634 FcConfigPatternsAdd (FcConfig   *config,
635                      FcPattern  *pattern,
636                      FcBool     accept);
637
638 FcPrivate FcBool
639 FcConfigAcceptFont (FcConfig        *config,
640                     const FcPattern *font);
641
642 FcPrivate FcFileTime
643 FcConfigModifiedTime (FcConfig *config);
644
645 FcPrivate FcBool
646 FcConfigAddCache (FcConfig *config, FcCache *cache,
647                   FcSetName set, FcStrSet *dirSet);
648
649 /* fcserialize.c */
650 FcPrivate intptr_t
651 FcAlignSize (intptr_t size);
652
653 FcPrivate FcSerialize *
654 FcSerializeCreate (void);
655
656 FcPrivate void
657 FcSerializeDestroy (FcSerialize *serialize);
658
659 FcPrivate FcBool
660 FcSerializeAlloc (FcSerialize *serialize, const void *object, int size);
661
662 FcPrivate intptr_t
663 FcSerializeReserve (FcSerialize *serialize, int size);
664
665 FcPrivate intptr_t
666 FcSerializeOffset (FcSerialize *serialize, const void *object);
667
668 FcPrivate void *
669 FcSerializePtr (FcSerialize *serialize, const void *object);
670
671 FcPrivate FcBool
672 FcLangSetSerializeAlloc (FcSerialize *serialize, const FcLangSet *l);
673
674 FcPrivate FcLangSet *
675 FcLangSetSerialize(FcSerialize *serialize, const FcLangSet *l);
676
677 /* fccharset.c */
678 FcPrivate void
679 FcLangCharSetPopulate (void);
680
681 FcPrivate FcCharSetFreezer *
682 FcCharSetFreezerCreate (void);
683
684 FcPrivate const FcCharSet *
685 FcCharSetFreeze (FcCharSetFreezer *freezer, const FcCharSet *fcs);
686
687 FcPrivate void
688 FcCharSetFreezerDestroy (FcCharSetFreezer *freezer);
689
690 FcPrivate FcBool
691 FcNameUnparseCharSet (FcStrBuf *buf, const FcCharSet *c);
692
693 FcPrivate FcCharSet *
694 FcNameParseCharSet (FcChar8 *string);
695
696 FcPrivate FcBool
697 FcNameUnparseValue (FcStrBuf    *buf,
698                     FcValue     *v0,
699                     FcChar8     *escape);
700
701 FcPrivate FcBool
702 FcNameUnparseValueList (FcStrBuf        *buf,
703                         FcValueListPtr  v,
704                         FcChar8         *escape);
705
706 FcPrivate FcCharLeaf *
707 FcCharSetFindLeafCreate (FcCharSet *fcs, FcChar32 ucs4);
708
709 FcPrivate FcBool
710 FcCharSetSerializeAlloc(FcSerialize *serialize, const FcCharSet *cs);
711
712 FcPrivate FcCharSet *
713 FcCharSetSerialize(FcSerialize *serialize, const FcCharSet *cs);
714
715 FcPrivate FcChar16 *
716 FcCharSetGetNumbers(const FcCharSet *c);
717
718 /* fcdbg.c */
719
720 FcPrivate void
721 FcValuePrintFile (FILE *f, const FcValue v);
722
723 FcPrivate void
724 FcValuePrintWithPosition (const FcValue v, FcBool show_pos_mark);
725
726 FcPrivate void
727 FcValueListPrintWithPosition (FcValueListPtr l, const FcValueListPtr pos);
728
729 FcPrivate void
730 FcValueListPrint (FcValueListPtr l);
731
732 FcPrivate void
733 FcLangSetPrint (const FcLangSet *ls);
734
735 FcPrivate void
736 FcOpPrint (FcOp op);
737
738 FcPrivate void
739 FcTestPrint (const FcTest *test);
740
741 FcPrivate void
742 FcExprPrint (const FcExpr *expr);
743
744 FcPrivate void
745 FcEditPrint (const FcEdit *edit);
746
747 FcPrivate void
748 FcSubstPrint (const FcSubst *subst);
749
750 FcPrivate void
751 FcCharSetPrint (const FcCharSet *c);
752
753 extern FcPrivate int FcDebugVal;
754
755 #define FcDebug() (FcDebugVal)
756
757 FcPrivate void
758 FcInitDebug (void);
759
760 /* fcdefault.c */
761 FcPrivate FcChar8 *
762 FcGetDefaultLang (void);
763
764 FcPrivate void
765 FcDefaultFini (void);
766
767 /* fcdir.c */
768
769 FcPrivate FcBool
770 FcFileIsLink (const FcChar8 *file);
771
772 FcPrivate FcBool
773 FcFileScanConfig (FcFontSet     *set,
774                   FcStrSet      *dirs,
775                   FcBlanks      *blanks,
776                   const FcChar8 *file,
777                   FcConfig      *config);
778
779 FcPrivate FcBool
780 FcDirScanConfig (FcFontSet      *set,
781                  FcStrSet       *dirs,
782                  FcBlanks       *blanks,
783                  const FcChar8  *dir,
784                  FcBool         force,
785                  FcConfig       *config);
786
787 /* fcfont.c */
788 FcPrivate int
789 FcFontDebug (void);
790
791 /* fcfs.c */
792
793 FcPrivate FcBool
794 FcFontSetSerializeAlloc (FcSerialize *serialize, const FcFontSet *s);
795
796 FcPrivate FcFontSet *
797 FcFontSetSerialize (FcSerialize *serialize, const FcFontSet * s);
798
799 /* fcxml.c */
800 FcPrivate void
801 FcTestDestroy (FcTest *test);
802
803 FcPrivate void
804 FcEditDestroy (FcEdit *e);
805
806 /* fclang.c */
807 FcPrivate FcLangSet *
808 FcFreeTypeLangSet (const FcCharSet  *charset,
809                    const FcChar8    *exclusiveLang);
810
811 FcPrivate FcChar8 *
812 FcLangNormalize (const FcChar8 *lang);
813
814 FcPrivate FcLangResult
815 FcLangCompare (const FcChar8 *s1, const FcChar8 *s2);
816
817 FcPrivate FcLangSet *
818 FcLangSetPromote (const FcChar8 *lang, FcValuePromotionBuffer *buf);
819
820 FcPrivate FcLangSet *
821 FcNameParseLangSet (const FcChar8 *string);
822
823 FcPrivate FcBool
824 FcNameUnparseLangSet (FcStrBuf *buf, const FcLangSet *ls);
825
826 FcPrivate FcChar8 *
827 FcNameUnparseEscaped (FcPattern *pat, FcBool escape);
828
829 /* fclist.c */
830
831 FcPrivate FcBool
832 FcListPatternMatchAny (const FcPattern *p,
833                        const FcPattern *font);
834
835 /* fcmatch.c */
836
837 /* fcname.c */
838
839 enum {
840   FC_INVALID_OBJECT = 0,
841 #define FC_OBJECT(NAME, Type) FC_##NAME##_OBJECT,
842 #include "fcobjs.h"
843 #undef FC_OBJECT
844   FC_ONE_AFTER_MAX_BASE_OBJECT
845 #define FC_MAX_BASE_OBJECT (FC_ONE_AFTER_MAX_BASE_OBJECT - 1)
846 };
847
848 FcPrivate FcBool
849 FcNameBool (const FcChar8 *v, FcBool *result);
850
851 FcPrivate FcBool
852 FcObjectValidType (FcObject object, FcType type);
853
854 FcPrivate FcObject
855 FcObjectFromName (const char * name);
856
857 FcPrivate const char *
858 FcObjectName (FcObject object);
859
860 FcPrivate FcObjectSet *
861 FcObjectGetSet (void);
862
863 #define FcObjectCompare(a, b)   ((int) a - (int) b)
864
865 /* fcpat.c */
866
867 FcPrivate FcValue
868 FcValueCanonicalize (const FcValue *v);
869
870 FcPrivate FcValueListPtr
871 FcValueListCreate (void);
872
873 FcPrivate void
874 FcValueListDestroy (FcValueListPtr l);
875
876 FcPrivate FcValueListPtr
877 FcValueListPrepend (FcValueListPtr vallist,
878                     FcValue        value,
879                     FcValueBinding binding);
880
881 FcPrivate FcValueListPtr
882 FcValueListAppend (FcValueListPtr vallist,
883                    FcValue        value,
884                    FcValueBinding binding);
885
886 FcPrivate FcValueListPtr
887 FcValueListDuplicate(FcValueListPtr orig);
888
889 FcPrivate FcPatternElt *
890 FcPatternObjectFindElt (const FcPattern *p, FcObject object);
891
892 FcPrivate FcPatternElt *
893 FcPatternObjectInsertElt (FcPattern *p, FcObject object);
894
895 FcPrivate FcBool
896 FcPatternObjectListAdd (FcPattern       *p,
897                         FcObject        object,
898                         FcValueListPtr  list,
899                         FcBool          append);
900
901 FcPrivate FcBool
902 FcPatternObjectAddWithBinding  (FcPattern       *p,
903                                 FcObject        object,
904                                 FcValue         value,
905                                 FcValueBinding  binding,
906                                 FcBool          append);
907
908 FcPrivate FcBool
909 FcPatternObjectAdd (FcPattern *p, FcObject object, FcValue value, FcBool append);
910
911 FcPrivate FcBool
912 FcPatternObjectAddWeak (FcPattern *p, FcObject object, FcValue value, FcBool append);
913
914 FcPrivate FcResult
915 FcPatternObjectGet (const FcPattern *p, FcObject object, int id, FcValue *v);
916
917 FcPrivate FcBool
918 FcPatternObjectDel (FcPattern *p, FcObject object);
919
920 FcPrivate FcBool
921 FcPatternObjectRemove (FcPattern *p, FcObject object, int id);
922
923 FcPrivate FcBool
924 FcPatternObjectAddInteger (FcPattern *p, FcObject object, int i);
925
926 FcPrivate FcBool
927 FcPatternObjectAddDouble (FcPattern *p, FcObject object, double d);
928
929 FcPrivate FcBool
930 FcPatternObjectAddString (FcPattern *p, FcObject object, const FcChar8 *s);
931
932 FcPrivate FcBool
933 FcPatternObjectAddMatrix (FcPattern *p, FcObject object, const FcMatrix *s);
934
935 FcPrivate FcBool
936 FcPatternObjectAddCharSet (FcPattern *p, FcObject object, const FcCharSet *c);
937
938 FcPrivate FcBool
939 FcPatternObjectAddBool (FcPattern *p, FcObject object, FcBool b);
940
941 FcPrivate FcBool
942 FcPatternObjectAddLangSet (FcPattern *p, FcObject object, const FcLangSet *ls);
943
944 FcPrivate FcResult
945 FcPatternObjectGetInteger (const FcPattern *p, FcObject object, int n, int *i);
946
947 FcPrivate FcResult
948 FcPatternObjectGetDouble (const FcPattern *p, FcObject object, int n, double *d);
949
950 FcPrivate FcResult
951 FcPatternObjectGetString (const FcPattern *p, FcObject object, int n, FcChar8 ** s);
952
953 FcPrivate FcResult
954 FcPatternObjectGetMatrix (const FcPattern *p, FcObject object, int n, FcMatrix **s);
955
956 FcPrivate FcResult
957 FcPatternObjectGetCharSet (const FcPattern *p, FcObject object, int n, FcCharSet **c);
958
959 FcPrivate FcResult
960 FcPatternObjectGetBool (const FcPattern *p, FcObject object, int n, FcBool *b);
961
962 FcPrivate FcResult
963 FcPatternObjectGetLangSet (const FcPattern *p, FcObject object, int n, FcLangSet **ls);
964
965 FcPrivate FcBool
966 FcPatternAppend (FcPattern *p, FcPattern *s);
967
968 FcPrivate const FcChar8 *
969 FcSharedStr (const FcChar8 *name);
970
971 FcPrivate FcBool
972 FcSharedStrFree (FcChar8 *name);
973
974 FcPrivate FcChar32
975 FcStringHash (const FcChar8 *s);
976
977 FcPrivate FcBool
978 FcPatternSerializeAlloc (FcSerialize *serialize, const FcPattern *pat);
979
980 FcPrivate FcPattern *
981 FcPatternSerialize (FcSerialize *serialize, const FcPattern *pat);
982
983 FcPrivate FcBool
984 FcValueListSerializeAlloc (FcSerialize *serialize, const FcValueList *pat);
985
986 FcPrivate FcValueList *
987 FcValueListSerialize (FcSerialize *serialize, const FcValueList *pat);
988
989 /* fcrender.c */
990
991 /* fcmatrix.c */
992
993 extern FcPrivate const FcMatrix    FcIdentityMatrix;
994
995 FcPrivate void
996 FcMatrixFree (FcMatrix *mat);
997
998 /* fcstat.c */
999
1000 FcPrivate int
1001 FcStat (const FcChar8 *file, struct stat *statb);
1002
1003 FcPrivate int
1004 FcStatChecksum (const FcChar8 *file, struct stat *statb);
1005
1006 FcPrivate FcBool
1007 FcIsFsMmapSafe (int fd);
1008
1009 FcPrivate FcBool
1010 FcIsFsMtimeBroken (const FcChar8 *dir);
1011
1012 /* fcstr.c */
1013 FcPrivate FcBool
1014 FcStrSetAddLangs (FcStrSet *strs, const char *languages);
1015
1016 FcPrivate void
1017 FcStrSetSort (FcStrSet * set);
1018
1019 FcPrivate void
1020 FcStrBufInit (FcStrBuf *buf, FcChar8 *init, int size);
1021
1022 FcPrivate void
1023 FcStrBufDestroy (FcStrBuf *buf);
1024
1025 FcPrivate FcChar8 *
1026 FcStrBufDone (FcStrBuf *buf);
1027
1028 FcPrivate FcChar8 *
1029 FcStrBufDoneStatic (FcStrBuf *buf);
1030
1031 FcPrivate FcBool
1032 FcStrBufChar (FcStrBuf *buf, FcChar8 c);
1033
1034 FcPrivate FcBool
1035 FcStrBufString (FcStrBuf *buf, const FcChar8 *s);
1036
1037 FcPrivate FcBool
1038 FcStrBufData (FcStrBuf *buf, const FcChar8 *s, int len);
1039
1040 FcPrivate int
1041 FcStrCmpIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2);
1042
1043 FcPrivate FcBool
1044 FcStrRegexCmp (const FcChar8 *s, const FcChar8 *regex);
1045
1046 FcPrivate FcBool
1047 FcStrRegexCmpIgnoreCase (const FcChar8 *s, const FcChar8 *regex);
1048
1049 FcPrivate const FcChar8 *
1050 FcStrContainsIgnoreBlanksAndCase (const FcChar8 *s1, const FcChar8 *s2);
1051
1052 FcPrivate const FcChar8 *
1053 FcStrContainsIgnoreCase (const FcChar8 *s1, const FcChar8 *s2);
1054
1055 FcPrivate const FcChar8 *
1056 FcStrContainsWord (const FcChar8 *s1, const FcChar8 *s2);
1057
1058 FcPrivate FcBool
1059 FcStrUsesHome (const FcChar8 *s);
1060
1061 FcPrivate FcChar8 *
1062 FcStrLastSlash (const FcChar8  *path);
1063
1064 FcPrivate FcChar32
1065 FcStrHashIgnoreCase (const FcChar8 *s);
1066
1067 FcPrivate FcChar8 *
1068 FcStrCanonFilename (const FcChar8 *s);
1069
1070 FcPrivate FcBool
1071 FcStrSerializeAlloc (FcSerialize *serialize, const FcChar8 *str);
1072
1073 FcPrivate FcChar8 *
1074 FcStrSerialize (FcSerialize *serialize, const FcChar8 *str);
1075
1076 /* fcobjs.c */
1077
1078 FcPrivate FcObject
1079 FcObjectLookupIdByName (const char *str);
1080
1081 FcPrivate FcObject
1082 FcObjectLookupBuiltinIdByName (const char *str);
1083
1084 FcPrivate const char *
1085 FcObjectLookupOtherNameById (FcObject id);
1086
1087 FcPrivate const FcObjectType *
1088 FcObjectLookupOtherTypeById (FcObject id);
1089
1090 FcPrivate const FcObjectType *
1091 FcObjectLookupOtherTypeByName (const char *str);
1092
1093 #endif /* _FC_INT_H_ */