scc

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

objtype.c (360B)


      1 #include <stdio.h>
      2 
      3 #include <scc/mach.h>
      4 
      5 #include "libmach.h"
      6 
      7 #include "elf/fun.h"
      8 #include "coff32/fun.h"
      9 
     10 static int (*ops[NFORMATS])(char *) = {
     11 	[COFF32] = coff32type,
     12 	[ELF] = elftype,
     13 };
     14 
     15 int
     16 objtype(char *name)
     17 {
     18 	int t;
     19 	int (**bp)(char *);
     20 
     21 	for (bp = ops; bp < &ops[NFORMATS]; ++bp) {
     22 		if ((t = (**bp)(name)) >= 0)
     23 			return t;
     24 	}
     25 
     26 	return -1;
     27 }