21 #include <freerdp/config.h>
31 #include <CoreGraphics/CGEvent.h>
33 #include <winpr/crt.h>
34 #include <winpr/wtsapi.h>
35 #include <winpr/assert.h>
37 #include <freerdp/freerdp.h>
38 #include <freerdp/constants.h>
39 #include <freerdp/channels/wtsvc.h>
40 #include <freerdp/channels/channels.h>
41 #include <freerdp/server/server-common.h>
46 #include <freerdp/log.h>
47 #define TAG SERVER_TAG("mac")
49 static void mf_server_main_loop(freerdp_listener* instance)
51 WINPR_ASSERT(instance);
52 WINPR_ASSERT(instance->GetEventHandles);
53 WINPR_ASSERT(instance->CheckFileDescriptor);
58 HANDLE handles[MAXIMUM_WAIT_OBJECTS] = { 0 };
59 DWORD count = instance->GetEventHandles(instance, handles, ARRAYSIZE(handles));
63 WLog_ERR(TAG,
"Failed to get FreeRDP file descriptor");
67 status = WaitForMultipleObjects(count, handles, FALSE, INFINITE);
68 if (status == WAIT_FAILED)
70 WLog_ERR(TAG,
"WaitForMultipleObjects failed");
74 if (instance->CheckFileDescriptor(instance) != TRUE)
80 instance->Close(instance);
83 int main(
int argc,
char* argv[])
85 freerdp_server_warn_unmaintained(argc, argv);
86 mf_server_info info = { .key =
"server.key", .cert =
"server.crt" };
88 freerdp_listener* instance;
90 signal(SIGPIPE, SIG_IGN);
92 WTSRegisterWtsApiFunctionTable(FreeRDP_InitWtsApi());
94 if (!(instance = freerdp_listener_new()))
97 instance->info = &info;
98 instance->PeerAccepted = mf_peer_accepted;
100 if (instance->Open(instance, NULL, 3389))
102 mf_server_main_loop(instance);
105 freerdp_listener_free(instance);