Exemplo n.º 1
0
void TEST_display_w() {
    char *routine = "TEST_display_w";
    printf(testing, routine);
    init_defaults();
    assert(defaults->dsp_width);
    printf(done, routine);
}
Exemplo n.º 2
0
void restart() {
  // let's restart the game
  init_defaults();
  init_drugs();
  init_screens();
  init_sheets();
}
Exemplo n.º 3
0
void TEST_display_h() {
    char *routine = "TEST_display_h";
    printf(testing, routine);
    init_defaults();
    assert(defaults->dsp_height);
    printf(done, routine);
}
Exemplo n.º 4
0
int main(int argc, char **argv) {
    struct passwd  *p;
    int             i, ecode;

    init_defaults(basename(argv[0]), "passwd");
    while ((i=getopt(argc,argv,"c")) != EOF) {
        switch (i) {
        case 'c':
            if (getuid() != 0) {
                fprintf(stderr,"%s: must be root to set chroot option\n", argv[0]);
                return EXIT_FAILURE;
            }
            passwd_stub = CHROOTED_PASSWD;
            break;
        default:
            fprintf(stderr,"%s: bad option %c\n", argv[0], i);
            return EXIT_FAILURE;
        }
    }
    if (optind == argc) {
        if (!(p = getpwuid(getuid()))) {
            fprintf(stderr, "%s: cannot locate your password entry\n", argv[0]);
            return EXIT_FAILURE;
        }
        return change_passwd(p);
    }
    /* passwd should use getopt to support -- syntax */
    ecode = Success;
    for (i = optind; i < argc; i++) {
        if (!(p = getpwnam(argv[i]))) {
            if (getuid() != 0) {
                fprintf(stderr, "%s: must be root to create new accounts\n",
                        argv[0]);
                return EXIT_FAILURE;
            }
            if (strlen(argv[i]) > LOGIN_NAME_MAX) {
                fprintf(stderr,"%s: username exceeds maximum length of %d characters\n", argv[0], LOGIN_NAME_MAX);
                return EXIT_FAILURE;
            }
            if (strchr(argv[i], ':')) {
                fprintf(stderr, "%s: username cannot contain ':' character\n",
                        argv[0]);
                return EXIT_FAILURE;
            }
            if ((ecode=create_account(argv[i])) != Success) {
                return ecode;
            }
        } else if (p->pw_uid != getuid() && getuid() != 0) {
            fprintf(stderr, "%s: sorry, only root may change another user's password\n", argv[0]);
        } else if ((ecode=change_passwd(p)) != Success) {
            return ecode;
        }
    }
    return ecode;
}
Exemplo n.º 5
0
Arquivo: xaut.c Projeto: hw94/ucognito
void _initialize() {
    if (defaults && defaults->display) {
        return;
    }
    if (!init_defaults()) {
        fprintf(stderr, "Failure initialize defaults\n");
        return;
    }
    if (!_init_ascii()) {
        fprintf(stderr, "Failure to initialize ascii keys\n");
        return;
    }
}
Exemplo n.º 6
0
void new_idw_window()
{
  idw_gc = GrNewGC();
	GrGetScreenInfo(&screen_info);

	init_defaults();
  init_drugs();
	init_screens();
	init_sheets();

	idw_wid = pz_new_window(0, HEADER_TOPLINE + 1, screen_info.cols, screen_info.rows - (HEADER_TOPLINE + 1), idw_do_draw, idw_do_keystroke);

	GrSelectEvents(idw_wid, GR_EVENT_MASK_EXPOSURE|GR_EVENT_MASK_KEY_DOWN);
	GrMapWindow(idw_wid);
}
Exemplo n.º 7
0
void
md_begin ()
{
  int i;

  init_defaults ();

  insn_hash = hash_new ();
  if (insn_hash == NULL)
    as_fatal ("Virtual memory exhausted");

  for (i = 0; i < pdp11_num_opcodes; i++)
    hash_insert (insn_hash, pdp11_opcodes[i].name, (PTR)(pdp11_opcodes + i));
  for (i = 0; i < pdp11_num_aliases; i++)
    hash_insert (insn_hash, pdp11_aliases[i].name, (PTR)(pdp11_aliases + i));
}
Exemplo n.º 8
0
Sprite::Sprite(lisp_object_t* cur)
{
  init_defaults();

  LispReader reader(cur);

  if(!reader.read_string("name",   &name))
    st_abort("Sprite wihtout name", "");
  reader.read_int("x-hotspot", &x_hotspot);
  reader.read_int("y-hotspot", &y_hotspot);
  reader.read_float("fps",     &fps);

  std::vector<std::string> images;
  if(!reader.read_string_vector("images", &images))
    st_abort("Sprite contains no images: ", name.c_str());

  for(std::vector<std::string>::size_type i = 0; i < images.size(); ++i)
    {
      surfaces.push_back(
          new Surface(datadir + "/images/" + images[i], USE_ALPHA));
    }        

  frame_delay = 1000.0f/fps;
}
Exemplo n.º 9
0
//---------------------------------------------------------------------------//
Schema::Schema(const std::string &json_schema)
{
    init_defaults();
    set(json_schema);
}
Exemplo n.º 10
0
//---------------------------------------------------------------------------//
Schema::Schema(const DataType &dtype)
{
    init_defaults();
    set(dtype);
}
Exemplo n.º 11
0
//---------------------------------------------------------------------------//
Schema::Schema(index_t dtype_id)
{
    init_defaults();
    set(dtype_id);
}
Exemplo n.º 12
0
static int
sudoers_policy_open(unsigned int version, sudo_conv_t conversation,
    sudo_printf_t plugin_printf, char * const settings[],
    char * const user_info[], char * const envp[])
{
    volatile int sources = 0;
    sigaction_t sa;
    struct sudo_nss *nss;

    if (!sudo_conv)
	sudo_conv = conversation;
    if (!sudo_printf)
	sudo_printf = plugin_printf;

    if (sigsetjmp(error_jmp, 1)) {
	/* called via error(), errorx() or log_error() */
	rewind_perms();
	return -1;
    }

    bindtextdomain("sudoers", LOCALEDIR);

    /*
     * Signal setup:
     *	Ignore keyboard-generated signals so the user cannot interrupt
     *  us at some point and avoid the logging.
     *  Install handler to wait for children when they exit.
     */
    zero_bytes(&sa, sizeof(sa));
    sigemptyset(&sa.sa_mask);
    sa.sa_flags = SA_RESTART;
    sa.sa_handler = SIG_IGN;
    (void) sigaction(SIGINT, &sa, &saved_sa_int);
    (void) sigaction(SIGQUIT, &sa, &saved_sa_quit);
    (void) sigaction(SIGTSTP, &sa, &saved_sa_tstp);

    sudo_setpwent();
    sudo_setgrent();

    /* Initialize environment functions (including replacements). */
    env_init(envp);

    /* Setup defaults data structures. */
    init_defaults();

    /* Parse settings and user_info */
    sudo_mode = deserialize_info(settings, user_info);

    init_vars(envp);		/* XXX - move this later? */

    /* Parse nsswitch.conf for sudoers order. */
    snl = sudo_read_nss();

    /* LDAP or NSS may modify the euid so we need to be root for the open. */
    set_perms(PERM_INITIAL);
    set_perms(PERM_ROOT);

    /* Open and parse sudoers, set global defaults */
    tq_foreach_fwd(snl, nss) {
	if (nss->open(nss) == 0 && nss->parse(nss) == 0) {
	    sources++;
	    if (nss->setdefs(nss) != 0)
		log_error(NO_STDERR|NO_EXIT, _("problem with defaults entries"));
	}
    }
    if (sources == 0) {
	warningx(_("no valid sudoers sources found, quitting"));
	return -1;
    }

    /* XXX - collect post-sudoers parse settings into a function */

    /*
     * Initialize external group plugin, if any.
     */
    if (def_group_plugin) {
	if (group_plugin_load(def_group_plugin) != TRUE)
	    def_group_plugin = NULL;
    }

    /*
     * Set runas passwd/group entries based on command line or sudoers.
     * Note that if runas_group was specified without runas_user we
     * defer setting runas_pw so the match routines know to ignore it.
     */
    if (runas_group != NULL) {
	set_runasgr(runas_group);
	if (runas_user != NULL)
	    set_runaspw(runas_user);
    } else
	set_runaspw(runas_user ? runas_user : def_runas_default);

    if (!update_defaults(SETDEF_RUNAS))
	log_error(NO_STDERR|NO_EXIT, _("problem with defaults entries"));

    if (def_fqdn)
	set_fqdn();	/* deferred until after sudoers is parsed */

    /* Set login class if applicable. */
    set_loginclass(sudo_user.pw);

    restore_perms();

    return TRUE;
}
Exemplo n.º 13
0
static void *
reload_thread(void *unused)
{
	extern int yynerrs;
	extern FILE *yyin;
	FILE *f;
	struct config_file *new_cfg = NULL, *tmp;
	struct sigaction signals;

	/* Initialize signals and start reload thread */
	bzero (&signals, sizeof(struct sigaction));
	sigemptyset(&signals.sa_mask);
	sigaddset(&signals.sa_mask, SIGUSR1);
	signals.sa_handler = sig_usr1_handler;
	sigaction (SIGUSR1, &signals, NULL);

	msg_info("reload_thread: starting...");

	/* lock on mutex until we got SIGUSR1 that unlocks mutex */
	while (1) {
		pthread_mutex_lock (&cfg_reload_mtx);
		pthread_cond_wait (&cfg_cond, &cfg_reload_mtx);
		pthread_mutex_unlock (&cfg_reload_mtx);
		msg_warn("reload_thread: reloading, rmilter version %s", MVERSION);
		/* lock for writing */
		CFG_WLOCK()
		;
		f = fopen (cfg->cfg_name, "r");

		if (f == NULL) {
			CFG_UNLOCK()
			;
			msg_warn("reload_thread: cannot open file %s, %m", cfg->cfg_name);
			continue;
		}

		new_cfg = (struct config_file*) malloc (sizeof(struct config_file));
		if (new_cfg == NULL) {
			CFG_UNLOCK()
			;
			fclose (f);
			msg_warn("reload_thread: malloc, %s", strerror (errno));
			continue;
		}

		bzero (new_cfg, sizeof(struct config_file));
		init_defaults (new_cfg);
		new_cfg->cfg_name = cfg->cfg_name;
		tmp = cfg;
		cfg = new_cfg;

		yyin = f;
		yyrestart (yyin);

		if (yyparse () != 0 || yynerrs > 0) {
			CFG_UNLOCK()
			;
			fclose (f);
			msg_warn("reload_thread: cannot parse config file %s",
					cfg->cfg_name);
			free_config (new_cfg);
			free (new_cfg);
			cfg = tmp;
			continue;
		}

		fclose (f);
		new_cfg->cfg_name = tmp->cfg_name;
		new_cfg->serial = tmp->serial + 1;

		/* Strictly set temp dir */
		if (!cfg->temp_dir) {
			msg_warn("tempdir is not set, trying to use $TMPDIR");
			cfg->temp_dir = getenv ("TMPDIR");

			if (!cfg->temp_dir) {
				cfg->temp_dir = strdup ("/tmp");
			}
		}
#ifdef HAVE_SRANDOMDEV
		srandomdev();
#else
		srand (time (NULL));
#endif
		/* Free old config */
		free_config (tmp);
		free (tmp);

		CFG_UNLOCK()
		;
	}
	return NULL;
}
Exemplo n.º 14
0
/*** plugin interface functions ***/
int input_init(input_parameter *param, int id)
{
    int i;
    
    init_defaults();
        
    plugin_number = id;

    param->argv[0] = INPUT_PLUGIN_NAME;

    /* show all parameters for DBG purposes */
    for(i = 0; i < param->argc; i++) {
        DBG("argv[%d]=%s\n", i, param->argv[i]);
    }

    reset_getopt();
    while(1) {
        int option_index = 0, c = 0;
        static struct option long_options[] = {
            {"h", no_argument, 0, 0},
            {"help", no_argument, 0, 0},
            {"d", required_argument, 0, 0},
            {"delay", required_argument, 0, 0},
            {"n", required_argument, 0, 0},
            {"name", required_argument, 0, 0},
            {"dl", required_argument, 0, 0},
            {"delim", required_argument, 0, 0},
            {0, 0, 0, 0}
        };

        c = getopt_long_only(param->argc, param->argv, "", long_options, &option_index);

        /* no more options to parse */
        if(c == -1) break;

        /* unrecognized option */
        if(c == '?') {
            help();
            return 1;
        }

        switch(option_index) {
            /* h, help */
        case 0:
        case 1:
            DBG("case 0,1\n");
            help();
            return 1;
            break;

            /* d, delay */
        case 2:
        case 3:
            DBG("case 2,3\n");
            delay = atoi(optarg);
            break;

            /* n, name */
        case 4:
        case 5:
            DBG("case 4,5\n");
            fifoname = strdup(optarg);
            break;

            /* dl, delim */
        case 6:
        case 7:
            DBG("case 6,7\n");
            frame_delim = strdup(optarg);
            frame_delim_size = strlen(frame_delim);            
            break;
        default:
            DBG("default case\n");
            help();
            return 1;
        }
    }

    pglobal = param->global;

    //TODO: WARNING ABOUT DEFAULTS
    
    IPRINT("forced delay......: %i\n", delay);
    IPRINT("frame delimeter...: %s\n", frame_delim);
    IPRINT("fifoname is.......: %s\n", fifoname);

    param->global->in[id].name = malloc((strlen(INPUT_PLUGIN_NAME) + 1) * sizeof(char));
    sprintf(param->global->in[id].name, INPUT_PLUGIN_NAME);

    return 0;
}
Exemplo n.º 15
0
//---------------------------------------------------------------------------//
Schema::Schema(const Schema &schema)
{
    init_defaults();
    set(schema);
}
Exemplo n.º 16
0
void pa_log_levelv_meta(
        pa_log_level_t level,
        const char*file,
        int line,
        const char *func,
        const char *format,
        va_list ap) {

    char *t, *n;
    int saved_errno = errno;
    char *bt = NULL;
    pa_log_target_t _target;
    pa_log_level_t _maximum_level;
    unsigned _show_backtrace;
    pa_log_flags_t _flags;

    /* We don't use dynamic memory allocation here to minimize the hit
     * in RT threads */
    char text[16*1024], location[128], timestamp[32];

    pa_assert(level < PA_LOG_LEVEL_MAX);
    pa_assert(format);

    PA_ONCE_BEGIN {
        init_defaults();
    } PA_ONCE_END;

    _target = target_override_set ? target_override : target;
    _maximum_level = PA_MAX(maximum_level, maximum_level_override);
    _show_backtrace = PA_MAX(show_backtrace, show_backtrace_override);
    _flags = flags | flags_override;

    if (PA_LIKELY(level > _maximum_level)) {
        errno = saved_errno;
        return;
    }

    pa_vsnprintf(text, sizeof(text), format, ap);

    if ((_flags & PA_LOG_PRINT_META) && file && line > 0 && func)
        pa_snprintf(location, sizeof(location), "[%s:%i %s()] ", file, line, func);
    else if ((_flags & (PA_LOG_PRINT_META|PA_LOG_PRINT_FILE)) && file)
        pa_snprintf(location, sizeof(location), "%s: ", pa_path_get_filename(file));
    else
        location[0] = 0;

    if (_flags & PA_LOG_PRINT_TIME) {
        static pa_usec_t start, last;
        pa_usec_t u, a, r;

        u = pa_rtclock_now();

        PA_ONCE_BEGIN {
            start = u;
            last = u;
        } PA_ONCE_END;

        r = u - last;
        a = u - start;

        /* This is not thread safe, but this is a debugging tool only
         * anyway. */
        last = u;

        pa_snprintf(timestamp, sizeof(timestamp), "(%4llu.%03llu|%4llu.%03llu) ",
                    (unsigned long long) (a / PA_USEC_PER_SEC),
                    (unsigned long long) (((a / PA_USEC_PER_MSEC)) % 1000),
                    (unsigned long long) (r / PA_USEC_PER_SEC),
                    (unsigned long long) (((r / PA_USEC_PER_MSEC)) % 1000));

    } else
Exemplo n.º 17
0
int main (int argc, char **argv) {
  toptions   *opt;
  tsequence  *seq;
  treadseq   *rs        = NULL;
  ttokenizer *tokenizer = NULL;
  char       *command;



  opt = (toptions *) calloc(1,sizeof(toptions));

  init_defaults(opt);
  process_args(opt, 0, argc, argv);

  if (!opt->terminate) {
    if (optind < argc)               rs = readseq_open(READSEQ_STRING, argv[optind]);
    else if (opt->inputfile)         rs = readseq_open(READSEQ_FILE,   opt->inputfile);
    else if (!isatty(fileno(stdin))) rs = readseq_open(READSEQ_STDIN,  NULL);
    else {
      printf("Interactive mode. Try `./RNAfold -h` for more information.\n", argv[0]);
      rl_init();
      opt->interactive = 1;
      opt->colored_output = 1 - opt->colored_output;
      tokenizer = tokenizer_new();
      rs = readseq_open(READSEQ_STRING, "");
    }

    while (1) {
      if (opt->interactive) {
        if (opt->colored_output)
          printf("%s\nInput sequence (upper or lower case); :q to quit, -h for help.\n....,....1....,....2....,....3....,....4....,....5....,....6....,....7....,....8\n%s",COLOR_RED,COLOR_DEFAULT);
        else
	  printf("\nInput sequence (upper or lower case); :q to quit, -h for help.\n....,....1....,....2....,....3....,....4....,....5....,....6....,....7....,....8\n");
        command = rl_gets();

        if (!command || (command[0] == '@') || ((command[0] == ':') && (command[1] == 'q'))) {
          pcolor(opt->colored_output,COLOR_BLUE);
          printf("Leaving RNAfold.");
          pcolor(opt->colored_output,COLOR_DEFAULT);
          printf("\n");
          exit(0);
        }
        else if (command[0] == ':') {
          pcolor(opt->colored_output,COLOR_BLUE);
          if (command[1] == 's') print_settings(opt);
          if (command[1] == 'd') {
            init_defaults(opt);
            opt->colored_output = 1;
            opt->interactive = 1;
            printf("Activated default configuration.\n");
            pcolor(opt->colored_output,COLOR_DEFAULT);
          }
          if (command[1] == 'e') {
            system(command + 2);
          }
          if (command[1] == 'r') {
            system("make update");
            system("./RNAfold");
            exit(0);
          }
        }
        else if (command[0] == '-') {
          tokenizer_exec(tokenizer, argv[0], command);
          process_args(opt, 1, tokenizer->count, tokenizer->token);
          if (opt->inputfile) {
            rs = readseq_free(rs);
            rs = readseq_open(READSEQ_FILE, opt->inputfile);
          }
          free(opt->inputfile);
          opt->inputfile = NULL;
        }
        else {
          rs = readseq_free(rs);
          rs = readseq_open(READSEQ_STRING, command);
        }
      }

      while (1) {
        seq = readseq_next_fasta(rs);
        if (!(seq->success)) break;
        if (1) {
          main_rnafold_mfe(opt, seq);
        }

        sequence_free(seq);
      }

      if (!opt->interactive) break;
    }
  }
  exit(0);
}
Exemplo n.º 18
0
/** Loads the stk configuration file. After loading it checks if all necessary
 *  values are actually defined, otherwise an error message is printed and STK
 *  is aborted.
 *  /param filename Name of the configuration file to load.
 */
void STKConfig::load(const std::string &filename)
{
    // Avoid loading the default config file if a user-specific
    // config file has already been loaded.
    if(m_has_been_loaded) return;
    m_has_been_loaded = true;

    init_defaults();

    XMLNode *root = 0;
    try
    {
        root = new XMLNode(filename);
        if(!root || root->getName()!="config")
        {
            if(root) delete root;
            std::ostringstream msg;
            msg << "Couldn't load config '" << filename << "': no config node.";
            throw std::runtime_error(msg.str());
        }
        getAllData(root);
    }

    catch(std::exception& err)
    {
        fprintf(stderr, "Error while parsing KartProperties '%s':\n",
                filename.c_str());
        fprintf(stderr, "%s", err.what());
        fprintf(stderr, "\n");
    }
    delete root;

    // Check that all necessary values are indeed set
    // -----------------------------------------------

#define CHECK_NEG(  a,strA) if(a<=UNDEFINED) {                         \
        fprintf(stderr,"Missing default value for '%s' in '%s'.\n",    \
                strA,filename.c_str());exit(-1);                       \
    }

    if(m_score_increase.size()==0 || (int)m_score_increase.size()!=m_max_karts)
    {
        fprintf(stderr,"Not or not enough scores defined in stk_config");
        exit(-1);
    }
    if(m_leader_intervals.size()==0)
    {
        fprintf(stderr,"No follow leader interval(s) defined in stk_config");
        exit(-1);
    }
    
    if(m_switch_items.size()!=Item::ITEM_LAST-Item::ITEM_FIRST+1)
    {
        fprintf(stderr,"No item switches defined in stk_config");
        exit(-1);
    }

    CHECK_NEG(m_max_karts,                 "<karts max=..."             );
    CHECK_NEG(m_gp_order,                  "grand-prix order=..."       );
    CHECK_NEG(m_parachute_friction,        "parachute-friction"         );
    CHECK_NEG(m_parachute_done_fraction,   "parachute-done-fraction"    );
    CHECK_NEG(m_parachute_time,            "parachute-time"             );
    CHECK_NEG(m_parachute_time_other,      "parachute-time-other"       );
    CHECK_NEG(m_bomb_time,                 "bomb-time"                  );
    CHECK_NEG(m_bomb_time_increase,        "bomb-time-increase"         );
    CHECK_NEG(m_anvil_time,                "anvil-time"                 );
    CHECK_NEG(m_anvil_weight,              "anvil-weight"               );
    CHECK_NEG(m_item_switch_time,          "item-switch-time"           );
    CHECK_NEG(m_bubble_gum_counter,        "bubblegum disappear counter");
    CHECK_NEG(m_explosion_impulse,         "explosion-impulse"          );
    CHECK_NEG(m_explosion_impulse_objects, "explosion-impulse-objects"  );
    CHECK_NEG(m_max_history,               "max-history"                );
    CHECK_NEG(m_max_skidmarks,             "max-skidmarks"              );
    CHECK_NEG(m_min_kart_version,          "<kart-version min...>"      );
    CHECK_NEG(m_max_kart_version,          "<kart-version max=...>"     );
    CHECK_NEG(m_min_track_version,         "min-track-version"          );
    CHECK_NEG(m_max_track_version,         "max-track-version"          );
    CHECK_NEG(m_skid_fadeout_time,         "skid-fadeout-time"          );
    CHECK_NEG(m_near_ground,               "near-ground"                );
    CHECK_NEG(m_delay_finish_time,         "delay-finish-time"          );
    CHECK_NEG(m_music_credit_time,         "music-credit-time"          );
    CHECK_NEG(m_leader_time_per_kart,      "leader time-per-kart"       );
    CHECK_NEG(m_penalty_time,              "penalty-time"               );

    m_kart_properties.checkAllSet(filename);
}   // load
Exemplo n.º 19
0
ConfigurationOptions::ConfigurationOptions()
{
  init_defaults();
  parse_config_file();
}
Exemplo n.º 20
0
void TEST_init_defaults() {
    char *routine = "TEST_init_defaults";
    printf(testing, routine);
    assert(init_defaults());
    printf(done, routine);
}
Exemplo n.º 21
0
//---------------------------------------------------------------------------//
Schema::Schema(const char *json_schema)
{
    init_defaults();
    set(std::string(json_schema));
}
Exemplo n.º 22
0
/** Loads the stk configuration file. After loading it checks if all necessary
 *  values are actually defined, otherwise an error message is printed and STK
 *  is aborted.
 *  /param filename Name of the configuration file to load.
 */
void STKConfig::load(const std::string &filename)
{
    // Avoid loading the default config file if a user-specific
    // config file has already been loaded.
    if(m_has_been_loaded) return;
    m_has_been_loaded = true;

    init_defaults();

    XMLNode *root = 0;
    try
    {
        root = new XMLNode(filename);
        if(!root || root->getName()!="config")
        {
            if(root) delete root;
            std::ostringstream msg;
            msg << "Couldn't load config '" << filename << "': no config node.";
            throw std::runtime_error(msg.str());
        }
        getAllData(root);
    }

    catch(std::exception& err)
    {
        Log::error("StkConfig", "FATAL ERROR while reading '%s':", filename.c_str());
        Log::fatal("StkConfig", "    %s", err.what());
    }
    delete root;

    // Check that all necessary values are indeed set
    // -----------------------------------------------

#define CHECK_NEG(  a,strA) if(a<=UNDEFINED) {                   \
        Log::fatal("StkConfig", "Missing default value for '%s' in '%s'.",    \
                   strA,filename.c_str());              \
    }

    if(m_score_increase.size()==0 || (int)m_score_increase.size()!=m_max_karts)
    {
        Log::fatal("StkConfig", "Not or not enough scores defined in stk_config");
    }
    if(m_leader_intervals.size()==0)
    {
        Log::fatal("StkConfig", "No follow leader interval(s) defined in stk_config");
    }

    if(m_switch_items.size()!=Item::ITEM_LAST-Item::ITEM_FIRST+1)
    {
        Log::fatal("StkConfig", "Wrong number of item switches defined in stk_config");
    }

    CHECK_NEG(m_max_karts,                 "<karts max=..."             );
    CHECK_NEG(m_item_switch_time,          "item-switch-time"           );
    CHECK_NEG(m_bubblegum_counter,         "bubblegum disappear counter");
    CHECK_NEG(m_explosion_impulse_objects, "explosion-impulse-objects"  );
    CHECK_NEG(m_max_skidmarks,             "max-skidmarks"              );
    CHECK_NEG(m_min_kart_version,          "<kart-version min...>"      );
    CHECK_NEG(m_max_kart_version,          "<kart-version max=...>"     );
    CHECK_NEG(m_min_track_version,         "min-track-version"          );
    CHECK_NEG(m_max_track_version,         "max-track-version"          );
    CHECK_NEG(m_skid_fadeout_time,         "skid-fadeout-time"          );
    CHECK_NEG(m_near_ground,               "near-ground"                );
    CHECK_NEG(m_delay_finish_time,         "delay-finish-time"          );
    CHECK_NEG(m_music_credit_time,         "music-credit-time"          );
    CHECK_NEG(m_leader_time_per_kart,      "leader time-per-kart"       );
    CHECK_NEG(m_penalty_time,              "penalty-time"               );
    CHECK_NEG(m_max_display_news,          "max-display-news"           );
    CHECK_NEG(m_replay_max_time,           "replay max-time"            );
    CHECK_NEG(m_replay_delta_angle,        "replay delta-angle"         );
    CHECK_NEG(m_replay_delta_pos2,         "replay delta-position"      );
    CHECK_NEG(m_replay_dt,                 "replay delta-t"             );
    CHECK_NEG(m_smooth_angle_limit,        "physics smooth-angle-limit" );

    // Square distance to make distance checks cheaper (no sqrt)
    m_replay_delta_pos2 *= m_replay_delta_pos2;
    m_default_kart_properties->checkAllSet(filename);
}   // load
Exemplo n.º 23
0
//---------------------------------------------------------------------------//
Schema::Schema()
{
    init_defaults();
}
Exemplo n.º 24
0
int main(int argc, char *argv[])
{
	int c, r;
	extern int yynerrs;
	extern FILE *yyin;
	const char *args = "c:hndv";
	char *cfg_file = NULL;
	FILE *f;
	pthread_t reload_thr;
	rmilter_pidfh_t *pfh = NULL;
	pid_t pid;

	daemonize = 1;

	/* Process command line options */
	while ((c = getopt (argc, argv, args)) != -1) {
		switch (c) {
		case 'c':
			if (optarg == NULL || *optarg == '\0') {
				fprintf (stderr, "Illegal config_file: %s\n", optarg);
				exit (EX_USAGE);
			}
			else {
				cfg_file = strdup (optarg);
			}
			break;
		case 'n':
			daemonize = 0;
			break;
		case 'd':
			yydebug = 1;
			break;
		case 'v':
			version ();
			break;
		case 'h':
		default:
			usage ();
			break;
		}
	}

	openlog ("rmilter.startup", LOG_PID, LOG_MAIL);

	cfg = (struct config_file*) malloc (sizeof(struct config_file));
	if (cfg == NULL) {
		msg_warn("malloc: %s", strerror (errno));
		return -1;
	}
	bzero (cfg, sizeof(struct config_file));
	init_defaults (cfg);

	if (cfg_file == NULL) {
		cfg_file = strdup ("/usr/local/etc/rmilter.conf");
	}

	f = fopen (cfg_file, "r");
	if (f == NULL) {
		msg_warn("cannot open file: %s", cfg_file);
		return EBADF;
	}
	yyin = f;

	yyrestart (yyin);

	if (yyparse () != 0 || yynerrs > 0) {
		msg_warn("yyparse: cannot parse config file, %d errors", yynerrs);
		return EBADF;
	}

	closelog ();
	openlog (cfg->syslog_name, LOG_PID, LOG_MAIL);

	if (!cfg->cache_use_redis) {
		msg_warn("rmilter is configured to work with legacy memcached cache,"
				" please consider switching to redis by adding "
				"'use_redis = true;' into configuration");
	}

	fclose (f);

	if (argv[0] && strrchr (argv[0], '/') != NULL) {
		_rmilter_progname = strrchr (argv[0], '/') + 1;
	}
	else {
		_rmilter_progname = argv[0];
	}

	cfg->cfg_name = strdup (cfg_file);

	/* Strictly set temp dir */
	if (!cfg->temp_dir) {
		msg_warn("tempdir is not set, trying to use $TMPDIR");
		cfg->temp_dir = getenv ("TMPDIR");

		if (!cfg->temp_dir) {
			cfg->temp_dir = strdup ("/tmp");
		}
	}
	if (cfg->sizelimit == 0) {
		msg_warn("maxsize is not set, no limits on size of scanned mail");
	}

#ifdef HAVE_SRANDOMDEV
	srandomdev();
#else
	srand (time (NULL));
#endif

	umask (0);
	rng_state = get_prng_state ();

	smfi_setconn (cfg->sock_cred);
	if (smfi_register (smfilter) == MI_FAILURE) {
		msg_err("smfi_register failed");
		exit (EX_UNAVAILABLE);
	}

	if (smfi_opensocket (true) == MI_FAILURE) {
		msg_err("Unable to open listening socket");
		exit (EX_UNAVAILABLE);
	}

	if (daemonize && daemon (0, 0) == -1) {
		msg_err("Unable to daemonize");
		exit (EX_UNAVAILABLE);
	}

	msg_info("main: starting rmilter version %s, listen on %s", MVERSION,
			cfg->sock_cred);

	if (pthread_create (&reload_thr, NULL, reload_thread, NULL)) {
		msg_warn("main: cannot start reload thread, ignoring error");
	}

	if (cfg->pid_file) {
		pfh = rmilter_pidfile_open (cfg->pid_file, 0644, &pid);

		if (pfh == NULL) {
			msg_err("Unable to open pidfile %s", cfg->pid_file);
			exit (EX_UNAVAILABLE);
		}

		rmilter_pidfile_write (pfh);
	}

	r = smfi_main ();

	if (cfg_file != NULL)
		free (cfg_file);

	if (pfh) {
		rmilter_pidfile_close (pfh);
	}

	return r;
}
Exemplo n.º 25
0
int main(int argc, char **argv)
{
  init_defaults();

  while (1) {
    int index, c = 0;

    c = getopt_long(argc, argv, short_options, long_options, &index);

    if (c == -1)
      break;

    switch (c) {
    case 0:
      break;

    case 'd':
      free(device_name);
      device_name = optarg;
      break;

    case 'W':
      v_width = atoi(optarg);
      break;

    case 'H':
      v_height = atoi(optarg);
      break;

    case 'c':
      num_frames = atoi(optarg);
      break;

    case 'f':
      framerate = atoi(optarg);
      break;

    case 'j':
      use_jpeg_header_boundry = true;
    break;

    case 'o':
      output = OUTPUT_STDOUT;
    break;

    default:
      usage(stderr, argc, argv);
      exit(EXIT_FAILURE);
    }

  }

  if ( io == IO_METHOD_USERPTR ) {
    fprintf(stderr, "IO_METHOD_USERPTR not supported yet, using MMAP instead");
    io = IO_METHOD_MMAP;
  }


  device_open();
  init_device();
  start_capturing();
 
  capture_loop();
 
  stop_capturing();
  uninit_device();
  device_close();

  return 0;
}
Exemplo n.º 26
0
int main(int argc, char* argv[])
{
	init_defaults(argc, argv);
	return stream();
}