#ident "$Id: test_ftello.c,v 1.4 2006/02/14 19:32:36 craig Exp $"
/*
 *               Copyright (C) 2005, BroadOn Communications Corp.
 *
 *  These coded instructions, statements, and computer programs contain
 *  unpublished  proprietary information of BroadOn Communications Corp.,
 *  and  are protected by Federal copyright law. They may not be disclosed
 *  to  third  parties or copied or duplicated in any form, in whole or in
 *  part, without the prior written consent of BroadOn Communications Corp.
 *
 */

/*
 */

#ifdef __CYGWIN__
#undef __STRICT_ANSI__
#else
#define fseeko(file, where, whence)     fseeko64(file, where, whence)
#define ftello(file)                    ftello64(file)
#endif

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/types.h>

extern FILE* fopen64 (const char* filename, const char* mode);

int
main(int argc, char *argv[])
{
    FILE        *inFile;
    off_t       offset;

    if (argc != 2) {
        printf ("Supply an argument\n");
        exit(1);
    }
    if ((inFile = fopen(argv[1], "r")) == NULL) {
        printf ("Can't open file\n");
        exit(1);
    }
    if (fseeko(inFile, 3 * 1024 * 1024 * 1024ULL, SEEK_SET) == -1) {
        perror ("fseeko:");
        exit(1);
    }
    offset = ftello(inFile);
    printf ("Offset value: 0x%llx (%d)\n", offset, sizeof(off_t));
    if (fseeko(inFile, 1024, SEEK_CUR) == -1) {
        perror ("fseeko (1)");
        exit(1);
    }
    offset = ftello(inFile);
    printf ("Offset value: 0x%llx (%d)\n", offset, sizeof(off_t));
    exit(0);
}
