scc

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

setidx32.c (497B)


      1 #include <stdio.h>
      2 #include <string.h>
      3 
      4 #include <scc/mach.h>
      5 
      6 #include "libmach.h"
      7 
      8 int
      9 setidx32(int order, long nsyms, char *names[], long offs[], FILE *fp)
     10 {
     11 	long i;
     12 	size_t len;
     13 	unsigned char buff[4];
     14 
     15 	pack(order, buff, "l", nsyms);
     16 	fwrite(buff, 4, 1, fp);
     17 
     18 	for (i = 0; i < nsyms; i++) {
     19 		pack(order, buff, "l", offs[i]);
     20 		fwrite(buff, 4, 1, fp);
     21 	}
     22 
     23 	for (i = 0; i < nsyms; i++) {
     24 		len = strlen(names[i]) + 1;
     25 		fwrite(names[i], len, 1, fp);
     26 	}
     27 
     28 	return fflush(fp) == EOF ? -1 : 0;
     29 }