/src/ghostpdl/pcl/pl/plvalue.c
Line | Count | Source |
1 | | /* Copyright (C) 2001-2023 Artifex Software, Inc. |
2 | | All Rights Reserved. |
3 | | |
4 | | This software is provided AS-IS with no warranty, either express or |
5 | | implied. |
6 | | |
7 | | This software is distributed under license and may not be copied, |
8 | | modified or distributed except as expressly authorized under the terms |
9 | | of the license contained in the file LICENSE in this distribution. |
10 | | |
11 | | Refer to licensing information at http://www.artifex.com or contact |
12 | | Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, |
13 | | CA 94129, USA, for further information. |
14 | | */ |
15 | | |
16 | | |
17 | | /* plvalue.c */ |
18 | | /* Accessors for big-endian multi-byte values */ |
19 | | |
20 | | #include "std.h" |
21 | | #include "plvalue.h" |
22 | | |
23 | | #define get_uint16(bptr)\ |
24 | 571M | (((bptr)[0] << 8) | (bptr)[1]) |
25 | | #define get_int16(bptr)\ |
26 | 24.3M | (((int)get_uint16(bptr) ^ 0x8000) - 0x8000) |
27 | | |
28 | | /* coverity[ -tainted_data_return ] */ |
29 | | /* coverity[ -tainted_data_argument : arg-0 ] */ |
30 | | int |
31 | | pl_get_int16(const byte * bptr) |
32 | 24.3M | { |
33 | 24.3M | return get_int16(bptr); |
34 | 24.3M | } |
35 | | |
36 | | /* coverity[ -tainted_data_return ] */ |
37 | | /* coverity[ -tainted_data_argument : arg-0 ] */ |
38 | | uint |
39 | | pl_get_uint16(const byte * bptr) |
40 | 484M | { |
41 | 484M | return get_uint16(bptr); |
42 | 484M | } |
43 | | |
44 | | /* coverity[ -tainted_data_return ] */ |
45 | | /* coverity[ -tainted_data_argument : arg-0 ] */ |
46 | | long |
47 | | pl_get_int32(const byte * bptr) |
48 | 0 | { |
49 | 0 | return ((long)get_int16(bptr) << 16) | get_uint16(bptr + 2); |
50 | 0 | } |
51 | | |
52 | | /* coverity[ -tainted_data_return ] */ |
53 | | /* coverity[ -tainted_data_argument : arg-0 ] */ |
54 | | ulong |
55 | | pl_get_uint32(const byte * bptr) |
56 | 31.6M | { |
57 | 31.6M | return ((ulong) get_uint16(bptr) << 16) | get_uint16(bptr + 2); |
58 | 31.6M | } |