2 * Copyright (C) 2005 David Turner
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2007 Red Hat, Inc.
6 * This is part of HarfBuzz, an OpenType Layout engine library.
8 * Permission is hereby granted, without written agreement and without
9 * license or royalty fees, to use, copy, modify, and distribute this
10 * software and its documentation for any purpose, provided that the
11 * above copyright notice and the following two paragraphs appear in
12 * all copies of this software.
14 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
15 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
16 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
17 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
20 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
21 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
22 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
23 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
24 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
26 * Red Hat Author(s): Behdad Esfahbod
29 #include "harfbuzz-impl.h"
30 #include "harfbuzz-stream-private.h"
35 #define LOG(x) _hb_log x
38 _hb_log( const char* format
, ... )
42 va_start( ap
, format
);
43 vfprintf( stderr
, format
, ap
);
48 #define LOG(x) do {} while (0)
52 _hb_close_stream( HB_Stream stream
)
62 _hb_stream_pos( HB_Stream stream
)
64 LOG(( "_hb_stream_pos() -> %ld\n", stream
->pos
));
70 _hb_stream_seek( HB_Stream stream
,
73 HB_Error error
= (HB_Error
)0;
76 if (pos
> stream
->size
)
77 error
= ERR(HB_Err_Read_Error
);
79 LOG(( "_hb_stream_seek(%ld) -> 0x%04X\n", pos
, error
));
85 _hb_stream_frame_enter( HB_Stream stream
,
88 HB_Error error
= HB_Err_Ok
;
90 /* check new position, watch for overflow */
91 if (HB_UNLIKELY (stream
->pos
+ count
> stream
->size
||
92 stream
->pos
+ count
< stream
->pos
))
94 error
= ERR(HB_Err_Read_Error
);
99 stream
->cursor
= stream
->base
+ stream
->pos
;
100 stream
->pos
+= count
;
103 LOG(( "_hb_stream_frame_enter(%ld) -> 0x%04X\n", count
, error
));
109 _hb_stream_frame_exit( HB_Stream stream
)
111 stream
->cursor
= NULL
;
113 LOG(( "_hb_stream_frame_exit()\n" ));