Ejemplo n.º 1
0
/* MAIN */
int main( int argc, char ** argv ) {
	struct opdis_options opts = {0}; // TODO: defaults
	struct job_options_t job_opts;

	set_defaults( &opts );

	argp_parse( &argp_cfg, argc, argv, 0, 0, &opts );

	if ( opts.list_arch ) {
		list_arch();
		return 0;
	}

	if ( opts.list_disasm_opt ) {
		list_disasm_opts();
		return 0;
	}

	if ( opts.list_syntax ) {
		list_syntax();
		return 0;
	}

	if ( opts.list_format ) {
		list_format();
		return 0;
	}

	if (! opts.jobs->num_items ) {
		/* if no jobs were requested, do a linear disasm of all */
		int i;
		for ( i = 0; i < opts.targets->num_items; i++ ) {
			job_list_add( opts.jobs, job_linear, "(default)", 
				      i + 1, 0, OPDIS_INVALID_ADDR, 0 );
		}
	}

	load_bfd_targets( & opts );

	if ( opts.dry_run ) {
		dry_run( & opts );
		return 0;
	}

	if (! opts.targets->num_items ) {
		fprintf( stderr, "No targets specified! Use -? for help.\n" );
		return 1;
	}

	configure_opdis( & opts );
	set_job_opts( &opts, &job_opts );
	job_list_perform_all( opts.jobs, &job_opts );

	output_disassembly( & opts );

	return 0;
}
Ejemplo n.º 2
0
/* Send list of registered commands to the given user. */
void command_send_list(User *user)
{
	int	i;
	Command	*cmd;

	if(user == NULL)
		return;
	for(i = 0; (cmd = qsarr_index(CmdInfo.commands, i)) != NULL; i++)
	{
		const char	*list = list_format(cmd);
		if(list != NULL)
			user_hear(user, "", NULL, list);
		else
			fprintf(stderr, "Can't list command '%s', too long\n", cmd->name);
	}
}