objprobe.c (424B)
1 #include <stdio.h> 2 3 #include <scc/mach.h> 4 5 #include "libmach.h" 6 7 int 8 objprobe(FILE *fp, char **name) 9 { 10 int n, t; 11 fpos_t pos; 12 Objops **opsp, *ops; 13 unsigned char buf[NBYTES]; 14 15 fgetpos(fp, &pos); 16 n = fread(buf, NBYTES, 1, fp); 17 fsetpos(fp, &pos); 18 19 if (n != 1 || ferror(fp)) 20 return -1; 21 22 for (opsp = objops; ops = *opsp; ++opsp) { 23 t = (*ops->probe)(buf, name); 24 if (t < 0) 25 continue; 26 return t; 27 } 28 29 return -1; 30 }