~ubuntu-branches/ubuntu/gutsy/vnc4/gutsy

« back to all changes in this revision

Viewing changes to unix/xc/extras/freetype2/include/freetype/cache/ftcmanag.h

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2006-05-15 20:35:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515203517-l4lre1ku942mn26k
Tags: 4.1.1+X4.3.0-10
* Correction of critical security issue. Thanks to Martin Kogler
  <e9925248@student.tuwien.ac.at> that informed me about the issue,
  and provided the patch.
  This flaw was originally found by Steve Wiseman of intelliadmin.com.
* Applied patch from Javier Kohen <jkohen@users.sourceforge.net> that
  inform the user that only 8 first characters of the password will
  actually be used when typing more than 8 characters, closes:
  #355619.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************/
 
2
/*                                                                         */
 
3
/*  ftcmanag.h                                                             */
 
4
/*                                                                         */
 
5
/*    FreeType Cache Manager (specification).                              */
 
6
/*                                                                         */
 
7
/*  Copyright 2000-2001 by                                                 */
 
8
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 
9
/*                                                                         */
 
10
/*  This file is part of the FreeType project, and may only be used,       */
 
11
/*  modified, and distributed under the terms of the FreeType project      */
 
12
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
 
13
/*  this file you indicate that you have read the license and              */
 
14
/*  understand and accept it fully.                                        */
 
15
/*                                                                         */
 
16
/***************************************************************************/
 
17
 
 
18
 
 
19
  /*************************************************************************/
 
20
  /*                                                                       */
 
21
  /* A cache manager is in charge of the following:                        */
 
22
  /*                                                                       */
 
23
  /*  - Maintain a mapping between generic FTC_FaceIDs and live FT_Face    */
 
24
  /*    objects.  The mapping itself is performed through a user-provided  */
 
25
  /*    callback.  However, the manager maintains a small cache of FT_Face */
 
26
  /*    and FT_Size objects in order to speed up things considerably.      */
 
27
  /*                                                                       */
 
28
  /*  - Manage one or more cache objects.  Each cache is in charge of      */
 
29
  /*    holding a varying number of `cache nodes'.  Each cache node        */
 
30
  /*    represents a minimal amount of individually accessible cached      */
 
31
  /*    data.  For example, a cache node can be an FT_Glyph image          */
 
32
  /*    containing a vector outline, or some glyph metrics, or anything    */
 
33
  /*    else.                                                              */
 
34
  /*                                                                       */
 
35
  /*    Each cache node has a certain size in bytes that is added to the   */
 
36
  /*    total amount of `cache memory' within the manager.                 */
 
37
  /*                                                                       */
 
38
  /*    All cache nodes are located in a global LRU list, where the oldest */
 
39
  /*    node is at the tail of the list.                                   */
 
40
  /*                                                                       */
 
41
  /*    Each node belongs to a single cache, and includes a reference      */
 
42
  /*    count to avoid destroying it (due to caching).                     */
 
43
  /*                                                                       */
 
44
  /*************************************************************************/
 
45
 
 
46
 
 
47
  /*************************************************************************/
 
48
  /*************************************************************************/
 
49
  /*************************************************************************/
 
50
  /*************************************************************************/
 
51
  /*************************************************************************/
 
52
  /*********                                                       *********/
 
53
  /*********             WARNING, THIS IS BETA CODE.               *********/
 
54
  /*********                                                       *********/
 
55
  /*************************************************************************/
 
56
  /*************************************************************************/
 
57
  /*************************************************************************/
 
58
  /*************************************************************************/
 
59
  /*************************************************************************/
 
60
 
 
61
 
 
62
#ifndef __FTCMANAG_H__
 
63
#define __FTCMANAG_H__
 
64
 
 
65
 
 
66
#include <ft2build.h>
 
67
#include FT_CACHE_H
 
68
#include FT_CACHE_INTERNAL_LRU_H
 
69
#include FT_CACHE_INTERNAL_CACHE_H
 
70
 
 
71
 
 
72
FT_BEGIN_HEADER
 
73
 
 
74
 
 
75
  /*************************************************************************/
 
76
  /*                                                                       */
 
77
  /* <Section>                                                             */
 
78
  /*    cache_subsystem                                                    */
 
79
  /*                                                                       */
 
80
  /*************************************************************************/
 
81
 
 
82
 
 
83
#define FTC_MAX_FACES_DEFAULT  2
 
84
#define FTC_MAX_SIZES_DEFAULT  4
 
85
#define FTC_MAX_BYTES_DEFAULT  200000L  /* ~200kByte by default */
 
86
 
 
87
  /* maximum number of caches registered in a single manager */
 
88
#define FTC_MAX_CACHES         16
 
89
 
 
90
 
 
91
  typedef struct  FTC_FamilyEntryRec_
 
92
  {
 
93
    FTC_Family  family;
 
94
    FTC_Cache   cache;
 
95
    FT_UInt     index;
 
96
    FT_UInt     link;
 
97
 
 
98
  } FTC_FamilyEntryRec, *FTC_FamilyEntry;
 
99
 
 
100
 
 
101
#define FTC_FAMILY_ENTRY_NONE  ( (FT_UInt)-1 )
 
102
 
 
103
 
 
104
  typedef struct  FTC_FamilyTableRec_
 
105
  {
 
106
    FT_UInt          count;
 
107
    FT_UInt          size;
 
108
    FTC_FamilyEntry  entries;
 
109
    FT_UInt          free;
 
110
  
 
111
  } FTC_FamilyTableRec, *FTC_FamilyTable;
 
112
 
 
113
 
 
114
  FT_EXPORT( FT_Error )
 
115
  ftc_family_table_alloc( FTC_FamilyTable   table,
 
116
                          FT_Memory         memory,
 
117
                          FTC_FamilyEntry  *aentry );
 
118
 
 
119
  FT_EXPORT( void )
 
120
  ftc_family_table_free( FTC_FamilyTable  table,
 
121
                         FT_UInt          idx );
 
122
 
 
123
 
 
124
  /*************************************************************************/
 
125
  /*                                                                       */
 
126
  /* <Struct>                                                              */
 
127
  /*    FTC_ManagerRec                                                     */
 
128
  /*                                                                       */
 
129
  /* <Description>                                                         */
 
130
  /*    The cache manager structure.                                       */
 
131
  /*                                                                       */
 
132
  /* <Fields>                                                              */
 
133
  /*    library      :: A handle to a FreeType library instance.           */
 
134
  /*                                                                       */
 
135
  /*    faces_list   :: The lru list of @FT_Face objects in the cache.     */
 
136
  /*                                                                       */
 
137
  /*    sizes_list   :: The lru list of @FT_Size objects in the cache.     */
 
138
  /*                                                                       */
 
139
  /*    max_weight   :: The maximum cache pool weight.                     */
 
140
  /*                                                                       */
 
141
  /*    cur_weight   :: The current cache pool weight.                     */
 
142
  /*                                                                       */
 
143
  /*    num_nodes    :: The current number of nodes in the manager.        */
 
144
  /*                                                                       */
 
145
  /*    nodes_list   :: The global lru list of all cache nodes.            */
 
146
  /*                                                                       */
 
147
  /*    caches       :: A table of installed/registered cache objects.     */
 
148
  /*                                                                       */
 
149
  /*    request_data :: User-provided data passed to the requester.        */
 
150
  /*                                                                       */
 
151
  /*    request_face :: User-provided function used to implement a mapping */
 
152
  /*                    between abstract @FTC_FaceID values and real       */
 
153
  /*                    @FT_Face objects.                                  */
 
154
  /*                                                                       */
 
155
  /*    families     :: Global table of families.                          */
 
156
  /*                                                                       */
 
157
  typedef struct  FTC_ManagerRec_
 
158
  {
 
159
    FT_Library          library;
 
160
    FT_LruList          faces_list;
 
161
    FT_LruList          sizes_list;
 
162
 
 
163
    FT_ULong            max_weight;
 
164
    FT_ULong            cur_weight;
 
165
    
 
166
    FT_UInt             num_nodes;
 
167
    FTC_Node            nodes_list;
 
168
    
 
169
    FTC_Cache           caches[FTC_MAX_CACHES];
 
170
 
 
171
    FT_Pointer          request_data;
 
172
    FTC_Face_Requester  request_face;
 
173
 
 
174
    FTC_FamilyTableRec  families;
 
175
 
 
176
  } FTC_ManagerRec;
 
177
 
 
178
 
 
179
  /*************************************************************************/
 
180
  /*                                                                       */
 
181
  /* <Function>                                                            */
 
182
  /*    FTC_Manager_Compress                                               */
 
183
  /*                                                                       */
 
184
  /* <Description>                                                         */
 
185
  /*    This function is used to check the state of the cache manager if   */
 
186
  /*    its `num_bytes' field is greater than its `max_bytes' field.  It   */
 
187
  /*    will flush as many old cache nodes as possible (ignoring cache     */
 
188
  /*    nodes with a non-zero reference count).                            */
 
189
  /*                                                                       */
 
190
  /* <InOut>                                                               */
 
191
  /*    manager :: A handle to the cache manager.                          */
 
192
  /*                                                                       */
 
193
  /* <Note>                                                                */
 
194
  /*    Client applications should not call this function directly.  It is */
 
195
  /*    normally invoked by specific cache implementations.                */
 
196
  /*                                                                       */
 
197
  /*    The reason this function is exported is to allow client-specific   */
 
198
  /*    cache classes.                                                     */
 
199
  /*                                                                       */
 
200
  FT_EXPORT( void )
 
201
  FTC_Manager_Compress( FTC_Manager  manager );
 
202
 
 
203
 
 
204
  /* this must be used internally for the moment */
 
205
  FT_EXPORT( FT_Error )
 
206
  FTC_Manager_Register_Cache( FTC_Manager      manager,
 
207
                              FTC_Cache_Class  clazz,
 
208
                              FTC_Cache       *acache );
 
209
 
 
210
 
 
211
  /* can be called to increment a node's reference count */
 
212
  FT_EXPORT( void )
 
213
  FTC_Node_Ref( FTC_Node     node,
 
214
                FTC_Manager  manager );
 
215
 
 
216
 
 
217
  /*************************************************************************/
 
218
  /*                                                                       */
 
219
  /* <Function>                                                            */
 
220
  /*    FTC_Node_Unref                                                     */
 
221
  /*                                                                       */
 
222
  /* <Description>                                                         */
 
223
  /*    Decrement a cache node's internal reference count.  When the count */
 
224
  /*    reaches 0, it is not destroyed but becomes eligible for subsequent */
 
225
  /*    cache flushes.                                                     */
 
226
  /*                                                                       */
 
227
  /* <Input>                                                               */
 
228
  /*    node    :: The cache node handle.                                  */
 
229
  /*                                                                       */
 
230
  /*    manager :: The cache manager handle.                               */
 
231
  /*                                                                       */
 
232
  FT_EXPORT( void )
 
233
  FTC_Node_Unref( FTC_Node     node,
 
234
                  FTC_Manager  manager );
 
235
 
 
236
 /* */
 
237
 
 
238
FT_END_HEADER
 
239
 
 
240
 
 
241
#endif /* __FTCMANAG_H__ */
 
242
 
 
243
 
 
244
/* END */