coff32xsetidx.c - scc - simple c99 compiler
(HTM) git clone git://git.simple-cc.org/scc
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Submodules
(DIR) README
(DIR) LICENSE
---
coff32xsetidx.c (555B)
---
1 #include <stdio.h>
2 #include <string.h>
3
4 #include <scc/mach.h>
5
6 #include "../libmach.h"
7 #include "fun.h"
8
9 int
10 coff32xsetidx(int order, long nsyms, char *names[], long offs[], FILE *fp)
11 {
12 long i, n;
13 size_t len;
14 unsigned char buff[4];
15
16 pack(order, buff, "l", nsyms);
17 fwrite(buff, 4, 1, fp);
18 n = 4;
19
20 for (i = 0; i < nsyms; i++) {
21 pack(order, buff, "l", offs[i]);
22 fwrite(buff, 4, 1, fp);
23 n += 4;
24 }
25
26 for (i = 0; i < nsyms; i++) {
27 len = strlen(names[i]) + 1;
28 fwrite(names[i], len, 1, fp);
29 n += len;
30 }
31
32 return fflush(fp) == EOF ? -1 : 0;
33 }