示例#1
0
文件: combine.c 项目: chemecse/piglit
/* Test texenv-combine with a single texture unit. */
static bool
run_single_texture_test(const struct test_param test_params[],
			const char *test_name)
{
	assert(num_tex_units == 1);
	setup_colors();

	const int num_tests = count_test_combinations(test_params);

	for (int test = 0; test < num_tests; test += test_stride) {
		/* 0. Setup state */
		reset_machine();
		setup_test_env(test, test_params);

		/* 1. Render with OpenGL */
		glTexCoord2f(0, 0); /* use texcoord (0,0) for all vertices */
		piglit_draw_rect(-1, -1, 2, 2);

		/* 2. Compute expected result */
		float expected[4];
		expected[3] = -1.0f;
		compute_tex_combine(0, machine.frag_color, expected);

		/* 3. Compare rendered result to expected result */
		if (!piglit_probe_pixel_rgba(0, 0, expected)) {
			printf("Single Texture Test %s %d\n", test_name,
			       test);
			print_test_env(test, test_params);
			return false;
		}
	}
	return true;
}
示例#2
0
int
main()
{
    CELL file_cpy = {0};
    WINDOW *mainwin;

    mainwin = initscr();
    start_color();
    setup_colors();
    cbreak();
    noecho();
    keypad(mainwin, TRUE);
    meta(mainwin, TRUE);
    raw();

    leaveok(mainwin, TRUE);
    wbkgd(mainwin, COLOR_PAIR(COLOR_MAIN));
    wattron(mainwin, COLOR_PAIR(COLOR_MAIN));
    werase(mainwin);
    refresh();

    file_cpy.window = mainwin;

    main_dir(&file_cpy);

    wbkgd(mainwin, A_NORMAL);
    werase(mainwin);
    echo();
    nocbreak();
    noraw();
    refresh();
    endwin();
    return TRUE;
}
int yahtzee_exec( int fdfb, int fdrc, int fdlcd, char *cfgfile )
{
	struct timeval	tv;
	int				x;

	if ( FBInitialize( 720, 576, 8, fdfb ) < 0 )
		return -1;

	setup_colors();

	if ( RcInitialize( fdrc ) < 0 )
		return -1;

	doexit=0;
	while( !doexit )
	{
		EnterPlayer();
		if ( !doexit )
		{
			RunYahtzee();
			DrawWinner();
		}
	}

	Fx2StopPig();

/* fx2 */
/* buffer leeren, damit neutrino nicht rumspinnt */
	realcode = RC_0;
	while( realcode != 0xee )
	{
		tv.tv_sec = 0;
		tv.tv_usec = 300000;
		x = select( 0, 0, 0, 0, &tv );		/* 300ms pause */
		RcGetActCode( );
	}

	RcClose();
	FBClose();

	return 0;
}
示例#4
0
/* redraws the pixmap onto the drawing area */
void
redraw(void)
{
  int i;

  if (drawing_area == NULL || drawing_area->window == NULL)
    return;

  if(tmp_pixmap == NULL) {
    setup_colors();
    image_data = carmen_graphics_convert_to_image(map, 0);
    map_pixmap = generate_pixmap(image_data, &(map->config), mult);

    tmp_pixmap = gdk_pixmap_new(drawing_area->window,
				drawing_area->allocation.width,
				drawing_area->allocation.height,
				-1);
    map_to_tmp();

  }

  if (show_offlimits) {
    gdk_gc_set_foreground (drawing_gc, &red);
    for (i = 0; i < num_offlimits_segments; i++)
      draw_offlimits(i);
  }

  if (show_place_names && place_list) {
    for (i = 0; i < place_list->num_places; i++)
      draw_place_name(i, tmp_pixmap, &carmen_red);
  }

  gdk_draw_pixmap(drawing_area->window,   //dest
		  drawing_area->style->fg_gc[GTK_WIDGET_STATE (drawing_area)],
		  tmp_pixmap,             //src
		  0, 0, 0, 0, -1, -1);

}
int tetris_exec( int fdfb, int fdrc, int fdlcd, char *cfgfile )
{
	struct timeval	tv;
	int				x;
	int				i;
	int				fd;
	FILE			*fp;
	char			*line;
	char			*p;

	if ( FBInitialize( 720, 576, 8, fdfb ) < 0 )
		return -1;

	setup_colors();

	if ( RcInitialize( fdrc ) < 0 )
		return -1;

/* load setup */
	fp = fopen( CONFIGDIR "/games.cfg", "r" );
	if ( fp )
	{
		line=malloc(128);
		isalloc=1;
#ifdef HAVE_CURL
		proxy_addr=0;
		proxy_user=0;
#endif
		hscore=0;
		while( fgets( line, 128, fp ) )
		{
			if ( *line == '#' )
				continue;
			if ( *line == ';' )
				continue;
			p=strchr(line,'\n');
			if ( p )
				*p=0;
			p=strchr(line,'=');
			if ( !p )
				continue;
			*p=0;
			p++;
#ifdef HAVE_CURL
			if ( !strcmp(line,"proxy") )
				proxy_addr=strdup(p);
			else if ( !strcmp(line,"proxy_user") )
				proxy_user=strdup(p);
			else if ( !strcmp(line,"hscore") )
				hscore=strdup(p);
#endif
		}
		fclose(fp);
		free(line);
	}

	fd = open( GAMESDIR "/tetris.hscore", O_RDONLY );
	if ( fd == -1 )
	{
		mkdir( GAMESDIR, 567 );
		for( i=0; i < 8; i++ )
		{
			strcpy(hsc[i].name,"nobody");
			hsc[i].points=30;
		}
	}
	else
	{
		read( fd, hsc, sizeof(hsc) );
		close(fd);
	}

#ifdef HAVE_CURL
	if ( hscore )
	{
		LoadHScore();
	}
#endif

#if defined(HAVE_DBOX_HARDWARE) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
	Fx2ShowPig( 480, 400, 176, 144 );
#endif

	while( doexit != 3 )
	{
		BoardInitialize();
		DrawBoard( );	/* 0 = all */
		NextItem();
#ifdef HAVE_DREAMBOX_HARDWARE
		Fx2ShowPig(480, 400, 176, 144 );
#endif
		doexit=0;
		while( !doexit )
		{
			tv.tv_sec = 0;
			tv.tv_usec = 10000;
			x = select( 0, 0, 0, 0, &tv );		/* 10ms pause */
			RcGetActCode( );
			if ( doexit )
				break;
			tv.tv_sec = 0;
			tv.tv_usec = 10000;
			x = select( 0, 0, 0, 0, &tv );		/* 10ms pause */
			RcGetActCode( );
			if ( doexit )
				break;
			MoveSide();
			if ( !FallDown() )
			{
				RemoveCompl();
				if ( !NextItem() )
					doexit=1;
			}
#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
			FBFlushGrafic();
#endif

			RcGetActCode( );
		}

		if ( doexit != 3 )
		{
			actcode=0xee;
			DrawGameOver();
#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
			FBFlushGrafic();
#endif
			doexit=0;
			SaveGame();
#ifdef HAVE_CURL
			if ( use_ihsc )
				ShowIHScore();
#endif
			ShowHScore(hsc);
			Fx2PigPause();

#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
			FBFlushGrafic();
#endif
			i=0;
			actcode=0xee;
			while(( actcode != RC_OK ) && !doexit )
			{
				tv.tv_sec = 0;
				tv.tv_usec = 100000;
				x = select( 0, 0, 0, 0, &tv );		/* 100ms pause */
				RcGetActCode( );
				i++;
				if ( i == 50 )
				{
					FBDrawString( 190, 480, 48, "press OK for new game",GRAY,0);
#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
					FBFlushGrafic();
#endif
				}
			}
			Fx2PigResume();
		}
	}

	Fx2StopPig();

#if defined(HAVE_DBOX_HARDWARE) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
/* fx2 */
/* buffer leeren, damit neutrino nicht rumspinnt */
	realcode = RC_0;
	while( realcode != 0xee )
	{
		tv.tv_sec = 0;
		tv.tv_usec = 300000;
		x = select( 0, 0, 0, 0, &tv );		/* 300ms pause */
		RcGetActCode( );
	}
#endif

	RcClose();
	FBClose();

/* save hscore */
	fd = open( GAMESDIR "/tetris.hscore", O_CREAT|O_WRONLY, 438 );
	if ( fd != -1 )
	{
		write( fd, hsc, sizeof(hsc) );
		close(fd);
	}

	if ( isalloc )
	{
#ifdef HAVE_CURL
		if ( proxy_addr )
			free ( proxy_addr );
		if ( proxy_user )
			free ( proxy_user );
#endif
		if ( hscore )
			free ( hscore );
	}

	return 0;
}
int snake_exec( int fdfb, int fdrc, int fdlcd, char *cfgfile )
{
	struct timeval	tv;
	int		x;

	if ( FBInitialize( 720, 576, 8, fdfb ) < 0 )
		return -1;

	setup_colors();

	if ( RcInitialize( fdrc ) < 0 )
		return -1;

	Fx2ShowPig( 540, 449, 135, 96 );

	while ( doexit != 3 ) {
		DrawMaze( );	/* 0 = all */

		doexit=0;
		while ( !doexit ) {
			tv.tv_sec = 0;
			tv.tv_usec = 100000;
			x = select( 0, 0, 0, 0, &tv );		/* 10ms pause */

			RcGetActCode( );
			MoveSnake();
#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
			FBFlushGrafic();
#endif
		}

		FreeSnake();

		if ( doexit != 3 ) {
			actcode=0xee;
			DrawFinalScore();
			DrawGameOver();
#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
			FBFlushGrafic();
#endif

			doexit=0;
			while (( actcode != RC_OK ) && !doexit ) {
				tv.tv_sec = 0;
				tv.tv_usec = 200000;
				x = select( 0, 0, 0, 0, &tv );		/* 100ms pause */
				RcGetActCode( );
			}
		}
	}

	Fx2StopPig();

	/* fx2 */
	/* buffer leeren, damit neutrino nicht rumspinnt */
	realcode = RC_0;
	while ( realcode != 0xee ) {
		tv.tv_sec = 0;
		tv.tv_usec = 300000;
		x = select( 0, 0, 0, 0, &tv );		/* 300ms pause */
		RcGetActCode( );
	}

	RcClose();
	FBClose();

	return 0;
}
示例#7
0
文件: gwave.c 项目: krichter722/gwave
void gwave_main(void *p, int argc, char **argv)
{
	int c;
	int i;
	int nobacktrace = 0;

	/* In guile-1.5 and later, need to use scm_primitive_eval_x
	 * in order to change modules so that our C primitives
	 * registered below become globals, instead of hidden away
	 * in the guile-user module
	 */
	{
		SCM exp = scm_c_read_string("(define-module (guile))");
		scm_primitive_eval_x(exp);
	}

	init_scwm_guile();
	init_gtkmisc();
	init_gwave();
	init_cmd();
	init_wavewin();
	init_wavelist();
	init_wavepanel();
	init_event();
	init_draw();
	
	gtk_init(&argc, &argv);

	prog_name = argv[0];

	/* simple pre-processing of debugging options that we need to set up
	 * before we get into guile.   These options cannot be bundled.
	 * Most of the general user options are handled in std-args.scm  */
	for(i = 1; i < argc; i++) {
		if(strcmp(argv[i], "-n") == 0) {
			nobacktrace = 1;
		} else if (strcmp(argv[i], "-v") == 0) {
			v_flag = 1;
		} else if (strcmp(argv[i], "-x") == 0) {
			x_flag = 1;
			SCM_SETCDR(scm_gwave_debug, SCM_BOOL_T);
		}
	}

	gtk_rc_parse_string(gwave_base_gtkrc);
	gtk_rc_parse("gwave.gtkrc");
//	assert( SCM_CONSP(scm_gwave_tooltips) );

#ifdef GUILE_GTK_EXTRA_LOADPATH
	scm_c_eval_string("(set! %load-path (cons \"" GUILE_GTK_EXTRA_LOADPATH "\" %load-path))");
#endif

	/* the default for this seems to have changed between guile-1.3
	   and guile-1.3.2;  only the first clause is needed when 
	   we drop support for guile-1.3.2 */
	if (!nobacktrace) {
		scm_c_eval_string("(debug-enable 'debug)(debug-enable 'backtrace) (read-enable 'positions)");
	} /* else {
	scm_c_eval_str("(debug-disable 'debug)(read-disable 'positions)");
	}*/

	/* the compiled-in initial scheme code comes from minimal.scm,
	   built into init_scheme_string.c by the Makefile
	   Among other things, it finds and loads system and user .gwaverc
	   files.
	*/
	{ /* scope */
		extern char *init_scheme_string;
		SCM res;
		if(v_flag) {fprintf(stderr, "running init_scheme_string\n");}
		res = scwm_safe_eval_str(init_scheme_string);
		if(v_flag) {
			printf("result="); fflush(stdout);
			scm_display(res, scm_cur_outp);
			printf("\n"); fflush(stdout);
		}
                if(!SCM_NFALSEP(res)) {
                        fprintf(stderr, "gwave: aborting due to errors.\n");
                        exit(1);
                }

	} /* end scope */

	wtable = g_new0(WaveTable, 1);
	wtable->cursor[0] = g_new0(VBCursor, 1);
	wtable->cursor[1] = g_new0(VBCursor, 1);
	wtable->srange = g_new0(SelRange, 1);
	wtable->npanels = 0;
	wtable->panels = NULL;

	setup_colors(wtable);
	setup_waveform_window();

	xg_init(NULL);  /* X-server interprocess communication for Gtk+ */

	gtk_main();
	exit(0);
}
int pacman_exec( int fdfb, int fdrc, int fdlcd, char *cfgfile )
{
	struct timeval	tv;
	int				x;
	int				jumplevel=-1;

	if ( FBInitialize( 720, 576, 8, fdfb ) < 0 )
		return -1;

	setup_colors();

	if ( RcInitialize( fdrc ) < 0 )
		return -1;

	InitLevel( 0 );

	while( doexit != 3 )
	{
		MazeInitialize();
		DrawMaze( );	/* 0 = all */
		DrawFill();
		DrawGhosts( );
		DrawPac( );
		MazePig();

		doexit=0;
		while( !doexit )
		{
			tv.tv_sec = 0;
#ifdef HAVE_DREAMBOX_HARDWARE
			tv.tv_usec = 8000;
#else
			tv.tv_usec = 1000;
#endif
			x = select( 0, 0, 0, 0, &tv );		/* 10ms pause */
	
			MovePac( );
			MoveGhosts( );
			DrawGhosts( );
			DrawPac( );
#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
			FBFlushGrafic();
#endif
			RcGetActCode( );
			CheckGhosts( );
		}

		if ( doexit != 3 )
		{
			actcode=0xee;
			if ( score )
				DrawScore();
			if ( !gametime )
				DrawGameOver();
#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
			FBFlushGrafic();
#endif
			doexit=0;
			jumplevel=-1;
			while(( actcode != RC_OK ) && !doexit )
			{
				tv.tv_sec = 0;
				tv.tv_usec = 100000;
				x = select( 0, 0, 0, 0, &tv );		/* 100ms pause */
				RcGetActCode( );
				if ( actcode == RC_HELP )
				{
					while( realcode != 0xee )
						RcGetActCode( );
					actcode=0xee;
					while(( actcode == 0xee ) && !doexit )
					{
						tv.tv_sec = 0;
						tv.tv_usec = 100000;
						x = select( 0, 0, 0, 0, &tv );		/* 100ms pause */
						RcGetActCode( );
					}
					if ( actcode <= RC_9 )
					{
						jumplevel=actcode;
						actcode=RC_OK;
					}
				}
			}
			if ( gametime )
				NextLevel();
			else
				InitLevel( jumplevel );
		}
	}

	Fx2StopPig();

/* fx2 */
/* buffer leeren, damit neutrino nicht rumspinnt */
	realcode = RC_0;
	while( realcode != 0xee )
	{
		tv.tv_sec = 0;
		tv.tv_usec = 300000;
		x = select( 0, 0, 0, 0, &tv );		/* 300ms pause */
		RcGetActCode( );
	}

	RcClose();
	FBClose();

	return 0;
}
示例#9
0
int mines_exec( int fdfb, int fdrc, int fdlcd, char *cfgfile )
{
	struct timeval	tv;
	int				x;

	if ( FBInitialize( 720, 576, 8, fdfb ) < 0 )
		return -1;

	setup_colors();

	if ( RcInitialize( fdrc ) < 0 )
		return -1;


	while( doexit != 3 )
	{
		BoardInitialize();
		DrawBoard( 0 );
		Fx2ShowPig( 470, 300, 176, 144 );

		doexit=0;
		while( !doexit )
		{
			tv.tv_sec = 0;
			tv.tv_usec = 10000;
			x = select( 0, 0, 0, 0, &tv );		/* 100ms pause */
	
			RcGetActCode( );
			MoveMouse();
#ifdef USEX
			FBFlushGrafic();
#endif
		}

		if ( doexit != 3 )
		{
			actcode=0xee;
			if ( doexit ==2 )
				DrawScore();
			else
				DrawGameOver();
#ifdef USEX
			FBFlushGrafic();
#endif
			doexit=0;
			while(( actcode != RC_OK ) && !doexit )
			{
				tv.tv_sec = 0;
				tv.tv_usec = 100000;
				x = select( 0, 0, 0, 0, &tv );		/* 100ms pause */
				RcGetActCode( );
			}
		}
	}

	Fx2StopPig();

/* fx2 */
/* buffer leeren, damit neutrino nicht rumspinnt */
	realcode = RC_0;
	while( realcode != 0xee )
	{
		tv.tv_sec = 0;
		tv.tv_usec = 300000;
		x = select( 0, 0, 0, 0, &tv );		/* 300ms pause */
		RcGetActCode( );
	}

	RcClose();
	FBClose();

	return 0;
}
示例#10
0
int bouquet_exec( int fdfb, int fdrc, int fdlcd, char *cfgfile )
{
	struct timeval	tv;
	int				t;
	int				r;
	int				i;
	int				idx=0;
	int				cnum;
	int				x;
	Channel			*ch=NULL;
	FILE			*fp;
	char			line[512];
	char			l2[512];
	char			*p;

	if ( FBInitialize( 720, 576, 8, fdfb ) < 0 )
		return -1;

	setup_colors();

	if ( RcInitialize( fdrc ) < 0 )
		return -1;

/* load setup */
	fp = fopen( CONFIGDIR "/zapit/services.xml", "r" );
	if ( !fp )
	{
		FBDrawString( 190, 100, 64, "services.xml not found !", RED, 0 );
#ifdef USEX
		FBFlushGrafic();
#endif
		tv.tv_sec = 5;
		tv.tv_usec = 0;
		select( 0, 0, 0, 0, &tv );

		RcClose();
		FBClose();

		return 0;
	}

	while( fgets(line,512,fp) )
	{
		num_lines++;
		if ( strstr(line,"channelNR") )
		{
			p=strstr(line,"serviceType");
			if ( p && (*(p+15) == '0') )
			{
				p+=16;
				if ( *p == '1' )
					num_ch_tv++;
				if ( *p == '2' )
					num_ch_radio++;
				if ( *p == '4' )
					num_ch_tv++;
			}
		}
	}
	fclose(fp);

	lines = (char**)malloc(sizeof(char*)*num_lines);
	tv_ch = (Channel*)malloc(sizeof(Channel)*num_ch_tv);
	radio_ch = (Channel*)malloc(sizeof(Channel)*num_ch_radio);
	for( i=0;i<num_ch_tv;i++)
		tv_ch[i].flag=0;
	for( i=0;i<num_ch_radio;i++)
		radio_ch[i].flag=0;

	fp = fopen( CONFIGDIR "/zapit/services.xml", "r" );
	t=num_ch_tv-1;
	r=num_ch_radio-1;
	for(i=0; i<num_lines;i++)
	{
		fgets( line, 512, fp );
		lines[i] = strdup(line);
		if ( !strstr(line,"channelNR") )
			continue;

		p=strstr(line,"name=");
		copyname(l2,p+6);

		p=strstr(line,"channelNR=");
		cnum=_atoi(p+11);

		if ( cnum )
			idx=cnum-1;

		p=strstr(line,"serviceType");
		if ( !p || ( *(p+15) != '0' ) )
			continue;

		switch( *(p+16) )
		{
		case '1' :
		case '4' :
			ch=tv_ch;
			if ( !cnum || ch[idx].flag )
			{
				idx=t;
				t--;
			}
			break;
		case '2' :
			ch=radio_ch;
			if ( !cnum || ch[idx].flag )
			{
				idx=r;
				r--;
			}
			break;
		default:
			p=0;
			break;
		}
		if ( !p )
			continue;

		ch[idx].name=strdup(l2);
		ch[idx].flag=*(p+14);
		ch[idx].line=lines[i];
	}
	fclose(fp);

	t=0;
	while( doexit != 3 )
	{
		if ( t )
			SortBouquet( radio_ch, num_ch_radio );
		else
			SortBouquet( tv_ch, num_ch_tv );
		t=!t;
		switch( doexit )
		{
		case 2 :
			doexit=0;
			break;
		case 1 :
			SaveServices();
			doexit=3;
			break;
		}
	}

	for( i=0; i<num_ch_tv; i++ )
		free( tv_ch[i].name );
	for( i=0; i<num_ch_radio; i++ )
		free( radio_ch[i].name );
	for( i=0; i<num_lines; i++ )
		free( lines[i] );
	free( lines );
	free( tv_ch );
	free( radio_ch );

/* fx2 */
/* buffer leeren, damit neutrino nicht rumspinnt */
	realcode = RC_0;
	while( realcode != 0xee )
	{
		tv.tv_sec = 0;
		tv.tv_usec = 300000;
		x = select( 0, 0, 0, 0, &tv );		/* 300ms pause */
		RcGetActCode( );
	}

	RcClose();
	FBClose();

	return 0;
}
示例#11
0
int master_exec( int fdfb, int fdrc, int fdlcd, char *cfgfile )
{
	struct timeval	tv;
	int				x;

	if ( FBInitialize( 720, 576, 8, fdfb ) < 0 )
		return -1;

	setup_colors();

	if ( RcInitialize( fdrc ) < 0 )
		return -1;


	while( doexit != 3 )
	{
		MasterInitialize();

#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
		FBFlushGrafic();
#endif
		Fx2ShowPig( 430, 355, 176, 144 );

		doexit=0;
		while( !doexit )
		{
			tv.tv_sec = 0;
			tv.tv_usec = 200000;
			select( 0, 0, 0, 0, &tv );

			actcode=0xee;
			RcGetActCode( );
			Play();
#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
			FBFlushGrafic();
#endif
			while( realcode != 0xee )
				RcGetActCode( );
		}
		if ( doexit == 4 )		// level changed
		{
			doexit=0;
			continue;
		}

		if ( doexit != 3 )
		{
			actcode=0xee;
#if defined(USEX) || defined(HAVE_SPARK_HARDWARE) || defined(HAVE_DUCKBOX_HARDWARE)
			FBFlushGrafic();
#endif
			doexit=0;
			while(( actcode != RC_OK ) && !doexit )
			{
				tv.tv_sec = 0;
				tv.tv_usec = 100000;
				x = select( 0, 0, 0, 0, &tv );		/* 100ms pause */
				RcGetActCode( );
				if (( actcode > 0 ) && (actcode < 5 ))
				{
					Play();
					doexit=1;
				}
			}
		}
	}

	Fx2StopPig();

/* fx2 */
/* buffer leeren, damit neutrino nicht rumspinnt */
	realcode = RC_0;
	while( realcode != 0xee )
	{
		tv.tv_sec = 0;
		tv.tv_usec = 300000;
		x = select( 0, 0, 0, 0, &tv );		/* 300ms pause */
		RcGetActCode( );
	}

	RcClose();
	FBClose();

	return 0;
}
示例#12
0
int main(int argc, char *argv[])
{
    struct vrmr_ctx vctx;

    int retval = 0, optch = 0;

    static char optstring[] = "c:d:hVW";
    struct option long_options[] = {
            {"configfile", required_argument, NULL, 'c'},
            {"debug", required_argument, NULL, 'd'},
            {"help", no_argument, NULL, 'h'},
            {"version", no_argument, NULL, 'V'},
            {"wizard", no_argument, NULL, 'W'},
            {0, 0, 0, 0},
    };
    int longopt_index = 0;

    int debug_level = NONE;
    PANEL *main_panels[5];
    char *s = NULL;

    /* some defaults */
    vuurmuur_semid = -1;
    vuurmuur_shmid = -1;
    vuurmuurlog_semid = -1;
    vuurmuurlog_shmid = -1;

    /* create the version string */
    snprintf(version_string, sizeof(version_string),
            "%s (using libvuurmuur %s)", VUURMUURCONF_VERSION,
            libvuurmuur_get_version());

    /* some initilization */
    if (vrmr_init(&vctx, "vuurmuur_conf") < 0)
        exit(EXIT_FAILURE);

    /* settings file */
    memset(vccnf.configfile_location, 0, sizeof(vccnf.configfile_location));
    if (vctx.conf.etcdir[0] == '\0')
        (void)strlcpy(vccnf.configfile_location, VUURMUURCONF_CONFIGFILE,
                sizeof(vccnf.configfile_location));
    else
        (void)snprintf(vccnf.configfile_location,
                sizeof(vccnf.configfile_location),
                "%s/vuurmuur/vuurmuur_conf.conf", vctx.conf.etcdir);

#ifdef ENABLE_NLS
    setlocale(LC_ALL, "");
    setlocale(LC_TIME, "");
    setlocale(LC_MESSAGES, "");
    setlocale(LC_COLLATE, "");
    setlocale(LC_CTYPE, "");
    setlocale(LC_MONETARY, "");
    setlocale(LC_NUMERIC, "");
#endif

    /* check if we are in utf-8 mode */
    utf8_mode = 0;

    if ((s = getenv("LC_ALL")) || (s = getenv("LC_CTYPE")) ||
            (s = getenv("LANG"))) {
        if (strstr(s, "UTF-8"))
            utf8_mode = 1;
    }

#ifdef ENABLE_NLS
    bindtextdomain("vuurmuur", xstr(VRMR_LOCALEDIR));
    textdomain("vuurmuur");
#endif

    /* process commandline options */
    while ((optch = getopt_long(argc, argv, optstring, long_options,
                    &longopt_index)) != -1) {
        switch (optch) {
            case 'h':
                print_commandline_args();
                break;

            /* configfile */
            case 'c':

                if (strlcpy(vctx.conf.configfile, optarg,
                            sizeof(vctx.conf.configfile)) >=
                        sizeof(vctx.conf.configfile)) {
                    vrmr_error(EXIT_FAILURE, VR_ERR,
                            gettext("commandline argument too long for option "
                                    "-c."));
                    exit(EXIT_FAILURE);
                }
                break;

            case 'd':

                /* convert the debug string and check the result */
                debug_level = atoi(optarg);
                if (debug_level < 0 || debug_level > HIGH) {
                    vrmr_error(EXIT_FAILURE, VR_ERR,
                            gettext("commandline debuglevel out of range."));
                    exit(EXIT_FAILURE);
                }
                vrmr_debug_level = debug_level;

                fprintf(stdout, "vuurmuur_conf: debugging enabled.\n");
                fprintf(stdout, "vuurmuur_conf: debug level: %d\n",
                        debug_level);
                break;

            case 'V':
                /* print version */
                fprintf(stdout, "Vuurmuur_conf %s\n", version_string);
                fprintf(stdout, "%s\n", VUURMUUR_COPYRIGHT);

                exit(EXIT_SUCCESS);

            case 'W': {
                char wizard_path[512] = "";
                snprintf(wizard_path, sizeof(wizard_path),
                        "%s/scripts/vuurmuur-wizard.sh", vctx.conf.datadir);
                printf("Running %s...\n", wizard_path);
                exec_wizard(wizard_path);
                exit(EXIT_SUCCESS);
            }
            default:

                vrmr_error(EXIT_FAILURE, VR_ERR,
                        gettext("unknown commandline option."));
                exit(EXIT_FAILURE);
        }
    }

    /*  close the STDERR_FILENO because it gives us annoying "Broken
        Pipe" errors on some systems with bash3. Let's see if this
        has negative side-effects. */
    close(STDERR_FILENO);

    /* init vuurmuur_conf config already to get background */
    (void)init_vcconfig(&vctx.conf, vccnf.configfile_location, &vccnf);

    /* Initialize curses */
    (void)initscr();
    (void)start_color();
    (void)cbreak();
    (void)noecho();
    (void)keypad(stdscr, (bool)TRUE);

    setup_colors();

    /* create the three main windows */
    if (!(status_frame_win = create_newwin(
                  3, COLS, LINES - 3, 0, NULL, vccnf.color_bgd)))
        exit(EXIT_FAILURE);
    if (!(status_win = create_newwin(
                  1, COLS - 4, LINES - 2, 2, NULL, vccnf.color_bgd)))
        exit(EXIT_FAILURE);
    if (!(top_win = create_newwin(3, COLS, 0, 0, NULL, vccnf.color_bgd)))
        exit(EXIT_FAILURE);
    if (!(main_win = create_newwin(
                  LINES - 6, COLS, 3, 0, NULL, vccnf.color_bgd)))
        exit(EXIT_FAILURE);
    if (!(mainlog_win = newwin(LINES - 8, COLS - 2, 4, 1)))
        exit(EXIT_FAILURE);

    (void)wbkgd(mainlog_win, vccnf.color_bgd);

    wattron(status_frame_win, vccnf.color_bgd);
    mvwprintw(status_frame_win, 0, 2, " %s ", gettext("Status"));
    mvwprintw(status_frame_win, 2,
            (int)(COLS - 4 - StrLen(vctx.user_data.realusername) - 6),
            " user: %s ", vctx.user_data.realusername);
    wattroff(status_frame_win, vccnf.color_bgd);

    /* Attach a panel to each window */
    main_panels[0] = new_panel(top_win);
    main_panels[1] = new_panel(main_win);
    main_panels[2] = new_panel(status_win);
    main_panels[3] = new_panel(mainlog_win);
    main_panels[4] = new_panel(status_frame_win);

    (void)update_panels();
    (void)doupdate();

    /* init the vrprint functions for the Gui */
    vrprint.error = vuumuurconf_print_error;
    vrprint.warning = vuumuurconf_print_warning;
    vrprint.info = vuumuurconf_print_info;

    if (status_print(status_win, gettext("This is Vuurmuur_conf %s, %s"),
                version_string, VUURMUUR_COPYRIGHT) < 0)
        exit(EXIT_FAILURE);

    /* setup the global busywin */
    VrBusyWinCreate();
    VrBusyWinHide();

    // form_test();

    /* startup_screen inits the config, loads the zones, rules, etc */
    if (startup_screen(&vctx, &vctx.rules, &vctx.zones, &vctx.services,
                &vctx.interfaces, &vctx.blocklist, &vctx.reg) < 0) {
        /* failure! Lets quit. */

        /* delete panels and windows */
        (void)del_panel(main_panels[0]);
        (void)del_panel(main_panels[1]);
        (void)del_panel(main_panels[2]);
        (void)del_panel(main_panels[3]);
        (void)del_panel(main_panels[4]);
        (void)destroy_win(top_win);
        (void)destroy_win(main_win);
        (void)destroy_win(status_win);
        (void)destroy_win(status_frame_win);
        /* clear screen */
        (void)refresh();
        /* end ncurses mode */
        (void)endwin();

        exit(EXIT_FAILURE);
    }

    /* setup statuslist */
    (void)setup_statuslist();

    status_print(status_win, STR_READY);

    mm_status_checkall(&vctx, NULL, &vctx.rules, &vctx.zones, &vctx.interfaces,
            &vctx.services);
    /* main menu loop */
    while (main_menu(&vctx, &vctx.rules, &vctx.zones, &vctx.interfaces,
                   &vctx.services, &vctx.blocklist, &vctx.reg) == 1)
        ;
    /* clean up the status list */
    vrmr_list_cleanup(&vuurmuur_status.StatusList);

    /* detach from shared memory, if we were attached */
    if (vuurmuur_shmp != NULL && vuurmuur_shmp != (char *)(-1) &&
            vuurmuur_shmtable != 0) {
        if (vrmr_lock(vuurmuur_semid)) {
            vuurmuur_shmtable->configtool.connected = 3;
            vrmr_unlock(vuurmuur_semid);
        }
        (void)shmdt(vuurmuur_shmp);
    }
    if (vuurmuurlog_shmp != NULL && vuurmuurlog_shmp != (char *)(-1) &&
            vuurmuurlog_shmtable != 0) {
        if (vrmr_lock(vuurmuurlog_semid)) {
            vuurmuurlog_shmtable->configtool.connected = 3;
            vrmr_unlock(vuurmuurlog_semid);
        }
        (void)shmdt(vuurmuurlog_shmp);
    }

    /* destroy the global busywin */
    VrBusyWinDelete();

    /* delete panels and windows */
    (void)del_panel(main_panels[0]);
    (void)del_panel(main_panels[1]);
    (void)del_panel(main_panels[2]);
    (void)del_panel(main_panels[3]);
    (void)del_panel(main_panels[4]);

    (void)destroy_win(mainlog_win);
    (void)destroy_win(top_win);
    (void)destroy_win(main_win);
    (void)destroy_win(status_win);
    (void)destroy_win(status_frame_win);
    /* clear screen */
    (void)refresh();

    /* end ncurses mode */
    (void)endwin();

    /* set error functions to the stdout versions */
    vrprint.error = vrmr_stdoutprint_error;
    vrprint.warning = vrmr_stdoutprint_warning;
    vrprint.info = vrmr_stdoutprint_info;
    vrprint.debug = vrmr_stdoutprint_debug;
    vrprint.audit = vrmr_stdoutprint_audit;

    /* unload the backends */
    if (vrmr_backends_unload(&vctx.conf, &vctx) < 0) {
        vrmr_error(-1, VR_ERR, gettext("unloading the backends failed"));
        retval = -1;
    }

    /* cleanup the datastructures */
    (void)vrmr_list_cleanup(&vctx.blocklist.list);
    (void)vrmr_destroy_serviceslist(&vctx.services);
    (void)vrmr_destroy_zonedatalist(&vctx.zones);
    (void)vrmr_rules_cleanup_list(&vctx.rules);
    (void)vrmr_destroy_interfaceslist(&vctx.interfaces);
    vrmr_deinit(&vctx);
    return (retval);
}
示例#13
0
文件: combine.c 项目: chemecse/piglit
/* We do a really short, simple test for GL_ARB_texture_env_crossbar since the
 * preceeding tests are pretty comprehensive and the crossbar feature is just
 * an incremental addition.  Basically, if we have N texture units we run N
 * tests.  For test [i] we set texture unit [i] to fetch the texture color
 * from unit [num_units - i - 1].  For units != i we use the constant color
 * (0,0,0,0).  We use GL_ADD mode to compute the sum over all units.  So
 * effectively, the result of texture combine is simply the incoming fragment
 * color plus unit [num_units - test - 1]'s texture color. */
static bool
run_crossbar_test()
{
	glGetIntegerv(GL_MAX_TEXTURE_UNITS, &num_tex_units);

	/* Set up constant texture state for all tests */
	setup_colors();
	reset_machine();
	for (int unit = 0; unit < num_tex_units; unit++) {
		tex_env(unit, GL_COMBINE_RGB_EXT, GL_ADD);
		tex_env(unit, GL_COMBINE_ALPHA_EXT, GL_ADD);
		tex_env(unit, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT);
		tex_env(unit, GL_SOURCE0_ALPHA_EXT, GL_PREVIOUS_EXT);
		/* SOURCE1_RGB/ALPHA is set below, per test */
		tex_env(unit, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
		tex_env(unit, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);
		tex_env(unit, GL_OPERAND2_RGB_EXT, GL_SRC_ALPHA);
		tex_env(unit, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA);
		tex_env(unit, GL_OPERAND1_ALPHA_EXT, GL_SRC_ALPHA);
		tex_env(unit, GL_OPERAND2_ALPHA_EXT, GL_SRC_ALPHA);
		tex_env(unit, GL_RGB_SCALE_EXT, 1);
		tex_env(unit, GL_ALPHA_SCALE, 1);

		machine.env_color[unit][0] = 0.0;
		machine.env_color[unit][1] = 0.0;
		machine.env_color[unit][2] = 0.0;
		machine.env_color[unit][3] = 0.0;
		glActiveTexture(GL_TEXTURE0 + unit);
		glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR,
			   machine.env_color[unit]);
	}

	for (int test = 0; test < num_tex_units; test++) {
		/* 1. Set up texture state */
		for (int unit = 0; unit < num_tex_units; unit++) {
			if (unit == test) {
				const int revUnit = num_tex_units - unit - 1;
				tex_env(unit, GL_SOURCE1_RGB_EXT,
					GL_TEXTURE0 + revUnit);
				tex_env(unit, GL_SOURCE1_ALPHA_EXT,
					GL_TEXTURE0 + revUnit);
			} else {
				tex_env(unit, GL_SOURCE1_RGB_EXT,
					GL_CONSTANT_EXT);
				tex_env(unit, GL_SOURCE1_ALPHA_EXT,
					GL_CONSTANT_EXT);
			}
		}

		/* 2. Render with OpenGL */
		/* texcoord (0,) for all vertices is OK */
		for (int unit = 0; unit < num_tex_units; unit++)
			glMultiTexCoord2f(GL_TEXTURE0 + unit, 0, 0);
		piglit_draw_rect(-1, -1, 2, 2);

		/* 3. Compute expected result */
		float prev_color[4];
		float expected[4];
		COPY4(prev_color, machine.frag_color);
		for (int unit = 0; unit < num_tex_units; unit++) {
			compute_tex_combine(unit, prev_color, expected);
			COPY4(prev_color, expected);
		}

		/* 4. Compare rendered result to expected result */
		if (!piglit_probe_pixel_rgba(0, 0, expected)) {
			printf("Texture crossbar test %d\n", test);
			return false;
		}
	}
	return true;
}
示例#14
0
文件: combine.c 项目: chemecse/piglit
/* Test texenv-combine with multiple texture units. */
static bool
run_multi_texture_test(void)
{
	static const GLenum combine_modes[10] = {
		GL_REPLACE,
		GL_ADD,
		GL_ADD_SIGNED_EXT,
		GL_MODULATE,
		GL_INTERPOLATE_EXT,
		GL_DOT3_RGB_EXT,
		GL_DOT3_RGBA_EXT,
		GL_MODULATE_ADD_ATI,
		GL_MODULATE_SIGNED_ADD_ATI,
		GL_MODULATE_SUBTRACT_ATI
	};
	const int num_modes = have_dot3 ? (have_combine3 ? 10 : 7) : 5;

	/* four texture units is enough to test */
	if (num_tex_units > 4)
		num_tex_units = 4;

	const int num_tests = count_multi_texture_test_combinations();

	setup_colors();
	for (int test_num = 0; test_num < num_tests;
	     test_num += test_stride) {
		/* 0. Set up texture units */
		reset_machine();
		int divisor = 1;
		for (int u = 0; u < num_tex_units; u++) {
			const int m = (test_num / divisor) % num_modes;
			const GLenum mode = combine_modes[m];

			/* Set GL_COMBINE_RGB_EXT and GL_COMBINE_ALPHA_EXT */
			tex_env(u, GL_COMBINE_RGB_EXT, mode);
			tex_env(u, GL_COMBINE_ALPHA_EXT,
				(mode == GL_DOT3_RGB_EXT ||
				 mode == GL_DOT3_RGBA_EXT)
					? GL_REPLACE
					: mode);
			tex_env(u, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT);
			tex_env(u, GL_SOURCE1_RGB_EXT, GL_PREVIOUS_EXT);
			tex_env(u, GL_SOURCE2_RGB_EXT, GL_TEXTURE);
			tex_env(u, GL_SOURCE0_ALPHA_EXT, GL_PREVIOUS_EXT);
			tex_env(u, GL_SOURCE1_ALPHA_EXT, GL_PREVIOUS_EXT);
			tex_env(u, GL_SOURCE2_ALPHA_EXT, GL_TEXTURE);
			tex_env(u, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
			tex_env(u, GL_OPERAND1_RGB_EXT,
				GL_ONE_MINUS_SRC_COLOR);
			tex_env(u, GL_OPERAND2_RGB_EXT, GL_SRC_ALPHA);
			tex_env(u, GL_OPERAND0_ALPHA_EXT, GL_SRC_ALPHA);
			tex_env(u, GL_OPERAND1_ALPHA_EXT,
				GL_ONE_MINUS_SRC_ALPHA);
			tex_env(u, GL_OPERAND2_ALPHA_EXT, GL_SRC_ALPHA);
			tex_env(u, GL_RGB_SCALE_EXT, 1);
			tex_env(u, GL_ALPHA_SCALE, 1);

			divisor *= num_modes;
		}

		/* 1. Render with OpenGL */
		/* use texcoord (0,0) for all vertices */
		for (int u = 0; u < num_tex_units; u++)
			glMultiTexCoord2f(GL_TEXTURE0 + u, 0, 0);
		piglit_draw_rect(-1, -1, 2, 2);

		/* 2. Compute expected result */
		float prev_color[4];
		float expected[4] = {0};
		COPY4(prev_color, machine.frag_color);
		for (int u = 0; u < num_tex_units; u++) {
			compute_tex_combine(u, prev_color, expected);
			COPY4(prev_color, expected);
		}

		/* 3. Compare rendered result to expected result */
		if (!piglit_probe_pixel_rgba(0, 0, expected)) {
			printf("Multi-texture test %d\n", test_num);
			return false;
		}
	}
	return true;
}
示例#15
0
int soko_exec( int fdfb, int fdrc, int fdlcd, char *cfgfile )
{
	struct timeval	tv;
	int				x;

	if ( FBInitialize( 720, 576, 8, fdfb ) < 0 )
		return -1;

	setup_colors();

	if ( RcInitialize( fdrc ) < 0 )
		return -1;

	Fx2ShowPig( 540, 450, 120, 90 );

	ladeVerzeichnis();
	Startbildschirm();

	while( doexit != 3 )
	{
		doexit=0;
		BoardInitialize();
#ifdef USEX
		FBFlushGrafic();
#endif

		if ( doexit == 4 )	/* fx2 - install error: no level found */
		{
			doexit=0;
			while(( actcode != RC_OK ) && !doexit )
			{
				tv.tv_sec = 0;
				tv.tv_usec = 100000;
				x = select( 0, 0, 0, 0, &tv );		/* 100ms pause */
				RcGetActCode( );
			}
			break;
		}

		while( !doexit )
		{
			tv.tv_sec = 0;
			tv.tv_usec = 10000;
			x = select( 0, 0, 0, 0, &tv );		/* 100ms pause */
	
			RcGetActCode( );
			MoveMouse();
		}

		if ( doexit != 3 )
		{
			actcode=0xee;
			if ( doexit ==2 )
				DrawScore();
			else
				DrawGameOver();
				if (level+1 < max_level)
					{
					level++;
					}
				else
					{
					level = 0;
					}
			doexit=0;
			while(( actcode != RC_OK ) && !doexit )
			{
				tv.tv_sec = 0;
				tv.tv_usec = 100000;
				x = select( 0, 0, 0, 0, &tv );		/* 100ms pause */
				RcGetActCode( );
			}
		}
	}

	Fx2StopPig();

/* fx2 */
/* buffer leeren, damit neutrino nicht rumspinnt */
	realcode = RC_0;
	while( realcode != 0xee )
	{
		tv.tv_sec = 0;
		tv.tv_usec = 300000;
		x = select( 0, 0, 0, 0, &tv );		/* 300ms pause */
		RcGetActCode( );
	}

	RcClose();
	FBClose();

	freeMem();

	return 0;
}