File: offsets.c

package info (click to toggle)
multicat 2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 312 kB
  • sloc: ansic: 3,872; makefile: 58; sh: 18
file content (67 lines) | stat: -rw-r--r-- 2,103 bytes parent folder | download
1
2
3
4
5
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*****************************************************************************
 * offsets.c: find position in an aux file
 *****************************************************************************
 * Copyright (C) 2009, 2011 VideoLAN
 * $Id$
 *
 * 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>
#include <stdbool.h>
#include <string.h>
#include <errno.h>

#include "util.h"

/*****************************************************************************
 * Entry point
 *****************************************************************************/
int main( int i_argc, char **pp_argv )
{
    int64_t i_wanted;
    off_t i_ret;

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

    i_wanted = strtoll( pp_argv[2], NULL, 0 );
    if ( !i_wanted )
    {
        printf( "0\n" );
        exit(EXIT_SUCCESS);
    }

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

    printf( "%jd\n", (intmax_t)i_ret );

    exit(EXIT_SUCCESS);
}