#include "refer.h" /* * read and write 32-bit longs in a machine-independent way * (given 8-bit bytes!) -- high byte first */ void putl(long ll, FILE *f) { putc(ll>>24, f); putc(ll>>16, f); putc(ll>>8, f); putc(ll, f); if (ferror(f)) err("error writing output index file"); } long getl(FILE *f) { long l; l = 0; l |= getc(f)<<24; l |= getc(f)<<16; l |= getc(f)<<8; l |= getc(f); if (ferror(f)) err("error reading index file"); else if (feof(f)) err("unexpected end-of-file on index file -- rerun pubindex?"); return l; } void xseek(FILE *f, Fpos l, int n) { if (fseek(f, l, n) < 0) err("error seeking on index file -- rerun pubindex?"); } #include #include long gdate(FILE *f) { struct stat sb; return fstat(fileno(f), &sb) >= 0? sb.st_mtime: 0; }