⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rdesktop.c

📁 rdesktop is a client for Microsoft Windows NT Terminal Server, Windows 2000 Terminal Services, Wind
💻 C
📖 第 1 页 / 共 3 页
字号:
				if (*p == '%')				{					g_width = -g_width;					p++;				}				if (*p == '+' || *p == '-')				{					g_pos |= (*p == '-') ? 2 : 1;					g_xpos = strtol(p, &p, 10);				}				if (*p == '+' || *p == '-')				{					g_pos |= (*p == '-') ? 4 : 1;					g_ypos = strtol(p, NULL, 10);				}				break;			case 'f':				g_fullscreen = True;				break;			case 'b':				g_bitmap_cache = False;				break;			case 'B':				g_ownbackstore = False;				break;			case 'e':				g_encryption = False;				break;			case 'E':				packet_encryption = False;				break;			case 'm':				g_sendmotion = False;				break;			case 'C':				g_owncolmap = True;				break;			case 'D':				g_hide_decorations = True;				break;			case 'K':				g_grab_keyboard = False;				break;			case 'S':				if (!strcmp(optarg, "standard"))				{					g_win_button_size = 18;					break;				}				g_win_button_size = strtol(optarg, &p, 10);				if (*p)				{					error("invalid button size\n");					return 1;				}				break;			case 'T':				STRNCPY(g_title, optarg, sizeof(g_title));				break;			case 'N':				g_numlock_sync = True;				break;			case 'X':				g_embed_wnd = strtol(optarg, NULL, 0);				break;			case 'a':				g_server_depth = strtol(optarg, NULL, 10);				if (g_server_depth != 8 &&				    g_server_depth != 16 &&				    g_server_depth != 15 && g_server_depth != 24)				{					error("Invalid server colour depth.\n");					return 1;				}				break;			case 'z':				DEBUG(("rdp compression enabled\n"));				flags |= (RDP_LOGON_COMPRESSION | RDP_LOGON_COMPRESSION2);				break;			case 'x':				if (str_startswith(optarg, "m"))	/* modem */				{					g_rdp5_performanceflags =						RDP5_NO_WALLPAPER | RDP5_NO_FULLWINDOWDRAG |						RDP5_NO_MENUANIMATIONS | RDP5_NO_THEMING;				}				else if (str_startswith(optarg, "b"))	/* broadband */				{					g_rdp5_performanceflags = RDP5_NO_WALLPAPER;				}				else if (str_startswith(optarg, "l"))	/* lan */				{					g_rdp5_performanceflags = RDP5_DISABLE_NOTHING;				}				else				{					g_rdp5_performanceflags = strtol(optarg, NULL, 16);				}				break;			case 'P':				g_bitmap_cache_persist_enable = True;				break;			case 'r':				if (str_startswith(optarg, "sound"))				{					optarg += 5;					if (*optarg == ':')					{						optarg++;						while ((p = next_arg(optarg, ',')))						{							if (str_startswith(optarg, "remote"))								flags |= RDP_LOGON_LEAVE_AUDIO;							if (str_startswith(optarg, "local"))#ifdef WITH_RDPSND								g_rdpsnd = True;#else								warning("Not compiled with sound support\n");#endif							if (str_startswith(optarg, "off"))#ifdef WITH_RDPSND								g_rdpsnd = False;#else								warning("Not compiled with sound support\n");#endif							optarg = p;						}					}					else					{#ifdef WITH_RDPSND						g_rdpsnd = True;#else						warning("Not compiled with sound support\n");#endif					}				}				else if (str_startswith(optarg, "disk"))				{					/* -r disk:h:=/mnt/floppy */					disk_enum_devices(&g_num_devices, optarg + 4);				}				else if (str_startswith(optarg, "comport"))				{					serial_enum_devices(&g_num_devices, optarg + 7);				}				else if (str_startswith(optarg, "lspci"))				{					lspci_enabled = True;				}				else if (str_startswith(optarg, "lptport"))				{					parallel_enum_devices(&g_num_devices, optarg + 7);				}				else if (str_startswith(optarg, "printer"))				{					printer_enum_devices(&g_num_devices, optarg + 7);				}				else if (str_startswith(optarg, "clientname"))				{					g_rdpdr_clientname = xmalloc(strlen(optarg + 11) + 1);					strcpy(g_rdpdr_clientname, optarg + 11);				}				else if (str_startswith(optarg, "clipboard"))				{					optarg += 9;					if (*optarg == ':')					{						optarg++;						if (str_startswith(optarg, "off"))							g_rdpclip = False;						else							cliprdr_set_mode(optarg);					}					else						g_rdpclip = True;				}				else				{					warning("Unknown -r argument\n\n\tPossible arguments are: comport, disk, lptport, printer, sound, clipboard\n");				}				break;			case '0':				g_console_session = True;				break;			case '4':				g_use_rdp5 = False;				break;			case '5':				g_use_rdp5 = True;				break;			case 'h':			case '?':			default:				usage(argv[0]);				return 1;		}	}	if (argc - optind != 1)	{		usage(argv[0]);		return 1;	}	STRNCPY(server, argv[optind], sizeof(server));	parse_server_and_port(server);	if (g_seamless_rdp)	{		if (g_win_button_size)		{			error("You cannot use -S and -A at the same time\n");			return 1;		}		g_rdp5_performanceflags &= ~RDP5_NO_FULLWINDOWDRAG;		if (geometry_option)		{			error("You cannot use -g and -A at the same time\n");			return 1;		}		if (g_fullscreen)		{			error("You cannot use -f and -A at the same time\n");			return 1;		}		if (g_hide_decorations)		{			error("You cannot use -D and -A at the same time\n");			return 1;		}		if (g_embed_wnd)		{			error("You cannot use -X and -A at the same time\n");			return 1;		}		if (!g_use_rdp5)		{			error("You cannot use -4 and -A at the same time\n");			return 1;		}		g_width = -100;		g_grab_keyboard = False;	}	if (!username_option)	{		pw = getpwuid(getuid());		if ((pw == NULL) || (pw->pw_name == NULL))		{			error("could not determine username, use -u\n");			return 1;		}		STRNCPY(g_username, pw->pw_name, sizeof(g_username));	}#ifdef HAVE_ICONV	if (g_codepage[0] == 0)	{		if (setlocale(LC_CTYPE, ""))		{			STRNCPY(g_codepage, nl_langinfo(CODESET), sizeof(g_codepage));		}		else		{			STRNCPY(g_codepage, DEFAULT_CODEPAGE, sizeof(g_codepage));		}	}#endif	if (g_hostname[0] == 0)	{		if (gethostname(fullhostname, sizeof(fullhostname)) == -1)		{			error("could not determine local hostname, use -n\n");			return 1;		}		p = strchr(fullhostname, '.');		if (p != NULL)			*p = 0;		STRNCPY(g_hostname, fullhostname, sizeof(g_hostname));	}	if (g_keymapname[0] == 0)	{		if (locale && xkeymap_from_locale(locale))		{			fprintf(stderr, "Autoselected keyboard map %s\n", g_keymapname);		}		else		{			STRNCPY(g_keymapname, "en-us", sizeof(g_keymapname));		}	}	if (locale)		xfree(locale);	if (prompt_password && read_password(password, sizeof(password)))		flags |= RDP_LOGON_AUTO;	if (g_title[0] == 0)	{		strcpy(g_title, "rdesktop - ");		strncat(g_title, server, sizeof(g_title) - sizeof("rdesktop - "));	}#ifdef RDP2VNC	rdp2vnc_connect(server, flags, domain, password, shell, directory);	return 0;#else	if (!ui_init())		return 1;#ifdef WITH_RDPSND	if (g_rdpsnd)		rdpsnd_init();#endif	if (lspci_enabled)		lspci_init();	rdpdr_init();	while (run_count < 2 && continue_connect)	/* add support for Session Directory; only reconnect once */	{		if (run_count == 0)		{			if (!rdp_connect(server, flags, domain, password, shell, directory))				return 1;		}		else if (!rdp_reconnect			 (server, flags, domain, password, shell, directory, g_redirect_cookie))			return 1;		/* By setting encryption to False here, we have an encrypted login 		   packet but unencrypted transfer of other packets */		if (!packet_encryption)			g_encryption = False;		DEBUG(("Connection successful.\n"));		memset(password, 0, sizeof(password));		if (run_count == 0)			if (!ui_create_window())				continue_connect = False;		if (continue_connect)			rdp_main_loop(&deactivated, &ext_disc_reason);		DEBUG(("Disconnecting...\n"));		rdp_disconnect();		if ((g_redirect == True) && (run_count == 0))	/* Support for Session Directory */		{			/* reset state of major globals */			rdesktop_reset_state();			STRNCPY(domain, g_redirect_domain, sizeof(domain));			STRNCPY(g_username, g_redirect_username, sizeof(g_username));			STRNCPY(password, g_redirect_password, sizeof(password));			STRNCPY(server, g_redirect_server, sizeof(server));			flags |= RDP_LOGON_AUTO;			g_redirect = False;		}		else		{			continue_connect = False;			ui_destroy_window();			break;		}		run_count++;	}	cache_save_state();	ui_deinit();	if (ext_disc_reason >= 2)		print_disconnect_reason(ext_disc_reason);	if (deactivated)	{		/* clean disconnect */		return 0;	}	else	{		if (ext_disc_reason == exDiscReasonAPIInitiatedDisconnect		    || ext_disc_reason == exDiscReasonAPIInitiatedLogoff)		{			/* not so clean disconnect, but nothing to worry about */			return 0;		}		else		{			/* return error */			return 2;		}	}#endif}#ifdef EGD_SOCKET/* Read 32 random bytes from PRNGD or EGD socket (based on OpenSSL RAND_egd) */static BOOLgenerate_random_egd(uint8 * buf){	struct sockaddr_un addr;	BOOL ret = False;	int fd;	fd = socket(AF_UNIX, SOCK_STREAM, 0);	if (fd == -1)		return False;	addr.sun_family = AF_UNIX;	memcpy(addr.sun_path, EGD_SOCKET, sizeof(EGD_SOCKET));	if (connect(fd, (struct sockaddr *) &addr, sizeof(addr)) == -1)		goto err;	/* PRNGD and EGD use a simple communications protocol */	buf[0] = 1;		/* Non-blocking (similar to /dev/urandom) */	buf[1] = 32;		/* Number of requested random bytes */	if (write(fd, buf, 2) != 2)		goto err;	if ((read(fd, buf, 1) != 1) || (buf[0] == 0))	/* Available? */		goto err;	if (read(fd, buf, 32) != 32)		goto err;	ret = True;      err:	close(fd);	return ret;}#endif/* Generate a 32-byte random for the secure transport code. */voidgenerate_random(uint8 * random){	struct stat st;	struct tms tmsbuf;	MD5_CTX md5;	uint32 *r;	int fd, n;	/* If we have a kernel random device, try that first */	if (((fd = open("/dev/urandom", O_RDONLY)) != -1)	    || ((fd = open("/dev/random", O_RDONLY)) != -1))	{		n = read(fd, random, 32);		close(fd);		if (n == 32)			return;	}#ifdef EGD_SOCKET	/* As a second preference use an EGD */	if (generate_random_egd(random))		return;#endif	/* Otherwise use whatever entropy we can gather - ideas welcome. */	r = (uint32 *) random;	r[0] = (getpid()) | (getppid() << 16);	r[1] = (getuid()) | (getgid() << 16);	r[2] = times(&tmsbuf);	/* system uptime (clocks) */	gettimeofday((struct timeval *) &r[3], NULL);	/* sec and usec */	stat("/tmp", &st);	r[5] = st.st_atime;	r[6] = st.st_mtime;	r[7] = st.st_ctime;	/* Hash both halves with MD5 to obscure possible patterns */	MD5_Init(&md5);	MD5_Update(&md5, random, 16);	MD5_Final(random, &md5);	MD5_Update(&md5, random + 16, 16);	MD5_Final(random + 16, &md5);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -