scc

A fork of https://git.simple-cc.org/scc/ for Qute

git clone https://git.8pit.net/scc.git

 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
11static int (*ops[NFORMATS])(int, long, char **, long *, FILE *);
12
13static int
14setidx(int type, long nsymbols, char *names[], long offs[], FILE *fp)
15{
16	return setidx32(BIG_ENDIAN, nsymbols, names, offs, fp);
17}
18
19int
20setindex(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
33static int (*ops[NFORMATS])(int, long, char **, long *, FILE *) = {
34	[COFF32] = setidx,
35	[ELF] = setidx,
36};