1 |
/* -*- c-basic-offset: 8 -*- |
/* -*- c-basic-offset: 8 -*- |
2 |
rdesktop: A Remote Desktop Protocol client. |
rdesktop: A Remote Desktop Protocol client. |
3 |
Entrypoint and utility functions |
Entrypoint and utility functions |
4 |
Copyright (C) Matthew Chapman 1999-2007 |
Copyright (C) Matthew Chapman 1999-2008 |
5 |
|
|
6 |
This program is free software; you can redistribute it and/or modify |
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 |
it under the terms of the GNU General Public License as published by |
48 |
#include "ssl.h" |
#include "ssl.h" |
49 |
|
|
50 |
char g_title[64] = ""; |
char g_title[64] = ""; |
51 |
char g_username[64]; |
char *g_username; |
52 |
char g_hostname[16]; |
char g_hostname[16]; |
53 |
char g_keymapname[PATH_MAX] = ""; |
char g_keymapname[PATH_MAX] = ""; |
54 |
unsigned int g_keylayout = 0x409; /* Defaults to US keyboard layout */ |
unsigned int g_keylayout = 0x409; /* Defaults to US keyboard layout */ |
77 |
RD_BOOL g_bitmap_cache_persist_enable = False; |
RD_BOOL g_bitmap_cache_persist_enable = False; |
78 |
RD_BOOL g_bitmap_cache_precache = True; |
RD_BOOL g_bitmap_cache_precache = True; |
79 |
RD_BOOL g_encryption = True; |
RD_BOOL g_encryption = True; |
80 |
RD_BOOL packet_encryption = True; |
RD_BOOL g_packet_encryption = True; |
81 |
RD_BOOL g_desktop_save = True; /* desktop save order */ |
RD_BOOL g_desktop_save = True; /* desktop save order */ |
82 |
RD_BOOL g_polygon_ellipse_orders = True; /* polygon / ellipse orders */ |
RD_BOOL g_polygon_ellipse_orders = True; /* polygon / ellipse orders */ |
83 |
RD_BOOL g_fullscreen = False; |
RD_BOOL g_fullscreen = False; |
87 |
RD_BOOL g_rdpclip = True; |
RD_BOOL g_rdpclip = True; |
88 |
RD_BOOL g_console_session = False; |
RD_BOOL g_console_session = False; |
89 |
RD_BOOL g_numlock_sync = False; |
RD_BOOL g_numlock_sync = False; |
90 |
RD_BOOL lspci_enabled = False; |
RD_BOOL g_lspci_enabled = False; |
91 |
RD_BOOL g_owncolmap = False; |
RD_BOOL g_owncolmap = False; |
92 |
RD_BOOL g_ownbackstore = True; /* We can't rely on external BackingStore */ |
RD_BOOL g_ownbackstore = True; /* We can't rely on external BackingStore */ |
93 |
RD_BOOL g_seamless_rdp = False; |
RD_BOOL g_seamless_rdp = False; |
99 |
char g_redirect_server[64]; |
char g_redirect_server[64]; |
100 |
char g_redirect_domain[16]; |
char g_redirect_domain[16]; |
101 |
char g_redirect_password[64]; |
char g_redirect_password[64]; |
102 |
char g_redirect_username[64]; |
char *g_redirect_username; |
103 |
char g_redirect_cookie[128]; |
char g_redirect_cookie[128]; |
104 |
uint32 g_redirect_flags = 0; |
uint32 g_redirect_flags = 0; |
105 |
|
|
127 |
usage(char *program) |
usage(char *program) |
128 |
{ |
{ |
129 |
fprintf(stderr, "rdesktop: A Remote Desktop Protocol client.\n"); |
fprintf(stderr, "rdesktop: A Remote Desktop Protocol client.\n"); |
130 |
fprintf(stderr, "Version " VERSION ". Copyright (C) 1999-2005 Matt Chapman.\n"); |
fprintf(stderr, "Version " VERSION ". Copyright (C) 1999-2008 Matthew Chapman.\n"); |
131 |
fprintf(stderr, "See http://www.rdesktop.org/ for more information.\n\n"); |
fprintf(stderr, "See http://www.rdesktop.org/ for more information.\n\n"); |
132 |
|
|
133 |
fprintf(stderr, "Usage: %s [options] server[:port]\n", program); |
fprintf(stderr, "Usage: %s [options] server[:port]\n", program); |
473 |
break; |
break; |
474 |
|
|
475 |
case 'u': |
case 'u': |
476 |
STRNCPY(g_username, optarg, sizeof(g_username)); |
g_username = (char *) xmalloc(strlen(optarg) + 1); |
477 |
|
STRNCPY(g_username, optarg, strlen(optarg) + 1); |
478 |
username_option = 1; |
username_option = 1; |
479 |
break; |
break; |
480 |
|
|
583 |
g_encryption = False; |
g_encryption = False; |
584 |
break; |
break; |
585 |
case 'E': |
case 'E': |
586 |
packet_encryption = False; |
g_packet_encryption = False; |
587 |
break; |
break; |
588 |
case 'm': |
case 'm': |
589 |
g_sendmotion = False; |
g_sendmotion = False; |
634 |
g_server_depth = strtol(optarg, NULL, 10); |
g_server_depth = strtol(optarg, NULL, 10); |
635 |
if (g_server_depth != 8 && |
if (g_server_depth != 8 && |
636 |
g_server_depth != 16 && |
g_server_depth != 16 && |
637 |
g_server_depth != 15 && g_server_depth != 24) |
g_server_depth != 15 && g_server_depth != 24 |
638 |
|
&& g_server_depth != 32) |
639 |
{ |
{ |
640 |
error("Invalid server colour depth.\n"); |
error("Invalid server colour depth.\n"); |
641 |
return 1; |
return 1; |
728 |
} |
} |
729 |
else if (str_startswith(optarg, "lspci")) |
else if (str_startswith(optarg, "lspci")) |
730 |
{ |
{ |
731 |
lspci_enabled = True; |
g_lspci_enabled = True; |
732 |
} |
} |
733 |
else if (str_startswith(optarg, "lptport")) |
else if (str_startswith(optarg, "lptport")) |
734 |
{ |
{ |
847 |
error("could not determine username, use -u\n"); |
error("could not determine username, use -u\n"); |
848 |
return 1; |
return 1; |
849 |
} |
} |
850 |
|
/* +1 for trailing \0 */ |
851 |
STRNCPY(g_username, pw->pw_name, sizeof(g_username)); |
int pwlen = strlen(pw->pw_name) + 1; |
852 |
|
g_username = (char *) xmalloc(pwlen); |
853 |
|
STRNCPY(g_username, pw->pw_name, pwlen); |
854 |
} |
} |
855 |
|
|
856 |
#ifdef HAVE_ICONV |
#ifdef HAVE_ICONV |
924 |
} |
} |
925 |
#endif |
#endif |
926 |
|
|
927 |
if (lspci_enabled) |
if (g_lspci_enabled) |
928 |
lspci_init(); |
lspci_init(); |
929 |
|
|
930 |
rdpdr_init(); |
rdpdr_init(); |
942 |
|
|
943 |
/* By setting encryption to False here, we have an encrypted login |
/* By setting encryption to False here, we have an encrypted login |
944 |
packet but unencrypted transfer of other packets */ |
packet but unencrypted transfer of other packets */ |
945 |
if (!packet_encryption) |
if (!g_packet_encryption) |
946 |
g_encryption = False; |
g_encryption = False; |
947 |
|
|
948 |
|
|
965 |
rdesktop_reset_state(); |
rdesktop_reset_state(); |
966 |
|
|
967 |
STRNCPY(domain, g_redirect_domain, sizeof(domain)); |
STRNCPY(domain, g_redirect_domain, sizeof(domain)); |
968 |
|
xfree(g_username); |
969 |
|
g_username = (char *) xmalloc(strlen(g_redirect_username) + 1); |
970 |
STRNCPY(g_username, g_redirect_username, sizeof(g_username)); |
STRNCPY(g_username, g_redirect_username, sizeof(g_username)); |
971 |
STRNCPY(password, g_redirect_password, sizeof(password)); |
STRNCPY(password, g_redirect_password, sizeof(password)); |
972 |
STRNCPY(server, g_redirect_server, sizeof(server)); |
STRNCPY(server, g_redirect_server, sizeof(server)); |
1011 |
} |
} |
1012 |
|
|
1013 |
#endif |
#endif |
1014 |
|
if (g_redirect_username) |
1015 |
|
xfree(g_redirect_username); |
1016 |
|
|
1017 |
|
xfree(g_username); |
1018 |
} |
} |
1019 |
|
|
1020 |
#ifdef EGD_SOCKET |
#ifdef EGD_SOCKET |
1139 |
|
|
1140 |
/* realloc; exit if out of memory */ |
/* realloc; exit if out of memory */ |
1141 |
void * |
void * |
1142 |
xrealloc(void *oldmem, int size) |
xrealloc(void *oldmem, size_t size) |
1143 |
{ |
{ |
1144 |
void *mem; |
void *mem; |
1145 |
|
|
1146 |
if (size < 1) |
if (size == 0) |
1147 |
size = 1; |
size = 1; |
1148 |
mem = realloc(oldmem, size); |
mem = realloc(oldmem, size); |
1149 |
if (mem == NULL) |
if (mem == NULL) |
1150 |
{ |
{ |
1151 |
error("xrealloc %d\n", size); |
error("xrealloc %ld\n", size); |
1152 |
exit(1); |
exit(1); |
1153 |
} |
} |
1154 |
return mem; |
return mem; |