scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

objdump.c (854B)


      1 #include <errno.h>
      2 #include <stdarg.h>
      3 #include <stdio.h>
      4 #include <stdlib.h>
      5 #include <string.h>
      6 
      7 #include <scc/arg.h>
      8 #include <scc/mach.h>
      9 
     10 char *argv0;
     11 static char *filename;
     12 static int status;
     13 
     14 static void
     15 error(char *fmt, ...)
     16 {
     17 	va_list va;
     18 
     19 	va_start(va, fmt);
     20 	fprintf(stderr, "objdump: %s: ", filename);
     21 	vfprintf(stderr, fmt, va);
     22 	putc('\n', stderr);
     23 	va_end(va);
     24 
     25 	status = EXIT_FAILURE;
     26 }
     27 
     28 static void
     29 dump(char *fname)
     30 {
     31 	/* TODO */
     32 }
     33 
     34 static void
     35 usage(void)
     36 {
     37 	fputs("usage: objdump file ...\n", stderr);
     38 	exit(1);
     39 }
     40 
     41 int
     42 main(int argc, char *argv[])
     43 {
     44 	ARGBEGIN {
     45 	default:
     46 		usage();
     47 	} ARGEND
     48 
     49 	if (argc == 0)
     50 		dump("a.out");
     51 	else while (*argv) {
     52 		dump(*argv++);
     53 	}
     54 
     55 	if (fclose(stdout) == EOF) {
     56 		fprintf(stderr,
     57 		        "objdump: writing output: %s\n",
     58 		        strerror(errno));
     59 		return EXIT_FAILURE;
     60 	}
     61 
     62 	return status;
     63 }