GUI-FreeRDP/freerdp/client/X11/cli/xrdp.c

72 lines
1.6 KiB
C
Raw Permalink Normal View History

2023-02-02 16:33:19 +00:00
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <winpr/crt.h>
#include <winpr/synch.h>
#include <winpr/thread.h>
#include <freerdp/freerdp.h>
#include <freerdp/client/cmdline.h>
#include "../xf_client.h"
#include "../xfreerdp.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <iup.h>
#include "xrdp.h"
int free_rdp_connect(int argc, char **argv)
{
int rc = 1;
int status;
HANDLE thread;
xfContext *xfc;
DWORD dwExitCode;
rdpContext *context;
rdpSettings *settings;
RDP_CLIENT_ENTRY_POINTS clientEntryPoints;
ZeroMemory(&clientEntryPoints, sizeof(RDP_CLIENT_ENTRY_POINTS));
clientEntryPoints.Size = sizeof(RDP_CLIENT_ENTRY_POINTS);
clientEntryPoints.Version = RDP_CLIENT_INTERFACE_VERSION;
RdpClientEntry(&clientEntryPoints);
context = freerdp_client_context_new(&clientEntryPoints);
if (!context)
return 1;
settings = context->settings;
xfc = (xfContext*) context;
status = freerdp_client_settings_parse_command_line(context->settings, argc, argv, FALSE);
if (status)
{
rc = freerdp_client_settings_command_line_status_print(settings, status, argc, argv);
if (settings->ListMonitors)
xf_list_monitors(xfc);
goto out;
}
if (freerdp_client_start(context) != 0)
goto out;
thread = freerdp_client_get_thread(context);
WaitForSingleObject(thread, INFINITE);
GetExitCodeThread(thread, &dwExitCode);
rc = xf_exit_code_from_disconnect_reason(dwExitCode);
freerdp_client_stop(context);
out: freerdp_client_context_free(context);
return rc;
}