Beispiel #1
0
int
main(int argc, char ** argv)
{
	struct thread_data * data;
	int rv;
	pthread_t thread;
	int index = 1;

	setlocale(LC_CTYPE, "");

	if (!freerdp_global_init())
	{
		printf("Error initializing freerdp\n");
		return 1;
	}
	freerdp_chanman_init();

	dfb_init(&argc, &argv);
	dfb_kb_init();

	while (1)
	{
		data = (struct thread_data *) malloc(sizeof(struct thread_data));
		data->settings = (rdpSet *) malloc(sizeof(rdpSet));
		data->chan_man = freerdp_chanman_new();
		rv = process_params(data->settings, data->chan_man, argc, argv, &index);
		if (rv == 0)
		{
			g_thread_count++;
			printf("starting thread %d to %s:%d\n", g_thread_count,
				data->settings->server, data->settings->tcp_port_rdp);
			pthread_create(&thread, 0, thread_func, data);
		}
		else
		{
			free(data->settings);
			freerdp_chanman_free(data->chan_man);
			free(data);
			break;
		}
	}

	while (g_thread_count > 0)
	{
		sleep(1);
	}

	freerdp_chanman_uninit();
	freerdp_global_finish();

	return 0;
}
Beispiel #2
0
INT WINAPI
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    int rv;
    int index = 1;
    wfInfo * wfi;
    WSADATA wsa_data;
    WNDCLASSEX wnd_cls;

    if (WSAStartup(0x101, &wsa_data) != 0)
    {
        return 1;
    }
    g_done_event = CreateEvent(0, 1, 0, 0);
#if defined(WITH_DEBUG) || defined(_DEBUG)
    create_console();
#endif
    if (!freerdp_global_init())
    {
        printf("Error initializing freerdp\n");
        return 1;
    }
    freerdp_chanman_init();
    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;

    if (!CreateThread(NULL, 0, kbd_thread_func, NULL, 0, NULL))
        printf("error creating keyboard handler thread");

    while (1)
    {
        wfi = (wfInfo *) malloc(sizeof(wfInfo));
        memset(wfi, 0, sizeof(wfInfo));
        wfi->settings = (rdpSet *) malloc(sizeof(rdpSet));
        wfi->chan_man = freerdp_chanman_new();

        wfi->clrconv = (HCLRCONV) malloc(sizeof(CLRCONV));
        memset(wfi->clrconv, 0, sizeof(CLRCONV));
        wfi->clrconv->alpha = 1;
        wfi->clrconv->palette = NULL;

        rv = process_params(wfi, __argc, __argv, &index);
        if (rv)
        {
            freerdp_chanman_free(wfi->chan_man);
            free(wfi->settings);
            free(wfi);
            break;
        }
        if (CreateThread(NULL, 0, thread_func, wfi, 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);

    freerdp_chanman_uninit();
    freerdp_global_finish();
    WSACleanup();
    return 0;
}
Beispiel #3
0
int
main(int argc, char ** argv)
{
	struct thread_data * data;
	int rv;
	pthread_t thread;
	int index = 1;

	char *home = getenv("HOME");
	if (home) {
		static char resourcefile[512];
		strncat(resourcefile, home, strlen(home));
		resourcefile[512-1] = (char)0;
		strcat(resourcefile, "/.directfbrc");
		resourcefile[512-1] = (char)0;

		char *display = getenv("DISPLAY");

#if   defined(__unix) || defined(__linux)
		char *graphics = "fbdev";
#elif defined(__APPLE__)
		char *graphics = "opengl";
#else
		char *graphics = "gdi";
#endif
		if (display) graphics = "x11";

		static char buffer[128];
		strcat(buffer, "system=");
		strcat(buffer, graphics);
		strcat(buffer, "\ndepth=32\nmode=1024x768\nautoflip-window\nforce-windowed\n");

		FILE *fp;
		fp = fopen(resourcefile, "wx"); /* "x" assures no overwrite of an existing resource file */
		if (fp != NULL)
		{
			fputs((char *)(&buffer), fp);
			fclose(fp);
			printf("INFO: created default DirectFB resource file: %s\n", resourcefile);
		}
	} else {
		printf("WARNING: HOME variable not set, unable to create a default DirectFB ~/.directfbrc resource file\n");
	}

	setlocale(LC_CTYPE, "");

	if (!freerdp_global_init())
	{
		printf("Error initializing freerdp\n");
		return 1;
	}
	freerdp_chanman_init();

	dfb_init(&argc, &argv);
	dfb_kb_init();

	freerdp_sem_create(&g_sem, 0);

	while (1)
	{
		data = (struct thread_data *) xmalloc(sizeof(struct thread_data));
		data->settings = (rdpSet *) xmalloc(sizeof(rdpSet));
		data->chan_man = freerdp_chanman_new();
		rv = process_params(data->settings, data->chan_man, argc, argv, &index);
		if (rv == 0)
		{
			g_thread_count++;
			printf("starting thread %d to %s:%d\n", g_thread_count,
				data->settings->server, data->settings->tcp_port_rdp);
			pthread_create(&thread, 0, thread_func, data);
		}
		else
		{
			free(data->settings);
			freerdp_chanman_free(data->chan_man);
			free(data);
			break;
		}
	}

	while (g_thread_count > 0)
	{
                DEBUG("main thread, waiting for all threads to exit");
                freerdp_sem_wait(&g_sem);
                DEBUG("main thread, all threads did exit");
	}

	freerdp_chanman_uninit();
	freerdp_global_finish();

	return 0;
}
Beispiel #4
0
int
main(int argc, char ** argv)
{
	int rv;
	xfInfo * xfi;
	pthread_t thread;
	int index = 1;
	char reason_msg[ERRINFO_BUFFER_SIZE];

	setlocale(LC_CTYPE, "");
	if (argc == 1)
	{
		out_args();
		return 0;
	}
	if (!freerdp_global_init())
	{
		printf("Error initializing freerdp\n");
		return 1;
	}
	freerdp_chanman_init();

	freerdp_sem_create(&g_sem, 0);

	while (1)
	{
		xfi = (xfInfo *) malloc(sizeof(xfInfo));
		memset(xfi, 0, sizeof(xfInfo));
		xfi->settings = (rdpSet *) malloc(sizeof(rdpSet));
		xfi->chan_man = freerdp_chanman_new();
		xfi->clrconv = (HCLRCONV) malloc(sizeof(CLRCONV));
		memset(xfi->clrconv, 0, sizeof(CLRCONV));

		xfi->clrconv->alpha = 1;
		xfi->clrconv->palette = NULL;

		rv = process_params(xfi, argc, argv, &index);
		if (rv)
		{
			free(xfi->settings);
			freerdp_chanman_free(xfi->chan_man);
			free(xfi);
			break;
		}

		DEBUG_X11("starting thread %d to %s:%d", g_thread_count,
			xfi->settings->server, xfi->settings->tcp_port_rdp);
		if (pthread_create(&thread, 0, thread_func, xfi) == 0)
		{
			g_thread_count++;
		}
	}

	if (g_thread_count > 0)
	{
		DEBUG_X11("main thread, waiting for all threads to exit");
		freerdp_sem_wait(&g_sem);
		DEBUG_X11("main thread, all threads did exit");
	}

	freerdp_chanman_uninit();
	freerdp_global_finish();

	if (g_error_code)
		return g_error_code;
	else if (g_disconnect_reason)
	{
		printf("disconnect: %s\n",
			freerdp_str_disconnect_reason(g_disconnect_reason, reason_msg, ERRINFO_BUFFER_SIZE));
	}

	return exit_code_from_disconnect_reason(g_disconnect_reason);
}