Esempio n. 1
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;
}
Esempio n. 2
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);
}