a180a41bba1d50822df23fff0099e90b86638b89vboxsync rdesktop: A Remote Desktop Protocol client.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync Parsing primitives
a180a41bba1d50822df23fff0099e90b86638b89vboxsync Copyright (C) Matthew Chapman 1999-2008
a180a41bba1d50822df23fff0099e90b86638b89vboxsync Copyright 2012 Henrik Andersson <hean01@cendio.se> for Cendio AB
a180a41bba1d50822df23fff0099e90b86638b89vboxsync This program is free software: you can redistribute it and/or modify
a180a41bba1d50822df23fff0099e90b86638b89vboxsync it under the terms of the GNU General Public License as published by
a180a41bba1d50822df23fff0099e90b86638b89vboxsync the Free Software Foundation, either version 3 of the License, or
a180a41bba1d50822df23fff0099e90b86638b89vboxsync (at your option) any later version.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync This program is distributed in the hope that it will be useful,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync but WITHOUT ANY WARRANTY; without even the implied warranty of
a180a41bba1d50822df23fff0099e90b86638b89vboxsync MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a180a41bba1d50822df23fff0099e90b86638b89vboxsync GNU General Public License for more details.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync You should have received a copy of the GNU General Public License
a180a41bba1d50822df23fff0099e90b86638b89vboxsync along with this program. If not, see <http://www.gnu.org/licenses/>.
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync * Oracle GPL Disclaimer: For the avoidance of doubt, except that if any license choice
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync * the General Public License version 2 (GPLv2) at this time for any software where
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync * a choice of GPL license versions is made available with the language indicating
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync * that GPLv2 or any later version may be used, or where a choice of which version
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync * of the GPL is applied is otherwise unspecified.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/* Parser state */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync unsigned char *p;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync /* Offsets of various headers */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define s_push_layer(s,h,n) { (s)->h = (s)->p; (s)->p += n; }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define in_uint16_le(s,v) { v = *(uint16 *)((s)->p); (s)->p += 2; }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define in_uint32_le(s,v) { v = *(uint32 *)((s)->p); (s)->p += 4; }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define out_uint16_le(s,v) { *(uint16 *)((s)->p) = v; (s)->p += 2; }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define out_uint32_le(s,v) { *(uint32 *)((s)->p) = v; (s)->p += 4; }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define in_uint16_le(s,v) { v = *((s)->p++); v += *((s)->p++) << 8; }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define out_uint16_le(s,v) { *((s)->p++) = (v) & 0xff; *((s)->p++) = ((v) >> 8) & 0xff; }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define out_uint32_le(s,v) { out_uint16_le(s, (v) & 0xffff); out_uint16_le(s, ((v) >> 16) & 0xffff); }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define in_uint16_be(s,v) { v = *(uint16 *)((s)->p); (s)->p += 2; }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define in_uint32_be(s,v) { v = *(uint32 *)((s)->p); (s)->p += 4; }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define out_uint16_be(s,v) { *(uint16 *)((s)->p) = v; (s)->p += 2; }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define out_uint32_be(s,v) { *(uint32 *)((s)->p) = v; (s)->p += 4; }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define in_uint16_be(s,v) { v = *((s)->p++); next_be(s,v); }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define in_uint32_be(s,v) { in_uint16_be(s,v); next_be(s,v); next_be(s,v); }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define out_uint16_be(s,v) { *((s)->p++) = ((v) >> 8) & 0xff; *((s)->p++) = (v) & 0xff; }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define out_uint32_be(s,v) { out_uint16_be(s, ((v) >> 16) & 0xffff); out_uint16_be(s, (v) & 0xffff); }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define in_uint8p(s,v,n) { v = (s)->p; (s)->p += n; }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define in_uint8a(s,v,n) { memcpy(v,(s)->p,n); (s)->p += n; }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define out_uint8p(s,v,n) { memcpy((s)->p,v,n); (s)->p += n; }
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define out_uint8s(s,n) { memset((s)->p,0,n); (s)->p += n; }