scc

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

coff32probe.c (334B)


      1 #include <stdio.h>
      2 
      3 #include <scc/mach.h>
      4 
      5 #include "../libmach.h"
      6 #include "coff32.h"
      7 
      8 int
      9 coff32probe(unsigned char *buf, char **name)
     10 {
     11 	struct arch *ap;
     12 
     13 	for (ap = coff32archs; ap->name; ap++) {
     14 		if (ap->magic[0] == buf[0] && ap->magic[1] == buf[1]) {
     15 			if (name)
     16 				*name = ap->name;
     17 			return ap->type;
     18 		}
     19 	}
     20 	return -1;
     21 }