offsets.c 2.05 KB
Newer Older
1 2 3
/*****************************************************************************
 * offsets.c: find position in an aux file
 *****************************************************************************
4
 * Copyright (C) 2009, 2011 VideoLAN
5
 * $Id$
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
 *
 * Authors: Christophe Massiot <massiot@via.ecp.fr>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdint.h>
31
#include <stdbool.h>
32 33
#include <string.h>
#include <errno.h>
34 35

#include "util.h"
36 37 38 39 40 41

/*****************************************************************************
 * Entry point
 *****************************************************************************/
int main( int i_argc, char **pp_argv )
{
42 43
    int64_t i_wanted;
    off_t i_ret;
44 45 46

    if ( i_argc != 3 )
    {
47 48
        msg_Err( NULL, "Usage: offsets <aux file> <27 MHz timestamp>" );
        msg_Err( NULL, "[offsets is deprecated, see multicat instead]" );
49 50 51
        exit(EXIT_FAILURE);
    }

52
    i_wanted = strtoll( pp_argv[2], NULL, 0 );
53 54 55 56 57 58
    if ( !i_wanted )
    {
        printf( "0\n" );
        exit(EXIT_SUCCESS);
    }

59 60
    i_ret = LookupAuxFile( pp_argv[1], i_wanted, false );
    if ( i_ret == -1 )
61 62
        exit(EXIT_FAILURE);

63
    printf( "%jd\n", (intmax_t)i_ret );
64 65 66 67

    exit(EXIT_SUCCESS);
}