int configure(map_config_t* config, int argc, char** argv) { int ch; static struct option longopts[] = { {"read", no_argument, NULL, 'r'}, {"create", no_argument, NULL, 'c'}, {"print", no_argument, NULL, 'p'}, {"output", required_argument, NULL, 'o'}, {"level", required_argument, NULL, 'l'}, {NULL, 0, NULL, 0} }; /* DEFAULTS */ config->level.x = 0; config->level.y = 0; config->level.t = 0; config->ot = OT_CREATE; config->print = FALSE; strcpy(config->outfile, "output.map"); while((ch = getopt_long(argc, argv, "rcpo:l:", longopts, NULL)) != -1) { switch(ch) { case 'r': config->ot = OT_READ; break; case 'c': config->ot = OT_CREATE; break; case 'o': strncpy(config->outfile, optarg, sizeof(config->outfile) - 1); break; case 'l': config->level = extract_level(optarg); break; case 'p': config->print = TRUE; break; default: usage(); } } argc -= optind; argv += optind; if(argc == 0) { printf("Input file name missing.\n"); usage(); } strncpy(config->infile, argv[0], sizeof(config->infile) - 1); return 0; }
static bool enabled(int tag) { ErgoLevel level = extract_level(tag); ErgoHeuristic n = extract_heuristic(tag); return level <= _level && _enabled[n]; }
int init_act_vect (FILE * fp, PlanAction ** plan_actions, int start_level) { float start_time; char Str[MAX_LENGTH]; char opname[MAX_LENGTH]; char operands[MAX_ARITY][MAX_LENGTH]; float duration; int num_operands = 0; int act_pos; int index_of_arg[MAX_ARITY]; char *cStr, *ptchr; int i; int level = 0; Bool no_dur; printf ("\n Load input plan:\n"); while (!feof (fp)) { cStr = Str; fgets (cStr, MAX_LENGTH, fp); for (i = 0; i < MAX_LENGTH; i++) cStr[i] = toupper (cStr[i]); if ((cStr[0] == ';') || (cStr[0] == '\n') || (cStr[0] == '\0')) continue; num_operands = 0; start_time = extract_level (cStr); cStr = strchr (cStr, ':'); if (cStr == NULL) continue; cStr++; while (TRUE) { if ((cStr[0] == '(') || (cStr[0] == ' ')) { cStr++; continue; } if (cStr[0] == '\0') { printf ("init_act_vect: opname not found (not even '(' )\n"); exit (1); } break; } sscanf (cStr, "%s", opname); if (strlen (opname) == 0) { printf ("init_act_vect: opname not found\n"); exit (1); } cStr += strlen (opname); while (TRUE) { if (cStr[0] == ' ') { cStr++; continue; } break; } while (TRUE) { sscanf (cStr, "%s", operands[num_operands]); for (i = 0; i < strlen (operands[num_operands]); i++) if (operands[num_operands][i] == ')') { operands[num_operands][i] = '\0'; break; } if (strlen (operands[num_operands]) == 0) { printf ("init_act_vect: ')' not found\n"); exit (1); } index_of_arg[num_operands] = get_index_of_constant (operands[num_operands]); if (index_of_arg[num_operands] == -1) { printf ("\n\nArg not found in constants table!\n\n"); exit (1); } cStr += strlen (operands[num_operands]); num_operands++; while (TRUE) { if (cStr[0] == ' ') { cStr++; continue; } break; } if (cStr[0] == ')') break; } no_dur = FALSE; while (TRUE) { if (cStr[0] == '\0') { no_dur = TRUE; break; } if (cStr[0] != '[') { cStr++; continue; } break; } cStr++; for (ptchr = cStr;; ptchr++) { if (ptchr[0] == ']') { ptchr[0] = '\0'; break; } if (ptchr[0] == '\0') { no_dur = TRUE; break; } } if (no_dur == TRUE) duration = 1; else duration = atof (cStr); act_pos = get_action_index (opname, index_of_arg); if (act_pos == -1) { printf ("\n\naction not found in gef_conns\n\n"); } if (act_pos != -1) { store_action_vect (plan_actions, act_pos, start_time, duration); level++; } } { PlanAction *p; printf ("\n"); for (p = *plan_actions; p; p = p->next) { printf ("\n"); printf ("%5.2f: (", p->start_time); print_op_name (p->act_pos); printf (") [%5.2f ]", p->duration); } printf ("\n\n"); } return level; }