scc

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

coff32setidx.c (579B)


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