ReactOS 0.4.16-dev-306-g647d351
ftstream.c File Reference
#include <ft2build.h>
Include dependency graph for ftstream.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define FT_COMPONENT   trace_stream
 

Functions

 FT_Stream_OpenMemory (FT_Stream stream, const FT_Byte *base, FT_ULong size)
 
 FT_Stream_Close (FT_Stream stream)
 
 FT_Stream_Seek (FT_Stream stream, FT_ULong pos)
 
 FT_Stream_Skip (FT_Stream stream, FT_Long distance)
 
 FT_Stream_Pos (FT_Stream stream)
 
 FT_Stream_Read (FT_Stream stream, FT_Byte *buffer, FT_ULong count)
 
 FT_Stream_ReadAt (FT_Stream stream, FT_ULong pos, FT_Byte *buffer, FT_ULong count)
 
 FT_Stream_TryRead (FT_Stream stream, FT_Byte *buffer, FT_ULong count)
 
 FT_Stream_ExtractFrame (FT_Stream stream, FT_ULong count, FT_Byte **pbytes)
 
 FT_Stream_ReleaseFrame (FT_Stream stream, FT_Byte **pbytes)
 
 FT_Stream_EnterFrame (FT_Stream stream, FT_ULong count)
 
 FT_Stream_ExitFrame (FT_Stream stream)
 
 FT_Stream_GetChar (FT_Stream stream)
 
 FT_Stream_GetUShort (FT_Stream stream)
 
 FT_Stream_GetUShortLE (FT_Stream stream)
 
 FT_Stream_GetUOffset (FT_Stream stream)
 
 FT_Stream_GetULong (FT_Stream stream)
 
 FT_Stream_GetULongLE (FT_Stream stream)
 
 FT_Stream_ReadChar (FT_Stream stream, FT_Error *error)
 
 FT_Stream_ReadUShort (FT_Stream stream, FT_Error *error)
 
 FT_Stream_ReadUShortLE (FT_Stream stream, FT_Error *error)
 
 FT_Stream_ReadUOffset (FT_Stream stream, FT_Error *error)
 
 FT_Stream_ReadULong (FT_Stream stream, FT_Error *error)
 
 FT_Stream_ReadULongLE (FT_Stream stream, FT_Error *error)
 
 FT_Stream_ReadFields (FT_Stream stream, const FT_Frame_Field *fields, void *structure)
 

Macro Definition Documentation

◆ FT_COMPONENT

#define FT_COMPONENT   trace_stream

Definition at line 31 of file ftstream.c.

Function Documentation

◆ FT_Stream_Close()

FT_Stream_Close ( FT_Stream  stream)

Definition at line 49 of file ftstream.c.

50 {
51 if ( stream && stream->close )
52 stream->close( stream );
53 }
Definition: parse.h:23

Referenced by FT_Stream_Free(), main(), PCF_Face_Done(), and woff_open_font().

◆ FT_Stream_EnterFrame()

FT_Stream_EnterFrame ( FT_Stream  stream,
FT_ULong  count 
)

Definition at line 234 of file ftstream.c.

236 {
239
240
241 /* check for nested frame access */
242 FT_ASSERT( stream && stream->cursor == 0 );
243
244 if ( stream->read )
245 {
246 /* allocate the frame in memory */
247 FT_Memory memory = stream->memory;
248
249
250 /* simple sanity check */
251 if ( count > stream->size )
252 {
253 FT_ERROR(( "FT_Stream_EnterFrame:"
254 " frame size (%lu) larger than stream size (%lu)\n",
255 count, stream->size ));
256
257 error = FT_THROW( Invalid_Stream_Operation );
258 goto Exit;
259 }
260
261#ifdef FT_DEBUG_MEMORY
262 /* assume _ft_debug_file and _ft_debug_lineno are already set */
263 stream->base = (unsigned char*)ft_mem_qalloc( memory,
264 (FT_Long)count,
265 &error );
266 if ( error )
267 goto Exit;
268#else
269 if ( FT_QALLOC( stream->base, count ) )
270 goto Exit;
271#endif
272 /* read it */
273 read_bytes = stream->read( stream, stream->pos,
274 stream->base, count );
275 if ( read_bytes < count )
276 {
277 FT_ERROR(( "FT_Stream_EnterFrame:"
278 " invalid read; expected %lu bytes, got %lu\n",
279 count, read_bytes ));
280
281 FT_FREE( stream->base );
282 error = FT_THROW( Invalid_Stream_Operation );
283 }
284 stream->cursor = stream->base;
285 stream->limit = stream->cursor + count;
287 }
288 else
289 {
290 /* check current and new position */
291 if ( stream->pos >= stream->size ||
292 stream->size - stream->pos < count )
293 {
294 FT_ERROR(( "FT_Stream_EnterFrame:"
295 " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
296 stream->pos, count, stream->size ));
297
298 error = FT_THROW( Invalid_Stream_Operation );
299 goto Exit;
300 }
301
302 /* set cursor */
303 stream->cursor = stream->base + stream->pos;
304 stream->limit = stream->cursor + count;
305 stream->pos += count;
306 }
307
308 Exit:
309 return error;
310 }
return FT_Err_Ok
Definition: ftbbox.c:511
#define FT_ASSERT(condition)
Definition: ftdebug.h:211
#define FT_ERROR(varformat)
Definition: ftdebug.h:181
#define FT_THROW(e)
Definition: ftdebug.h:213
ft_mem_qalloc(FT_Memory memory, FT_Long size, FT_Error *p_error)
Definition: ftutil.c:66
#define FT_FREE(ptr)
Definition: ftmemory.h:329
#define FT_QALLOC(ptr, size)
Definition: ftmemory.h:316
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
unsigned long FT_ULong
Definition: fttypes.h:253
int FT_Error
Definition: fttypes.h:300
signed long FT_Long
Definition: fttypes.h:242
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define error(str)
Definition: mkdosfs.c:1605
static char memory[1024 *256]
Definition: process.c:116
static BOOL read_bytes(parse_buffer *buf, LPVOID data, DWORD size)
Definition: parsing.c:168
static void Exit(void)
Definition: sock.c:1330
ULARGE_INTEGER pos
Definition: request.c:4380
unsigned int size
Definition: parse.h:27

Referenced by FT_Access_Frame(), FT_Stream_ExtractFrame(), FT_Stream_ReadFields(), parse_afm(), pcf_get_bitmaps(), and pcf_get_encodings().

◆ FT_Stream_ExitFrame()

FT_Stream_ExitFrame ( FT_Stream  stream)

Definition at line 314 of file ftstream.c.

315 {
316 /* IMPORTANT: The assertion stream->cursor != 0 was removed, given */
317 /* that it is possible to access a frame of length 0 in */
318 /* some weird fonts (usually, when accessing an array of */
319 /* 0 records, like in some strange kern tables). */
320 /* */
321 /* In this case, the loader code handles the 0-length table */
322 /* gracefully; however, stream.cursor is really set to 0 by the */
323 /* FT_Stream_EnterFrame() call, and this is not an error. */
324 /* */
325 FT_ASSERT( stream );
326
327 if ( stream->read )
328 {
329 FT_Memory memory = stream->memory;
330
331#ifdef FT_DEBUG_MEMORY
332 ft_mem_free( memory, stream->base );
333 stream->base = NULL;
334#else
335 FT_FREE( stream->base );
336#endif
337 }
338 stream->cursor = NULL;
339 stream->limit = NULL;
340 }
#define NULL
Definition: types.h:112
ft_mem_free(FT_Memory memory, const void *P)
Definition: ftutil.c:170

Referenced by FT_Forget_Frame(), FT_Stream_ReadFields(), pcf_get_bitmaps(), and pcf_get_encodings().

◆ FT_Stream_ExtractFrame()

FT_Stream_ExtractFrame ( FT_Stream  stream,
FT_ULong  count,
FT_Byte **  pbytes 
)

Definition at line 193 of file ftstream.c.

196 {
198
199
201 if ( !error )
202 {
203 *pbytes = (FT_Byte*)stream->cursor;
204
205 /* equivalent to FT_Stream_ExitFrame(), with no memory block release */
206 stream->cursor = NULL;
207 stream->limit = NULL;
208 }
209
210 return error;
211 }
FT_Stream_EnterFrame(FT_Stream stream, FT_ULong count)
Definition: ftstream.c:234
unsigned char FT_Byte
Definition: fttypes.h:154

Referenced by FT_Extract_Frame().

◆ FT_Stream_GetChar()

FT_Stream_GetChar ( FT_Stream  stream)

Definition at line 344 of file ftstream.c.

345 {
347
348
349 FT_ASSERT( stream && stream->cursor );
350
351 result = 0;
352 if ( stream->cursor < stream->limit )
353 result = (FT_Char)*stream->cursor++;
354
355 return result;
356 }
signed char FT_Char
Definition: fttypes.h:143
GLuint64EXT * result
Definition: glext.h:11304

◆ FT_Stream_GetULong()

FT_Stream_GetULong ( FT_Stream  stream)

Definition at line 416 of file ftstream.c.

417 {
418 FT_Byte* p;
420
421
422 FT_ASSERT( stream && stream->cursor );
423
424 result = 0;
425 p = stream->cursor;
426 if ( p + 3 < stream->limit )
428 stream->cursor = p;
429 return result;
430 }
#define FT_NEXT_ULONG(buffer)
Definition: ftstream.h:238
GLfloat GLfloat p
Definition: glext.h:8902

◆ FT_Stream_GetULongLE()

FT_Stream_GetULongLE ( FT_Stream  stream)

Definition at line 434 of file ftstream.c.

435 {
436 FT_Byte* p;
438
439
440 FT_ASSERT( stream && stream->cursor );
441
442 result = 0;
443 p = stream->cursor;
444 if ( p + 3 < stream->limit )
446 stream->cursor = p;
447 return result;
448 }
#define FT_NEXT_ULONG_LE(buffer)
Definition: ftstream.h:257

◆ FT_Stream_GetUOffset()

FT_Stream_GetUOffset ( FT_Stream  stream)

Definition at line 398 of file ftstream.c.

399 {
400 FT_Byte* p;
402
403
404 FT_ASSERT( stream && stream->cursor );
405
406 result = 0;
407 p = stream->cursor;
408 if ( p + 2 < stream->limit )
410 stream->cursor = p;
411 return result;
412 }
#define FT_NEXT_UOFF3(buffer)
Definition: ftstream.h:232

◆ FT_Stream_GetUShort()

FT_Stream_GetUShort ( FT_Stream  stream)

Definition at line 360 of file ftstream.c.

361 {
362 FT_Byte* p;
364
365
366 FT_ASSERT( stream && stream->cursor );
367
368 result = 0;
369 p = stream->cursor;
370 if ( p + 1 < stream->limit )
372 stream->cursor = p;
373
374 return result;
375 }
#define FT_NEXT_USHORT(buffer)
Definition: ftstream.h:226
unsigned short FT_UShort
Definition: fttypes.h:209

◆ FT_Stream_GetUShortLE()

FT_Stream_GetUShortLE ( FT_Stream  stream)

Definition at line 379 of file ftstream.c.

380 {
381 FT_Byte* p;
383
384
385 FT_ASSERT( stream && stream->cursor );
386
387 result = 0;
388 p = stream->cursor;
389 if ( p + 1 < stream->limit )
391 stream->cursor = p;
392
393 return result;
394 }
#define FT_NEXT_USHORT_LE(buffer)
Definition: ftstream.h:245

◆ FT_Stream_OpenMemory()

FT_Stream_OpenMemory ( FT_Stream  stream,
const FT_Byte base,
FT_ULong  size 
)

Definition at line 35 of file ftstream.c.

38 {
39 stream->base = (FT_Byte*) base;
40 stream->size = size;
41 stream->pos = 0;
42 stream->cursor = NULL;
43 stream->read = NULL;
44 stream->close = NULL;
45 }
GLsizeiptr size
Definition: glext.h:5919

Referenced by cid_face_open(), FT_New_Memory_Stream(), FT_Stream_New(), load_truetype_glyph(), and woff_open_font().

◆ FT_Stream_Pos()

FT_Stream_Pos ( FT_Stream  stream)

Definition at line 103 of file ftstream.c.

104 {
105 return stream->pos;
106 }

◆ FT_Stream_Read()

FT_Stream_Read ( FT_Stream  stream,
FT_Byte buffer,
FT_ULong  count 
)

Definition at line 110 of file ftstream.c.

113 {
115 }
FT_Stream_ReadAt(FT_Stream stream, FT_ULong pos, FT_Byte *buffer, FT_ULong count)
Definition: ftstream.c:119
GLuint buffer
Definition: glext.h:5915

Referenced by FT_Raccess_Get_HeaderInfo(), FT_Read_Stream(), and pcf_get_properties().

◆ FT_Stream_ReadAt()

FT_Stream_ReadAt ( FT_Stream  stream,
FT_ULong  pos,
FT_Byte buffer,
FT_ULong  count 
)

Definition at line 119 of file ftstream.c.

123 {
126
127
128 if ( pos >= stream->size )
129 {
130 FT_ERROR(( "FT_Stream_ReadAt:"
131 " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
132 pos, stream->size ));
133
134 return FT_THROW( Invalid_Stream_Operation );
135 }
136
137 if ( stream->read )
138 read_bytes = stream->read( stream, pos, buffer, count );
139 else
140 {
142 if ( read_bytes > count )
144
146 }
147
149
150 if ( read_bytes < count )
151 {
152 FT_ERROR(( "FT_Stream_ReadAt:"
153 " invalid read; expected %lu bytes, got %lu\n",
154 count, read_bytes ));
155
156 error = FT_THROW( Invalid_Stream_Operation );
157 }
158
159 return error;
160 }
#define FT_MEM_COPY(dest, source, count)
Definition: ftmemory.h:228

Referenced by FT_Read_Stream_At(), and FT_Stream_Read().

◆ FT_Stream_ReadChar()

FT_Stream_ReadChar ( FT_Stream  stream,
FT_Error error 
)

Definition at line 452 of file ftstream.c.

454 {
455 FT_Byte result = 0;
456
457
458 FT_ASSERT( stream );
459
460 *error = FT_Err_Ok;
461
462 if ( stream->read )
463 {
464 if ( stream->read( stream, stream->pos, &result, 1L ) != 1L )
465 goto Fail;
466 }
467 else
468 {
469 if ( stream->pos < stream->size )
470 result = stream->base[stream->pos];
471 else
472 goto Fail;
473 }
474 stream->pos++;
475
476 return (FT_Char)result;
477
478 Fail:
479 *error = FT_THROW( Invalid_Stream_Operation );
480 FT_ERROR(( "FT_Stream_ReadChar:"
481 " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
482 stream->pos, stream->size ));
483
484 return 0;
485 }
int Fail
Definition: ehthrow.cxx:24

◆ FT_Stream_ReadFields()

FT_Stream_ReadFields ( FT_Stream  stream,
const FT_Frame_Field fields,
void structure 
)

Definition at line 714 of file ftstream.c.

717 {
719 FT_Bool frame_accessed = 0;
721
722
723 if ( !fields )
724 return FT_THROW( Invalid_Argument );
725
726 if ( !stream )
727 return FT_THROW( Invalid_Stream_Handle );
728
729 cursor = stream->cursor;
730
732 do
733 {
735 FT_Int sign_shift;
736 FT_Byte* p;
737
738
739 switch ( fields->value )
740 {
741 case ft_frame_start: /* access a new frame */
743 if ( error )
744 goto Exit;
745
746 frame_accessed = 1;
747 cursor = stream->cursor;
748 fields++;
749 continue; /* loop! */
750
751 case ft_frame_bytes: /* read a byte sequence */
752 case ft_frame_skip: /* skip some bytes */
753 {
754 FT_UInt len = fields->size;
755
756
757 if ( cursor + len > stream->limit )
758 {
759 error = FT_THROW( Invalid_Stream_Operation );
760 goto Exit;
761 }
762
763 if ( fields->value == ft_frame_bytes )
764 {
765 p = (FT_Byte*)structure + fields->offset;
766 FT_MEM_COPY( p, cursor, len );
767 }
768 cursor += len;
769 fields++;
770 continue;
771 }
772
773 case ft_frame_byte:
774 case ft_frame_schar: /* read a single byte */
776 sign_shift = 24;
777 break;
778
780 case ft_frame_ushort_be: /* read a 2-byte big-endian short */
782 sign_shift = 16;
783 break;
784
786 case ft_frame_ushort_le: /* read a 2-byte little-endian short */
788 sign_shift = 16;
789 break;
790
791 case ft_frame_long_be:
792 case ft_frame_ulong_be: /* read a 4-byte big-endian long */
794 sign_shift = 0;
795 break;
796
797 case ft_frame_long_le:
798 case ft_frame_ulong_le: /* read a 4-byte little-endian long */
800 sign_shift = 0;
801 break;
802
803 case ft_frame_off3_be:
804 case ft_frame_uoff3_be: /* read a 3-byte big-endian long */
806 sign_shift = 8;
807 break;
808
809 case ft_frame_off3_le:
810 case ft_frame_uoff3_le: /* read a 3-byte little-endian long */
812 sign_shift = 8;
813 break;
814
815 default:
816 /* otherwise, exit the loop */
817 stream->cursor = cursor;
818 goto Exit;
819 }
820
821 /* now, compute the signed value is necessary */
822 if ( fields->value & FT_FRAME_OP_SIGNED )
823 value = (FT_ULong)( (FT_Int32)( value << sign_shift ) >> sign_shift );
824
825 /* finally, store the value in the object */
826
827 p = (FT_Byte*)structure + fields->offset;
828 switch ( fields->size )
829 {
830 case ( 8 / FT_CHAR_BIT ):
831 *(FT_Byte*)p = (FT_Byte)value;
832 break;
833
834 case ( 16 / FT_CHAR_BIT ):
836 break;
837
838 case ( 32 / FT_CHAR_BIT ):
839 *(FT_UInt32*)p = (FT_UInt32)value;
840 break;
841
842 default: /* for 64-bit systems */
843 *(FT_ULong*)p = (FT_ULong)value;
844 }
845
846 /* go to next field */
847 fields++;
848 }
849 while ( 1 );
850
851 Exit:
852 /* close the frame if it was opened by this read */
853 if ( frame_accessed )
855
856 return error;
857 }
switch(r->id)
Definition: btrfs.c:3046
#define FT_CHAR_BIT
Definition: ftconfig.h:70
FT_Stream_ExitFrame(FT_Stream stream)
Definition: ftstream.c:314
#define FT_FRAME_OP_SIGNED
Definition: ftstream.h:41
@ ft_frame_uoff3_be
Definition: ftstream.h:75
@ ft_frame_byte
Definition: ftstream.h:62
@ ft_frame_short_le
Definition: ftstream.h:68
@ ft_frame_off3_be
Definition: ftstream.h:76
@ ft_frame_long_le
Definition: ftstream.h:73
@ ft_frame_ulong_le
Definition: ftstream.h:72
@ ft_frame_ulong_be
Definition: ftstream.h:70
@ ft_frame_bytes
Definition: ftstream.h:80
@ ft_frame_skip
Definition: ftstream.h:81
@ ft_frame_short_be
Definition: ftstream.h:66
@ ft_frame_uoff3_le
Definition: ftstream.h:77
@ ft_frame_ushort_be
Definition: ftstream.h:65
@ ft_frame_start
Definition: ftstream.h:60
@ ft_frame_off3_le
Definition: ftstream.h:78
@ ft_frame_ushort_le
Definition: ftstream.h:67
@ ft_frame_long_be
Definition: ftstream.h:71
@ ft_frame_schar
Definition: ftstream.h:63
#define FT_NEXT_UOFF3_LE(buffer)
Definition: ftstream.h:251
#define FT_NEXT_BYTE(buffer)
Definition: ftstream.h:220
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:108
unsigned int FT_UInt
Definition: fttypes.h:231
signed int FT_Int
Definition: fttypes.h:220
GLenum GLsizei len
Definition: glext.h:6722
const char cursor[]
Definition: icontest.c:13
const char * fields[10]
Definition: parser.c:313
Definition: pdh_main.c:94

◆ FT_Stream_ReadULong()

FT_Stream_ReadULong ( FT_Stream  stream,
FT_Error error 
)

Definition at line 624 of file ftstream.c.

626 {
627 FT_Byte reads[4];
628 FT_Byte* p = 0;
629 FT_ULong result = 0;
630
631
632 FT_ASSERT( stream );
633
634 *error = FT_Err_Ok;
635
636 if ( stream->pos + 3 < stream->size )
637 {
638 if ( stream->read )
639 {
640 if ( stream->read( stream, stream->pos, reads, 4L ) != 4L )
641 goto Fail;
642
643 p = reads;
644 }
645 else
646 p = stream->base + stream->pos;
647
648 if ( p )
650 }
651 else
652 goto Fail;
653
654 stream->pos += 4;
655
656 return result;
657
658 Fail:
659 *error = FT_THROW( Invalid_Stream_Operation );
660 FT_ERROR(( "FT_Stream_ReadULong:"
661 " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
662 stream->pos, stream->size ));
663
664 return 0;
665 }

◆ FT_Stream_ReadULongLE()

FT_Stream_ReadULongLE ( FT_Stream  stream,
FT_Error error 
)

Definition at line 669 of file ftstream.c.

671 {
672 FT_Byte reads[4];
673 FT_Byte* p = 0;
674 FT_ULong result = 0;
675
676
677 FT_ASSERT( stream );
678
679 *error = FT_Err_Ok;
680
681 if ( stream->pos + 3 < stream->size )
682 {
683 if ( stream->read )
684 {
685 if ( stream->read( stream, stream->pos, reads, 4L ) != 4L )
686 goto Fail;
687
688 p = reads;
689 }
690 else
691 p = stream->base + stream->pos;
692
693 if ( p )
695 }
696 else
697 goto Fail;
698
699 stream->pos += 4;
700
701 return result;
702
703 Fail:
704 *error = FT_THROW( Invalid_Stream_Operation );
705 FT_ERROR(( "FT_Stream_ReadULongLE:"
706 " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
707 stream->pos, stream->size ));
708
709 return 0;
710 }

◆ FT_Stream_ReadUOffset()

FT_Stream_ReadUOffset ( FT_Stream  stream,
FT_Error error 
)

Definition at line 579 of file ftstream.c.

581 {
582 FT_Byte reads[3];
583 FT_Byte* p = 0;
584 FT_ULong result = 0;
585
586
587 FT_ASSERT( stream );
588
589 *error = FT_Err_Ok;
590
591 if ( stream->pos + 2 < stream->size )
592 {
593 if ( stream->read )
594 {
595 if (stream->read( stream, stream->pos, reads, 3L ) != 3L )
596 goto Fail;
597
598 p = reads;
599 }
600 else
601 p = stream->base + stream->pos;
602
603 if ( p )
605 }
606 else
607 goto Fail;
608
609 stream->pos += 3;
610
611 return result;
612
613 Fail:
614 *error = FT_THROW( Invalid_Stream_Operation );
615 FT_ERROR(( "FT_Stream_ReadUOffset:"
616 " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
617 stream->pos, stream->size ));
618
619 return 0;
620 }

◆ FT_Stream_ReadUShort()

FT_Stream_ReadUShort ( FT_Stream  stream,
FT_Error error 
)

Definition at line 489 of file ftstream.c.

491 {
492 FT_Byte reads[2];
493 FT_Byte* p = 0;
494 FT_UShort result = 0;
495
496
497 FT_ASSERT( stream );
498
499 *error = FT_Err_Ok;
500
501 if ( stream->pos + 1 < stream->size )
502 {
503 if ( stream->read )
504 {
505 if ( stream->read( stream, stream->pos, reads, 2L ) != 2L )
506 goto Fail;
507
508 p = reads;
509 }
510 else
511 p = stream->base + stream->pos;
512
513 if ( p )
515 }
516 else
517 goto Fail;
518
519 stream->pos += 2;
520
521 return result;
522
523 Fail:
524 *error = FT_THROW( Invalid_Stream_Operation );
525 FT_ERROR(( "FT_Stream_ReadUShort:"
526 " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
527 stream->pos, stream->size ));
528
529 return 0;
530 }

◆ FT_Stream_ReadUShortLE()

FT_Stream_ReadUShortLE ( FT_Stream  stream,
FT_Error error 
)

Definition at line 534 of file ftstream.c.

536 {
537 FT_Byte reads[2];
538 FT_Byte* p = 0;
539 FT_UShort result = 0;
540
541
542 FT_ASSERT( stream );
543
544 *error = FT_Err_Ok;
545
546 if ( stream->pos + 1 < stream->size )
547 {
548 if ( stream->read )
549 {
550 if ( stream->read( stream, stream->pos, reads, 2L ) != 2L )
551 goto Fail;
552
553 p = reads;
554 }
555 else
556 p = stream->base + stream->pos;
557
558 if ( p )
560 }
561 else
562 goto Fail;
563
564 stream->pos += 2;
565
566 return result;
567
568 Fail:
569 *error = FT_THROW( Invalid_Stream_Operation );
570 FT_ERROR(( "FT_Stream_ReadUShortLE:"
571 " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
572 stream->pos, stream->size ));
573
574 return 0;
575 }

◆ FT_Stream_ReleaseFrame()

FT_Stream_ReleaseFrame ( FT_Stream  stream,
FT_Byte **  pbytes 
)

Definition at line 215 of file ftstream.c.

217 {
218 if ( stream && stream->read )
219 {
220 FT_Memory memory = stream->memory;
221
222#ifdef FT_DEBUG_MEMORY
223 ft_mem_free( memory, *pbytes );
224 *pbytes = NULL;
225#else
226 FT_FREE( *pbytes );
227#endif
228 }
229 *pbytes = NULL;
230 }

Referenced by FT_Release_Frame().

◆ FT_Stream_Seek()

FT_Stream_Seek ( FT_Stream  stream,
FT_ULong  pos 
)

Definition at line 57 of file ftstream.c.

59 {
61
62
63 if ( stream->read )
64 {
65 if ( stream->read( stream, pos, 0, 0 ) )
66 {
67 FT_ERROR(( "FT_Stream_Seek:"
68 " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
69 pos, stream->size ));
70
71 error = FT_THROW( Invalid_Stream_Operation );
72 }
73 }
74 /* note that seeking to the first position after the file is valid */
75 else if ( pos > stream->size )
76 {
77 FT_ERROR(( "FT_Stream_Seek:"
78 " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
79 pos, stream->size ));
80
81 error = FT_THROW( Invalid_Stream_Operation );
82 }
83
84 if ( !error )
85 stream->pos = pos;
86
87 return error;
88 }

Referenced by ft_lzwstate_io(), ft_open_face_internal(), FT_Raccess_Get_DataOffsets(), FT_Raccess_Get_HeaderInfo(), FT_Seek_Stream(), and FT_Stream_Skip().

◆ FT_Stream_Skip()

FT_Stream_Skip ( FT_Stream  stream,
FT_Long  distance 
)

Definition at line 92 of file ftstream.c.

94 {
95 if ( distance < 0 )
96 return FT_THROW( Invalid_Stream_Operation );
97
99 }
FT_Stream_Seek(FT_Stream stream, FT_ULong pos)
Definition: ftstream.c:57
GLsizei GLsizei GLfloat distance
Definition: glext.h:11755

Referenced by FT_Skip_Stream().

◆ FT_Stream_TryRead()

FT_Stream_TryRead ( FT_Stream  stream,
FT_Byte buffer,
FT_ULong  count 
)

Definition at line 164 of file ftstream.c.

167 {
169
170
171 if ( stream->pos >= stream->size )
172 goto Exit;
173
174 if ( stream->read )
176 else
177 {
179 if ( read_bytes > count )
181
183 }
184
186
187 Exit:
188 return read_bytes;
189 }

Referenced by _bdf_readstream(), ft_lzwstate_io(), and ft_lzwstate_refill().