1 |
/* |
2 |
rdesktop: A Remote Desktop Protocol client. |
3 |
Protocol services - parsing layer |
4 |
Copyright (C) Matthew Chapman 1999-2000 |
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 |
/* Parser state */ |
22 |
typedef struct stream |
23 |
{ |
24 |
/* Parsing layer */ |
25 |
unsigned char *data; |
26 |
unsigned int size; |
27 |
unsigned int offset; |
28 |
unsigned int end; |
29 |
BOOL marshall; |
30 |
BOOL error; |
31 |
|
32 |
/* Other layers */ |
33 |
int iso_offset; |
34 |
int mcs_offset; |
35 |
int rdp_offset; |
36 |
|
37 |
} *STREAM; |
38 |
|
39 |
/* Connection state */ |
40 |
typedef struct connection |
41 |
{ |
42 |
/* User interface */ |
43 |
HWINDOW wnd; |
44 |
HBITMAP bmpcache[3][600]; |
45 |
FONT_GLYPH fontcache[12][256]; |
46 |
BLOB textcache[256]; |
47 |
uint8 deskcache[0x38400]; |
48 |
|
49 |
/* Parsing layer */ |
50 |
struct stream in; |
51 |
struct stream out; |
52 |
|
53 |
/* TCP layer */ |
54 |
int tcp_socket; |
55 |
|
56 |
/* MCS layer */ |
57 |
uint16 mcs_userid; |
58 |
|
59 |
} *HCONN; |
60 |
|
61 |
#define STREAM_INIT(s,m) { s.data = xmalloc(2048); s.end = s.size = 2048; s.offset = 0; s.marshall = m; s.error = False; } |
62 |
#define STREAM_SIZE(s,l) { if (l > s.size) { s.data = xrealloc(s.data,l); s.end = s.size = l; } } |
63 |
#define REMAINING(s) ( s->end - s->offset ) |
64 |
#define PUSH_LAYER(s,v,l) { s.v = s.offset; s.offset += l; } |
65 |
#define POP_LAYER(s,v) { s.offset = s.v; } |
66 |
#define MARK_END(s) { s.end = s.offset; } |
67 |
#define PRS_ERROR(s) (!(s)->error) |