comparison ticoff/main.c @ 70:6799a5c57a49

tiobjd started
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sat, 22 Mar 2014 02:29:22 +0000
parents
children c15cd3d695c0
comparison
equal deleted inserted replaced
69:10de8a00c519 70:6799a5c57a49
1 /*
2 * tiobjd main() function and command dispatch
3 */
4
5 #include <sys/types.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <strings.h>
10 #include "filestruct.h"
11 #include "globals.h"
12
13 extern int dump_filehdr_info();
14
15 static struct cmdtab {
16 char *cmd;
17 int (*func)();
18 } cmdtab[] = {
19 {"hdr", dump_filehdr_info},
20 {0, 0}
21 };
22
23 main(argc, argv)
24 char **argv;
25 {
26 struct cmdtab *tp;
27
28 if (argc != 3) {
29 fprintf(stderr, "usage: %s <objfile> <op>\n", argv[0]);
30 exit(1);
31 }
32 objfilename = argv[1];
33 mmap_objfile();
34 initial_parse_hdr();
35 for (tp = cmdtab; tp->cmd; tp++)
36 if (!strcmp(tp->cmd, argv[2]))
37 break;
38 if (!tp->func) {
39 fprintf(stderr, "\"%s\": unknown or unimplemented command\n",
40 argv[2]);
41 exit(1);
42 }
43 return tp->func();
44 }