in = fopen(argv[1], "r");
in = fopen(argv[1], "rb");
main(int argc, char **argv){    PRBool verbose_mode = PR_FALSE;    XPTState *state;    XPTCursor curs, *cursor = &curs;    XPTHeader *header;    struct stat file_stat;    size_t flen;    char *whole;    FILE *in;    switch (argc) {    case 2:        if (argv[1][0] == '-') {            xpt_dump_usage(argv);            return 1;        }        if (stat(argv[1], &file_stat) != 0) {            perror("FAILED: fstat");            return 1;        }        flen = file_stat.st_size;        in = fopen(argv[1], "r");        break;    case 3:        verbose_mode = PR_TRUE;        if (argv[1][0] != '-' || argv[1][1] != 'v') {            xpt_dump_usage(argv);            return 1;        }        if (stat(argv[2], &file_stat) != 0) {            perror("FAILED: fstat");            return 1;        }        flen = file_stat.st_size;        in = fopen(argv[2], "r");        break;    default:        xpt_dump_usage(argv);        return 1;    }    if (!in) {        perror("FAILED: fopen");        return 1;    }    whole = malloc(flen);    if (!whole) {        perror("FAILED: malloc for whole");        return 1;    }    if (flen > 0) {        size_t rv = fread(whole, 1, flen, in);        if (rv < 0) {            perror("FAILED: reading typelib file");            return 1;        }        if (rv < flen) {            fprintf(stderr, "short read (%d vs %d)! ouch!\n", rv, flen);            return 1;        }        if (ferror(in) != 0 || fclose(in) != 0)            perror("FAILED: Unable to read typelib file.\n");                state = XPT_NewXDRState(XPT_DECODE, whole, flen);        if (!XPT_MakeCursor(state, XPT_HEADER, 0, cursor)) {            fprintf(stdout, "MakeCursor failed\n");            return 1;        }        if (!XPT_DoHeader(cursor, &header)) {            fprintf(stdout, "DoHeader failed\n");            return 1;        }        if (!XPT_DumpHeader(header, BASE_INDENT, verbose_mode)) {            perror("FAILED: XPT_DumpHeader");            return 1;        }           XPT_DestroyXDRState(state);        free(whole);    }    return 0;}