1 /* 2 rdesktop: A Remote Desktop Protocol client. 3 Common data types 4 Copyright (C) Matthew Chapman 1999-2008 5 Copyright 2014 Henrik Andersson <hean01@cendio.se> for Cendio AB 6 Copyright 2017 Karl Mikaelsson <derfian@cendio.se> for Cendio AB 7 8 This program is free software: you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation, either version 3 of the License, or 11 (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program. If not, see <http://www.gnu.org/licenses/>. 20 */ 21 22 #ifndef _TYPES_H 23 #define _TYPES_H 24 25 #include <stdint.h> 26 #include "constants.h" 27 #include "stream.h" 28 29 typedef int RD_BOOL; 30 31 #ifndef True 32 #define True (1) 33 #define False (0) 34 #endif 35 36 #ifndef PATH_MAX 37 #define PATH_MAX 256 38 #endif 39 40 typedef unsigned char uint8; 41 typedef signed char sint8; 42 typedef unsigned short uint16; 43 typedef signed short sint16; 44 typedef unsigned int uint32; 45 typedef signed int sint32; 46 typedef uint64_t uint64; 47 typedef int64_t sint64; 48 49 #define RD_UINT32_MAX (uint32)(-1) 50 51 typedef void *RD_HBITMAP; 52 typedef void *RD_HGLYPH; 53 typedef void *RD_HCOLOURMAP; 54 typedef void *RD_HCURSOR; 55 56 57 typedef enum _RDP_VERSION 58 { 59 RDP_V4 = 4, 60 RDP_V5 = 5, 61 RDP_V6 = 6 62 } RDP_VERSION; 63 64 65 typedef struct _RD_POINT 66 { 67 sint16 x, y; 68 } 69 RD_POINT; 70 71 typedef struct _COLOURENTRY 72 { 73 uint8 red; 74 uint8 green; 75 uint8 blue; 76 77 } 78 COLOURENTRY; 79 80 typedef struct _COLOURMAP 81 { 82 uint16 ncolours; 83 COLOURENTRY *colours; 84 85 } 86 COLOURMAP; 87 88 typedef struct _BOUNDS 89 { 90 sint16 left; 91 sint16 top; 92 sint16 right; 93 sint16 bottom; 94 95 } 96 BOUNDS; 97 98 typedef struct _PEN 99 { 100 uint8 style; 101 uint8 width; 102 uint32 colour; 103 104 } 105 PEN; 106 107 /* this is whats in the brush cache */ 108 typedef struct _BRUSHDATA 109 { 110 uint32 colour_code; 111 uint32 data_size; 112 uint8 *data; 113 } 114 BRUSHDATA; 115 116 typedef struct _BRUSH 117 { 118 uint8 xorigin; 119 uint8 yorigin; 120 uint8 style; 121 uint8 pattern[8]; 122 BRUSHDATA *bd; 123 } 124 BRUSH; 125 126 typedef struct _FONTGLYPH 127 { 128 sint16 offset; 129 sint16 baseline; 130 uint16 width; 131 uint16 height; 132 RD_HBITMAP pixmap; 133 134 } 135 FONTGLYPH; 136 137 typedef struct _DATABLOB 138 { 139 void *data; 140 int size; 141 142 } 143 DATABLOB; 144 145 typedef struct _key_translation 146 { 147 /* For normal scancode translations */ 148 uint8 scancode; 149 uint16 modifiers; 150 /* For sequences. If keysym is nonzero, the fields above are not used. */ 151 uint32 seq_keysym; /* Really KeySym */ 152 struct _key_translation *next; 153 } 154 key_translation; 155 156 typedef struct _key_translation_entry 157 { 158 key_translation *tr; 159 /* The full KeySym for this entry, not KEYMAP_MASKed */ 160 uint32 keysym; 161 /* This will be non-NULL if there has been a hash collision */ 162 struct _key_translation_entry *next; 163 } 164 key_translation_entry; 165 166 typedef struct _VCHANNEL 167 { 168 uint16 mcs_id; 169 char name[8]; 170 uint32 flags; 171 struct stream in; 172 void (*process) (STREAM); 173 } 174 VCHANNEL; 175 176 /* PSTCACHE */ 177 typedef uint8 HASH_KEY[8]; 178 179 /* Header for an entry in the persistent bitmap cache file */ 180 typedef struct _PSTCACHE_CELLHEADER 181 { 182 HASH_KEY key; 183 uint8 width, height; 184 uint16 length; 185 uint32 stamp; 186 } 187 CELLHEADER; 188 189 #define MAX_CBSIZE 256 190 191 /* RDPSND */ 192 typedef struct _RD_WAVEFORMATEX 193 { 194 uint16 wFormatTag; 195 uint16 nChannels; 196 uint32 nSamplesPerSec; 197 uint32 nAvgBytesPerSec; 198 uint16 nBlockAlign; 199 uint16 wBitsPerSample; 200 uint16 cbSize; 201 uint8 cb[MAX_CBSIZE]; 202 } RD_WAVEFORMATEX; 203 204 typedef struct _RDPCOMP 205 { 206 uint32 roff; 207 uint8 hist[RDP_MPPC_DICT_SIZE]; 208 struct stream ns; 209 } 210 RDPCOMP; 211 212 /* RDPDR */ 213 typedef uint32 RD_NTSTATUS; 214 typedef uint32 RD_NTHANDLE; 215 216 typedef struct _DEVICE_FNS 217 { 218 RD_NTSTATUS(*create) (uint32 device, uint32 desired_access, uint32 share_mode, 219 uint32 create_disposition, uint32 flags_and_attributes, 220 char *filename, RD_NTHANDLE * handle); 221 RD_NTSTATUS(*close) (RD_NTHANDLE handle); 222 RD_NTSTATUS(*read) (RD_NTHANDLE handle, uint8 * data, uint32 length, uint64 offset, 223 uint32 * result); 224 RD_NTSTATUS(*write) (RD_NTHANDLE handle, uint8 * data, uint32 length, uint64 offset, 225 uint32 * result); 226 RD_NTSTATUS(*device_control) (RD_NTHANDLE handle, uint32 request, STREAM in, STREAM out); 227 } 228 DEVICE_FNS; 229 230 231 typedef struct rdpdr_device_info 232 { 233 uint32 device_type; 234 RD_NTHANDLE handle; 235 char name[8]; 236 char *local_path; 237 void *pdevice_data; 238 } 239 RDPDR_DEVICE; 240 241 typedef struct rdpdr_disk_device_info 242 { 243 char name[PATH_MAX]; 244 } 245 DISK_DEVICE; 246 247 typedef struct rdpdr_serial_device_info 248 { 249 int dtr; 250 int rts; 251 uint32 control, xonoff, onlimit, offlimit; 252 uint32 baud_rate, 253 queue_in_size, 254 queue_out_size, 255 wait_mask, 256 read_interval_timeout, 257 read_total_timeout_multiplier, 258 read_total_timeout_constant, 259 write_total_timeout_multiplier, write_total_timeout_constant, posix_wait_mask; 260 uint8 stop_bits, parity, word_length; 261 uint8 chars[6]; 262 struct termios *ptermios, *pold_termios; 263 int event_txempty, event_cts, event_dsr, event_rlsd, event_pending; 264 } 265 SERIAL_DEVICE; 266 267 typedef struct rdpdr_parallel_device_info 268 { 269 char *driver, *printer; 270 uint32 queue_in_size, 271 queue_out_size, 272 wait_mask, 273 read_interval_timeout, 274 read_total_timeout_multiplier, 275 read_total_timeout_constant, 276 write_total_timeout_multiplier, 277 write_total_timeout_constant, posix_wait_mask, bloblen; 278 uint8 *blob; 279 } 280 PARALLEL_DEVICE; 281 282 typedef struct rdpdr_printer_info 283 { 284 FILE *printer_fp; 285 char *driver, *printer; 286 uint32 bloblen; 287 uint8 *blob; 288 RD_BOOL default_printer; 289 } 290 PRINTER; 291 292 typedef struct notify_data 293 { 294 time_t modify_time; 295 time_t status_time; 296 time_t total_time; 297 unsigned int num_entries; 298 } 299 NOTIFY; 300 301 typedef struct fileinfo 302 { 303 uint32 device_id, flags_and_attributes, accessmask; 304 char path[PATH_MAX]; 305 DIR *pdir; 306 struct dirent *pdirent; 307 char pattern[PATH_MAX]; 308 RD_BOOL delete_on_close; 309 NOTIFY notify; 310 uint32 info_class; 311 } 312 FILEINFO; 313 314 typedef RD_BOOL(*str_handle_lines_t) (const char *line, void *data); 315 316 typedef enum 317 { 318 Fixed, 319 PercentageOfScreen, 320 Workarea, 321 Fullscreen, 322 } window_size_type_t; 323 324 #endif /* _TYPES_H */ 325