in = fopen(XPTFILE, "r");
in = fopen(XPTFILE, "rb");
XPTHeader *getheader() {    XPTState *state;    XPTCursor curs, *cursor = &curs;    XPTHeader *header;    struct stat file_stat;    int flen;    char *whole;    FILE *in;    if (stat(XPTFILE, &file_stat) != 0) {        perror("FAILED: fstat");        return NULL;    }    flen = file_stat.st_size;    in = fopen(XPTFILE, "r");    if (!in) {        perror("FAILED: fopen");        return NULL;    }    whole = (char *)malloc(flen);    if (!whole) {        perror("FAILED: malloc for whole");        return NULL;    }    if (flen > 0) {        fread(whole, flen, 1, in);        state = XPT_NewXDRState(XPT_DECODE, whole, flen);        if (!XPT_MakeCursor(state, XPT_HEADER, 0, cursor)) {            fprintf(stdout, "MakeCursor failed\n");            return NULL;        }        if (!XPT_DoHeader(cursor, &header)) {            fprintf(stdout, "DoHeader failed\n");            return NULL;        }       free(header);          XPT_DestroyXDRState(state);       // assum'd to be OK       free(whole);       fclose(in);       return header;    }    free(whole);    fclose(in);    return NULL;}