VirtualBox

source: vbox/trunk/src/VBox/RDP/client-1.8.3/parse.h@ 61540

最後變更 在這個檔案從61540是 55123,由 vboxsync 提交於 10 年 前

rdesktop 1.8.3 modified for VBox

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 4.1 KB
 
1/*
2 rdesktop: A Remote Desktop Protocol client.
3 Parsing primitives
4 Copyright (C) Matthew Chapman 1999-2008
5 Copyright 2012 Henrik Andersson <[email protected]> for Cendio AB
6
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19*/
20
21/*
22 * Oracle GPL Disclaimer: For the avoidance of doubt, except that if any license choice
23 * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
24 * the General Public License version 2 (GPLv2) at this time for any software where
25 * a choice of GPL license versions is made available with the language indicating
26 * that GPLv2 or any later version may be used, or where a choice of which version
27 * of the GPL is applied is otherwise unspecified.
28 */
29
30/* Parser state */
31typedef struct stream
32{
33 unsigned char *p;
34 unsigned char *end;
35 unsigned char *data;
36 unsigned int size;
37
38 /* Offsets of various headers */
39 unsigned char *iso_hdr;
40 unsigned char *mcs_hdr;
41 unsigned char *sec_hdr;
42 unsigned char *rdp_hdr;
43 unsigned char *channel_hdr;
44
45}
46 *STREAM;
47
48#define s_push_layer(s,h,n) { (s)->h = (s)->p; (s)->p += n; }
49#define s_pop_layer(s,h) (s)->p = (s)->h;
50#define s_mark_end(s) (s)->end = (s)->p;
51#define s_check(s) ((s)->p <= (s)->end)
52#define s_check_rem(s,n) ((s)->p + n <= (s)->end)
53#define s_check_end(s) ((s)->p == (s)->end)
54#define s_length(s) ((s)->end - (s)->data)
55#define s_reset(s) ((s)->end = (s)->p = (s)->data)
56
57#if defined(L_ENDIAN) && !defined(NEED_ALIGN)
58#define in_uint16_le(s,v) { v = *(uint16 *)((s)->p); (s)->p += 2; }
59#define in_uint32_le(s,v) { v = *(uint32 *)((s)->p); (s)->p += 4; }
60#define out_uint16_le(s,v) { *(uint16 *)((s)->p) = v; (s)->p += 2; }
61#define out_uint32_le(s,v) { *(uint32 *)((s)->p) = v; (s)->p += 4; }
62
63#else
64#define in_uint16_le(s,v) { v = *((s)->p++); v += *((s)->p++) << 8; }
65#define in_uint32_le(s,v) { in_uint16_le(s,v) \
66 v += *((s)->p++) << 16; v += *((s)->p++) << 24; }
67#define out_uint16_le(s,v) { *((s)->p++) = (v) & 0xff; *((s)->p++) = ((v) >> 8) & 0xff; }
68#define out_uint32_le(s,v) { out_uint16_le(s, (v) & 0xffff); out_uint16_le(s, ((v) >> 16) & 0xffff); }
69#endif
70
71#if defined(B_ENDIAN) && !defined(NEED_ALIGN)
72#define in_uint16_be(s,v) { v = *(uint16 *)((s)->p); (s)->p += 2; }
73#define in_uint32_be(s,v) { v = *(uint32 *)((s)->p); (s)->p += 4; }
74#define out_uint16_be(s,v) { *(uint16 *)((s)->p) = v; (s)->p += 2; }
75#define out_uint32_be(s,v) { *(uint32 *)((s)->p) = v; (s)->p += 4; }
76
77#define B_ENDIAN_PREFERRED
78#define in_uint16(s,v) in_uint16_be(s,v)
79#define in_uint32(s,v) in_uint32_be(s,v)
80#define out_uint16(s,v) out_uint16_be(s,v)
81#define out_uint32(s,v) out_uint32_be(s,v)
82
83#else
84#define in_uint16_be(s,v) { v = *((s)->p++); next_be(s,v); }
85#define in_uint32_be(s,v) { in_uint16_be(s,v); next_be(s,v); next_be(s,v); }
86#define out_uint16_be(s,v) { *((s)->p++) = ((v) >> 8) & 0xff; *((s)->p++) = (v) & 0xff; }
87#define out_uint32_be(s,v) { out_uint16_be(s, ((v) >> 16) & 0xffff); out_uint16_be(s, (v) & 0xffff); }
88#endif
89
90#ifndef B_ENDIAN_PREFERRED
91#define in_uint16(s,v) in_uint16_le(s,v)
92#define in_uint32(s,v) in_uint32_le(s,v)
93#define out_uint16(s,v) out_uint16_le(s,v)
94#define out_uint32(s,v) out_uint32_le(s,v)
95#endif
96
97#define in_uint8(s,v) v = *((s)->p++);
98#define in_uint8p(s,v,n) { v = (s)->p; (s)->p += n; }
99#define in_uint8a(s,v,n) { memcpy(v,(s)->p,n); (s)->p += n; }
100#define in_uint8s(s,n) (s)->p += n;
101#define out_uint8(s,v) *((s)->p++) = v;
102#define out_uint8p(s,v,n) { memcpy((s)->p,v,n); (s)->p += n; }
103#define out_uint8a(s,v,n) out_uint8p(s,v,n);
104#define out_uint8s(s,n) { memset((s)->p,0,n); (s)->p += n; }
105
106#define next_be(s,v) v = ((v) << 8) + *((s)->p++);
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette