entier LataOptions::parse_option(const Nom & s)
{
  if (s.debute_par("verbosity=")) {
    entier level = read_int_opt(s);
    set_Journal_level(level);
  } else if (s.debute_par("regularize=")) {
    regularize = true;
    regularize_tolerance = read_float_opt(s);
  } else if (s.debute_par("regularize_polyedre=")) {
    regularize_polyedre = read_int_opt(s);
  } else if (s.debute_par("extend_domain=")) {
    extend_domain = read_int_opt(s);
  } else if (s == "invalidate") {
    invalidate = true;
  } else if (s.debute_par("reconnect=")) {
    reconnect = true;
    reconnect_tolerance = read_float_opt(s);   
  } else if (s.debute_par("reconnect_tolerance=")) {
    reconnect_tolerance = read_float_opt(s);   
  } else if (s == "dualmesh") {
    dual_mesh = true;
  } else if (s == "nodualmesh") {
    dual_mesh = false;
  } else if (s == "ncmesh") {
    nc_mesh = true;
  } else if (s == "facesmesh") {
    faces_mesh = true;
  } else if (s == "nofacesmesh") {
    faces_mesh = false;
  } else if (s == "boundarymesh") {
    boundary_mesh = true;
  } else if (s.debute_par("clipbox=")) {
    Noms list = extract_list(((const char*)s)+8);
    if (list.size() != 6) {
      Journal() << "Error : clipbox parameters expects 6 values" << endl;
      throw;
    }
    for (entier i = 0; i < 3; i++) {
      clipbox_min[i] = read_float_opt(list[i]);
      clipbox_max[i] = read_float_opt(list[i+3]);
    }
  } else if (s == "load_virtual_elements") {
    load_virtual_elements = true;
  } else if (s == "user_fields") {
    user_fields_ = true;
    Journal() << "Option: User_fields ON" << endl;
  } else if (s.debute_par("ijk_mesh_nb_parts")) {
    ijk_mesh_nb_parts_ = read_int_opt(s);
  } else if (s == "export_fields_at_faces") {
    export_fields_at_faces_ = 1;
  } else if (s.debute_par("ijk_virt_layer=")) {
    ijk_virt_layer = read_int_opt(s);
  } else
    return user_fields_options_.parse_option(s);;
  return 1;
}
Ejemplo n.º 2
0
/**
	maybe_setup
	Creates the ~/.freenote/probe.team file, based on user input.
	Assumes that we are /not/ daemonized yet.
	Returns 0 for success (i.e., successful setup -or- the probe has
	already been set up), -1 for failure (ex., couldn't write to the file).
*/
int maybe_setup()
{
	fm_init_base();
	if(read_str_opt("auto-setup")) {
		return set_teamstring(read_str_opt("auto-setup"));
	}
	if(read_int_opt("setup") || 
		!(fm_exists(FM_TEAM_INFO) || read_int_opt("no-tokens"))) {
		try(do_setup());
		p_exit(PEXIT_NORMAL);
	}
	return 0;
}

/*
	do_setup
	Does the setup.  Returns 0 for success, -1 for failure.
	It doesn't use io_* because it's interactive.
*/
static int do_setup()
{
	char	team[TEAM_MAXLEN],
		pin[PIN_MAXLEN],
		*tmp = fm_abs(FM_TEAM_INFO);
	int	r;

	//  It's a little long.
	printf(	"FreeNote Probe Setup:\n"
		"Please follow the on-screen instructions.\n"
		"\n"
		"If you do not have a team, you can visit http://freenote."
		"petta-tech.com\nto register.\n"
		"If you don't want to register, you can run the probe with"
		"the\n'--no-tokens'/'-n' option, "
		"or add 'no-tokens' to ~/.freenote/rc.\n"
		"Please enter your team name:  ");
	fgets(team, TEAM_MAXLEN, stdin);
	chomp(team);
	printf("Please enter your team's pin code:  ");
	fgets(pin, PIN_MAXLEN, stdin);
	chomp(pin);
	printf("Writing the information to %s...\n", tmp);
	r = set_team_info(team, pin);
	try(r);
	printf("Ready to roll!  Run the probe again, without --setup.\n");

	return r;
}

/**
	set_team_info
	Generates ~/.freenote/probe.team from the two arguments (the team
	name and the pin code).  Returns 0 for success, -1 for failure.
*/
int set_team_info(const char *team_name, const char *pin_code)
{
	// strlen("team_name:", ";\n", "pin_code:", ";\n\0") = 24
	char buffer[TEAM_MAXLEN + PIN_MAXLEN + 24];

	sprintf(buffer, "team_name:%s;\npin_code:%s;\n", team_name, pin_code);
	return fm_write(FM_TEAM_INFO, buffer, strlen(buffer)) - 1;
}