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