Commit 22c54994 authored by Christophe Massiot's avatar Christophe Massiot

* lasts.c: New utility to tell the total duration of an aux file.

parent c1c4e238
......@@ -9,18 +9,20 @@ OBJ_INGESTS = ingests.o util.o
OBJ_AGGREGARTP = aggregartp.o util.o
OBJ_REORDERTP = reordertp.o util.o
OBJ_OFFSETS = offsets.o util.o
OBJ_LASTS = lasts.o
PREFIX ?= /usr/local
BIN = $(DESTDIR)/$(PREFIX)/bin
MAN = $(DESTDIR)/$(PREFIX)/share/man/man1
all: multicat ingests aggregartp reordertp offsets
all: multicat ingests aggregartp reordertp offsets lasts
$(OBJ_MULTICAT): Makefile util.h
$(OBJ_INGESTS): Makefile util.h
$(OBJ_AGGREGARTP): Makefile util.h
$(OBJ_REORDERTP): Makefile util.h
$(OBJ_OFFSETS): Makefile util.h
$(OBJ_LASTS): Makefile
multicat: $(OBJ_MULTICAT)
$(CC) -o $@ $(OBJ_MULTICAT) $(LDLIBS)
......@@ -37,15 +39,18 @@ reordertp: $(OBJ_REORDERTP)
offsets: $(OBJ_OFFSETS)
$(CC) -o $@ $(OBJ_OFFSETS) $(LDLIBS)
lasts: $(OBJ_LASTS)
$(CC) -o $@ $(OBJ_LASTS) $(LDLIBS)
clean:
-rm -f multicat $(OBJ_MULTICAT) ingests $(OBJ_INGESTS) aggregartp $(OBJ_AGGREGARTP) reordertp $(OBJ_REORDERTP) offsets $(OBJ_OFFSETS)
-rm -f multicat $(OBJ_MULTICAT) ingests $(OBJ_INGESTS) aggregartp $(OBJ_AGGREGARTP) reordertp $(OBJ_REORDERTP) offsets $(OBJ_OFFSETS) lasts $(OBJ_LASTS)
install: all
@install -d $(BIN)
@install -d $(MAN)
@install multicat ingests aggregartp reordertp offsets $(BIN)
@install multicat.1 ingests.1 aggregartp.1 reordertp.1 offsets.1 $(MAN)
@install multicat ingests aggregartp reordertp offsets lasts $(BIN)
@install multicat.1 ingests.1 aggregartp.1 reordertp.1 offsets.1 lasts.1 $(MAN)
uninstall:
@rm $(BIN)/multicat $(BIN)/ingests $(BIN)/aggregartp $(BIN)/reordertp $(BIN)/offsets
@rm $(MAN)/multicat.1 $(MAN)/ingests.1 $(MAN)/aggregartp.1 $(MAN)/reordertp.1 $(MAN)/offsets.1
@rm $(BIN)/multicat $(BIN)/ingests $(BIN)/aggregartp $(BIN)/reordertp $(BIN)/offsets $(BIN)/lasts
@rm $(MAN)/multicat.1 $(MAN)/ingests.1 $(MAN)/aggregartp.1 $(MAN)/reordertp.1 $(MAN)/offsets.1 $(MAN)/lasts.1
.TH Lasts "1" "November 9, 2011" "Multicat 2.0"
.SH NAME
lasts \- Indicate duration of file based on multicat's auxiliary file
.SH SYNOPSIS
.B lasts
<aux file>
.SH DESCRIPTION
LasTS is a companion application for multicat, to manipulate auxiliary files.
It returns the total duration of a file, based on the auxiliary file created
by multicat or ingesTS.
.SH SEE ALSO
.BR aggregartp (1),
.BR desaggregartp (1),
.BR ingests (1),
.BR multicat (1),
.BR offsets (1).
.br
Read the README file for more information about the configuration of lasts.
.SH AUTHOR
lasts was written by Christophe Massiot.
.SH LICENCE
This program is free software; you can redistribute it and/or modify it under the terms of
version 2 of the GNU General Public License as published by the Free Software Foundation.
.PP
This manual page was written by Rémi Duraffort <ivoire at videolan dot org>,
for the Debian project (and may be used by others).
/*****************************************************************************
* lasts.c: give the duration of an aux file
*****************************************************************************
* Copyright (C) 2009, 2011 VideoLAN
* $Id: lasts.c 10 2005-11-16 18:09:00Z cmassiot $
*
* 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 <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
/*****************************************************************************
* Entry point
*****************************************************************************/
int main(int i_argc, char **ppsz_argv)
{
uint64_t i_stc0, i_stcn;
uint8_t p_aux[8];
int i_fd;
if (i_argc != 2 || !strcmp(ppsz_argv[1], "-h") ||
!strcmp(ppsz_argv[1], "--help"))
{
fprintf(stderr, "Usage: lasts <aux file>");
exit(EXIT_FAILURE);
}
i_fd = open(ppsz_argv[1], O_RDONLY);
if (i_fd == -1)
{
fprintf(stderr, "cannot open (%m)\n");
exit(EXIT_FAILURE);
}
if (read(i_fd, p_aux, sizeof(p_aux)) != sizeof(p_aux))
{
fprintf(stderr, "cannot read (%m)\n");
close(i_fd);
exit(EXIT_FAILURE);
}
i_stc0 = ((uint64_t)p_aux[0] << 56)
| ((uint64_t)p_aux[1] << 48)
| ((uint64_t)p_aux[2] << 40)
| ((uint64_t)p_aux[3] << 32)
| ((uint64_t)p_aux[4] << 24)
| ((uint64_t)p_aux[5] << 16)
| ((uint64_t)p_aux[6] << 8)
| ((uint64_t)p_aux[7] << 0);
if (lseek(i_fd, -(off_t)sizeof(p_aux), SEEK_END) == -1)
{
fprintf(stderr, "cannot lseek (%m)\n");
close(i_fd);
exit(EXIT_FAILURE);
}
if (read(i_fd, p_aux, sizeof(p_aux)) != sizeof(p_aux))
{
fprintf(stderr, "cannot read (%m)\n");
close(i_fd);
exit(EXIT_FAILURE);
}
close(i_fd);
i_stcn = ((uint64_t)p_aux[0] << 56)
| ((uint64_t)p_aux[1] << 48)
| ((uint64_t)p_aux[2] << 40)
| ((uint64_t)p_aux[3] << 32)
| ((uint64_t)p_aux[4] << 24)
| ((uint64_t)p_aux[5] << 16)
| ((uint64_t)p_aux[6] << 8)
| ((uint64_t)p_aux[7] << 0);
printf( "%"PRIu64"\n", i_stcn - i_stc0);
exit(EXIT_SUCCESS);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment