Ejemplo n.º 1
0
/****************************************************************************
 * parse_nvramtool_args
 *
 * Parse command line arguments.
 ****************************************************************************/
void parse_nvramtool_args(int argc, char *argv[])
{
	nvramtool_op_modifier_info_t *mod_info;
	int i, op_found;
	char c;

	for (i = 0, mod_info = nvramtool_op_modifiers;
	     i < NVRAMTOOL_NUM_OP_MODIFIERS; i++, mod_info++) {
		mod_info->found = FALSE;
		mod_info->found_seq = 0;
		mod_info->param = NULL;
	}

	op_found = FALSE;
	opterr = 0;

	do {
		switch (c = getopt(argc, argv, getopt_string)) {
		case 'a':
			register_op(&op_found,
				    NVRAMTOOL_OP_CMOS_SHOW_ALL_PARAMS, NULL);
			break;
		case 'b':
			register_op(&op_found, NVRAMTOOL_OP_WRITE_CMOS_DUMP,
				    optarg);
			break;
		case 'B':
			register_op(&op_found, NVRAMTOOL_OP_READ_CMOS_DUMP,
				    optarg);
			break;
		case 'c':
			register_op(&op_found, NVRAMTOOL_OP_CMOS_CHECKSUM,
				    handle_optional_arg(argc, argv));
			break;
		case 'd':
			register_op(&op_found, NVRAMTOOL_OP_LBTABLE_DUMP, NULL);
			break;
		case 'e':
			register_op(&op_found, NVRAMTOOL_OP_SHOW_PARAM_VALUES,
				    optarg);
			break;
		case 'h':
			register_op(&op_found, NVRAMTOOL_OP_SHOW_USAGE, NULL);
			break;
		case 'i':
			register_op(&op_found,
				    NVRAMTOOL_OP_CMOS_SET_PARAMS_STDIN, NULL);
			break;
		case 'l':
			register_op(&op_found, NVRAMTOOL_OP_LBTABLE_SHOW_INFO,
				    handle_optional_arg(argc, argv));
			break;
		case 'n':
			register_op_modifier(NVRAMTOOL_MOD_SHOW_VALUE_ONLY,
					     NULL);
			break;
		case 'p':
			register_op(&op_found,
				    NVRAMTOOL_OP_CMOS_SET_PARAMS_FILE, optarg);
			break;
		case 'r':
			register_op(&op_found, NVRAMTOOL_OP_CMOS_SHOW_ONE_PARAM,
				    optarg);
			break;
		case 't':
			register_op_modifier(NVRAMTOOL_MOD_USE_CMOS_OPT_TABLE,
					     NULL);
			break;
		case 'v':
			register_op(&op_found, NVRAMTOOL_OP_SHOW_VERSION, NULL);
			break;
		case 'w':
			register_op(&op_found, NVRAMTOOL_OP_CMOS_SET_ONE_PARAM,
				    optarg);
			break;
		case 'x':
			register_op(&op_found, NVRAMTOOL_OP_SHOW_CMOS_HEX_DUMP,
				    NULL);
			break;
		case 'X':
			register_op(&op_found, NVRAMTOOL_OP_SHOW_CMOS_DUMPFILE,
				    optarg);
			break;
		case 'y':
			register_op_modifier(NVRAMTOOL_MOD_USE_CMOS_LAYOUT_FILE,
					     optarg);
			break;
		case 'Y':
			register_op(&op_found, NVRAMTOOL_OP_SHOW_LAYOUT, NULL);
			break;
		case -1:	/* no more command line args */
			break;
		case '?':	/* unknown option found */
		case 1:	/* nonoption command line arg found */
		default:
			usage(stderr);
			break;
		}
	} while (c != -1);

	if (!op_found)
		usage(stderr);

	resolve_op_modifiers();
	sanity_check_args();
}
Ejemplo n.º 2
0
void cibyl_fops_register(const char *uri, cibyl_fops_t *fop, int is_default)
{
  register_op(&fops, uri, fop, is_default);
}
Ejemplo n.º 3
0
void cibyl_dops_register(const char *uri, cibyl_dops_t *dop, int is_default)
{
  /* OK. Pretty ugly, but what the heck... */
  register_op((void*)&dops,
              uri, (cibyl_fops_t*)dop, is_default);
}
Ejemplo n.º 4
0
// for constructing operations
int profiler::curr_opcode = 0;
int profiler::register_op(char* name) {
    assert(curr_opcode < NUM_OPCODES()); // increase NUM_OPCODES if fails
    int result = curr_opcode++;
    OP_TO_NAME[result] = name;
    return result;
}

// initialized by set_num_ids
int* profiler::id_counts;
int profiler::num_ids;

// the names of these fields should match those targetted from the
// compiler
int profiler::BINOP_ADD =       register_op("add");
int profiler::BINOP_SUB =       register_op("sub");
int profiler::BINOP_MUL =       register_op("mul");
int profiler::BINOP_DIV =       register_op("div");
int profiler::BINOP_MOD =       register_op("mod");
int profiler::BINOP_AND =       register_op("and");
int profiler::BINOP_OR =        register_op("or");
int profiler::BINOP_EQ =        register_op("eq");
int profiler::BINOP_NEQ =       register_op("neq");
int profiler::BINOP_LT =        register_op("lt");
int profiler::BINOP_LE =        register_op("le");
int profiler::BINOP_GT =        register_op("gt");
int profiler::BINOP_GE =        register_op("ge");
// These are bitwise AND/OR/XOR:
int profiler::BINOP_BAND =      register_op("band");
int profiler::BINOP_BOR =       register_op("bor");