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