scc

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

setindex.c (665B)


      1 #include <errno.h>
      2 #include <stdio.h>
      3 
      4 #include <scc/mach.h>
      5 
      6 #include "libmach.h"
      7 
      8 #include "elf/fun.h"
      9 #include "coff32/fun.h"
     10 
     11 static int (*ops[NFORMATS])(int, long, char **, long *, FILE *);
     12 
     13 static int
     14 setidx(int type, long nsymbols, char *names[], long offs[], FILE *fp)
     15 {
     16 	return setidx32(BIG_ENDIAN, nsymbols, names, offs, fp);
     17 }
     18 
     19 int
     20 setindex(int type, long nsyms, char **names, long *offs, FILE *fp)
     21 {
     22 	int fmt;
     23 
     24 	fmt = FORMAT(type);
     25 	if (fmt >= NFORMATS) {
     26 		errno = ERANGE;
     27 		return -1;
     28 	}
     29 
     30 	return (*ops[fmt])(type, nsyms, names, offs, fp);
     31 }
     32 
     33 static int (*ops[NFORMATS])(int, long, char **, long *, FILE *) = {
     34 	[COFF32] = setidx,
     35 	[ELF] = setidx,
     36 };