51 |
char g_username[64]; |
char g_username[64]; |
52 |
char g_hostname[16]; |
char g_hostname[16]; |
53 |
char g_keymapname[PATH_MAX] = ""; |
char g_keymapname[PATH_MAX] = ""; |
54 |
int g_keylayout = 0x409; /* Defaults to US keyboard layout */ |
unsigned int g_keylayout = 0x409; /* Defaults to US keyboard layout */ |
55 |
int g_keyboard_type = 0x4; /* Defaults to US keyboard layout */ |
int g_keyboard_type = 0x4; /* Defaults to US keyboard layout */ |
56 |
int g_keyboard_subtype = 0x0; /* Defaults to US keyboard layout */ |
int g_keyboard_subtype = 0x0; /* Defaults to US keyboard layout */ |
57 |
int g_keyboard_functionkeys = 0xc; /* Defaults to US keyboard layout */ |
int g_keyboard_functionkeys = 0xc; /* Defaults to US keyboard layout */ |
69 |
2 xpos neg, |
2 xpos neg, |
70 |
4 ypos neg */ |
4 ypos neg */ |
71 |
extern int g_tcp_port_rdp; |
extern int g_tcp_port_rdp; |
72 |
int g_server_bpp = 8; |
int g_server_depth = 8; |
73 |
int g_win_button_size = 0; /* If zero, disable single app mode */ |
int g_win_button_size = 0; /* If zero, disable single app mode */ |
74 |
BOOL g_bitmap_compression = True; |
BOOL g_bitmap_compression = True; |
75 |
BOOL g_sendmotion = True; |
BOOL g_sendmotion = True; |
86 |
BOOL g_use_rdp5 = True; |
BOOL g_use_rdp5 = True; |
87 |
BOOL g_console_session = False; |
BOOL g_console_session = False; |
88 |
BOOL g_numlock_sync = False; |
BOOL g_numlock_sync = False; |
89 |
|
BOOL lspci_enabled = False; |
90 |
BOOL g_owncolmap = False; |
BOOL g_owncolmap = False; |
91 |
BOOL g_ownbackstore = True; /* We can't rely on external BackingStore */ |
BOOL g_ownbackstore = True; /* We can't rely on external BackingStore */ |
92 |
uint32 g_embed_wnd; |
uint32 g_embed_wnd; |
381 |
char fullhostname[64]; |
char fullhostname[64]; |
382 |
char domain[16]; |
char domain[16]; |
383 |
char password[64]; |
char password[64]; |
384 |
char shell[128]; |
char shell[256]; |
385 |
char directory[32]; |
char directory[256]; |
386 |
BOOL prompt_password, deactivated; |
BOOL prompt_password, deactivated; |
387 |
struct passwd *pw; |
struct passwd *pw; |
388 |
uint32 flags, ext_disc_reason = 0; |
uint32 flags, ext_disc_reason = 0; |
591 |
break; |
break; |
592 |
|
|
593 |
case 'a': |
case 'a': |
594 |
g_server_bpp = strtol(optarg, NULL, 10); |
g_server_depth = strtol(optarg, NULL, 10); |
595 |
if (g_server_bpp != 8 && g_server_bpp != 16 && g_server_bpp != 15 |
if (g_server_depth != 8 && |
596 |
&& g_server_bpp != 24) |
g_server_depth != 16 && |
597 |
|
g_server_depth != 15 && g_server_depth != 24) |
598 |
{ |
{ |
599 |
error("invalid server bpp\n"); |
error("Invalid server colour depth.\n"); |
600 |
return 1; |
return 1; |
601 |
} |
} |
602 |
break; |
break; |
680 |
{ |
{ |
681 |
serial_enum_devices(&g_num_devices, optarg + 7); |
serial_enum_devices(&g_num_devices, optarg + 7); |
682 |
} |
} |
683 |
|
else if (str_startswith(optarg, "lspci")) |
684 |
|
{ |
685 |
|
lspci_enabled = True; |
686 |
|
} |
687 |
else if (str_startswith(optarg, "lptport")) |
else if (str_startswith(optarg, "lptport")) |
688 |
{ |
{ |
689 |
parallel_enum_devices(&g_num_devices, optarg + 7); |
parallel_enum_devices(&g_num_devices, optarg + 7); |
809 |
if (g_rdpsnd) |
if (g_rdpsnd) |
810 |
rdpsnd_init(); |
rdpsnd_init(); |
811 |
#endif |
#endif |
812 |
|
|
813 |
|
if (lspci_enabled) |
814 |
|
lspci_init(); |
815 |
|
|
816 |
rdpdr_init(); |
rdpdr_init(); |
817 |
|
|
818 |
while (run_count < 2 && continue_connect) /* add support for Session Directory; only reconnect once */ |
while (run_count < 2 && continue_connect) /* add support for Session Directory; only reconnect once */ |
1187 |
} |
} |
1188 |
|
|
1189 |
|
|
1190 |
|
/* Split input into lines, and call linehandler for each |
1191 |
|
line. Incomplete lines are saved in the rest variable, which should |
1192 |
|
initially point to NULL. When linehandler returns False, stop and |
1193 |
|
return False. Otherwise, return True. */ |
1194 |
|
BOOL |
1195 |
|
str_handle_lines(const char *input, char **rest, str_handle_lines_t linehandler, void *data) |
1196 |
|
{ |
1197 |
|
char *buf, *p; |
1198 |
|
char *oldrest; |
1199 |
|
size_t inputlen; |
1200 |
|
size_t buflen; |
1201 |
|
size_t restlen = 0; |
1202 |
|
BOOL ret = True; |
1203 |
|
|
1204 |
|
/* Copy data to buffer */ |
1205 |
|
inputlen = strlen(input); |
1206 |
|
if (*rest) |
1207 |
|
restlen = strlen(*rest); |
1208 |
|
buflen = restlen + inputlen + 1; |
1209 |
|
buf = (char *) xmalloc(buflen); |
1210 |
|
buf[0] = '\0'; |
1211 |
|
if (*rest) |
1212 |
|
STRNCPY(buf, *rest, buflen); |
1213 |
|
strncat(buf, input, inputlen); |
1214 |
|
p = buf; |
1215 |
|
|
1216 |
|
while (1) |
1217 |
|
{ |
1218 |
|
char *newline = strchr(p, '\n'); |
1219 |
|
if (newline) |
1220 |
|
{ |
1221 |
|
*newline = '\0'; |
1222 |
|
if (!linehandler(p, data)) |
1223 |
|
{ |
1224 |
|
p = newline + 1; |
1225 |
|
ret = False; |
1226 |
|
break; |
1227 |
|
} |
1228 |
|
p = newline + 1; |
1229 |
|
} |
1230 |
|
else |
1231 |
|
{ |
1232 |
|
break; |
1233 |
|
|
1234 |
|
} |
1235 |
|
} |
1236 |
|
|
1237 |
|
/* Save in rest */ |
1238 |
|
oldrest = *rest; |
1239 |
|
restlen = buf + buflen - p; |
1240 |
|
*rest = (char *) xmalloc(restlen); |
1241 |
|
STRNCPY((*rest), p, restlen); |
1242 |
|
xfree(oldrest); |
1243 |
|
|
1244 |
|
xfree(buf); |
1245 |
|
return ret; |
1246 |
|
} |
1247 |
|
|
1248 |
|
/* Execute the program specified by argv. For each line in |
1249 |
|
stdout/stderr output, call linehandler. Returns false on failure. */ |
1250 |
|
BOOL |
1251 |
|
subprocess(char *const argv[], str_handle_lines_t linehandler, void *data) |
1252 |
|
{ |
1253 |
|
pid_t child; |
1254 |
|
int fd[2]; |
1255 |
|
int n = 1; |
1256 |
|
char output[256]; |
1257 |
|
char *rest = NULL; |
1258 |
|
|
1259 |
|
if (pipe(fd) < 0) |
1260 |
|
{ |
1261 |
|
perror("pipe"); |
1262 |
|
return False; |
1263 |
|
} |
1264 |
|
|
1265 |
|
if ((child = fork()) < 0) |
1266 |
|
{ |
1267 |
|
perror("fork"); |
1268 |
|
return False; |
1269 |
|
} |
1270 |
|
|
1271 |
|
/* Child */ |
1272 |
|
if (child == 0) |
1273 |
|
{ |
1274 |
|
/* Close read end */ |
1275 |
|
close(fd[0]); |
1276 |
|
|
1277 |
|
/* Redirect stdout and stderr to pipe */ |
1278 |
|
dup2(fd[1], 1); |
1279 |
|
dup2(fd[1], 2); |
1280 |
|
|
1281 |
|
/* Execute */ |
1282 |
|
execvp(argv[0], argv); |
1283 |
|
perror("Error executing child"); |
1284 |
|
_exit(128); |
1285 |
|
} |
1286 |
|
|
1287 |
|
/* Parent. Close write end. */ |
1288 |
|
close(fd[1]); |
1289 |
|
while (n > 0) |
1290 |
|
{ |
1291 |
|
n = read(fd[0], output, 255); |
1292 |
|
output[n] = '\0'; |
1293 |
|
str_handle_lines(output, &rest, linehandler, data); |
1294 |
|
} |
1295 |
|
xfree(rest); |
1296 |
|
|
1297 |
|
return True; |
1298 |
|
} |
1299 |
|
|
1300 |
|
|
1301 |
/* not all clibs got ltoa */ |
/* not all clibs got ltoa */ |
1302 |
#define LTOA_BUFSIZE (sizeof(long) * 8 + 1) |
#define LTOA_BUFSIZE (sizeof(long) * 8 + 1) |
1303 |
|
|