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