view ticoff/main.c @ 75:1a23ff9a81de

tiobjd: dumpsym implemented
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Tue, 25 Mar 2014 20:38:31 +0000
parents c15cd3d695c0
children 590396e27e96
line wrap: on
line source

/*
 * tiobjd main() function and command dispatch
 */

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include "globals.h"

extern int cmd_dumpsym();
extern int cmd_sechdr();
extern int dump_filehdr_info();

static struct cmdtab {
	char	*cmd;
	int	(*func)();
} cmdtab[] = {
	{"dumpsym", cmd_dumpsym},
	{"hdr", dump_filehdr_info},
	{"sechdr", cmd_sechdr},
	{0, 0}
};

main(argc, argv)
	char **argv;
{
	struct cmdtab *tp;

	if (argc != 3) {
		fprintf(stderr, "usage: %s <objfile> <op>\n", argv[0]);
		exit(1);
	}
	objfilename = argv[1];
	mmap_objfile();
	initial_parse_hdr();
	for (tp = cmdtab; tp->cmd; tp++)
		if (!strcmp(tp->cmd, argv[2]))
			break;
	if (!tp->func) {
		fprintf(stderr, "\"%s\": unknown or unimplemented command\n",
			argv[2]);
		exit(1);
	}
	return tp->func();
}