int main(int argc, char* argv[]) { pthread_t thread; freerdp* instance; dfContext* context; rdpChannels* channels; struct thread_data* data; setlocale(LC_ALL, ""); freerdp_channels_global_init(); g_sem = freerdp_sem_new(1); instance = freerdp_new(); instance->PreConnect = df_pre_connect; instance->PostConnect = df_post_connect; instance->VerifyCertificate = df_verify_certificate; instance->ReceiveChannelData = df_receive_channel_data; instance->context_size = sizeof(dfContext); instance->ContextNew = df_context_new; instance->ContextFree = df_context_free; freerdp_context_new(instance); context = (dfContext*) instance->context; channels = instance->context->channels; DirectFBInit(&argc, &argv); freerdp_parse_args(instance->settings, argc, argv, df_process_plugin_args, channels, NULL, NULL); data = (struct thread_data*) xzalloc(sizeof(struct thread_data)); data->instance = instance; g_thread_count++; pthread_create(&thread, 0, thread_func, data); while (g_thread_count > 0) { freerdp_sem_wait(g_sem); } freerdp_channels_global_uninit(); return 0; }
int main(int argc, char* argv[]) { pthread_t thread; freerdp* instance; tfContext* context; struct thread_data* data; rdpChannels* channels; freerdp_channels_global_init(); g_sem = freerdp_sem_new(1); instance = freerdp_new(); instance->PreConnect = tf_pre_connect; instance->PostConnect = tf_post_connect; instance->ReceiveChannelData = tf_receive_channel_data; instance->ContextSize = (pcContextSize) tf_context_size; instance->ContextNew = (pcContextNew) tf_context_new; instance->ContextFree = (pcContextFree) tf_context_free; freerdp_context_new(instance); context = (tfContext*) instance->context; channels = context->channels; freerdp_parse_args(instance->settings, argc, argv, tf_process_plugin_args, channels, NULL, NULL); data = (struct thread_data*) xzalloc(sizeof(struct thread_data)); data->instance = instance; g_thread_count++; pthread_create(&thread, 0, thread_func, data); while (g_thread_count > 0) { freerdp_sem_wait(g_sem); } freerdp_channels_global_uninit(); return 0; }
void test_args(void) { char* argv_c[] = { "freerdp", "-a", "8", "-u", "testuser", "-d", "testdomain", "-g", "640x480", "address1:3389", "freerdp", "-a", "16", "-u", "testuser", "-d", "testdomain", "-g", "1280x960", "address2:3390" }; char** argv = argv_c; int argc = ARRAY_SIZE(argv_c); int i; int c; rdpSettings* settings; i = 0; while (argc > 0) { settings = settings_new(NULL); i++; c = freerdp_parse_args(settings, argc, argv, process_plugin_args, NULL, process_ui_args, NULL); CU_ASSERT(c > 0); if (c == 0) { settings_free(settings); break; } CU_ASSERT(settings->color_depth == i * 8); CU_ASSERT(settings->width == i * 640); CU_ASSERT(settings->height == i * 480); CU_ASSERT(settings->port == i + 3388); settings_free(settings); argc -= c; argv += c; } CU_ASSERT(i == 2); }
int main(int argc, char* argv[]) { pthread_t thread; freerdp* instance; struct thread_data* data; rdpChanMan* chanman; freerdp_chanman_global_init(); g_sem = freerdp_sem_new(1); instance = freerdp_new(); instance->PreConnect = tf_pre_connect; instance->PostConnect = tf_post_connect; instance->ReceiveChannelData = tf_receive_channel_data; chanman = freerdp_chanman_new(); SET_CHANMAN(instance, chanman); freerdp_parse_args(instance->settings, argc, argv, tf_process_plugin_args, chanman, NULL, NULL); data = (struct thread_data*) xzalloc(sizeof(struct thread_data)); data->instance = instance; g_thread_count++; pthread_create(&thread, 0, thread_func, data); while (g_thread_count > 0) { freerdp_sem_wait(g_sem); } freerdp_chanman_global_uninit(); return 0; }
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { freerdp* instance; thread_data* data; WSADATA wsa_data; WNDCLASSEX wnd_cls; if (NULL == getenv("HOME")) { char home[MAX_PATH * 2] = "HOME="; strcat(home, getenv("HOMEDRIVE")); strcat(home, getenv("HOMEPATH")); _putenv(home); } if (WSAStartup(0x101, &wsa_data) != 0) return 1; g_done_event = CreateEvent(0, 1, 0, 0); #if defined(WITH_DEBUG) || defined(_DEBUG) wf_create_console(); #endif g_default_cursor = LoadCursor(NULL, IDC_ARROW); wnd_cls.cbSize = sizeof(WNDCLASSEX); wnd_cls.style = CS_HREDRAW | CS_VREDRAW; wnd_cls.lpfnWndProc = wf_event_proc; wnd_cls.cbClsExtra = 0; wnd_cls.cbWndExtra = 0; wnd_cls.hIcon = LoadIcon(NULL, IDI_APPLICATION); wnd_cls.hCursor = g_default_cursor; wnd_cls.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); wnd_cls.lpszMenuName = NULL; wnd_cls.lpszClassName = g_wnd_class_name; wnd_cls.hInstance = hInstance; wnd_cls.hIconSm = LoadIcon(NULL, IDI_APPLICATION); RegisterClassEx(&wnd_cls); g_hInstance = hInstance; freerdp_channels_global_init(); instance = freerdp_new(); instance->PreConnect = wf_pre_connect; instance->PostConnect = wf_post_connect; instance->VerifyCertificate = wf_verify_certificate; instance->ReceiveChannelData = wf_receive_channel_data; instance->context_size = sizeof(wfContext); instance->ContextNew = wf_context_new; instance->ContextFree = wf_context_free; freerdp_context_new(instance); instance->context->argc = __argc; instance->context->argv = __argv; if (!CreateThread(NULL, 0, kbd_thread_func, NULL, 0, NULL)) printf("error creating keyboard handler thread"); //while (1) { int arg_parse_result; data = (thread_data*) xzalloc(sizeof(thread_data)); data->instance = instance; arg_parse_result = freerdp_parse_args(instance->settings, __argc, __argv, wf_process_plugin_args, instance->context->channels, wf_process_client_args, NULL); if (arg_parse_result < 0) { if (arg_parse_result == FREERDP_ARGS_PARSE_FAILURE) printf("failed to parse arguments.\n"); #ifdef _DEBUG system("pause"); #endif exit(-1); } if (CreateThread(NULL, 0, thread_func, data, 0, NULL) != 0) g_thread_count++; } if (g_thread_count > 0) WaitForSingleObject(g_done_event, INFINITE); else MessageBox(GetConsoleWindow(), L"Failed to start wfreerdp.\n\nPlease check the debug output.", L"FreeRDP Error", MB_ICONSTOP); WSACleanup(); #ifdef _DEBUG system("pause"); #endif return 0; }