1 | /*
|
---|
2 | rdesktop: A Remote Desktop Protocol client.
|
---|
3 | Master include file
|
---|
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 | #include <stdlib.h>
|
---|
22 | #include <stdio.h>
|
---|
23 | #include <string.h>
|
---|
24 | #ifdef _WIN32
|
---|
25 | #define WINVER 0x0400
|
---|
26 | #include <windows.h>
|
---|
27 | #include <winsock.h>
|
---|
28 | #include <time.h>
|
---|
29 | #define DIR int
|
---|
30 | #else
|
---|
31 | #include <dirent.h>
|
---|
32 | #include <sys/time.h>
|
---|
33 | #ifdef HAVE_SYS_SELECT_H
|
---|
34 | #include <sys/select.h>
|
---|
35 | #else
|
---|
36 | #include <sys/types.h>
|
---|
37 | #include <unistd.h>
|
---|
38 | #endif
|
---|
39 | #endif
|
---|
40 | #include <limits.h> /* PATH_MAX */
|
---|
41 |
|
---|
42 | #define VERSION "1.6.0"
|
---|
43 |
|
---|
44 | #ifdef VBOX
|
---|
45 | #undef DEBUG
|
---|
46 | #endif
|
---|
47 |
|
---|
48 | #ifdef WITH_DEBUG
|
---|
49 | #define DEBUG(args) printf args;
|
---|
50 | #else
|
---|
51 | #define DEBUG(args)
|
---|
52 | #endif
|
---|
53 |
|
---|
54 | #ifdef WITH_DEBUG_KBD
|
---|
55 | #define DEBUG_KBD(args) printf args;
|
---|
56 | #else
|
---|
57 | #define DEBUG_KBD(args)
|
---|
58 | #endif
|
---|
59 |
|
---|
60 | #ifdef WITH_DEBUG_RDP5
|
---|
61 | #define DEBUG_RDP5(args) printf args;
|
---|
62 | #else
|
---|
63 | #define DEBUG_RDP5(args)
|
---|
64 | #endif
|
---|
65 |
|
---|
66 | #ifdef WITH_DEBUG_CLIPBOARD
|
---|
67 | #define DEBUG_CLIPBOARD(args) printf args;
|
---|
68 | #else
|
---|
69 | #define DEBUG_CLIPBOARD(args)
|
---|
70 | #endif
|
---|
71 |
|
---|
72 | #ifdef WITH_DEBUG_SOUND
|
---|
73 | #define DEBUG_SOUND(args) printf args;
|
---|
74 | #else
|
---|
75 | #define DEBUG_SOUND(args)
|
---|
76 | #endif
|
---|
77 |
|
---|
78 | #ifdef WITH_DEBUG_CHANNEL
|
---|
79 | #define DEBUG_CHANNEL(args) printf args;
|
---|
80 | #else
|
---|
81 | #define DEBUG_CHANNEL(args)
|
---|
82 | #endif
|
---|
83 |
|
---|
84 | #ifdef WITH_DEBUG_SCARD
|
---|
85 | #define DEBUG_SCARD(args) printf args;
|
---|
86 | #else
|
---|
87 | #define DEBUG_SCARD(args)
|
---|
88 | #endif
|
---|
89 |
|
---|
90 | #define STRNCPY(dst,src,n) { strncpy(dst,src,n-1); dst[n-1] = 0; }
|
---|
91 |
|
---|
92 | #ifndef MIN
|
---|
93 | #define MIN(x,y) (((x) < (y)) ? (x) : (y))
|
---|
94 | #endif
|
---|
95 |
|
---|
96 | #ifndef MAX
|
---|
97 | #define MAX(x,y) (((x) > (y)) ? (x) : (y))
|
---|
98 | #endif
|
---|
99 |
|
---|
100 | /* timeval macros */
|
---|
101 | #ifndef timerisset
|
---|
102 | #define timerisset(tvp)\
|
---|
103 | ((tvp)->tv_sec || (tvp)->tv_usec)
|
---|
104 | #endif
|
---|
105 | #ifndef timercmp
|
---|
106 | #define timercmp(tvp, uvp, cmp)\
|
---|
107 | ((tvp)->tv_sec cmp (uvp)->tv_sec ||\
|
---|
108 | (tvp)->tv_sec == (uvp)->tv_sec &&\
|
---|
109 | (tvp)->tv_usec cmp (uvp)->tv_usec)
|
---|
110 | #endif
|
---|
111 | #ifndef timerclear
|
---|
112 | #define timerclear(tvp)\
|
---|
113 | ((tvp)->tv_sec = (tvp)->tv_usec = 0)
|
---|
114 | #endif
|
---|
115 |
|
---|
116 | /* If configure does not define the endianess, try
|
---|
117 | to find it out */
|
---|
118 | #if !defined(L_ENDIAN) && !defined(B_ENDIAN)
|
---|
119 | #if __BYTE_ORDER == __LITTLE_ENDIAN
|
---|
120 | #define L_ENDIAN
|
---|
121 | #elif __BYTE_ORDER == __BIG_ENDIAN
|
---|
122 | #define B_ENDIAN
|
---|
123 | #else
|
---|
124 | #error Unknown endianness. Edit rdesktop.h.
|
---|
125 | #endif
|
---|
126 | #endif /* B_ENDIAN, L_ENDIAN from configure */
|
---|
127 |
|
---|
128 | /* No need for alignment on x86 and amd64 */
|
---|
129 | #if !defined(NEED_ALIGN)
|
---|
130 | #if !(defined(__x86__) || defined(__x86_64__) || \
|
---|
131 | defined(__AMD64__) || defined(_M_IX86) || \
|
---|
132 | defined(__i386__))
|
---|
133 | #define NEED_ALIGN
|
---|
134 | #endif
|
---|
135 | #endif
|
---|
136 |
|
---|
137 | #include "parse.h"
|
---|
138 | #include "constants.h"
|
---|
139 | #include "types.h"
|
---|
140 |
|
---|
141 | #ifndef MAKE_PROTO
|
---|
142 | #include "proto.h"
|
---|
143 | #endif
|
---|