Пример #1
0
Файл: main.c Проект: rpreen/xcsf
int main(int argc, char *argv[0])
{    
	if(argc < 2 || argc > 4) {
		printf("Usage: xcsf inputfile [MaxTrials] [NumExp]\n");
		exit(EXIT_FAILURE);
	} 

	// initialise environment
	constants_init(argc, argv);
	random_init();
	func_init(argv[1]);
	gen_outfname(argv[1]);

	// run experiments
	double err[PERF_AVG_TRIALS];
	double terr[PERF_AVG_TRIALS];
	for(int e = 1; e < NUM_EXPERIMENTS+1; e++) {
		printf("\nExperiment: %d\n", e);
		pop_init();
		outfile_init(e);
		// each trial in an experiment
		for(int cnt = 0; cnt < MAX_TRIALS; cnt++) {
			trial(cnt, true, err); // train
			trial(cnt, false, terr);// test
			// display performance
			if(cnt%PERF_AVG_TRIALS == 0 && cnt > 0)
				disp_perf(err, terr, cnt, pop_num);
		}
		// clean up
		set_kill(&pset);
		outfile_close();
	}
	func_free();
	return EXIT_SUCCESS;
}
Пример #2
0
int exec_open( NAME_LIST *fnames, Elf32_Half machine,
               int code_size, int data_size )
{
    if (!fnames)
    {
        yyerror("No output file specified");
    }
    else if (fnames->next)
    {
        yyerror("Multiple output files specified");
    }
    else if (elf_version(EV_CURRENT) == EV_NONE)
    {
        yyerror( "Elf library is out of date" );
    }
    else
    {
        outfile_init( fnames->name, machine, TRUE,
                      code_size, data_size );
        out_file_machine = machine;
        out_file_name = strdup( fnames->name );
        if ( !fixup_code_map( machine, &fixup_code ) )
        {
            yyerror( "Relocations for this machine type are not supported" );
            return FALSE;
        }
        return TRUE;
    }
    return FALSE;
}
Пример #3
0
int hashcat_session_init (hashcat_ctx_t *hashcat_ctx, const char *install_folder, const char *shared_folder, int argc, char **argv, const int comptime)
{
  user_options_t *user_options = hashcat_ctx->user_options;

  /**
   * make it a bit more comfortable to use some of the special modes in hashcat
   */

  user_options_session_auto (hashcat_ctx);

  /**
   * event init (needed for logging so should be first)
   */

  const int rc_event_init = event_ctx_init (hashcat_ctx);

  if (rc_event_init == -1) return -1;

  /**
   * status init
   */

  const int rc_status_init = status_ctx_init (hashcat_ctx);

  if (rc_status_init == -1) return -1;

  /**
   * folder
   */

  const int rc_folder_config_init = folder_config_init (hashcat_ctx, install_folder, shared_folder);

  if (rc_folder_config_init == -1) return -1;

  /**
   * pidfile
   */

  const int rc_pidfile_init = pidfile_ctx_init (hashcat_ctx);

  if (rc_pidfile_init == -1) return -1;

  /**
   * restore
   */

  const int rc_restore_init = restore_ctx_init (hashcat_ctx, argc, argv);

  if (rc_restore_init == -1) return -1;

  /**
   * process user input
   */

  user_options_preprocess (hashcat_ctx);

  user_options_extra_init (hashcat_ctx);

  user_options_postprocess (hashcat_ctx);

  /**
   * logfile
   */

  const int rc_logfile_init = logfile_init (hashcat_ctx);

  if (rc_logfile_init == -1) return -1;

  /**
   * cpu affinity
   */

  const int rc_affinity = set_cpu_affinity (hashcat_ctx);

  if (rc_affinity == -1) return -1;

  /**
   * prepare seeding for random number generator, required by logfile and rules generator
   */

  setup_seeding (user_options->rp_gen_seed_chgd, user_options->rp_gen_seed);

  /**
   * To help users a bit
   */

  setup_environment_variables ();

  setup_umask ();

  /**
   * tuning db
   */

  const int rc_tuning_db = tuning_db_init (hashcat_ctx);

  if (rc_tuning_db == -1) return -1;

  /**
   * induction directory
   */

  const int rc_induct_ctx_init = induct_ctx_init (hashcat_ctx);

  if (rc_induct_ctx_init == -1) return -1;

  /**
   * outfile-check directory
   */

  const int rc_outcheck_ctx_init = outcheck_ctx_init (hashcat_ctx);

  if (rc_outcheck_ctx_init == -1) return -1;

  /**
   * outfile itself
   */

  const int rc_outfile_init = outfile_init (hashcat_ctx);

  if (rc_outfile_init == -1) return -1;

  /**
   * potfile init
   * this is only setting path because potfile can be used in read and write mode depending on user options
   * plus it depends on hash_mode, so we continue using it in outer_loop
   */

  const int rc_potfile_init = potfile_init (hashcat_ctx);

  if (rc_potfile_init == -1) return -1;

  /**
   * dictstat init
   */

  const int rc_dictstat_init = dictstat_init (hashcat_ctx);

  if (rc_dictstat_init == -1) return -1;

  /**
   * loopback init
   */

  const int rc_loopback_init = loopback_init (hashcat_ctx);

  if (rc_loopback_init == -1) return -1;

  /**
   * debugfile init
   */

  const int rc_debugfile_init = debugfile_init (hashcat_ctx);

  if (rc_debugfile_init == -1) return -1;

  /**
   * Try to detect if all the files we're going to use are accessible in the mode we want them
   */

  const int rc_user_options_check_files = user_options_check_files (hashcat_ctx);

  if (rc_user_options_check_files == -1) return -1;

  /**
   * Init OpenCL library loader
   */

  const int rc_opencl_init = opencl_ctx_init (hashcat_ctx);

  if (rc_opencl_init == -1) return -1;

  /**
   * Init OpenCL devices
   */

  const int rc_devices_init = opencl_ctx_devices_init (hashcat_ctx, comptime);

  if (rc_devices_init == -1) return -1;

  /**
   * HM devices: init
   */

  const int rc_hwmon_init = hwmon_ctx_init (hashcat_ctx);

  if (rc_hwmon_init == -1) return -1;

  // done

  return 0;
}