Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /***************************************************************************/ |
michael@0 | 2 | /* */ |
michael@0 | 3 | /* ftsystem.h */ |
michael@0 | 4 | /* */ |
michael@0 | 5 | /* FreeType low-level system interface definition (specification). */ |
michael@0 | 6 | /* */ |
michael@0 | 7 | /* Copyright 1996-2001, 2002, 2005, 2010 by */ |
michael@0 | 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
michael@0 | 9 | /* */ |
michael@0 | 10 | /* This file is part of the FreeType project, and may only be used, */ |
michael@0 | 11 | /* modified, and distributed under the terms of the FreeType project */ |
michael@0 | 12 | /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
michael@0 | 13 | /* this file you indicate that you have read the license and */ |
michael@0 | 14 | /* understand and accept it fully. */ |
michael@0 | 15 | /* */ |
michael@0 | 16 | /***************************************************************************/ |
michael@0 | 17 | |
michael@0 | 18 | |
michael@0 | 19 | #ifndef __FTSYSTEM_H__ |
michael@0 | 20 | #define __FTSYSTEM_H__ |
michael@0 | 21 | |
michael@0 | 22 | |
michael@0 | 23 | #include <ft2build.h> |
michael@0 | 24 | |
michael@0 | 25 | |
michael@0 | 26 | FT_BEGIN_HEADER |
michael@0 | 27 | |
michael@0 | 28 | |
michael@0 | 29 | /*************************************************************************/ |
michael@0 | 30 | /* */ |
michael@0 | 31 | /* <Section> */ |
michael@0 | 32 | /* system_interface */ |
michael@0 | 33 | /* */ |
michael@0 | 34 | /* <Title> */ |
michael@0 | 35 | /* System Interface */ |
michael@0 | 36 | /* */ |
michael@0 | 37 | /* <Abstract> */ |
michael@0 | 38 | /* How FreeType manages memory and i/o. */ |
michael@0 | 39 | /* */ |
michael@0 | 40 | /* <Description> */ |
michael@0 | 41 | /* This section contains various definitions related to memory */ |
michael@0 | 42 | /* management and i/o access. You need to understand this */ |
michael@0 | 43 | /* information if you want to use a custom memory manager or you own */ |
michael@0 | 44 | /* i/o streams. */ |
michael@0 | 45 | /* */ |
michael@0 | 46 | /*************************************************************************/ |
michael@0 | 47 | |
michael@0 | 48 | |
michael@0 | 49 | /*************************************************************************/ |
michael@0 | 50 | /* */ |
michael@0 | 51 | /* M E M O R Y M A N A G E M E N T */ |
michael@0 | 52 | /* */ |
michael@0 | 53 | /*************************************************************************/ |
michael@0 | 54 | |
michael@0 | 55 | |
michael@0 | 56 | /************************************************************************* |
michael@0 | 57 | * |
michael@0 | 58 | * @type: |
michael@0 | 59 | * FT_Memory |
michael@0 | 60 | * |
michael@0 | 61 | * @description: |
michael@0 | 62 | * A handle to a given memory manager object, defined with an |
michael@0 | 63 | * @FT_MemoryRec structure. |
michael@0 | 64 | * |
michael@0 | 65 | */ |
michael@0 | 66 | typedef struct FT_MemoryRec_* FT_Memory; |
michael@0 | 67 | |
michael@0 | 68 | |
michael@0 | 69 | /************************************************************************* |
michael@0 | 70 | * |
michael@0 | 71 | * @functype: |
michael@0 | 72 | * FT_Alloc_Func |
michael@0 | 73 | * |
michael@0 | 74 | * @description: |
michael@0 | 75 | * A function used to allocate `size' bytes from `memory'. |
michael@0 | 76 | * |
michael@0 | 77 | * @input: |
michael@0 | 78 | * memory :: |
michael@0 | 79 | * A handle to the source memory manager. |
michael@0 | 80 | * |
michael@0 | 81 | * size :: |
michael@0 | 82 | * The size in bytes to allocate. |
michael@0 | 83 | * |
michael@0 | 84 | * @return: |
michael@0 | 85 | * Address of new memory block. 0~in case of failure. |
michael@0 | 86 | * |
michael@0 | 87 | */ |
michael@0 | 88 | typedef void* |
michael@0 | 89 | (*FT_Alloc_Func)( FT_Memory memory, |
michael@0 | 90 | long size ); |
michael@0 | 91 | |
michael@0 | 92 | |
michael@0 | 93 | /************************************************************************* |
michael@0 | 94 | * |
michael@0 | 95 | * @functype: |
michael@0 | 96 | * FT_Free_Func |
michael@0 | 97 | * |
michael@0 | 98 | * @description: |
michael@0 | 99 | * A function used to release a given block of memory. |
michael@0 | 100 | * |
michael@0 | 101 | * @input: |
michael@0 | 102 | * memory :: |
michael@0 | 103 | * A handle to the source memory manager. |
michael@0 | 104 | * |
michael@0 | 105 | * block :: |
michael@0 | 106 | * The address of the target memory block. |
michael@0 | 107 | * |
michael@0 | 108 | */ |
michael@0 | 109 | typedef void |
michael@0 | 110 | (*FT_Free_Func)( FT_Memory memory, |
michael@0 | 111 | void* block ); |
michael@0 | 112 | |
michael@0 | 113 | |
michael@0 | 114 | /************************************************************************* |
michael@0 | 115 | * |
michael@0 | 116 | * @functype: |
michael@0 | 117 | * FT_Realloc_Func |
michael@0 | 118 | * |
michael@0 | 119 | * @description: |
michael@0 | 120 | * A function used to re-allocate a given block of memory. |
michael@0 | 121 | * |
michael@0 | 122 | * @input: |
michael@0 | 123 | * memory :: |
michael@0 | 124 | * A handle to the source memory manager. |
michael@0 | 125 | * |
michael@0 | 126 | * cur_size :: |
michael@0 | 127 | * The block's current size in bytes. |
michael@0 | 128 | * |
michael@0 | 129 | * new_size :: |
michael@0 | 130 | * The block's requested new size. |
michael@0 | 131 | * |
michael@0 | 132 | * block :: |
michael@0 | 133 | * The block's current address. |
michael@0 | 134 | * |
michael@0 | 135 | * @return: |
michael@0 | 136 | * New block address. 0~in case of memory shortage. |
michael@0 | 137 | * |
michael@0 | 138 | * @note: |
michael@0 | 139 | * In case of error, the old block must still be available. |
michael@0 | 140 | * |
michael@0 | 141 | */ |
michael@0 | 142 | typedef void* |
michael@0 | 143 | (*FT_Realloc_Func)( FT_Memory memory, |
michael@0 | 144 | long cur_size, |
michael@0 | 145 | long new_size, |
michael@0 | 146 | void* block ); |
michael@0 | 147 | |
michael@0 | 148 | |
michael@0 | 149 | /************************************************************************* |
michael@0 | 150 | * |
michael@0 | 151 | * @struct: |
michael@0 | 152 | * FT_MemoryRec |
michael@0 | 153 | * |
michael@0 | 154 | * @description: |
michael@0 | 155 | * A structure used to describe a given memory manager to FreeType~2. |
michael@0 | 156 | * |
michael@0 | 157 | * @fields: |
michael@0 | 158 | * user :: |
michael@0 | 159 | * A generic typeless pointer for user data. |
michael@0 | 160 | * |
michael@0 | 161 | * alloc :: |
michael@0 | 162 | * A pointer type to an allocation function. |
michael@0 | 163 | * |
michael@0 | 164 | * free :: |
michael@0 | 165 | * A pointer type to an memory freeing function. |
michael@0 | 166 | * |
michael@0 | 167 | * realloc :: |
michael@0 | 168 | * A pointer type to a reallocation function. |
michael@0 | 169 | * |
michael@0 | 170 | */ |
michael@0 | 171 | struct FT_MemoryRec_ |
michael@0 | 172 | { |
michael@0 | 173 | void* user; |
michael@0 | 174 | FT_Alloc_Func alloc; |
michael@0 | 175 | FT_Free_Func free; |
michael@0 | 176 | FT_Realloc_Func realloc; |
michael@0 | 177 | }; |
michael@0 | 178 | |
michael@0 | 179 | |
michael@0 | 180 | /*************************************************************************/ |
michael@0 | 181 | /* */ |
michael@0 | 182 | /* I / O M A N A G E M E N T */ |
michael@0 | 183 | /* */ |
michael@0 | 184 | /*************************************************************************/ |
michael@0 | 185 | |
michael@0 | 186 | |
michael@0 | 187 | /************************************************************************* |
michael@0 | 188 | * |
michael@0 | 189 | * @type: |
michael@0 | 190 | * FT_Stream |
michael@0 | 191 | * |
michael@0 | 192 | * @description: |
michael@0 | 193 | * A handle to an input stream. |
michael@0 | 194 | * |
michael@0 | 195 | */ |
michael@0 | 196 | typedef struct FT_StreamRec_* FT_Stream; |
michael@0 | 197 | |
michael@0 | 198 | |
michael@0 | 199 | /************************************************************************* |
michael@0 | 200 | * |
michael@0 | 201 | * @struct: |
michael@0 | 202 | * FT_StreamDesc |
michael@0 | 203 | * |
michael@0 | 204 | * @description: |
michael@0 | 205 | * A union type used to store either a long or a pointer. This is used |
michael@0 | 206 | * to store a file descriptor or a `FILE*' in an input stream. |
michael@0 | 207 | * |
michael@0 | 208 | */ |
michael@0 | 209 | typedef union FT_StreamDesc_ |
michael@0 | 210 | { |
michael@0 | 211 | long value; |
michael@0 | 212 | void* pointer; |
michael@0 | 213 | |
michael@0 | 214 | } FT_StreamDesc; |
michael@0 | 215 | |
michael@0 | 216 | |
michael@0 | 217 | /************************************************************************* |
michael@0 | 218 | * |
michael@0 | 219 | * @functype: |
michael@0 | 220 | * FT_Stream_IoFunc |
michael@0 | 221 | * |
michael@0 | 222 | * @description: |
michael@0 | 223 | * A function used to seek and read data from a given input stream. |
michael@0 | 224 | * |
michael@0 | 225 | * @input: |
michael@0 | 226 | * stream :: |
michael@0 | 227 | * A handle to the source stream. |
michael@0 | 228 | * |
michael@0 | 229 | * offset :: |
michael@0 | 230 | * The offset of read in stream (always from start). |
michael@0 | 231 | * |
michael@0 | 232 | * buffer :: |
michael@0 | 233 | * The address of the read buffer. |
michael@0 | 234 | * |
michael@0 | 235 | * count :: |
michael@0 | 236 | * The number of bytes to read from the stream. |
michael@0 | 237 | * |
michael@0 | 238 | * @return: |
michael@0 | 239 | * The number of bytes effectively read by the stream. |
michael@0 | 240 | * |
michael@0 | 241 | * @note: |
michael@0 | 242 | * This function might be called to perform a seek or skip operation |
michael@0 | 243 | * with a `count' of~0. A non-zero return value then indicates an |
michael@0 | 244 | * error. |
michael@0 | 245 | * |
michael@0 | 246 | */ |
michael@0 | 247 | typedef unsigned long |
michael@0 | 248 | (*FT_Stream_IoFunc)( FT_Stream stream, |
michael@0 | 249 | unsigned long offset, |
michael@0 | 250 | unsigned char* buffer, |
michael@0 | 251 | unsigned long count ); |
michael@0 | 252 | |
michael@0 | 253 | |
michael@0 | 254 | /************************************************************************* |
michael@0 | 255 | * |
michael@0 | 256 | * @functype: |
michael@0 | 257 | * FT_Stream_CloseFunc |
michael@0 | 258 | * |
michael@0 | 259 | * @description: |
michael@0 | 260 | * A function used to close a given input stream. |
michael@0 | 261 | * |
michael@0 | 262 | * @input: |
michael@0 | 263 | * stream :: |
michael@0 | 264 | * A handle to the target stream. |
michael@0 | 265 | * |
michael@0 | 266 | */ |
michael@0 | 267 | typedef void |
michael@0 | 268 | (*FT_Stream_CloseFunc)( FT_Stream stream ); |
michael@0 | 269 | |
michael@0 | 270 | |
michael@0 | 271 | /************************************************************************* |
michael@0 | 272 | * |
michael@0 | 273 | * @struct: |
michael@0 | 274 | * FT_StreamRec |
michael@0 | 275 | * |
michael@0 | 276 | * @description: |
michael@0 | 277 | * A structure used to describe an input stream. |
michael@0 | 278 | * |
michael@0 | 279 | * @input: |
michael@0 | 280 | * base :: |
michael@0 | 281 | * For memory-based streams, this is the address of the first stream |
michael@0 | 282 | * byte in memory. This field should always be set to NULL for |
michael@0 | 283 | * disk-based streams. |
michael@0 | 284 | * |
michael@0 | 285 | * size :: |
michael@0 | 286 | * The stream size in bytes. |
michael@0 | 287 | * |
michael@0 | 288 | * pos :: |
michael@0 | 289 | * The current position within the stream. |
michael@0 | 290 | * |
michael@0 | 291 | * descriptor :: |
michael@0 | 292 | * This field is a union that can hold an integer or a pointer. It is |
michael@0 | 293 | * used by stream implementations to store file descriptors or `FILE*' |
michael@0 | 294 | * pointers. |
michael@0 | 295 | * |
michael@0 | 296 | * pathname :: |
michael@0 | 297 | * This field is completely ignored by FreeType. However, it is often |
michael@0 | 298 | * useful during debugging to use it to store the stream's filename |
michael@0 | 299 | * (where available). |
michael@0 | 300 | * |
michael@0 | 301 | * read :: |
michael@0 | 302 | * The stream's input function. |
michael@0 | 303 | * |
michael@0 | 304 | * close :: |
michael@0 | 305 | * The stream's close function. |
michael@0 | 306 | * |
michael@0 | 307 | * memory :: |
michael@0 | 308 | * The memory manager to use to preload frames. This is set |
michael@0 | 309 | * internally by FreeType and shouldn't be touched by stream |
michael@0 | 310 | * implementations. |
michael@0 | 311 | * |
michael@0 | 312 | * cursor :: |
michael@0 | 313 | * This field is set and used internally by FreeType when parsing |
michael@0 | 314 | * frames. |
michael@0 | 315 | * |
michael@0 | 316 | * limit :: |
michael@0 | 317 | * This field is set and used internally by FreeType when parsing |
michael@0 | 318 | * frames. |
michael@0 | 319 | * |
michael@0 | 320 | */ |
michael@0 | 321 | typedef struct FT_StreamRec_ |
michael@0 | 322 | { |
michael@0 | 323 | unsigned char* base; |
michael@0 | 324 | unsigned long size; |
michael@0 | 325 | unsigned long pos; |
michael@0 | 326 | |
michael@0 | 327 | FT_StreamDesc descriptor; |
michael@0 | 328 | FT_StreamDesc pathname; |
michael@0 | 329 | FT_Stream_IoFunc read; |
michael@0 | 330 | FT_Stream_CloseFunc close; |
michael@0 | 331 | |
michael@0 | 332 | FT_Memory memory; |
michael@0 | 333 | unsigned char* cursor; |
michael@0 | 334 | unsigned char* limit; |
michael@0 | 335 | |
michael@0 | 336 | } FT_StreamRec; |
michael@0 | 337 | |
michael@0 | 338 | |
michael@0 | 339 | /* */ |
michael@0 | 340 | |
michael@0 | 341 | |
michael@0 | 342 | FT_END_HEADER |
michael@0 | 343 | |
michael@0 | 344 | #endif /* __FTSYSTEM_H__ */ |
michael@0 | 345 | |
michael@0 | 346 | |
michael@0 | 347 | /* END */ |