Exemplo n.º 1
0
Arquivo: bs.c Projeto: a565109863/src
int
main(int argc, char *argv[])
{
    if (pledge("stdio rpath tty", NULL) == -1)
        err(1, "pledge");

    do_options(argc, argv);

    intro();
    do {
	initgame();
	while(awinna() == -1)
	{
	    if (!blitz)
	    {
		if (!salvo)
		{
	    	    if(turn)
			(void) cputurn();
		    else
			(void) plyturn();
		}
		else  /* salvo */
		{
		    int i;

		    i = scount(turn);
		    while (i--)
		    {
			if (turn)
			{
			    if (cputurn() && awinna() != -1)
				i = 0;
			}
			else
			{
			    if (plyturn() && awinna() != -1)
				i = 0;
			}
		    }
		}
	    }
	    else  /* blitz */
	    	while(turn ? cputurn() : plyturn())
		{
		    if (turn)   /* Pause between successive computer shots */
		    {
			(void)refresh();
			(void)sleep(1);
		    }
		    if (awinna() != -1)
		     break;
		}
	    turn = OTHER;
	}
    } while
	(playagain());
    uninitgame(0);
    return 0;
}
Exemplo n.º 2
0
int main(int argc, char *argv[])
{
	if (!do_options(&argc, &argv))
		return EXIT_FAILURE;

	switch (mode) {
	case CLIENT:
		do_client(host, port, files);
		break;
	case SERVER:
		do_server(port);
		break;
	}

	return EXIT_SUCCESS;
}
Exemplo n.º 3
0
int
main(int argc, char *argv[])
{
    setlocale(LC_ALL, "");

    do_options(argc, argv);

    intro();
    do {
	initgame();
	while (awinna() == -1) {
	    if (!blitz) {
		if (!salvo) {
		    if (turn)
			(void) cputurn();
		    else
			(void) plyturn();
		} else {
		    register int i;

		    i = scount(turn);
		    while (i--) {
			if (turn) {
			    if (cputurn() && awinna() != -1)
				i = 0;
			} else {
			    if (plyturn() && awinna() != -1)
				i = 0;
			}
		    }
		}
	    } else
		while ((turn ? cputurn() : plyturn()) && awinna() == -1)
		    continue;
	    turn = OTHER;
	}
    } while
	(playagain());
    uninitgame(0);
    /*NOTREACHED */
}
Exemplo n.º 4
0
int
main(int argc, char **argv)
{
    do_options(argc, argv);

    intro();
    do {
		initgame();
		while(awinna() == -1) {
		    if (!blitz) {
				if (!salvo) {
		    	    if (turn)
		    	    	cputurn();
		    	    else plyturn();
				} else {
				     register int i;

				     i = scount(turn);
				     while (i--) {
					 	if (turn)
					 	    if (cputurn())
							 	if (awinna() != -1)
							     	i = 0;
					 	else
					 	    if(plyturn())
							 	if (awinna() != -1)
							     	i = 0;
				 	}
			    }
		    } else {
		    	while((turn) ? cputurn() : plyturn());
		    }
		    turn = OTHER;
		}
    } while(playagain());
    uninitgame();
    exit(0);
}
Exemplo n.º 5
0
int
bsignal(int argc, char **argv)
{
    int numJobs;
    LS_LONG_INT *jobIds;
    int signalValue;

    if (lsb_init(argv[0]) < 0) {
	lsb_perror("lsb_init");
	exit(-1);
    }

    if (strstr (argv[0], "bkill"))
        signalValue = SIGKILL;
    else if (strstr (argv[0], "bstop"))
        signalValue = SIGSTOP;
    else if (strstr (argv[0], "bresume"))
        signalValue = SIGCONT;
    else if (strstr (argv[0], "bchkpnt"))
        signalValue = SIGCHK;
    else if (strstr (argv[0], "bdel"))
        signalValue = SIGDEL;
    else {
        fprintf(stderr, (_i18n_msg_get(ls_catd,NL_SETN,468, "%s: Illegal operation\n")), argv[0]); /* catgets  468  */
        exit (-1);
    }
    numJobs = do_options (argc, argv, &jobIds, signalValue);

    if ((signalValue == SIGKILL)
	&& (sigValue != SIGFORCE)
	&& (sigValue >= LSF_NSIG || sigValue < 1) ) {
        fprintf(stderr, (_i18n_msg_get(ls_catd,NL_SETN,469, "%d: Illegal signal value\n")), sigValue); /* catgets  469  */
        exit(-1);
    }

    return (signalJobs (jobIds, numJobs));

}
Exemplo n.º 6
0
int
main(int argc, char *argv[]) {
	progname = argv[0];		/* save program name */
	argv++, argc--;			/* and skip it */

	/* Set the default output and debug streams */
	OutputFile = stdout;
	DebugFile = stdout;

	/* Get command line options */
	{	int nop = do_options(progname, optlist, argc, argv);
		argc -= nop, argv += nop;	/* skip them */
	}

	/* Treat the value options */
	if (minrunstring) {
		MinRunSize = strtoul(minrunstring, NULL, 10);
		if (MinRunSize == 0) fatal("bad or zero run size; form is: -r N");
	}
	if (pagewidthstring) {
		PageWidth = atoi(pagewidthstring);
		if (PageWidth == 0) fatal("bad or zero page width; form is: -w N");
	}
	if (outputname) {
		OutputFile = fopen(outputname, "w");
		if (OutputFile == 0) {
			char msg[500];

			sprintf(msg, "cannot open output file %s", outputname);
			fatal(msg);
			/*NOTREACHED*/
		}
	}

	if (option_set('-')) {
		/* it is the lexical scan only */
		while (argv[0]) {
			print_stream(argv[0]);
			argv++;
		}
		return 0;
	}

	/* Start processing */
	InitLanguage();

	/* Read the input files */
	Pass1(argc, argv);

	/* Set up the forward reference table */
	MakeForwardReferences();

	/* Compare the input files to find runs */
	Compare();

	/* Delete forward reference table */
	FreeForwardReferences();

	/* Find positions of the runs found */
	Pass2();

	/* Print the similarities */
	Pass3();

	return 0;
}
Exemplo n.º 7
0
int main(int argc, char **argv)
{
	time_t rx_time;
	time_t real_time;
	time_t offset;
	int ret;
	struct dvbfe_handle *fe;
	struct dvbfe_info fe_info;

	do_print = 0;
	do_force = 0;
	do_set = 0;
	do_quiet = 0;
	ProgName = argv[0];

/*
 * Process command line arguments
 */
	do_options(argc, argv);
	if (do_quiet && do_print) {
		errmsg("quiet and print options are mutually exclusive.\n");
		exit(1);
	}

/*
 * Find the frontend type
 */
	if ((fe = dvbfe_open(adapter, 0, 1)) == NULL) {
		errmsg("Unable to open frontend.\n");
		exit(1);
	}
	dvbfe_get_info(fe, 0, &fe_info, DVBFE_INFO_QUERYTYPE_IMMEDIATE, 0);

/*
 * Get the date from the currently tuned multiplex
 */
	switch(fe_info.type) {
	case DVBFE_TYPE_DVBS:
	case DVBFE_TYPE_DVBC:
	case DVBFE_TYPE_DVBT:
		ret = dvb_scan_date(&rx_time, timeout);
		break;

	case DVBFE_TYPE_ATSC:
		ret = atsc_scan_date(&rx_time, timeout);
		break;

	default:
		errmsg("Unsupported frontend type.\n");
		exit(1);
	}
	if (ret != 0) {
		errmsg("Unable to get time from multiplex.\n");
		exit(1);
	}
	time(&real_time);
	offset = rx_time - real_time;
	if (do_print) {
		fprintf(stdout, "System time: %s", ctime(&real_time));
		fprintf(stdout, "    RX time: %s", ctime(&rx_time));
		fprintf(stdout, "     Offset: %ld seconds\n", offset);
	} else if (!do_quiet) {
		fprintf(stdout, "%s", ctime(&rx_time));
	}
	if (do_set) {
		if (labs(offset) > ALLOWABLE_DELTA) {
			if (do_force) {
				if (0 != set_time(&rx_time)) {
					errmsg("setting the time failed\n");
				}
			} else {
				errmsg("multiplex time differs by more than %d from system.\n", ALLOWABLE_DELTA);
				errmsg("use -f to force system clock to new time.\n");
				exit(1);
			}
		} else {
			set_time(&rx_time);
		}
	}			/* #end if (do_set) */
	return (0);
}
Exemplo n.º 8
0
void golgotha_app::receive_event(i4_event * ev)
{
	switch (ev->type())
	{
		case i4_event::DISPLAY_CHANGE:
			{
				CAST_PTR(dev, i4_display_change_event_class, ev);
				if (dev->change==i4_display_change_event_class::SIZE_CHANGE)
				{
					get_root_window()->resize(get_display()->width(),get_display()->height());
				}

			} break;
		case i4_event::DO_COMMAND:
			{
				fo_sym.get();

				g1_cwin_man->receive_event(ev);
				char * cmd=((i4_do_command_event_class *)ev)->command;
				li_symbol * s=li_get_symbol(cmd);
				if (li_get_fun(s,0))
				{
					li_call(s);
				}

				g1_input.receive_event(ev);
			} break;

		case i4_event::END_COMMAND:
			{
				g1_cwin_man->receive_event(ev);
				char cmd[200];
				sprintf(cmd, "-%s",((i4_do_command_event_class *)ev)->command);
				li_symbol * s=li_get_symbol(cmd);
				if (li_get_fun(s,0))
				{
					li_call(cmd);
				}
				g1_input.receive_event(ev);
			} break;

		case i4_event::USER_MESSAGE:
			{
				CAST_PTR(uev,i4_user_message_event_class,ev);
				switch (uev->sub_type)
				{
					case G1_MAIN_MENU:
						do_main_menu();
						break;

					case G1_NETWORK_MENU:
						network_menu();
						break;
					case G1_SERVER_MENU:
						server_menu();
						break;
					case G1_CLIENT_JOINED_MENU:
						client_wait_menu();
						break;

					case G1_YOU_LOSE:
						help_screen("youlose_screen", G1_MAIN_MENU);
						break;

					case G1_YOU_WIN:
						{
							CAST_PTR(fptr,i4_file_open_message_class,uev);
							win_screen("youwin_screen", fptr->filename);
						}
						break;

					case G1_HELP_SCREEN:
						help_screen("help_screen", G1_RETURN_TO_GAME);
						break;

					case G1_START_HELP_SCREEN:
						help_screen("help_screen", G1_START_NEW_GAME);
						break;

					case G1_PLOT_SCREEN:
						plot_screen();
						break;

					case G1_START_NEW_GAME:
						start_new_game();
						break;

					case G1_RETURN_TO_GAME:
						return_to_game();
						break;

					case G1_SAVEGAME_SAVE:
						save_savegame();
						break;

					case G1_SAVEGAME_SAVE_OK:
						save_savegame_ok(uev); //Saving a savegame must not change
						//the map's filename.
						break;

					case G1_SAVEGAME_LOAD_OK:
						start_saved_game(uev);
						break;

					case G1_SAVEGAME_LOAD:
						open_savegame();
						break;

					case G1_OPTIONS:
						do_options();
						break;

					case G1_QUIT:
						quit();
						break;
					case G1_ESCAPE:
						do_main_menu();
						break;

					case G1_MAP_CHANGED:
						map_changed();
						break;

					case G1_GET_ROOT_IMAGE:
						{
							CAST_PTR(get, g1_get_root_image_event, ev);
							get->result=display->get_screen();
						} break;


					case G1_REDRAW_LATER:
						{
							redraw_later.waiting=i4_F;
							li_call("redraw_all");
						} break;

					case G1_PLAY_MOVIE:
						if (g1_map_is_loaded())
						{
							pre_play_save();

							if (g1_get_map()->start_movie())
							{
								playing_movie=i4_T;
								g1_resources.paused=i4_F;
							}

						}
						break;

					case G1_STOP_MOVIE:
						{
							if (playing_movie)
							{
								if (g1_map_is_loaded())
								{
									g1_get_map()->stop_movie();

									post_play_load();
								}

								playing_movie=i4_F;

								if (g1_current_controller.get() &&
									g1_current_controller->view.get_view_mode()==G1_CAMERA_MODE)
								{
									g1_current_controller->view.suggest_camera_mode(G1_ACTION_MODE);
								}
							}

						} break;

					case G1_GET_CURRENT_MOVIE:
						{
							if (g1_map_is_loaded())
							{
								CAST_PTR(mev, g1_get_current_movie_event, ev);
								mev->mflow=g1_get_map()->current_movie;
							}

						} break;

					case G1_INTERLACE_PIXEL:
						{
							g1_cwin_man->destroy_views();
							g1_resources.render_window_expand_mode = R1_COPY_1x1_SCANLINE_SKIP;
							g1_cwin_man->create_views();
						} break;

					case G1_DOUBLE_PIXEL:
						{
							g1_cwin_man->destroy_views();
							g1_resources.render_window_expand_mode = R1_COPY_2x2;
							g1_cwin_man->create_views();
						} break;

					case G1_NORMAL_PIXEL:
						{
							g1_cwin_man->destroy_views();
							g1_resources.render_window_expand_mode = R1_COPY_1x1;
							g1_cwin_man->create_views();
						} break;

				}
			} break;

		default:
			i4_application_class::receive_event(ev);
	}
}
Exemplo n.º 9
0
/*
 * Set the system time
 */
int set_time(time_t *new_time)
{
#if defined(__FreeBSD__)
  struct timeval tp;
  tp.tv_sec=*new_time;
  tp.tv_usec=0;
  if (settimeofday(&tp,0)) {
#else
  if (stime(new_time)) {
#endif
    perror("Unable to set time");
    exit(1);
  }
  return 0;
}


int main(int argc, char **argv)
{
  time_t dvb_time;
  time_t real_time;
  time_t offset;

  do_print = 0;
  do_force = 0;
  do_set = 0;
  do_quiet = 0;
  ProgName = argv[0];

/*
 * Process command line arguments
 */
  do_options(argc, argv);
  if (do_quiet && do_print) {
    errmsg("quiet and print options are mutually exclusive.\n");
    exit(1);
  }
/*
 * Get the date from the currently tuned DTT multiplex
 */
  dvb_time = scan_date();
  if (dvb_time == 0) {
    errmsg("Unable to get time from multiplex.\n");
    exit(1);
  }
  time(&real_time);
  offset = dvb_time - real_time;
  if (do_print) {
    fprintf(stdout, "System time: %s", ctime(&real_time));
    fprintf(stdout, "   DTT time: %s", ctime(&dvb_time));
    fprintf(stdout, "     Offset: %ld seconds\n", offset);
  } else if (!do_quiet) {
    fprintf(stdout, "%s", ctime(&dvb_time));
  }
  if (do_set) {
    if (labs(offset) > ALLOWABLE_DELTA) {
      if (do_force) {
        set_time(&dvb_time);
      } else {
	errmsg("multiplex time differs by more than %d from system.\n", ALLOWABLE_DELTA);
	errmsg("use -f to force system clock to new time.\n");
        exit(1);
      }
    } else {
      set_time(&dvb_time);
    }
  } /* #end if (do_set) */
  return(0);
}
Exemplo n.º 10
0
int     mcpp_lib_main
#else
int     main
#endif
(
    int argc,
    char ** argv
)
{
    char *  in_file = NULL;
    char *  out_file = NULL;
    char *  stdin_name = "<stdin>";

    if (setjmp( error_exit) == -1) {
        errors++;
        goto  fatal_error_exit;
    }

#if MCPP_LIB
    /* Initialize global and static variables.  */
    init_main();
    init_directive();
    init_eval();
    init_support();
    init_system();
#endif

    fp_in = stdin;
    fp_out = stdout;
    fp_err = stderr;
    fp_debug = stdout;
        /*
         * Debugging information is output to stdout in order to
         *      synchronize with preprocessed output.
         */

    inc_dirp = &null;   /* Initialize to current (null) directory   */
    cur_fname = cur_fullname = "(predefined)";  /* For predefined macros    */
    init_defines();                         /* Predefine macros     */
    mb_init();      /* Should be initialized prior to get options   */
    do_options( argc, argv, &in_file, &out_file);   /* Command line options */

    /* Open input file, "-" means stdin.    */
    if (in_file != NULL && ! str_eq( in_file, "-")) {
        if ((fp_in = fopen( in_file, "r")) == NULL) {
            mcpp_fprintf( ERR, "Can't open input file \"%s\".\n", in_file);
            errors++;
#if MCPP_LIB
            goto  fatal_error_exit;
#else
            return( IO_ERROR);
#endif
        }
    } else {
        in_file = stdin_name;
    }
    /* Open output file, "-" means stdout.  */
    if (out_file != NULL && ! str_eq( out_file, "-")) {
        if ((fp_out = fopen( out_file, "w")) == NULL) {
            mcpp_fprintf( ERR, "Can't open output file \"%s\".\n", out_file);
            errors++;
#if MCPP_LIB
            goto  fatal_error_exit;
#else
            return( IO_ERROR);
#endif
        }
        fp_debug = fp_out;
    }
    if (option_flags.q) {                   /* Redirect diagnostics */
        if ((fp_err = fopen( "mcpp.err", "a")) == NULL) {
            errors++;
            mcpp_fprintf( OUT, "Can't open \"mcpp.err\"\n");
#if MCPP_LIB
            goto  fatal_error_exit;
#else
            return( IO_ERROR);
#endif
        }
    }
    init_sys_macro();       /* Initialize system-specific macros    */
    add_file( fp_in, NULL, in_file, in_file, FALSE);
                                        /* "open" main input file   */
    infile->dirp = inc_dirp;
    infile->sys_header = FALSE;
    cur_fullname = in_file;
    if (mkdep && str_eq( infile->real_fname, stdin_name) == FALSE)
        put_depend( in_file);       /* Putout target file name      */
    at_start();                     /* Do the pre-main commands     */

    mcpp_main();                    /* Process main file            */

    if (mkdep)
        put_depend( NULL);      /* Append '\n' to dependency line   */
    at_end();                       /* Do the final commands        */

fatal_error_exit:
#if MCPP_LIB
    /* Free malloced memory */
    if (mcpp_debug & MACRO_CALL) {
        if (in_file != stdin_name)
            free( in_file);
    }
    clear_filelist();
    clear_symtable();
#endif

    if (fp_in != stdin)
        fclose( fp_in);
    if (fp_out != stdout)
        fclose( fp_out);
    if (fp_err != stderr)
        fclose( fp_err);

    if (mcpp_debug & MEMORY)
        print_heap();
    if (errors > 0 && option_flags.no_source_line == FALSE) {
        mcpp_fprintf( ERR, "%d error%s in preprocessor.\n",
                errors, (errors == 1) ? "" : "s");
        return  IO_ERROR;
    }
    return  IO_SUCCESS;                             /* No errors    */
}