VirtualBox

source: vbox/trunk/src/VBox/RDP/client/parse.h@ 11982

最後變更 在這個檔案從11982是 11982,由 vboxsync 提交於 16 年 前

All: license header changes for 2.0 (OSE headers, add Sun GPL/LGPL disclaimer)

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 4.0 KB
 
1/*
2 rdesktop: A Remote Desktop Protocol client.
3 Parsing primitives
4 Copyright (C) Matthew Chapman 1999-2007
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/
20
21/*
22 * Sun 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, Sun 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
55#if defined(L_ENDIAN) && !defined(NEED_ALIGN)
56#define in_uint16_le(s,v) { v = *(uint16 *)((s)->p); (s)->p += 2; }
57#define in_uint32_le(s,v) { v = *(uint32 *)((s)->p); (s)->p += 4; }
58#define out_uint16_le(s,v) { *(uint16 *)((s)->p) = v; (s)->p += 2; }
59#define out_uint32_le(s,v) { *(uint32 *)((s)->p) = v; (s)->p += 4; }
60
61#else
62#define in_uint16_le(s,v) { v = *((s)->p++); v += *((s)->p++) << 8; }
63#define in_uint32_le(s,v) { in_uint16_le(s,v) \
64 v += *((s)->p++) << 16; v += *((s)->p++) << 24; }
65#define out_uint16_le(s,v) { *((s)->p++) = (v) & 0xff; *((s)->p++) = ((v) >> 8) & 0xff; }
66#define out_uint32_le(s,v) { out_uint16_le(s, (v) & 0xffff); out_uint16_le(s, ((v) >> 16) & 0xffff); }
67#endif
68
69#if defined(B_ENDIAN) && !defined(NEED_ALIGN)
70#define in_uint16_be(s,v) { v = *(uint16 *)((s)->p); (s)->p += 2; }
71#define in_uint32_be(s,v) { v = *(uint32 *)((s)->p); (s)->p += 4; }
72#define out_uint16_be(s,v) { *(uint16 *)((s)->p) = v; (s)->p += 2; }
73#define out_uint32_be(s,v) { *(uint32 *)((s)->p) = v; (s)->p += 4; }
74
75#define B_ENDIAN_PREFERRED
76#define in_uint16(s,v) in_uint16_be(s,v)
77#define in_uint32(s,v) in_uint32_be(s,v)
78#define out_uint16(s,v) out_uint16_be(s,v)
79#define out_uint32(s,v) out_uint32_be(s,v)
80
81#else
82#define in_uint16_be(s,v) { v = *((s)->p++); next_be(s,v); }
83#define in_uint32_be(s,v) { in_uint16_be(s,v); next_be(s,v); next_be(s,v); }
84#define out_uint16_be(s,v) { *((s)->p++) = ((v) >> 8) & 0xff; *((s)->p++) = (v) & 0xff; }
85#define out_uint32_be(s,v) { out_uint16_be(s, ((v) >> 16) & 0xffff); out_uint16_be(s, (v) & 0xffff); }
86#endif
87
88#ifndef B_ENDIAN_PREFERRED
89#define in_uint16(s,v) in_uint16_le(s,v)
90#define in_uint32(s,v) in_uint32_le(s,v)
91#define out_uint16(s,v) out_uint16_le(s,v)
92#define out_uint32(s,v) out_uint32_le(s,v)
93#endif
94
95#define in_uint8(s,v) v = *((s)->p++);
96#define in_uint8p(s,v,n) { v = (s)->p; (s)->p += n; }
97#define in_uint8a(s,v,n) { memcpy(v,(s)->p,n); (s)->p += n; }
98#define in_uint8s(s,n) (s)->p += n;
99#define out_uint8(s,v) *((s)->p++) = v;
100#define out_uint8p(s,v,n) { memcpy((s)->p,v,n); (s)->p += n; }
101#define out_uint8a(s,v,n) out_uint8p(s,v,n);
102#define out_uint8s(s,n) { memset((s)->p,0,n); (s)->p += n; }
103
104#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