2 rdesktop: A Remote Desktop Protocol client.
4 Copyright (C) Matthew Chapman 1999-2008
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 3 of the License, or
9 (at your option) any later version.
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.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #include <winsock2.h> /* winsock2.h first */
33 #ifdef HAVE_SYS_SELECT_H
34 #include <sys/select.h>
35 #else /* HAVE_SYS_SELECT_H */
36 #include <sys/types.h>
38 #endif /* HAVE_SYS_SELECT_H */
40 //#include <limits.h> /* PATH_MAX */
41 #ifdef HAVE_SYSEXITS_H
45 #define VERSION "1.8.3"
47 /* standard exit codes */
66 #ifndef EX_UNAVAILABLE
67 #define EX_UNAVAILABLE 69
70 #define EX_SOFTWARE 70
79 #define EX_CANTCREAT 73
85 #define EX_TEMPFAIL 75
88 #define EX_PROTOCOL 76
97 /* rdesktop specific exit codes, lined up with disconnect PDU reasons */
98 #define EXRD_API_DISCONNECT 1
99 #define EXRD_API_LOGOFF 2
100 #define EXRD_IDLE_TIMEOUT 3
101 #define EXRD_LOGON_TIMEOUT 4
102 #define EXRD_REPLACED 5
103 #define EXRD_OUT_OF_MEM 6
104 #define EXRD_DENIED 7
105 #define EXRD_DENIED_FIPS 8
106 #define EXRD_INSUFFICIENT_PRIVILEGES 9
107 #define EXRD_FRESH_CREDENTIALS_REQUIRED 10
108 #define EXRD_RPC_DISCONNECT_BY_USER 11
109 #define EXRD_DISCONNECT_BY_USER 12
110 #define EXRD_LIC_INTERNAL 16
111 #define EXRD_LIC_NOSERVER 17
112 #define EXRD_LIC_NOLICENSE 18
113 #define EXRD_LIC_MSG 19
114 #define EXRD_LIC_HWID 20
115 #define EXRD_LIC_CLIENT 21
116 #define EXRD_LIC_NET 22
117 #define EXRD_LIC_PROTO 23
118 #define EXRD_LIC_ENC 24
119 #define EXRD_LIC_UPGRADE 25
120 #define EXRD_LIC_NOREMOTE 26
122 /* other exit codes */
123 #define EXRD_WINDOW_CLOSED 62
124 #define EXRD_UNKNOWN 63
127 #define DEBUG(args) printf args;
132 #ifdef WITH_DEBUG_KBD
133 #define DEBUG_KBD(args) printf args;
135 #define DEBUG_KBD(args)
138 #ifdef WITH_DEBUG_RDP5
139 #define DEBUG_RDP5(args) printf args;
141 #define DEBUG_RDP5(args)
144 #ifdef WITH_DEBUG_CLIPBOARD
145 #define DEBUG_CLIPBOARD(args) printf args;
147 #define DEBUG_CLIPBOARD(args)
150 #ifdef WITH_DEBUG_SOUND
151 #define DEBUG_SOUND(args) printf args;
153 #define DEBUG_SOUND(args)
156 #ifdef WITH_DEBUG_CHANNEL
157 #define DEBUG_CHANNEL(args) printf args;
159 #define DEBUG_CHANNEL(args)
162 #ifdef WITH_DEBUG_SCARD
163 #define DEBUG_SCARD(args) printf args;
165 #define DEBUG_SCARD(args)
168 #define STRNCPY(dst,src,n) { strncpy(dst,src,n-1); dst[n-1] = 0; }
171 #define MIN(x,y) (((x) < (y)) ? (x) : (y))
175 #define MAX(x,y) (((x) > (y)) ? (x) : (y))
180 #define timerisset(tvp)\
181 ((tvp)->tv_sec || (tvp)->tv_usec)
184 #define timercmp(tvp, uvp, cmp)\
185 ((tvp)->tv_sec cmp (uvp)->tv_sec ||\
186 (tvp)->tv_sec == (uvp)->tv_sec &&\
187 (tvp)->tv_usec cmp (uvp)->tv_usec)
190 #define timerclear(tvp)\
191 ((tvp)->tv_sec = (tvp)->tv_usec = 0)
194 /* If configure does not define the endianess, try
196 #if !defined(L_ENDIAN) && !defined(B_ENDIAN)
197 #if __BYTE_ORDER == __LITTLE_ENDIAN
199 #elif __BYTE_ORDER == __BIG_ENDIAN
202 #error Unknown endianness. Edit rdesktop.h.
204 #endif /* B_ENDIAN, L_ENDIAN from configure */
206 /* No need for alignment on x86 and amd64 */
207 #if !defined(NEED_ALIGN)
208 #if !(defined(__x86__) || defined(__x86_64__) || \
209 defined(__AMD64__) || defined(_M_IX86) || \
216 #include "constants.h"