Compare commits
No commits in common. "master" and "2016" have entirely different histories.
99 changed files with 22899 additions and 777 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +0,0 @@
|
||||||
.venv
|
|
||||||
*~
|
|
4
CVSROOT/access
Normal file
4
CVSROOT/access
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
#
|
||||||
|
# Wer committen darf
|
17
CVSROOT/avail
Normal file
17
CVSROOT/avail
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
#
|
||||||
|
# Wer welche Teile bearbeiten darf
|
||||||
|
#
|
||||||
|
# Beispiele:
|
||||||
|
# Gruppendefinition
|
||||||
|
#group|meisters|peter,jdp,markm,joe
|
||||||
|
# Gruppendefinition aus Datei
|
||||||
|
#group|penaltybox|!badcommitters
|
||||||
|
# Verboten fuer alle
|
||||||
|
#unavail||src/contrib/binutils,src/contrib/file
|
||||||
|
# Erlaubt fuer einige
|
||||||
|
#avail|:meisters|CVSROOT
|
||||||
|
#
|
||||||
|
# Alle duerfen ueberall
|
||||||
|
avail
|
284
CVSROOT/cfg.pm
Executable file
284
CVSROOT/cfg.pm
Executable file
|
@ -0,0 +1,284 @@
|
||||||
|
# $Id$
|
||||||
|
# $FreeBSD: cfg.pm,v 1.50 2003/02/28 18:28:11 peter Exp $
|
||||||
|
|
||||||
|
####################################################################
|
||||||
|
####################################################################
|
||||||
|
# This file contains the default configuration for the CVSROOT
|
||||||
|
# perl scripts. You are advised to override the configuration
|
||||||
|
# in the cfg_local.pm file instead of here.
|
||||||
|
#
|
||||||
|
# WARNING: You are strongly advised to check for syntax errors
|
||||||
|
# in this file before committing it. Use: perl -cw cfg.pm
|
||||||
|
####################################################################
|
||||||
|
####################################################################
|
||||||
|
|
||||||
|
package cfg;
|
||||||
|
use strict;
|
||||||
|
use vars qw(
|
||||||
|
$ADD_TO_LINE $AVAIL_FILE $CHECK_HEADERS $COMMITCHECK_EXTRA
|
||||||
|
@COMMIT_HOSTS $COMMITTER $DEBUG $DIFF_BLOCK_TOTAL_LINES $EXCLUDE_FILE
|
||||||
|
$FILE_PREFIX $IDHEADER $LAST_FILE @LOG_FILE_MAP $MAILADDRS $MAILBANNER
|
||||||
|
$MAILCMD $MAIL_BRANCH_HDR $MAIL_ON_DIR_CREATION $MAIL_TRANSFORM
|
||||||
|
$MINCVSVERSION $MAX_DIFF_SIZE $NO_DOS_LINEBREAKS $PID $PROG_CVS
|
||||||
|
$PROG_MV %TEMPLATE_HEADERS $TMPDIR $UNEXPAND_RCSID $WARN_HEADERS
|
||||||
|
);
|
||||||
|
|
||||||
|
my $CVSROOT = $ENV{'CVSROOT'} || die "Can't determine \$CVSROOT!";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
######################
|
||||||
|
### global options ###
|
||||||
|
######################
|
||||||
|
### WARNING: these aren't global across all the scripts yet.
|
||||||
|
### This is work in progress.
|
||||||
|
|
||||||
|
# Process group id; used as a unique number in temporary file names.
|
||||||
|
$PID = getpgrp();
|
||||||
|
|
||||||
|
# Debug level, 0 = off, 1 = on.
|
||||||
|
$DEBUG = 0;
|
||||||
|
|
||||||
|
# Location of temporary directory.
|
||||||
|
$TMPDIR = "/tmp/";
|
||||||
|
|
||||||
|
# The filename prefix used for temporary files.
|
||||||
|
$FILE_PREFIX = "#cvs.files.$PID";
|
||||||
|
|
||||||
|
# The file used to store the name of the last directory examined
|
||||||
|
# when processing a multi-directory commit.
|
||||||
|
$LAST_FILE = "$TMPDIR/$FILE_PREFIX.lastdir";
|
||||||
|
# System tools.
|
||||||
|
$PROG_CVS = '/usr/local/bin/cvs'; # cvs(1)
|
||||||
|
$PROG_MV = '/bin/mv'; # mv(1)
|
||||||
|
|
||||||
|
# The username of the committer.
|
||||||
|
$COMMITTER = $ENV{"LOGNAME"} || $ENV{'USER'} || getlogin
|
||||||
|
|| (getpwuid($<))[0] || sprintf("uid#%d",$<);
|
||||||
|
|
||||||
|
|
||||||
|
###################
|
||||||
|
### commitcheck ###
|
||||||
|
###################
|
||||||
|
|
||||||
|
# A list of hosts the it's ok to commit on. Useful if your committers
|
||||||
|
# take local copies of the repository to work off-line.
|
||||||
|
# (Empty if you don't want checks.)
|
||||||
|
@COMMIT_HOSTS = ();
|
||||||
|
|
||||||
|
# The minimum version of cvs that we will work with.
|
||||||
|
$MINCVSVERSION = "1090900"; # 1.9.9p0
|
||||||
|
|
||||||
|
# Additional commit time checks. This is an anonymous subroutine
|
||||||
|
# that gets called early on in the validation process to see whether
|
||||||
|
# the committer is allowed to commit. It should return true if
|
||||||
|
# everything is ok, otherwise the commit will be terminated.
|
||||||
|
$COMMITCHECK_EXTRA = "";
|
||||||
|
|
||||||
|
|
||||||
|
###################
|
||||||
|
### cvs_acls.pl ###
|
||||||
|
###################
|
||||||
|
|
||||||
|
# The name of the avail file that defines who's allow to
|
||||||
|
# commit to what.
|
||||||
|
$AVAIL_FILE = "$CVSROOT/CVSROOT/avail";
|
||||||
|
|
||||||
|
|
||||||
|
################
|
||||||
|
### logcheck ###
|
||||||
|
################
|
||||||
|
|
||||||
|
# These are the optional headers that can be filled at the end of
|
||||||
|
# each commit message. The associated value is a regular-expression
|
||||||
|
# that is used to type-check the entered value. If a match fails
|
||||||
|
# then the commit is rejected. (See rcstemplate).
|
||||||
|
#
|
||||||
|
# Make sure that these are also described in the rcstemplate to
|
||||||
|
# make their usage clear to committers.
|
||||||
|
#
|
||||||
|
# In addition any of these entries that are left blank are removed
|
||||||
|
# from the log at commit time. [Please note that for them to be
|
||||||
|
# removed from the rcslog in the repository you need to be running
|
||||||
|
# the version of cvs in the FreeBSD source tree. We've got a local
|
||||||
|
# patch that causes cvs to read back the commit message after the
|
||||||
|
# commit_prep.pl script has had a chance to modify it (via the
|
||||||
|
# 'commitinfo' hook). ]
|
||||||
|
%TEMPLATE_HEADERS = (
|
||||||
|
# "Reviewed by" => '.*',
|
||||||
|
# "Submitted by" => '.*',
|
||||||
|
# "Obtained from" => '.*',
|
||||||
|
# "Approved by" => '.*',
|
||||||
|
# "PR" => '.*',
|
||||||
|
# "MFC after" => '\d+(\s+(days?|weeks?|months?))?'
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
######################
|
||||||
|
### commit_prep.pl ###
|
||||||
|
######################
|
||||||
|
|
||||||
|
# Check for instances of $IDHEADER in committed files, and
|
||||||
|
# bomb out if they're not present, or corrupted.
|
||||||
|
# Exclusions can be specified in the exclude file.
|
||||||
|
# Currently $IDHEADER must be an instance of '$ CVSHeader $', or an alias
|
||||||
|
# defined in CVSROOT/options.
|
||||||
|
$CHECK_HEADERS = 0;
|
||||||
|
$EXCLUDE_FILE = "$CVSROOT/CVSROOT/exclude";
|
||||||
|
|
||||||
|
# Make a header check a non-fatal error - just warn, don't exit.
|
||||||
|
$WARN_HEADERS = 0;
|
||||||
|
|
||||||
|
# WARNING: You will also need to be running the version of cvs that
|
||||||
|
# the FreeBSD project is using; I believe that we have some local patches
|
||||||
|
# that aren't in the main 'cvs' source.
|
||||||
|
# Additionally you'll need to tweak CVSROOT/options if you wish to use your
|
||||||
|
# own ident header.
|
||||||
|
$IDHEADER = 'CVSHeader';
|
||||||
|
|
||||||
|
# Contract any instances of $IDHEADER in the source file before committing.
|
||||||
|
# This is useful because it means that expanded headers aren't stored in
|
||||||
|
# the repository as part of the delta.
|
||||||
|
$UNEXPAND_RCSID = 0;
|
||||||
|
|
||||||
|
# Check for DOS/WINDOWS/MAC linebreaks in the file, bomb out if present.
|
||||||
|
# Exclusions can be specified in the exclude file.
|
||||||
|
$NO_DOS_LINEBREAKS = 0;
|
||||||
|
|
||||||
|
|
||||||
|
####################
|
||||||
|
### log_accum.pl ###
|
||||||
|
####################
|
||||||
|
|
||||||
|
# The command used to mail the log messages.
|
||||||
|
# Usually something like '/usr/sbin/sendmail'.
|
||||||
|
$MAILCMD = "/usr/sbin/sendmail";
|
||||||
|
|
||||||
|
# Email addresses of recipients of commit mail.
|
||||||
|
$MAILADDRS = 'nobody';
|
||||||
|
|
||||||
|
# Extra banner added to the top of commit email.
|
||||||
|
# Use "" if you don't want one.
|
||||||
|
# i.e. $MAILBANNER = "Project X CVS Repository";
|
||||||
|
$MAILBANNER = "";
|
||||||
|
|
||||||
|
# Send mail when directories are created in the repository.
|
||||||
|
# 0 = off, 1 = on.
|
||||||
|
$MAIL_ON_DIR_CREATION = 0;
|
||||||
|
|
||||||
|
# Include the names of the branches committed to in the commit email,
|
||||||
|
# using this header (leave off the trailing ':').
|
||||||
|
# Use "" if you don't want one.
|
||||||
|
$MAIL_BRANCH_HDR = "X-CVS-Branch";
|
||||||
|
|
||||||
|
# Include a 'To:' header in the generated commit mail?
|
||||||
|
$ADD_TO_LINE = 1;
|
||||||
|
|
||||||
|
# This is a way to post-process the log email before it is mailed.
|
||||||
|
# Some people find it useful to use this to create URLs in their
|
||||||
|
# commit mails to show the patch in a web page (using cvsweb) for
|
||||||
|
# instance.
|
||||||
|
#
|
||||||
|
# The $MAIL_TRANSFORM variable should be "" if you don't want to
|
||||||
|
# use this feature. Otherwise it should be a reference to a
|
||||||
|
# subroutine that is passed the email message as a list, and returns
|
||||||
|
# the modified list to the log_accum.pl script. The list has one
|
||||||
|
# element per email line, with no trailing line feeds. This function
|
||||||
|
# shouldn't add them. If $DEBUG is switched on the log_accum.pl
|
||||||
|
# script will show the before and after on stdout at commit time.
|
||||||
|
#
|
||||||
|
# The example below shows a way of inserting links to cvsweb.
|
||||||
|
$MAIL_TRANSFORM = "";
|
||||||
|
#$MAIL_TRANSFORM = sub {
|
||||||
|
# add_cvsweb_entry("http://www.example.org/cgi-bin/cvsweb.cgi", @_);
|
||||||
|
#};
|
||||||
|
|
||||||
|
# A copy of the commit summary is saved locally as well as being
|
||||||
|
# emailed to the committers. The name of the local log is obtained
|
||||||
|
# by performing a pattern match on the directory that the files are
|
||||||
|
# in. The following map defines the file names and their associated
|
||||||
|
# pattern match. They are checked in order. The name 'other' is
|
||||||
|
# used if none of the patterns match.
|
||||||
|
#
|
||||||
|
# XXX The directory that the logs are placed in should be a
|
||||||
|
# configuration option too.
|
||||||
|
@LOG_FILE_MAP = (
|
||||||
|
'CVSROOT' => '^CVSROOT/',
|
||||||
|
'doc' => '^doc/',
|
||||||
|
'user' => '^src/',
|
||||||
|
'other' => '.*'
|
||||||
|
);
|
||||||
|
|
||||||
|
# Include diffs of not greater than this size in kbytes in the
|
||||||
|
# commit mail for each file modified. (0 = off).
|
||||||
|
$MAX_DIFF_SIZE = 0;
|
||||||
|
|
||||||
|
# Maximum size of in lines of the diff block.
|
||||||
|
$DIFF_BLOCK_TOTAL_LINES = 200;
|
||||||
|
|
||||||
|
|
||||||
|
######################
|
||||||
|
# EXAMPLES
|
||||||
|
######################
|
||||||
|
# A function for post-processing a log message
|
||||||
|
# and outputing it with URLs to a cvsweb.cgi in.
|
||||||
|
sub add_cvsweb_entry {
|
||||||
|
my $url_to_cvsweb = shift;
|
||||||
|
my @input = @_;
|
||||||
|
my @output = ();
|
||||||
|
|
||||||
|
# Skip down to the revision summary.
|
||||||
|
while (1) {
|
||||||
|
my $line = shift @input;
|
||||||
|
last unless defined($line);
|
||||||
|
|
||||||
|
push @output, $line;
|
||||||
|
last if $line =~ /^\s*Revision\s*Changes\s*Path\s*$/;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add the url links
|
||||||
|
my $skip = 0;
|
||||||
|
foreach (@input) {
|
||||||
|
# The revision block is terminated with an empty line.
|
||||||
|
$skip = 1 if $_ =~ /^\s*$/;
|
||||||
|
|
||||||
|
push @output, $_;
|
||||||
|
next if $skip;
|
||||||
|
|
||||||
|
my ($rev, $add, $sub, $file, $status) = split;
|
||||||
|
|
||||||
|
$rev =~ /(?:(.*)\.)?([^\.]+)\.([^\.]+)$/;
|
||||||
|
my ($base, $r1, $r2) = ($1, $2, $3);
|
||||||
|
my $prevrev = "";
|
||||||
|
if ($r2 == 1) {
|
||||||
|
$prevrev = $base;
|
||||||
|
} else {
|
||||||
|
$prevrev = "$base." if $base;
|
||||||
|
$prevrev .= "$r1." . ($r2 - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
my $baseurl = "$url_to_cvsweb/$file";
|
||||||
|
my $extra;
|
||||||
|
if (defined($status)) {
|
||||||
|
$rev = $prevrev if $status =~ /dead/;
|
||||||
|
$extra = "?rev=$rev&content-type=text/plain";
|
||||||
|
} else {
|
||||||
|
$extra = ".diff?r1=$prevrev&r2=$rev&f=h";
|
||||||
|
}
|
||||||
|
push @output, "$baseurl$extra";
|
||||||
|
}
|
||||||
|
|
||||||
|
return @output;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
# Load the local configuration file, that allows the entries in this
|
||||||
|
# file to be overridden.
|
||||||
|
######################################################################
|
||||||
|
eval { require "$CVSROOT/CVSROOT/cfg_local.pm" }
|
||||||
|
if -e "$CVSROOT/CVSROOT/cfg_local.pm";
|
||||||
|
warn $@ if $@;
|
||||||
|
|
||||||
|
1; # Perl requires all modules to return true. Don't delete!!!!
|
||||||
|
#end
|
70
CVSROOT/cfg_local.pm
Normal file
70
CVSROOT/cfg_local.pm
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
# $Id$
|
||||||
|
# $FreeBSD: cfg_local.pm,v 1.26 2003/02/28 21:17:06 peter Exp $
|
||||||
|
|
||||||
|
####################################################################
|
||||||
|
####################################################################
|
||||||
|
# This file contains local configuration for the CVSROOT perl
|
||||||
|
# scripts. It is loaded by cfg.pm and overrides the default
|
||||||
|
# configuration in that file.
|
||||||
|
#
|
||||||
|
# It is advised that you test it with
|
||||||
|
# 'env CVSROOT=/path/to/cvsroot perl -cw cfg.pm'
|
||||||
|
# before you commit any changes. The check is to cfg.pm which
|
||||||
|
# loads this file.
|
||||||
|
####################################################################
|
||||||
|
####################################################################
|
||||||
|
|
||||||
|
# Noch nicht
|
||||||
|
#$CHECK_HEADERS = 1;
|
||||||
|
$IDHEADER = 'Id';
|
||||||
|
$UNEXPAND_RCSID = 1;
|
||||||
|
|
||||||
|
%TEMPLATE_HEADERS = (
|
||||||
|
# "Reviewed by" => '.*',
|
||||||
|
# "Submitted by" => '.*',
|
||||||
|
# "Obtained from" => '.*',
|
||||||
|
# "Approved by" => '.*',
|
||||||
|
# "PR" => '.*',
|
||||||
|
# "MFC after" => '\d+(\s+(days?|weeks?|months?))?'
|
||||||
|
);
|
||||||
|
|
||||||
|
$MAILADDRS = 'zs64-admin@zs64.net';
|
||||||
|
#$MAILCMD = "/usr/local/bin/mailsend -H";
|
||||||
|
$MAIL_BRANCH_HDR = "X-SCHLEPPERBANDE";
|
||||||
|
$MAILBANNER = "Schlepperbande repository";
|
||||||
|
if (defined $ENV{'CVS_COMMIT_ATTRIB'}) {
|
||||||
|
my $attrib = $ENV{'CVS_COMMIT_ATTRIB'};
|
||||||
|
$MAILBANNER .= " ($attrib committer)";
|
||||||
|
}
|
||||||
|
$MAIL_TRANSFORM = sub {
|
||||||
|
add_cvsweb_entry("https://koef.zs64.net/schlepperbande/cvs/cvsweb.cgi", @_);
|
||||||
|
};
|
||||||
|
|
||||||
|
$MAX_DIFF_SIZE = 4096;
|
||||||
|
|
||||||
|
|
||||||
|
# Sanity check to make sure we've been run through the wrapper and are
|
||||||
|
# now primary group 'ncvs'.
|
||||||
|
#
|
||||||
|
#$COMMITCHECK_EXTRA = sub {
|
||||||
|
# my $GRP=`/usr/bin/id -gn`;
|
||||||
|
# chomp $GRP;
|
||||||
|
# unless ( $GRP =~ /^ncvs$/ ) {
|
||||||
|
# print "You do not have group ncvs (commitcheck)!\n";
|
||||||
|
# exit 1; # We could return false here. But there's
|
||||||
|
# # nothing to stop us taking action here instead.
|
||||||
|
# }
|
||||||
|
# return 1;
|
||||||
|
#};
|
||||||
|
|
||||||
|
@LOG_FILE_MAP = (
|
||||||
|
'CVSROOT' => '^CVSROOT/',
|
||||||
|
'distrib' => '^distrib/',
|
||||||
|
|
||||||
|
'test' => '^test/',
|
||||||
|
|
||||||
|
'other' => '.*'
|
||||||
|
);
|
||||||
|
|
||||||
|
1; # Perl requires all modules to return true. Don't delete!!!!
|
||||||
|
#end
|
28
CVSROOT/checkoutlist
Normal file
28
CVSROOT/checkoutlist
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
# The "checkoutlist" file is used to support additional version controlled
|
||||||
|
# administrative files in $CVSROOT/CVSROOT, such as template files.
|
||||||
|
#
|
||||||
|
# The first entry on a line is a filename which will be checked out from
|
||||||
|
# the corresponding RCS file in the $CVSROOT/CVSROOT directory.
|
||||||
|
# The remainder of the line is an error message to use if the file cannot
|
||||||
|
# be checked out.
|
||||||
|
#
|
||||||
|
# File format:
|
||||||
|
#
|
||||||
|
# [<whitespace>]<filename><whitespace><error message><end-of-line>
|
||||||
|
#
|
||||||
|
# comment lines begin with '#'
|
||||||
|
access
|
||||||
|
avail
|
||||||
|
cfg.pm
|
||||||
|
cfg_local.pm
|
||||||
|
commit_prep.pl
|
||||||
|
commitcheck
|
||||||
|
cvs_acls.pl
|
||||||
|
exclude
|
||||||
|
log_accum.pl
|
||||||
|
logcheck
|
||||||
|
options
|
||||||
|
rcstemplate
|
||||||
|
tagcheck
|
||||||
|
unwrap
|
||||||
|
wrap
|
313
CVSROOT/commit_prep.pl
Executable file
313
CVSROOT/commit_prep.pl
Executable file
|
@ -0,0 +1,313 @@
|
||||||
|
#!/usr/bin/perl -w
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
# $FreeBSD: commit_prep.pl,v 1.65 2002/08/31 06:07:42 jmallett Exp $
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Perl filter to handle pre-commit checking of files. This program
|
||||||
|
# records the last directory where commits will be taking place for
|
||||||
|
# use by the log_accum.pl script. For new files, it forces the
|
||||||
|
# existence of a RCS "Id" keyword in the first ten lines of the file.
|
||||||
|
# For existing files, it checks the version number in the "Id" line to
|
||||||
|
# prevent losing changes because an old version of a file was copied
|
||||||
|
# into the direcory.
|
||||||
|
#
|
||||||
|
# Possible future enhancements:
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Check for cruft left by unresolved conflicts. Search for
|
||||||
|
# "^<<<<<<<$", "^-------$", and "^>>>>>>>$".
|
||||||
|
#
|
||||||
|
# Look for a copyright and automagically update it to the
|
||||||
|
# current year.
|
||||||
|
#
|
||||||
|
# Contributed by David Hampton <hampton@cisco.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
require 5.003; # to be sure. log_accum needs perl5
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use lib $ENV{CVSROOT};
|
||||||
|
use CVSROOT::cfg;
|
||||||
|
my $CVSROOT = $ENV{'CVSROOT'} || die "Can't determine \$CVSROOT!";
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
#
|
||||||
|
# Constants
|
||||||
|
#
|
||||||
|
############################################################
|
||||||
|
my $ENTRIES = "CVS/Entries";
|
||||||
|
|
||||||
|
|
||||||
|
# The "Id" header to check for.
|
||||||
|
my $HEADER = $cfg::IDHEADER;
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
#
|
||||||
|
# Error messages
|
||||||
|
#
|
||||||
|
############################################################
|
||||||
|
my $NoId = "%s - \"\$$HEADER\$\" keyword is either missing or corrupt.\n";
|
||||||
|
|
||||||
|
# Protect string from substitution by RCS.
|
||||||
|
my $NoName = "%s - The ID line should contain only \$$HEADER\$ for " .
|
||||||
|
"a newly created file.\n";
|
||||||
|
|
||||||
|
#$DelPath = "
|
||||||
|
#%s - The old path and version has been deleted from \$$HEADER\$.\n";
|
||||||
|
|
||||||
|
my $BadName = "%s - The pathname '%s'
|
||||||
|
in the \$$HEADER\$ line does not match the actual filename.\n";
|
||||||
|
|
||||||
|
my $BadVersion = "%s - GRRR!! You spammed your copy of the file
|
||||||
|
which was based upon version %s, with a different version based
|
||||||
|
upon %s. Please move your '%s' out of the way,
|
||||||
|
perform an update to get the current version, and then
|
||||||
|
CAREFULLY merge your changes into that file.\n";
|
||||||
|
|
||||||
|
my $DOSLineBreak = "%s - Dos/Windows/Mac linebreaks encountered (line %d).\n";
|
||||||
|
my $DOSLineErr = "PLEASE use only UNIX linebreaks.\n";
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
#
|
||||||
|
# Subroutines
|
||||||
|
#
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
# Write a single line to a file.
|
||||||
|
sub write_line {
|
||||||
|
my $filename = shift; # File to write to.
|
||||||
|
my $line = shift; # Line to write to the file.
|
||||||
|
|
||||||
|
open FILE, ">$filename" or die "Cannot open $filename, stopped\n";
|
||||||
|
print FILE "$line\n";
|
||||||
|
close FILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check to see whether a file is mentioned in the exclusion file.
|
||||||
|
sub exclude_file {
|
||||||
|
my $filename = shift;
|
||||||
|
my $directory = shift;
|
||||||
|
|
||||||
|
my $path = "$directory/$filename";
|
||||||
|
if (open(EX, "< $cfg::EXCLUDE_FILE")) {
|
||||||
|
while (<EX>) {
|
||||||
|
chomp;
|
||||||
|
my $ex_entry = $_;
|
||||||
|
|
||||||
|
# Skip comments and blank lines.
|
||||||
|
next if $ex_entry =~ /^#/;
|
||||||
|
next if $ex_entry =~ /^$/;
|
||||||
|
|
||||||
|
if ($path =~ /$ex_entry/) {
|
||||||
|
close(EX);
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close(EX);
|
||||||
|
}
|
||||||
|
|
||||||
|
# File shouldn't be excluded.
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check_version {
|
||||||
|
my $filename = shift;
|
||||||
|
my $directory = shift;
|
||||||
|
my $hastag = shift;
|
||||||
|
my $lastversion = shift;
|
||||||
|
|
||||||
|
my $found_rcsid; # True if our rcsid was found in the file.
|
||||||
|
my $rcsid; # The rcsid that was in the file.
|
||||||
|
my $rcsid_info; # The expanded values of the rcsid.
|
||||||
|
my $rname; # The file pathname, parsed from the rcsid.
|
||||||
|
my $version; # The file version, parsed from the rcsid.
|
||||||
|
my $dos_line_brk_found; # True if we found a DOS line break in the file.
|
||||||
|
my $line_number; # Keep track of where the line break is.
|
||||||
|
|
||||||
|
# not present - either removed or let cvs deal with it.
|
||||||
|
return 0 unless -f $filename;
|
||||||
|
|
||||||
|
# Search the file for our rcsid.
|
||||||
|
open FILE, $filename or die "Cannot open $filename, stopped\n";
|
||||||
|
$found_rcsid = 0;
|
||||||
|
$dos_line_brk_found = 0;
|
||||||
|
$line_number = 0;
|
||||||
|
$rcsid_info = "";
|
||||||
|
while (<FILE>) {
|
||||||
|
$line_number++;
|
||||||
|
if ( /^.*(\$$HEADER(: ([^\$]* )?)?\$)/) {
|
||||||
|
$rcsid = $1;
|
||||||
|
$rcsid_info = $3 || "";
|
||||||
|
$found_rcsid = 1;
|
||||||
|
} elsif ( $cfg::NO_DOS_LINEBREAKS and /\r/ ) {
|
||||||
|
# Found a DOS linebreak
|
||||||
|
printf($DOSLineBreak, "$directory/$filename",
|
||||||
|
$line_number);
|
||||||
|
$dos_line_brk_found = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close FILE;
|
||||||
|
($rname, $version) = split /\s/, $rcsid_info;
|
||||||
|
|
||||||
|
# The file must not contain DOS linebreaks.
|
||||||
|
if ($dos_line_brk_found) {
|
||||||
|
print $DOSLineErr;
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
# The file should have had an rcsid in it!
|
||||||
|
unless ($found_rcsid) {
|
||||||
|
printf($NoId, "$directory/$filename");
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
# Ignore version mismatches (MFC spamming etc) on branches.
|
||||||
|
if ($hastag) {
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
# A new file should have an unexpanded rcsid.
|
||||||
|
if ($lastversion eq '0') {
|
||||||
|
unless ($rcsid_info eq "") {
|
||||||
|
printf($NoName, "$directory/$filename");
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
# It's ok for the rcsid to be not expanded.
|
||||||
|
if ($rcsid_info eq "") {
|
||||||
|
return (0);
|
||||||
|
# if ($directory =~ /^ports\//) {
|
||||||
|
# return (0); # ok for ports
|
||||||
|
# }
|
||||||
|
# # Don't know whether to allow or trap this. It means
|
||||||
|
# # one could bypass the version spam checks by simply
|
||||||
|
# # using a bare tag.
|
||||||
|
# printf($DelPath, "$directory/$filename");
|
||||||
|
# return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check that the file name in the rcsid matches reality.
|
||||||
|
if ($rname ne "$directory/$filename,v") {
|
||||||
|
# If ports and the pathname is just the basename
|
||||||
|
# (eg: somebody sent in a port with $Id$ and the
|
||||||
|
# committer changed Id -> $HEADER and the version
|
||||||
|
# numbers otherwise match.
|
||||||
|
if (!($directory =~ /^ports\// && $rname eq "$filename,v")) {
|
||||||
|
printf($BadName, "$directory/$filename,v", $rname);
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check that the version in the rcsid matches reality.
|
||||||
|
if ($lastversion ne $version) {
|
||||||
|
printf($BadVersion, $filename, $lastversion,
|
||||||
|
$version, "$directory/$filename");
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Do file fixups, i.e. replacing $ Id: .* $ with $ Id $.
|
||||||
|
sub fix_up_file {
|
||||||
|
my $filename = shift;
|
||||||
|
|
||||||
|
# not present - either removed or let cvs deal with it.
|
||||||
|
return 0 unless -f $filename;
|
||||||
|
|
||||||
|
open F, "< $filename" or die "Can't open $filename!\n";
|
||||||
|
my @file = <F>;
|
||||||
|
close F;
|
||||||
|
|
||||||
|
open F, "> $filename.tmp" or die "Can't create $filename tmpfile!\n";
|
||||||
|
while (@file) {
|
||||||
|
my $line = shift @file;
|
||||||
|
|
||||||
|
$line =~ s/\$$HEADER:.*?\$/\$$HEADER\$/g;
|
||||||
|
print F $line or die "Out of disk space?\n";
|
||||||
|
}
|
||||||
|
close F;
|
||||||
|
|
||||||
|
# overwrite the original file......
|
||||||
|
system($cfg::PROG_MV, "$filename.tmp", $filename);
|
||||||
|
die "Can't recreate $filename!\n" if $? >> 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
#############################################################
|
||||||
|
#
|
||||||
|
# Main Body
|
||||||
|
#
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
#print("ARGV - ", join(":", @ARGV), "\n");
|
||||||
|
#print("id - ", $cfg::PID, "\n");
|
||||||
|
|
||||||
|
#
|
||||||
|
# Suck in the Entries file
|
||||||
|
#
|
||||||
|
my %cvsversion;
|
||||||
|
my %cvstag;
|
||||||
|
open ENTRIES, $ENTRIES or die "Cannot open $ENTRIES.\n";
|
||||||
|
while (<ENTRIES>) {
|
||||||
|
chomp;
|
||||||
|
next if /^D/;
|
||||||
|
|
||||||
|
my ($filename, $ver, $stamp, $opt, $tag) = split '/', substr($_, 1);
|
||||||
|
$cvsversion{$filename} = $ver;
|
||||||
|
$cvstag{$filename} = $tag;
|
||||||
|
$stamp = $opt; #silence -w
|
||||||
|
}
|
||||||
|
close ENTRIES;
|
||||||
|
|
||||||
|
my $directory = $ARGV[0];
|
||||||
|
shift @ARGV;
|
||||||
|
|
||||||
|
$directory =~ s,^$CVSROOT[/]+,,;
|
||||||
|
|
||||||
|
my $check_id = 0;
|
||||||
|
if ($directory =~ /^src\/contrib/) {
|
||||||
|
$check_id = 3;
|
||||||
|
}
|
||||||
|
if ($directory =~ /^src\/crypto/) {
|
||||||
|
$check_id = 3;
|
||||||
|
}
|
||||||
|
#
|
||||||
|
# Now check each file name passed in, except those excluded.
|
||||||
|
#
|
||||||
|
if ($cfg::CHECK_HEADERS or $cfg::WARN_HEADERS) {
|
||||||
|
my $failed = 0;
|
||||||
|
foreach my $arg (@ARGV) {
|
||||||
|
my $hastag = ($cvstag{$arg} ne '');
|
||||||
|
next if ($check_id == 3 && $hastag);
|
||||||
|
|
||||||
|
# Ignore the file if it's in the exclude list.
|
||||||
|
next if exclude_file($arg, $directory);
|
||||||
|
|
||||||
|
# Check to make sure that the file hasn't had
|
||||||
|
# it's revision string changed.
|
||||||
|
$failed += &check_version($arg, $directory, $hastag,
|
||||||
|
$cvsversion{$arg});
|
||||||
|
|
||||||
|
# Unexpand the rcsid if required.
|
||||||
|
fix_up_file($arg) if $cfg::UNEXPAND_RCSID and !$failed;
|
||||||
|
}
|
||||||
|
if ($failed and not $cfg::WARN_HEADERS) {
|
||||||
|
print "\n";
|
||||||
|
unlink($cfg::LAST_FILE);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Record this directory as the last one checked. This will be used
|
||||||
|
# by the log_accumulate script to determine when it is processing
|
||||||
|
# the final directory of a multi-directory commit.
|
||||||
|
#
|
||||||
|
&write_line($cfg::LAST_FILE, $directory);
|
||||||
|
|
||||||
|
exit(0);
|
74
CVSROOT/commitcheck
Executable file
74
CVSROOT/commitcheck
Executable file
|
@ -0,0 +1,74 @@
|
||||||
|
#!/usr/bin/perl -w
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
# $FreeBSD: commitcheck,v 1.26 2002/10/13 23:25:06 peter Exp $
|
||||||
|
|
||||||
|
#
|
||||||
|
# This script is the first thing that is run at commit time
|
||||||
|
# to determine whether the committer has commit priviledges.
|
||||||
|
# (See CVSROOT/commitinfo).
|
||||||
|
#
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use lib $ENV{CVSROOT};
|
||||||
|
use CVSROOT::cfg;
|
||||||
|
my $CVSROOT = $ENV{CVSROOT} || die "Can't determine CVSROOT (commitcheck)!\n";
|
||||||
|
|
||||||
|
# Check that the user is committing on the right machine.
|
||||||
|
#
|
||||||
|
use Sys::Hostname;
|
||||||
|
my $hostname = hostname();
|
||||||
|
if (@cfg::COMMIT_HOSTS && !grep(/^\Q$hostname\E$/i, @cfg::COMMIT_HOSTS)) {
|
||||||
|
print "Please don't commit on this host!\n";
|
||||||
|
print "Please commit on ",
|
||||||
|
join(" or ", @cfg::COMMIT_HOSTS),
|
||||||
|
" instead.\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Run locally defined extra commitchecks.
|
||||||
|
if (defined($cfg::COMMITCHECK_EXTRA) && $cfg::COMMITCHECK_EXTRA) {
|
||||||
|
die 'commitcheck: $cfg::COMMITCHECK_EXTRA isn\'t a sub!'
|
||||||
|
unless ref($cfg::COMMITCHECK_EXTRA) eq "CODE";
|
||||||
|
|
||||||
|
die "Failed commitcheck_extra\n" unless &$cfg::COMMITCHECK_EXTRA();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Ensure the minimum version of cvs is installed.
|
||||||
|
#
|
||||||
|
#my $VERSTR = `$cfg::PROG_CVS -v`;
|
||||||
|
#$VERSTR =~ s/.*Concurrent\D*(\S*).*/$1/s;
|
||||||
|
#$VERSTR =~ s/\D+/./g;
|
||||||
|
#my $VERSION = sprintf "%d%02d%02d%02d\n", split /\./, $VERSTR;
|
||||||
|
#unless ($VERSION && $VERSION >= $cfg::MINCVSVERSION) {
|
||||||
|
# print "The wrong version of CVS is installed (commitcheck)!\n";
|
||||||
|
# exit 1;
|
||||||
|
#}
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Does the access control list allow them commit access?
|
||||||
|
#
|
||||||
|
system("$CVSROOT/CVSROOT/cvs_acls.pl", @ARGV);
|
||||||
|
if ($? >> 8) {
|
||||||
|
print "Access control checks failed! (cvs_acls.pl)\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Last minute checks and preparations for log_accum.pl later. This
|
||||||
|
# records the last directory in this commit so that log_accum knows when
|
||||||
|
# to finish coalescing commit messages and mail it.
|
||||||
|
#
|
||||||
|
system("$CVSROOT/CVSROOT/commit_prep.pl", @ARGV);
|
||||||
|
if ($? >> 8) {
|
||||||
|
print "commit_prep.pl failed!\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
exit 0; # Lets do it!
|
||||||
|
|
||||||
|
#end
|
16
CVSROOT/commitinfo
Normal file
16
CVSROOT/commitinfo
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
# The "commitinfo" file is used to control pre-commit checks.
|
||||||
|
# The filter on the right is invoked with the repository and a list
|
||||||
|
# of files to check. A non-zero exit of the filter program will
|
||||||
|
# cause the commit to be aborted.
|
||||||
|
#
|
||||||
|
# The first entry on a line is a regular expression which is tested
|
||||||
|
# against the directory that the change is being committed to, relative
|
||||||
|
# to the $CVSROOT. For the first match that is found, then the remainder
|
||||||
|
# of the line is the name of the filter to run.
|
||||||
|
#
|
||||||
|
# If the repository name does not match any of the regular expressions in this
|
||||||
|
# file, the "DEFAULT" line is used, if it is specified.
|
||||||
|
#
|
||||||
|
# If the name "ALL" appears as a regular expression it is always used
|
||||||
|
# in addition to the first matching regex or "DEFAULT".
|
||||||
|
ALL $CVSROOT/CVSROOT/commitcheck
|
21
CVSROOT/config
Normal file
21
CVSROOT/config
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# Set this to "no" if pserver shouldn't check system users/passwords
|
||||||
|
#SystemAuth=no
|
||||||
|
|
||||||
|
# Put CVS lock files in this directory rather than directly in the repository.
|
||||||
|
#LockDir=/var/lock/cvs
|
||||||
|
|
||||||
|
# Set `TopLevelAdmin' to `yes' to create a CVS directory at the top
|
||||||
|
# level of the new working directory when using the `cvs checkout'
|
||||||
|
# command.
|
||||||
|
#TopLevelAdmin=no
|
||||||
|
|
||||||
|
# Set `LogHistory' to `all' or `TOFEWGCMAR' to log all transactions to the
|
||||||
|
# history file, or a subset as needed (ie `TMAR' logs all write operations)
|
||||||
|
#LogHistory=TOFEWGCMAR
|
||||||
|
|
||||||
|
# Set `RereadLogAfterVerify' to `always' (the default) to allow the verifymsg
|
||||||
|
# script to change the log message. Set it to `stat' to force CVS to verify# that the file has changed before reading it (this can take up to an extra
|
||||||
|
# second per directory being committed, so it is not recommended for large
|
||||||
|
# repositories. Set it to `never' (the previous CVS behavior) to prevent
|
||||||
|
# verifymsg scripts from changing the log message.
|
||||||
|
#RereadLogAfterVerify=always
|
246
CVSROOT/cvs_acls.pl
Executable file
246
CVSROOT/cvs_acls.pl
Executable file
|
@ -0,0 +1,246 @@
|
||||||
|
#!/usr/bin/perl -w
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
# $FreeBSD: cvs_acls.pl,v 1.24 2002/07/22 17:24:29 joe Exp $
|
||||||
|
#
|
||||||
|
# Access control lists for CVS. dgg@ksr.com (David G. Grubbs)
|
||||||
|
#
|
||||||
|
# ==== FORMAT OF THE avail FILE:
|
||||||
|
#
|
||||||
|
# The avail file determines whether you may commit files. It contains lines
|
||||||
|
# read from top to bottom, keeping track of a single "bit". The "bit"
|
||||||
|
# defaults to "on". It can be turned "off" by "unavail" lines and "on" by
|
||||||
|
# "avail" lines. ==> Last one counts.
|
||||||
|
#
|
||||||
|
# Any line not beginning with "avail" or "unavail" is ignored.
|
||||||
|
#
|
||||||
|
# Lines beginning with "avail" or "unavail" are assumed to be '|'-separated
|
||||||
|
# triples: (All spaces and tabs are ignored in a line.)
|
||||||
|
#
|
||||||
|
# {avail.*,unavail.*} [| user,user,... [| repos,repos,...]]
|
||||||
|
#
|
||||||
|
# 1. String starting with "avail" or "unavail".
|
||||||
|
# 2. Optional, comma-separated list of usernames.
|
||||||
|
# 3. Optional, comma-separated list of repository pathnames.
|
||||||
|
# These are pathnames relative to $CVSROOT. They can be directories or
|
||||||
|
# filenames. A directory name allows access to all files and
|
||||||
|
# directories below it.
|
||||||
|
#
|
||||||
|
# Example: (Text from the ';;' rightward may not appear in the file.)
|
||||||
|
#
|
||||||
|
# unavail ;; Make whole repository unavailable.
|
||||||
|
# avail|dgg ;; Except for user "dgg".
|
||||||
|
# avail|fred, john|bin/ls ;; Except when "fred" or "john" commit to
|
||||||
|
# ;; the module whose repository is "bin/ls"
|
||||||
|
#
|
||||||
|
# PROGRAM LOGIC:
|
||||||
|
#
|
||||||
|
# CVS passes to @ARGV an absolute directory pathname (the repository
|
||||||
|
# appended to your $CVSROOT variable), followed by a list of filenames
|
||||||
|
# within that directory.
|
||||||
|
#
|
||||||
|
# We walk through the avail file looking for a line that matches both
|
||||||
|
# the username and repository.
|
||||||
|
#
|
||||||
|
# A username match is simply the user's name appearing in the second
|
||||||
|
# column of the avail line in a space-or-comma separate list.
|
||||||
|
#
|
||||||
|
# A repository match is either:
|
||||||
|
# - One element of the third column matches $ARGV[0], or some
|
||||||
|
# parent directory of $ARGV[0].
|
||||||
|
# - Otherwise *all* file arguments ($ARGV[1..$#ARGV]) must be
|
||||||
|
# in the file list in one avail line.
|
||||||
|
# - In other words, using directory names in the third column of
|
||||||
|
# the avail file allows committing of any file (or group of
|
||||||
|
# files in a single commit) in the tree below that directory.
|
||||||
|
# - If individual file names are used in the third column of
|
||||||
|
# the avail file, then files must be committed individually or
|
||||||
|
# all files specified in a single commit must all appear in
|
||||||
|
# third column of a single avail line.
|
||||||
|
#
|
||||||
|
# Additional (2001/11/16): I've added a group function for labelling
|
||||||
|
# groups of users. To define a group add a line in the avail file of
|
||||||
|
# the form:
|
||||||
|
# group|grpname1|joe,fred,bob
|
||||||
|
# group|grpname2|pete,:grpname1,simon
|
||||||
|
# group|grpname2|sid,:grpname2,mike
|
||||||
|
# group|anothergroup|!filename/containing/listofusers
|
||||||
|
#
|
||||||
|
# The group name can be used in any place a user name could be used in
|
||||||
|
# an avail or unavail line. Just precede the group name with a ':'
|
||||||
|
# character. In the example above you'll note that you can define a
|
||||||
|
# group more than once. Each definition overrides the previous one,
|
||||||
|
# but can include itself to add to it.
|
||||||
|
#
|
||||||
|
# In place of a username in any of the above rules, you can specify
|
||||||
|
# a group name preceeded with a ':' character, or a filename preceeded
|
||||||
|
# with a '!' character. In the case of a file it is assumed relative to
|
||||||
|
# $CVSROOT/CVSROOT/ unless it started witha leading '/'. All blank lines
|
||||||
|
# and comments are ignored, and the remaining lines are treated as one
|
||||||
|
# username per line.
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
use lib $ENV{CVSROOT};
|
||||||
|
use CVSROOT::cfg;
|
||||||
|
my $CVSROOT = $ENV{'CVSROOT'} || die "Can't determine \$CVSROOT!";
|
||||||
|
|
||||||
|
my $debug = $cfg::DEBUG;
|
||||||
|
|
||||||
|
my %GROUPS; # List of committer groups
|
||||||
|
my $exit_val = 0; # Good Exit value
|
||||||
|
my $universal_off = 0;
|
||||||
|
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# process any variable=value switches
|
||||||
|
#######################################
|
||||||
|
my $die = '';
|
||||||
|
eval "print STDERR \$die='Unknown parameter $1\n' if !defined \$$1; \$$1=\$';"
|
||||||
|
while ($ARGV[0] =~ /^(\w+)=/ && shift(@ARGV));
|
||||||
|
exit 255 if $die;
|
||||||
|
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# Work out where in the repo we're at.
|
||||||
|
#######################################
|
||||||
|
my $repos = shift;
|
||||||
|
$repos =~ s:^$CVSROOT/::;
|
||||||
|
grep($_ = $repos . '/' . $_, @ARGV);
|
||||||
|
|
||||||
|
print "$$ Repos: $repos\n","$$ ==== ",join("\n$$ ==== ",@ARGV),"\n" if $debug;
|
||||||
|
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# Check that the user has permission.
|
||||||
|
#######################################
|
||||||
|
|
||||||
|
# It is ok for the avail file not to exist.
|
||||||
|
exit 0 unless -e $cfg::AVAIL_FILE;
|
||||||
|
|
||||||
|
# Suck in a list of committer groups from the avail file.
|
||||||
|
open (AVAIL, $cfg::AVAIL_FILE) || die "open $cfg::AVAIL_FILE: $!\n";
|
||||||
|
while (<AVAIL>) {
|
||||||
|
next unless /^group\|/;
|
||||||
|
chomp;
|
||||||
|
|
||||||
|
my ($keywrd, $gname, $members) = split /\|/, $_;
|
||||||
|
$GROUPS{$gname} = expand_users($members);
|
||||||
|
}
|
||||||
|
close(AVAIL);
|
||||||
|
|
||||||
|
|
||||||
|
open (AVAIL, $cfg::AVAIL_FILE) || die "open $cfg::AVAIL_FILE: $!\n";
|
||||||
|
while (<AVAIL>) {
|
||||||
|
chomp;
|
||||||
|
next if /^\s*\#/;
|
||||||
|
next if /^\s*$/;
|
||||||
|
next if /^group\|/;
|
||||||
|
|
||||||
|
print "--------------------\n" if $debug;
|
||||||
|
|
||||||
|
my $rule = $_;
|
||||||
|
my ($flagstr, $u, $m) = split(/[\s,]*\|[\s,]*/, $rule);
|
||||||
|
|
||||||
|
# Skip anything not starting with "avail" or "unavail" and complain.
|
||||||
|
if ($flagstr !~ /^avail/ && $flagstr !~ /^unavail/) {
|
||||||
|
print "Bad avail line: $rule\n";
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set which bit we are playing with. ('0' is OK == Available).
|
||||||
|
my $flag = (($& eq "avail") ? 0 : 1);
|
||||||
|
|
||||||
|
# If we find a "universal off" flag (i.e. a simple "unavail")
|
||||||
|
# remember it
|
||||||
|
my $universal_off = 1 if ($flag && !$u && !$m);
|
||||||
|
|
||||||
|
# Expand any group names into a full user list.
|
||||||
|
my $users = expand_users($u);
|
||||||
|
|
||||||
|
# $cfg::COMMITTER considered "in user list" if actually in list
|
||||||
|
# or is NULL
|
||||||
|
my $in_user = (!$u || grep ($_ eq $cfg::COMMITTER,
|
||||||
|
split(/[\s,]+/, $users)));
|
||||||
|
print "$$ \$cfg::COMMITTER ($cfg::COMMITTER) in user list: $rule\n"
|
||||||
|
if $debug && $in_user;
|
||||||
|
|
||||||
|
# Module matches if it is a NULL module list in the avail line.
|
||||||
|
# If module list is not null, we check every argument combination.
|
||||||
|
my $in_repo = (!$m || 0);
|
||||||
|
unless ($in_repo) {
|
||||||
|
my @tmp = split(/[\s,]+/, $m);
|
||||||
|
for my $j (@tmp) {
|
||||||
|
# If the repos from avail is a parent(or equal)
|
||||||
|
# dir of $repos, OK
|
||||||
|
if ($repos eq $j || $repos =~ /^$j\//) {
|
||||||
|
$in_repo = 1;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unless ($in_repo) {
|
||||||
|
#$in_repo = 1;
|
||||||
|
for my $j (@ARGV) {
|
||||||
|
last unless $in_repo = grep ($_ eq $j, @tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print "$$ \$repos($repos) in repository list: $rule\n"
|
||||||
|
if $debug && $in_repo;
|
||||||
|
|
||||||
|
print "$$ Expanded user list: $users\n" if $debug;
|
||||||
|
|
||||||
|
$exit_val = $flag if ($in_user && $in_repo);
|
||||||
|
print "$$ ==== \$exit_val = $exit_val\n$$ ==== \$flag = $flag\n"
|
||||||
|
if $debug;
|
||||||
|
}
|
||||||
|
close(AVAIL);
|
||||||
|
print "$$ ==== \$exit_val = $exit_val\n" if $debug;
|
||||||
|
print "**** Access denied: Insufficient Karma ($cfg::COMMITTER|$repos)\n"
|
||||||
|
if $exit_val;
|
||||||
|
print "**** Access allowed: Personal Karma exceeds Environmental Karma.\n"
|
||||||
|
if $debug && $universal_off && !$exit_val;
|
||||||
|
exit($exit_val);
|
||||||
|
|
||||||
|
|
||||||
|
# Expand a user specification containing group names and deltas into
|
||||||
|
# a definitive list of users.
|
||||||
|
sub expand_users {
|
||||||
|
my $user_list = shift || "";
|
||||||
|
|
||||||
|
# Parse the members.
|
||||||
|
my @members = split /,/, $user_list;
|
||||||
|
my %members;
|
||||||
|
foreach my $m (@members) {
|
||||||
|
if ($m =~ s/^://) {
|
||||||
|
if (!defined($GROUPS{$m})) {
|
||||||
|
warn "Group '$m' not defined before use in " .
|
||||||
|
"$cfg::AVAIL_FILE.\n";
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
# Add the specified group to the membership.
|
||||||
|
foreach (split /,/, $GROUPS{$m}) {
|
||||||
|
$members{$_} = 1;
|
||||||
|
}
|
||||||
|
} elsif ($m =~ s/\!//) {
|
||||||
|
$m = "$CVSROOT/CVSROOT/$m" if $m !~ /^\//;
|
||||||
|
if (open USERLIST, $m) {
|
||||||
|
while (<USERLIST>) {
|
||||||
|
chomp;
|
||||||
|
s/\s*(#.*)?$//;
|
||||||
|
next if /^$/;
|
||||||
|
|
||||||
|
$members{$_} = 1;
|
||||||
|
}
|
||||||
|
close USERLIST;
|
||||||
|
} else {
|
||||||
|
warn "Can't open user file $m " .
|
||||||
|
"defined in $cfg::AVAIL_FILE.\n";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$members{$m} = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return join("," , sort keys %members);
|
||||||
|
}
|
26
CVSROOT/cvswrappers
Normal file
26
CVSROOT/cvswrappers
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
# This file affects handling of files based on their names.
|
||||||
|
#
|
||||||
|
# The -m option specifies whether CVS attempts to merge files.
|
||||||
|
#
|
||||||
|
# The -k option specifies keyword expansion (e.g. -kb for binary).
|
||||||
|
#
|
||||||
|
# Format of wrapper file ($CVSROOT/CVSROOT/cvswrappers or .cvswrappers)
|
||||||
|
#
|
||||||
|
# wildcard [option value][option value]...
|
||||||
|
#
|
||||||
|
# where option is one of
|
||||||
|
# -f from cvs filter value: path to filter
|
||||||
|
# -t to cvs filter value: path to filter
|
||||||
|
# -m update methodology value: MERGE or COPY
|
||||||
|
# -k expansion mode value: b, o, kkv, &c
|
||||||
|
#
|
||||||
|
# and value is a single-quote delimited value.
|
||||||
|
#
|
||||||
|
*.bin -k 'b'
|
||||||
|
*.gif -k 'b'
|
||||||
|
*.ico -k 'b'
|
||||||
|
*.jpg -k 'b'
|
||||||
|
*.pdf -k 'b'
|
||||||
|
*.png -k 'b'
|
||||||
|
*.jpg -k 'b'
|
||||||
|
*.zip -k 'b'
|
21
CVSROOT/editinfo
Normal file
21
CVSROOT/editinfo
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# The "editinfo" file is used to allow verification of logging
|
||||||
|
# information. It works best when a template (as specified in the
|
||||||
|
# rcsinfo file) is provided for the logging procedure. Given a
|
||||||
|
# template with locations for, a bug-id number, a list of people who
|
||||||
|
# reviewed the code before it can be checked in, and an external
|
||||||
|
# process to catalog the differences that were code reviewed, the
|
||||||
|
# following test can be applied to the code:
|
||||||
|
#
|
||||||
|
# Making sure that the entered bug-id number is correct.
|
||||||
|
# Validating that the code that was reviewed is indeed the code being
|
||||||
|
# checked in (using the bug-id number or a seperate review
|
||||||
|
# number to identify this particular code set.).
|
||||||
|
#
|
||||||
|
# If any of the above test failed, then the commit would be aborted.
|
||||||
|
#
|
||||||
|
# Actions such as mailing a copy of the report to each reviewer are
|
||||||
|
# better handled by an entry in the loginfo file.
|
||||||
|
#
|
||||||
|
# One thing that should be noted is the the ALL keyword is not
|
||||||
|
# supported. There can be only one entry that matches a given
|
||||||
|
# repository.
|
75
CVSROOT/exclude
Normal file
75
CVSROOT/exclude
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
# Exclusions list for header checking.
|
||||||
|
# $Id$
|
||||||
|
# $FreeBSD: exclude,v 1.105 2003/11/07 04:27:59 kan Exp $
|
||||||
|
#
|
||||||
|
|
||||||
|
# Skip dot files.
|
||||||
|
^(.*/)?\.
|
||||||
|
|
||||||
|
# A number of files in CVSROOT don't need to be checked.
|
||||||
|
^CVSROOT/cvsignore
|
||||||
|
^CVSROOT/options
|
||||||
|
^CVSROOT/rcstemplate
|
||||||
|
|
||||||
|
^distrib/
|
||||||
|
^www/
|
||||||
|
|
||||||
|
^doc/.*\.eps
|
||||||
|
^doc/.*\.png
|
||||||
|
^doc/.*\.scr
|
||||||
|
|
||||||
|
# Skip all ports files except for Makefiles.
|
||||||
|
^ports/.*(?<!/Makefile)$
|
||||||
|
|
||||||
|
^src/contrib/gdb/gdb/version.in
|
||||||
|
^src/contrib/groff/tmac/
|
||||||
|
^src/contrib/nvi/catalog
|
||||||
|
^src/etc/minfree
|
||||||
|
^src/etc/motd
|
||||||
|
^src/lib/libc_r/test/.*\.exp
|
||||||
|
^src/lib/libz/.*(?<!/Makefile)$
|
||||||
|
^src/release/sysinstall/help/.*\.hlp
|
||||||
|
^src/share/examples/cvsup/refuse
|
||||||
|
^src/share/examples/etc/bsd-style-copyright
|
||||||
|
^src/share/info/dir-tmpl
|
||||||
|
^src/share/man/man0
|
||||||
|
^src/sys/boot/common/help.common
|
||||||
|
^src/sys/boot/i386/loader/help.i386
|
||||||
|
^src/sys/boot/pc98/loader/help.pc98
|
||||||
|
^src/sys/boot/sparc64/loader/help.sparc64
|
||||||
|
^src/sys/contrib/dev/acpica
|
||||||
|
^src/sys/contrib/dev/ath
|
||||||
|
^src/sys/contrib/ia64/libuwx/
|
||||||
|
^src/tools/.*\.gif
|
||||||
|
^src/tools/.*\.png
|
||||||
|
^src/tools/regression/.*\.(in|out)
|
||||||
|
^src/usr.bin/doscmd/fonts.dir
|
||||||
|
^src/usr.bin/more/more.help
|
||||||
|
^src/usr.bin/mail/misc/mail.help
|
||||||
|
^src/usr.bin/mail/misc/mail.tildehelp
|
||||||
|
^src/usr.sbin/sysinstall/help/.*\.hlp
|
||||||
|
^src/.*\.ps
|
||||||
|
|
||||||
|
# src/share/zoneinfo is an externally-maintained database
|
||||||
|
# (would have been in src/contrib had the latter existed sooner).
|
||||||
|
# We don't normally keep local modifications to it, but it's no
|
||||||
|
# longer on the vendor branch for historical reasons.
|
||||||
|
# Exclude it so that we can use the vendor files verbatim.
|
||||||
|
^src/share/zoneinfo/[Ta-z]
|
||||||
|
|
||||||
|
# Treat the TrustedBSD Web site just as the FreeBSD Web site.
|
||||||
|
^projects/trustedbsd/www/
|
||||||
|
|
||||||
|
# Skip the CVSweb icon files
|
||||||
|
^projects/cvsweb/icons/
|
||||||
|
|
||||||
|
# Dictionaries should have no extra noise in them
|
||||||
|
^src/share/dict/*
|
||||||
|
|
||||||
|
# OpenSSL Generated manpages
|
||||||
|
^src/secure/lib/libcrypto/man
|
||||||
|
^src/secure/lib/libssl/man
|
||||||
|
^src/secure/usr.bin/openssl/man
|
||||||
|
|
||||||
|
# OpenSSH sources
|
||||||
|
^src/crypto/openssh
|
903
CVSROOT/log_accum.pl
Executable file
903
CVSROOT/log_accum.pl
Executable file
|
@ -0,0 +1,903 @@
|
||||||
|
#!/usr/bin/perl -w
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
# $FreeBSD: log_accum.pl,v 1.122 2003/02/28 18:28:11 peter Exp $
|
||||||
|
#
|
||||||
|
# Perl filter to handle the log messages from the checkin of files in
|
||||||
|
# a directory. This script will group the lists of files by log
|
||||||
|
# message, and mail a single consolidated log message at the end of
|
||||||
|
# the commit.
|
||||||
|
#
|
||||||
|
# This file assumes a pre-commit checking program that leaves the
|
||||||
|
# names of the first and last commit directories in a temporary file.
|
||||||
|
#
|
||||||
|
# Originally by David Hampton <hampton@cisco.com>
|
||||||
|
#
|
||||||
|
# Extensively hacked for FreeBSD by Peter Wemm <peter@netplex.com.au>,
|
||||||
|
# with parts stolen from Greg Woods <woods@most.wierd.com> version.
|
||||||
|
#
|
||||||
|
# Extensively cleaned up and re-worked to use an external configuration
|
||||||
|
# file by Josef Karthauser <joe@tao.org.uk>.
|
||||||
|
|
||||||
|
require 5.003; # might work with older perl5
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use Text::Tabs;
|
||||||
|
|
||||||
|
use lib $ENV{CVSROOT};
|
||||||
|
use CVSROOT::cfg;
|
||||||
|
my $CVSROOT = $ENV{'CVSROOT'} || die "Can't determine \$CVSROOT!";
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
#
|
||||||
|
# Constants
|
||||||
|
#
|
||||||
|
############################################################
|
||||||
|
my $STATE_NONE = 0;
|
||||||
|
my $STATE_CHANGED = 1;
|
||||||
|
my $STATE_ADDED = 2;
|
||||||
|
my $STATE_REMOVED = 3;
|
||||||
|
my $STATE_LOG = 4;
|
||||||
|
|
||||||
|
my $BASE_FN = "$cfg::TMPDIR/$cfg::FILE_PREFIX";
|
||||||
|
my $LAST_FILE = $cfg::LAST_FILE;
|
||||||
|
my $CHANGED_FILE = "$BASE_FN.changed";
|
||||||
|
my $ADDED_FILE = "$BASE_FN.added";
|
||||||
|
my $REMOVED_FILE = "$BASE_FN.removed";
|
||||||
|
my $LOG_FILE = "$BASE_FN.log";
|
||||||
|
my $SUMMARY_FILE = "$BASE_FN.summary";
|
||||||
|
my $LOGNAMES_FILE = "$BASE_FN.lognames";
|
||||||
|
my $SUBJ_FILE = "$BASE_FN.subj";
|
||||||
|
my $TAGS_FILE = "$BASE_FN.tags";
|
||||||
|
my $DIFF_FILE = "$BASE_FN.diff";
|
||||||
|
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
#
|
||||||
|
# Subroutines
|
||||||
|
#
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
# Remove the temporary files.
|
||||||
|
sub cleanup_tmpfiles {
|
||||||
|
my @files; # The list of temporary files.
|
||||||
|
|
||||||
|
# Don't clean up afterwards if in debug mode.
|
||||||
|
return if $cfg::DEBUG;
|
||||||
|
|
||||||
|
opendir DIR, $cfg::TMPDIR or die "Cannot open directory: $cfg::TMPDIR!";
|
||||||
|
push @files, grep /^$cfg::FILE_PREFIX\..*$/, readdir(DIR);
|
||||||
|
closedir DIR;
|
||||||
|
|
||||||
|
foreach (@files) {
|
||||||
|
unlink "$cfg::TMPDIR/$_";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Append a line to a named file.
|
||||||
|
sub append_line {
|
||||||
|
my $filename = shift; # File to append to.
|
||||||
|
my $line = shift; # Line to append.
|
||||||
|
|
||||||
|
open FILE, ">>$filename" or
|
||||||
|
die "Cannot open for append file $filename.\n";
|
||||||
|
print FILE "$line\n";
|
||||||
|
close FILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Read the first line from a named file.
|
||||||
|
sub read_line {
|
||||||
|
my $filename = shift; # The file to read the line from.
|
||||||
|
|
||||||
|
my $line; # The line read from the file.
|
||||||
|
|
||||||
|
open FILE, "<$filename" or die "Cannot read file $filename!";
|
||||||
|
$line = <FILE>;
|
||||||
|
close FILE;
|
||||||
|
chomp $line;
|
||||||
|
|
||||||
|
return $line;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Return the contents of a file as a list of strings,
|
||||||
|
# with trailing line feeds removed.
|
||||||
|
# Return an empty list of the file couldn't be opened for some reason.
|
||||||
|
sub read_logfile {
|
||||||
|
my $filename = shift; # The file to read from.
|
||||||
|
|
||||||
|
my @text = (); # The contents of the file.
|
||||||
|
|
||||||
|
if (open FILE, "<$filename") {
|
||||||
|
while (<FILE>) {
|
||||||
|
chomp;
|
||||||
|
push @text, $_;
|
||||||
|
}
|
||||||
|
close FILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return @text;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Write a list to a file.
|
||||||
|
sub write_logfile {
|
||||||
|
my $filename = shift; # File to write to.
|
||||||
|
my @lines = @_; # Contents to write to file.
|
||||||
|
|
||||||
|
open FILE, ">$filename" or
|
||||||
|
die "Cannot open for write log file $filename.";
|
||||||
|
print FILE map { "$_\n" } @lines;
|
||||||
|
close FILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub format_names {
|
||||||
|
my $dir = shift;
|
||||||
|
my @files = @_;
|
||||||
|
|
||||||
|
my $indent = length($dir);
|
||||||
|
$indent = 20 if $indent < 20;
|
||||||
|
|
||||||
|
my $format = " %-" . sprintf("%d", $indent) . "s ";
|
||||||
|
|
||||||
|
my @lines = (sprintf($format, $dir));
|
||||||
|
|
||||||
|
if ($cfg::DEBUG) {
|
||||||
|
print STDERR "format_names(): dir = ", $dir;
|
||||||
|
#print STDERR "; tag = ", $tag;
|
||||||
|
print STDERR "; files = ", join(":", @files), ".\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach my $file (@files) {
|
||||||
|
if (length($lines[$#lines]) + length($file) > 66) {
|
||||||
|
$lines[++$#lines] = sprintf($format, "", "");
|
||||||
|
}
|
||||||
|
$lines[$#lines] .= $file . " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
return @lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub format_lists {
|
||||||
|
my $header = shift;
|
||||||
|
my @lines = @_;
|
||||||
|
|
||||||
|
print STDERR "format_lists(): ", join(":", @lines), "\n" if $cfg::DEBUG;
|
||||||
|
|
||||||
|
my $lastdir = '';
|
||||||
|
my $lastsep = '';
|
||||||
|
my $tag = '';
|
||||||
|
my @files = ();
|
||||||
|
my @text = ();
|
||||||
|
foreach my $line (@lines) {
|
||||||
|
if ($line =~ /.*\/$/) {
|
||||||
|
push @text, &format_names($lastdir, @files) if $lastdir;
|
||||||
|
@files = ();
|
||||||
|
|
||||||
|
$lastdir = $line;
|
||||||
|
$lastdir =~ s,/$,,;
|
||||||
|
|
||||||
|
$tag = ""; # next thing is a tag
|
||||||
|
} elsif (!$tag) {
|
||||||
|
$tag = $line;
|
||||||
|
next if "$header$tag" eq $lastsep;
|
||||||
|
|
||||||
|
$lastsep = $header . $tag;
|
||||||
|
if ($tag eq 'HEAD') {
|
||||||
|
push @text, " $header files:";
|
||||||
|
} else {
|
||||||
|
push @text, sprintf(" %-22s (Branch: %s)",
|
||||||
|
"$header files:", $tag);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
push @files, $line;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
push @text, &format_names($lastdir, sort @files);
|
||||||
|
|
||||||
|
return @text;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub append_names_to_file {
|
||||||
|
my $filename = shift;
|
||||||
|
my $dir = shift;
|
||||||
|
my $tag = shift;
|
||||||
|
my @files = @_;
|
||||||
|
|
||||||
|
return unless @files;
|
||||||
|
|
||||||
|
open FILE, ">>$filename" or die "Cannot append to file $filename.";
|
||||||
|
|
||||||
|
print FILE $dir, "\n";
|
||||||
|
print FILE $tag, "\n";
|
||||||
|
print FILE map { "$_\n" } @files;
|
||||||
|
close FILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Use cvs status to obtain the current revision number of a given file.
|
||||||
|
#
|
||||||
|
sub get_revision_number {
|
||||||
|
my $file = shift;
|
||||||
|
|
||||||
|
my $rcsfile = "";
|
||||||
|
my $revision = "";
|
||||||
|
|
||||||
|
open(RCS, "-|") || exec $cfg::PROG_CVS, '-Qn', 'status', $file;
|
||||||
|
while (<RCS>) {
|
||||||
|
if (/^[ \t]*Repository revision/) {
|
||||||
|
chomp;
|
||||||
|
my @revline = split;
|
||||||
|
$revision = $revline[2];
|
||||||
|
$revline[3] =~ m|^$CVSROOT/+(.*),v$|;
|
||||||
|
$rcsfile = $1;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close RCS;
|
||||||
|
|
||||||
|
$rcsfile =~ s|/Attic/|/|; # Remove 'Attic/' if present.
|
||||||
|
return($revision, $rcsfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Return the previous revision number.
|
||||||
|
#
|
||||||
|
sub previous_revision {
|
||||||
|
my $rev = shift;
|
||||||
|
|
||||||
|
$rev =~ /(?:(.*)\.)?([^\.]+)\.([^\.]+)$/;
|
||||||
|
my ($base, $r1, $r2) = ($1, $2, $3);
|
||||||
|
|
||||||
|
my $prevrev = "";
|
||||||
|
if ($r2 == 1) {
|
||||||
|
$prevrev = $base;
|
||||||
|
} else {
|
||||||
|
$prevrev = "$base." if $base;
|
||||||
|
$prevrev .= "$r1." . ($r2 - 1);
|
||||||
|
}
|
||||||
|
return $prevrev;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Count the number of lines in a given revision of a file.
|
||||||
|
#
|
||||||
|
sub count_lines_in_revision {
|
||||||
|
my $file = shift; # File in repository.
|
||||||
|
my $rev = shift; # Revision number.
|
||||||
|
|
||||||
|
my $lines = 0;
|
||||||
|
open(RCS, "-|") ||
|
||||||
|
exec $cfg::PROG_CVS, '-Qn', 'update', '-p', "-r$rev", $file;
|
||||||
|
while (<RCS>) {
|
||||||
|
++$lines;
|
||||||
|
}
|
||||||
|
close RCS;
|
||||||
|
|
||||||
|
return $lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Summarise details of the file modifications.
|
||||||
|
#
|
||||||
|
sub change_summary_changed {
|
||||||
|
my $outfile = shift; # File name of output file.
|
||||||
|
my @filenames = @_; # List of files to check.
|
||||||
|
|
||||||
|
foreach my $file (@filenames) {
|
||||||
|
next unless $file;
|
||||||
|
|
||||||
|
my $delta = "";
|
||||||
|
my ($rev, $rcsfile) = get_revision_number($file);
|
||||||
|
|
||||||
|
if ($rev and $rcsfile) {
|
||||||
|
open(RCS, "-|") ||
|
||||||
|
exec $cfg::PROG_CVS, '-Qn', 'log', "-r$rev", $file;
|
||||||
|
while (<RCS>) {
|
||||||
|
if (/^date:.*lines:\s(.*)$/) {
|
||||||
|
$delta = $1;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close RCS;
|
||||||
|
}
|
||||||
|
|
||||||
|
&append_line($outfile, "$rev,$delta,,$rcsfile");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Summarise details of added files.
|
||||||
|
#
|
||||||
|
sub change_summary_added {
|
||||||
|
my $outfile = shift; # File name of output file.
|
||||||
|
my @filenames = @_; # List of files to check.
|
||||||
|
|
||||||
|
foreach my $file (@filenames) {
|
||||||
|
next unless $file;
|
||||||
|
|
||||||
|
my $delta = "";
|
||||||
|
my ($rev, $rcsfile) = get_revision_number($file);
|
||||||
|
|
||||||
|
if ($rev and $rcsfile) {
|
||||||
|
my $lines = count_lines_in_revision($file, $rev);
|
||||||
|
$delta = "+$lines -0";
|
||||||
|
}
|
||||||
|
|
||||||
|
&append_line($outfile, "$rev,$delta,new,$rcsfile");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Summarise details of removed files.
|
||||||
|
#
|
||||||
|
sub change_summary_removed {
|
||||||
|
my $outfile = shift; # File name of output file.
|
||||||
|
my @filenames = @_; # List of files to check.
|
||||||
|
|
||||||
|
foreach my $file (@filenames) {
|
||||||
|
next unless $file;
|
||||||
|
|
||||||
|
my $delta = "";
|
||||||
|
my ($rev, $rcsfile) = get_revision_number($file);
|
||||||
|
|
||||||
|
if ($rev and $rcsfile) {
|
||||||
|
my $prevrev = previous_revision($rev);
|
||||||
|
my $lines = count_lines_in_revision($file, $prevrev);
|
||||||
|
$delta = "+0 -$lines";
|
||||||
|
}
|
||||||
|
|
||||||
|
&append_line($outfile, "$rev,$delta,dead,$rcsfile");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub build_header {
|
||||||
|
delete $ENV{'TZ'};
|
||||||
|
|
||||||
|
my $datestr = `/bin/date +"%Y/%m/%d %H:%M:%S %Z"`;
|
||||||
|
chomp $datestr;
|
||||||
|
|
||||||
|
my $header = sprintf("%-8s %s", $cfg::COMMITTER, $datestr);
|
||||||
|
|
||||||
|
my @text;
|
||||||
|
push @text, $header;
|
||||||
|
push @text, "";
|
||||||
|
push @text, " $cfg::MAILBANNER", "" if $cfg::MAILBANNER;
|
||||||
|
|
||||||
|
return @text;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# !!! Mailing-list and commitlog history file mappings here !!!
|
||||||
|
# This needs pulling out as a configuration block somewhere so
|
||||||
|
# that others can easily change it.
|
||||||
|
sub get_log_name {
|
||||||
|
my $dir = shift; # Directory name
|
||||||
|
|
||||||
|
|
||||||
|
for my $i (0 .. ($#cfg::LOG_FILE_MAP - 1) / 2) {
|
||||||
|
my $log = $cfg::LOG_FILE_MAP[$i * 2];
|
||||||
|
my $pattern = $cfg::LOG_FILE_MAP[$i * 2 + 1];
|
||||||
|
|
||||||
|
return $log if $dir =~ /$pattern/;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'other';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub do_changes_file {
|
||||||
|
my @text = @_;
|
||||||
|
|
||||||
|
my %unique = ();
|
||||||
|
my @mailaddrs = &read_logfile($LOGNAMES_FILE);
|
||||||
|
foreach my $category (@mailaddrs) {
|
||||||
|
next if ($unique{$category});
|
||||||
|
$unique{$category} = 1;
|
||||||
|
|
||||||
|
my $changes = "$CVSROOT/CVSROOT/commitlogs/$category";
|
||||||
|
open CHANGES, ">>$changes"
|
||||||
|
or die "Cannot open $changes.\n";
|
||||||
|
print CHANGES map { "$_\n" } @text;
|
||||||
|
print CHANGES "\n\n\n";
|
||||||
|
close CHANGES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub mail_notification {
|
||||||
|
my @text = @_;
|
||||||
|
|
||||||
|
# This is turned off since the To: lines go overboard.
|
||||||
|
# Also it has bit-rotted since, and can't just be switched on again.
|
||||||
|
# - but keep it for the time being in case we do something like cvs-stable
|
||||||
|
# my @mailaddrs = &read_logfile($LOGNAMES_FILE);
|
||||||
|
# print(MAIL 'To: cvs-committers' . $dom . ", cvs-all" . $dom);
|
||||||
|
# foreach $line (@mailaddrs) {
|
||||||
|
# next if ($unique{$line});
|
||||||
|
# $unique{$line} = 1;
|
||||||
|
# next if /^cvs-/;
|
||||||
|
# print(MAIL ", " . $line . $dom);
|
||||||
|
# }
|
||||||
|
# print(MAIL "\n");
|
||||||
|
|
||||||
|
my @email = ();
|
||||||
|
|
||||||
|
my $to = $cfg::MAILADDRS;
|
||||||
|
print "Mailing the commit message to '$to'.\n";
|
||||||
|
|
||||||
|
push @email, "To: $to" if $cfg::ADD_TO_LINE;
|
||||||
|
|
||||||
|
my $subject = 'Subject: Schlepperbande commit:';
|
||||||
|
my @subj = &read_logfile($SUBJ_FILE);
|
||||||
|
my $subjlines = 0;
|
||||||
|
my $subjwords = 0; # minimum of two "words" per line
|
||||||
|
LINE: foreach my $line (@subj) {
|
||||||
|
foreach my $word (split(/ /, $line)) {
|
||||||
|
if ($subjwords > 2 &&
|
||||||
|
length("$subject $word") > 75) {
|
||||||
|
if ($subjlines > 2) {
|
||||||
|
$subject .= " ...";
|
||||||
|
}
|
||||||
|
push @email, $subject;
|
||||||
|
if ($subjlines > 2) {
|
||||||
|
$subject = "";
|
||||||
|
last LINE;
|
||||||
|
}
|
||||||
|
|
||||||
|
# rfc822 continuation line
|
||||||
|
$subject = " ";
|
||||||
|
$subjwords = 0;
|
||||||
|
$subjlines++;
|
||||||
|
}
|
||||||
|
$subject .= " " . $word;
|
||||||
|
$subjwords++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
push @email, $subject if $subject;
|
||||||
|
|
||||||
|
# If required add a header to the mail msg showing
|
||||||
|
# which branches were modified during the commit.
|
||||||
|
if ($cfg::MAIL_BRANCH_HDR) {
|
||||||
|
my %tags = map { $_ => 1 } &read_logfile($TAGS_FILE);
|
||||||
|
if (keys %tags) {
|
||||||
|
push @email, $cfg::MAIL_BRANCH_HDR . ": " .
|
||||||
|
join(",", sort keys %tags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
push @email, "";
|
||||||
|
push @email, @text;
|
||||||
|
|
||||||
|
# Transform the email message?
|
||||||
|
if (defined($cfg::MAIL_TRANSFORM) && $cfg::MAIL_TRANSFORM) {
|
||||||
|
die 'log_accum.pl: $cfg::MAIL_TRANSFORM isn\'t a sub!'
|
||||||
|
unless ref($cfg::MAIL_TRANSFORM) eq "CODE";
|
||||||
|
|
||||||
|
if ($cfg::DEBUG) {
|
||||||
|
print "Email transform.\n";
|
||||||
|
print map { "Before: $_\n" } @email;
|
||||||
|
}
|
||||||
|
|
||||||
|
@email = &$cfg::MAIL_TRANSFORM(@email);
|
||||||
|
|
||||||
|
print map { "After: $_\n" } @email if $cfg::DEBUG;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Send the email.
|
||||||
|
open MAIL, "| $cfg::MAILCMD $to"
|
||||||
|
or die "Please check $cfg::MAILCMD.";
|
||||||
|
print MAIL map { "$_\n" } @email;
|
||||||
|
close MAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Return the length of the longest value in the list.
|
||||||
|
sub longest_value {
|
||||||
|
my @values = @_;
|
||||||
|
|
||||||
|
my @sorted = sort { $b <=> $a } map { length $_ } @values;
|
||||||
|
return $sorted[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub format_summaries {
|
||||||
|
my @filenames = @_;
|
||||||
|
|
||||||
|
my @revs;
|
||||||
|
my @deltas;
|
||||||
|
my @files;
|
||||||
|
my @statuses;
|
||||||
|
|
||||||
|
# Parse the summary file.
|
||||||
|
foreach my $filename (@filenames) {
|
||||||
|
open FILE, $filename or next;
|
||||||
|
while (<FILE>) {
|
||||||
|
chomp;
|
||||||
|
my ($r, $d, $s, $f) = split(/,/, $_, 4);
|
||||||
|
push @revs, $r;
|
||||||
|
push @deltas, $d;
|
||||||
|
push @statuses, $s;
|
||||||
|
push @files, $f;
|
||||||
|
}
|
||||||
|
close FILE;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Format the output, extra spaces after "Changes"
|
||||||
|
# to match historic formatting.
|
||||||
|
my $r_max = longest_value("Revision", @revs) + 2;
|
||||||
|
my $d_max = longest_value("Changes ", @deltas) + 2;
|
||||||
|
|
||||||
|
my @text;
|
||||||
|
my $fmt = "%-" . $r_max . "s%-" . $d_max . "s%s";
|
||||||
|
push @text, sprintf $fmt, "Revision", "Changes", "Path";
|
||||||
|
|
||||||
|
my @order = sort { $files[$a] cmp $files[$b] } (0 .. $#revs);
|
||||||
|
foreach (@order) {
|
||||||
|
my $file = $files[$_];
|
||||||
|
my $status = $statuses[$_];
|
||||||
|
$file .= " ($status)" if $status;
|
||||||
|
push @text, sprintf $fmt, $revs[$_], $deltas[$_], $file;
|
||||||
|
}
|
||||||
|
|
||||||
|
return @text;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Make a diff of the changes.
|
||||||
|
#
|
||||||
|
sub do_diff {
|
||||||
|
my $outfile = shift;
|
||||||
|
my @filenames = @_; # List of files to check.
|
||||||
|
|
||||||
|
foreach my $file (@filenames) {
|
||||||
|
next unless $file;
|
||||||
|
|
||||||
|
my $diff;
|
||||||
|
|
||||||
|
my ($rev, $rcsfile) = get_revision_number($file);
|
||||||
|
|
||||||
|
#
|
||||||
|
# If this is a binary file, don't try to report a diff;
|
||||||
|
# not only is it meaningless, but it also screws up some
|
||||||
|
# mailers. We rely on Perl's 'is this binary' algorithm;
|
||||||
|
# it's pretty good. But not perfect.
|
||||||
|
#
|
||||||
|
if (($file =~ /\.(?:pdf|gif|jpg|tar|tgz|gz)$/i) or (-B $file)) {
|
||||||
|
$diff .= "Index: $file\n";
|
||||||
|
$diff .= "=" x 67 . "\n";
|
||||||
|
$diff .= "\t<<Binary file>>\n";
|
||||||
|
} else {
|
||||||
|
#
|
||||||
|
# Get the differences between this and the previous
|
||||||
|
# revision, being aware that new files always have
|
||||||
|
# revision '1.1' and new branches always end in '.n.1'.
|
||||||
|
#
|
||||||
|
if ($rev =~ /^(.*)\.([0-9]+)$/) {
|
||||||
|
my $prev_rev = previous_revision($rev);
|
||||||
|
|
||||||
|
my @args = ();
|
||||||
|
if ($rev eq '1.1') {
|
||||||
|
$diff .= "Index: $file\n"
|
||||||
|
. "=" x 68 . "\n";
|
||||||
|
@args = ('-Qn', 'update', '-p',
|
||||||
|
'-r1.1', $file);
|
||||||
|
} else {
|
||||||
|
@args = ('-Qn', 'diff', '-u',
|
||||||
|
"-r$prev_rev", "-r$rev", $file);
|
||||||
|
}
|
||||||
|
|
||||||
|
print "Generating diff: $cfg::PROG_CVS @args\n"
|
||||||
|
if $cfg::DEBUG;
|
||||||
|
open(DIFF, "-|") || exec $cfg::PROG_CVS, @args;
|
||||||
|
while(<DIFF>) {
|
||||||
|
$diff .= $_;
|
||||||
|
}
|
||||||
|
close DIFF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
my $diff_length = length($diff);
|
||||||
|
if ($diff_length > $cfg::MAX_DIFF_SIZE * 1024) {
|
||||||
|
$diff = "File/diff for $file is too large (" .
|
||||||
|
$diff_length . " bytes > " .
|
||||||
|
$cfg::MAX_DIFF_SIZE * 1024 . " bytes)!\n";
|
||||||
|
}
|
||||||
|
#&append_line($outfile, "$diff");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#############################################################
|
||||||
|
#
|
||||||
|
# Main Body
|
||||||
|
#
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
#
|
||||||
|
# Setup environment
|
||||||
|
#
|
||||||
|
umask (002);
|
||||||
|
|
||||||
|
#
|
||||||
|
# Initialize basic variables
|
||||||
|
#
|
||||||
|
my $input_params = $ARGV[0];
|
||||||
|
my ($directory, @filenames) = split " ", $input_params;
|
||||||
|
#@files = split(' ', $input_params);
|
||||||
|
|
||||||
|
my @path = split('/', $directory);
|
||||||
|
my $dir;
|
||||||
|
if ($#path == 0) {
|
||||||
|
$dir = ".";
|
||||||
|
} else {
|
||||||
|
$dir = join('/', @path[1..$#path]);
|
||||||
|
}
|
||||||
|
$dir = $dir . "/";
|
||||||
|
|
||||||
|
#
|
||||||
|
# Throw some values at the developer if in debug mode
|
||||||
|
#
|
||||||
|
if ($cfg::DEBUG) {
|
||||||
|
print "ARGV - ", join(":", @ARGV), "\n";
|
||||||
|
print "directory - ", $directory, "\n";
|
||||||
|
print "filenames - ", join(":", @filenames), "\n";
|
||||||
|
print "path - ", join(":", @path), "\n";
|
||||||
|
print "dir - ", $dir, "\n";
|
||||||
|
print "pid - ", $cfg::PID, "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Was used for To: lines, still used for commitlogs naming.
|
||||||
|
&append_line($LOGNAMES_FILE, &get_log_name("$directory/"));
|
||||||
|
&append_line($SUBJ_FILE, "$directory " . join(" ", sort @filenames));
|
||||||
|
|
||||||
|
#
|
||||||
|
# Check for a new directory first. This will always appear as a
|
||||||
|
# single item in the argument list, and an empty log message.
|
||||||
|
#
|
||||||
|
if ($input_params =~ /New directory/) {
|
||||||
|
my @text = &build_header();
|
||||||
|
|
||||||
|
push @text, " $input_params";
|
||||||
|
&do_changes_file(@text);
|
||||||
|
&mail_notification(@text) if $cfg::MAIL_ON_DIR_CREATION;
|
||||||
|
&cleanup_tmpfiles();
|
||||||
|
exit 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Check for an import command. This will always appear as a
|
||||||
|
# single item in the argument list, and a log message.
|
||||||
|
#
|
||||||
|
if ($input_params =~ /Imported sources/) {
|
||||||
|
my @text = &build_header();
|
||||||
|
my $vendor_tag;
|
||||||
|
|
||||||
|
push @text, " $input_params";
|
||||||
|
|
||||||
|
while (<STDIN>) {
|
||||||
|
chomp;
|
||||||
|
push @text, " $_";
|
||||||
|
|
||||||
|
$vendor_tag = $1 if /Vendor Tag:\s*(\S*)/;
|
||||||
|
}
|
||||||
|
&append_line($TAGS_FILE, $vendor_tag) if $vendor_tag;
|
||||||
|
|
||||||
|
&do_changes_file(@text);
|
||||||
|
&mail_notification(@text);
|
||||||
|
#system("/usr/local/bin/awake", $directory);
|
||||||
|
&cleanup_tmpfiles();
|
||||||
|
exit 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Iterate over the body of the message collecting information.
|
||||||
|
#
|
||||||
|
my %added_files; # Hashes containing lists of files
|
||||||
|
my %changed_files; # that have been changed, keyed
|
||||||
|
my %removed_files; # by branch tag.
|
||||||
|
|
||||||
|
my @log_lines; # The lines of the log message.
|
||||||
|
|
||||||
|
my $tag = "HEAD"; # Default branch is HEAD.
|
||||||
|
my $state = $STATE_NONE; # Initially in no state.
|
||||||
|
|
||||||
|
while (<STDIN>) {
|
||||||
|
s/[ \t\n]+$//; # delete trailing space
|
||||||
|
|
||||||
|
# parse the revision tag if it exists.
|
||||||
|
if (/^Revision\/Branch:(.*)/) { $tag = $1; next; }
|
||||||
|
if (/^[ \t]+Tag: (.*)/) { $tag = $1; next; }
|
||||||
|
if (/^[ \t]+No tag$/) { $tag = "HEAD"; next; }
|
||||||
|
|
||||||
|
# check for a state change, guarding against similar markers
|
||||||
|
# in the log message itself.
|
||||||
|
unless ($state == $STATE_LOG) {
|
||||||
|
if (/^Modified Files/) { $state = $STATE_CHANGED; next; }
|
||||||
|
if (/^Added Files/) { $state = $STATE_ADDED; next; }
|
||||||
|
if (/^Removed Files/) { $state = $STATE_REMOVED; next; }
|
||||||
|
if (/^Log Message/) { $state = $STATE_LOG; next; }
|
||||||
|
}
|
||||||
|
|
||||||
|
# don't so anything if we're not in a state.
|
||||||
|
next if $state == $STATE_NONE;
|
||||||
|
|
||||||
|
# collect the log line (ignoring empty template entries)?
|
||||||
|
if ($state == $STATE_LOG) {
|
||||||
|
next if /^(.*):$/ and $cfg::TEMPLATE_HEADERS{$1};
|
||||||
|
|
||||||
|
push @log_lines, $_;
|
||||||
|
}
|
||||||
|
|
||||||
|
# otherwise collect information about which files changed.
|
||||||
|
my @files = split;
|
||||||
|
push @{ $changed_files{$tag} }, @files if $state == $STATE_CHANGED;
|
||||||
|
push @{ $added_files{$tag} }, @files if $state == $STATE_ADDED;
|
||||||
|
push @{ $removed_files{$tag} }, @files if $state == $STATE_REMOVED;
|
||||||
|
}
|
||||||
|
&append_line($TAGS_FILE, $tag);
|
||||||
|
|
||||||
|
#
|
||||||
|
# Strip leading and trailing blank lines from the log message.
|
||||||
|
# Compress multiple blank lines in the body of the message down to a
|
||||||
|
# single blank line.
|
||||||
|
# Convert tabs to spaces, so that when we indent the email message and
|
||||||
|
# log file everything still lines up.
|
||||||
|
# (Note, this only does the mail and changes log, not the rcs log).
|
||||||
|
#
|
||||||
|
my $log_message = join "\n", @log_lines;
|
||||||
|
$log_message =~ s/\n{3,}/\n\n/g;
|
||||||
|
$log_message =~ s/^\n+//;
|
||||||
|
$log_message =~ s/\n+$//;
|
||||||
|
@log_lines = expand(split /\n/, $log_message);
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Find the log file that matches this log message
|
||||||
|
#
|
||||||
|
my $message_index; # The index of this log message
|
||||||
|
for ($message_index = 0; ; $message_index++) {
|
||||||
|
last unless -e "$LOG_FILE.$message_index";
|
||||||
|
|
||||||
|
my @text = &read_logfile("$LOG_FILE.$message_index");
|
||||||
|
last unless @text;
|
||||||
|
last if "@log_lines" eq "@text";
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Spit out the information gathered in this pass.
|
||||||
|
#
|
||||||
|
foreach my $tag ( keys %added_files ) {
|
||||||
|
&append_names_to_file("$ADDED_FILE.$message_index", $dir, $tag,
|
||||||
|
@{ $added_files{$tag} });
|
||||||
|
}
|
||||||
|
foreach my $tag ( keys %changed_files ) {
|
||||||
|
&append_names_to_file("$CHANGED_FILE.$message_index", $dir, $tag,
|
||||||
|
@{ $changed_files{$tag} });
|
||||||
|
}
|
||||||
|
foreach my $tag ( keys %removed_files ) {
|
||||||
|
&append_names_to_file("$REMOVED_FILE.$message_index", $dir, $tag,
|
||||||
|
@{ $removed_files{$tag} });
|
||||||
|
}
|
||||||
|
&write_logfile("$LOG_FILE.$message_index", @log_lines);
|
||||||
|
|
||||||
|
#
|
||||||
|
# Save the info for the commit summary.
|
||||||
|
#
|
||||||
|
foreach my $tag ( keys %added_files ) {
|
||||||
|
&change_summary_added("$SUMMARY_FILE.$message_index",
|
||||||
|
@{ $added_files{$tag} });
|
||||||
|
&do_diff("$DIFF_FILE.$message_index", @{ $added_files{$tag} })
|
||||||
|
if ( $cfg::MAX_DIFF_SIZE > 0 );
|
||||||
|
}
|
||||||
|
foreach my $tag ( keys %changed_files ) {
|
||||||
|
&change_summary_changed("$SUMMARY_FILE.$message_index",
|
||||||
|
@{ $changed_files{$tag} });
|
||||||
|
&do_diff("$DIFF_FILE.$message_index", @{ $changed_files{$tag} })
|
||||||
|
if ( $cfg::MAX_DIFF_SIZE > 0 );
|
||||||
|
}
|
||||||
|
foreach my $tag ( keys %removed_files ) {
|
||||||
|
&change_summary_removed("$SUMMARY_FILE.$message_index",
|
||||||
|
@{ $removed_files{$tag} });
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Check whether this is the last directory. If not, quit.
|
||||||
|
# The last directory name was written by commit_prep.pl on
|
||||||
|
# the way in.
|
||||||
|
#
|
||||||
|
if (-e $LAST_FILE) {
|
||||||
|
$_ = &read_line($LAST_FILE);
|
||||||
|
my $tmpfiles = $directory;
|
||||||
|
$tmpfiles =~ s,([^a-zA-Z0-9_/]),\\$1,g;
|
||||||
|
unless (grep(/$tmpfiles$/, $_)) {
|
||||||
|
print "More commits to come...\n";
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# This is it. The commits are all finished. Lump everything together
|
||||||
|
# into a single message, fire a copy off to the mailing list, and drop
|
||||||
|
# it on the end of the Changes file.
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Produce the final compilation of the log messages
|
||||||
|
#
|
||||||
|
my $diff_num_lines = $cfg::DIFF_BLOCK_TOTAL_LINES;
|
||||||
|
for (my $i = 0; ; $i++) {
|
||||||
|
last unless -e "$LOG_FILE.$i";
|
||||||
|
|
||||||
|
my @log_msg = &build_header();
|
||||||
|
|
||||||
|
my @mod_lines = &read_logfile("$CHANGED_FILE.$i");
|
||||||
|
push @log_msg, &format_lists("Modified", @mod_lines) if @mod_lines;
|
||||||
|
|
||||||
|
my @add_lines = &read_logfile("$ADDED_FILE.$i");
|
||||||
|
push @log_msg, &format_lists("Added", @add_lines) if @add_lines;
|
||||||
|
|
||||||
|
my @rem_lines = &read_logfile("$REMOVED_FILE.$i");
|
||||||
|
push @log_msg, &format_lists("Removed", @rem_lines) if @rem_lines;
|
||||||
|
|
||||||
|
my @msg_lines = &read_logfile("$LOG_FILE.$i");
|
||||||
|
push @log_msg, " Log:", (map { " $_" } @msg_lines) if @msg_lines;
|
||||||
|
|
||||||
|
|
||||||
|
if (-e "$SUMMARY_FILE.$i") {
|
||||||
|
push @log_msg, " ", map {" $_"}
|
||||||
|
format_summaries("$SUMMARY_FILE.$i");
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Add a copy of the message in the relevant log files.
|
||||||
|
#
|
||||||
|
&do_changes_file(@log_msg);
|
||||||
|
|
||||||
|
#
|
||||||
|
# Add the diff after writing the log files.
|
||||||
|
#
|
||||||
|
if (-e "$DIFF_FILE.$i" and $diff_num_lines > 0) {
|
||||||
|
my @diff_block = read_logfile("$DIFF_FILE.$i");
|
||||||
|
|
||||||
|
my $lines_to_use = scalar @diff_block;
|
||||||
|
$lines_to_use = $diff_num_lines
|
||||||
|
if $lines_to_use > $diff_num_lines;
|
||||||
|
|
||||||
|
push @log_msg, " ",
|
||||||
|
map {" $_"} @diff_block[0 .. $lines_to_use - 1];
|
||||||
|
|
||||||
|
$diff_num_lines -= $lines_to_use;
|
||||||
|
if ($diff_num_lines <= 0) {
|
||||||
|
push @log_msg, "",
|
||||||
|
"----------------------------------------------",
|
||||||
|
"Diff block truncated. (Max lines = " .
|
||||||
|
$cfg::DIFF_BLOCK_TOTAL_LINES . ")",
|
||||||
|
"----------------------------------------------",
|
||||||
|
"";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Mail out the notification.
|
||||||
|
#
|
||||||
|
&mail_notification(@log_msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
#system("/usr/local/bin/awake", $directory);
|
||||||
|
&cleanup_tmpfiles();
|
||||||
|
exit 0;
|
||||||
|
# EOF
|
137
CVSROOT/logcheck
Executable file
137
CVSROOT/logcheck
Executable file
|
@ -0,0 +1,137 @@
|
||||||
|
#! /usr/bin/perl -w
|
||||||
|
#
|
||||||
|
# $FreeBSD: logcheck,v 1.24 2001/12/24 15:00:18 joe Exp $
|
||||||
|
#
|
||||||
|
# This hack is to sanitise the results of what the user may have
|
||||||
|
# "done" while editing the commit log message.. :-) Peter Wemm.
|
||||||
|
#
|
||||||
|
# Note: this uses an enhancement to cvs's verifymsg functionality.
|
||||||
|
# Normally, the check is advisory only, the FreeBSD version reads
|
||||||
|
# back the file after the verifymsg file so that this script can
|
||||||
|
# make changes.
|
||||||
|
#
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use lib $ENV{CVSROOT};
|
||||||
|
use CVSROOT::cfg;
|
||||||
|
|
||||||
|
|
||||||
|
#############################################################
|
||||||
|
#
|
||||||
|
# Main Body
|
||||||
|
#
|
||||||
|
############################################################
|
||||||
|
|
||||||
|
my $filename = shift;
|
||||||
|
die "Usage: logcheck filename\n" unless $filename;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Read the log file in, stripping 'CVS:' lines and removing trailing
|
||||||
|
# white spaces.
|
||||||
|
open IN, "< $filename" or
|
||||||
|
die "logcheck: Cannot open for reading: $filename: $!\n";
|
||||||
|
my @log_in = map { s/^(.*?)\s*$/$1/; $1 } grep { !/^CVS:/ } <IN>;
|
||||||
|
close IN;
|
||||||
|
|
||||||
|
# Remove duplicate blank lines.
|
||||||
|
my $i = 0;
|
||||||
|
while ($i < scalar(@log_in) - 1) {
|
||||||
|
if ($log_in[$i] eq "" && $log_in[$i + 1] eq "") {
|
||||||
|
splice(@log_in, $i, 1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
++$i;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Remove leading and trailing blank lines. (There will be at most
|
||||||
|
# one because of the duplicate removal above).
|
||||||
|
shift @log_in if $log_in[0] eq "";
|
||||||
|
pop @log_in if $log_in[-1] eq "";
|
||||||
|
|
||||||
|
# Scan through the commit message looking for templated headers
|
||||||
|
# as defined in the configuration file, and rcstemplate.
|
||||||
|
# Assume that these only exist in the last paragraph.
|
||||||
|
# Filter out blank entries, and type check if necessary.
|
||||||
|
my $j = $#log_in; # The index of the last entry in the commit msg.
|
||||||
|
my $error = 0;
|
||||||
|
while ($j >= 0) {
|
||||||
|
my $logline = $log_in[$j];
|
||||||
|
|
||||||
|
--$j;
|
||||||
|
|
||||||
|
# Hitting a blank line means that we've seen all of the last paragraph.
|
||||||
|
last if $logline eq "";
|
||||||
|
|
||||||
|
unless ($logline =~ /^(.*?):\s*(.*)$/) {
|
||||||
|
### XXX
|
||||||
|
# We're here because we saw a line that didn't match
|
||||||
|
# a template header (no ':'). This could be a continuation
|
||||||
|
# line from the previous header, or the log message proper.
|
||||||
|
# We don't know, so run the risk of checking the last paragraph
|
||||||
|
# of the log message for headers.
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $header = $1;
|
||||||
|
my $value = $2;
|
||||||
|
my $pattern = $cfg::TEMPLATE_HEADERS{$header};
|
||||||
|
|
||||||
|
# Ignore unrecognised headers.
|
||||||
|
unless (defined($pattern)) {
|
||||||
|
### print "Warning: unknown template header: $header\n";
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Filter out the template header if it's blank.
|
||||||
|
if ($value eq "") {
|
||||||
|
splice(@log_in, $j + 1, 1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Type check the header
|
||||||
|
unless ($value =~ /^$pattern$/) {
|
||||||
|
print "Error: $header: should match '$pattern'.\n";
|
||||||
|
++$error;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Make sure that there is some content in the log message.
|
||||||
|
# XXX Note that logcheck isn't evoked if the log message is
|
||||||
|
# completely empty. This is a bug in cvs.
|
||||||
|
my $log = "@log_in";
|
||||||
|
die "Log message contains no content!\n" if $log =~ /^\s*$/;
|
||||||
|
|
||||||
|
|
||||||
|
# Write the modified log file back out.
|
||||||
|
my $tmpfile = $filename . "tmp";
|
||||||
|
open OUT, "> $tmpfile" or
|
||||||
|
die "logcheck: Cannot open for writing: $tmpfile: $!\n";
|
||||||
|
print OUT map { "$_\n" } @log_in;
|
||||||
|
close OUT;
|
||||||
|
|
||||||
|
|
||||||
|
# Stop the commit if there was a problem with the template headers.
|
||||||
|
if ($error) {
|
||||||
|
print "There were $error errors in the template headers.\n";
|
||||||
|
print "Please fix the log message and commit again.\n";
|
||||||
|
print "A copy of your log message was saved in $tmpfile.\n";
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Nuke likely editor backups.
|
||||||
|
unlink "$filename.~";
|
||||||
|
unlink "$filename.bak";
|
||||||
|
|
||||||
|
|
||||||
|
# Overwrite the log message with our sanitised one. (See the comment
|
||||||
|
# block at the top of this script for an explaination of why.)
|
||||||
|
rename($tmpfile, $filename) or
|
||||||
|
die "logcheck: Could not rename $tmpfile to $filename: $!";
|
||||||
|
|
||||||
|
exit 0;
|
27
CVSROOT/loginfo
Normal file
27
CVSROOT/loginfo
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
# The "loginfo" file controls where "cvs commit" log information
|
||||||
|
# is sent. The first entry on a line is a regular expression which must match
|
||||||
|
# the directory that the change is being made to, relative to the
|
||||||
|
# $CVSROOT. If a match is found, then the remainder of the line is a filter
|
||||||
|
# program that should expect log information on its standard input.
|
||||||
|
#
|
||||||
|
# If the repository name does not match any of the regular expressions in this
|
||||||
|
# file, the "DEFAULT" line is used, if it is specified.
|
||||||
|
#
|
||||||
|
# If the name ALL appears as a regular expression it is always used
|
||||||
|
# in addition to the first matching regex or DEFAULT.
|
||||||
|
#
|
||||||
|
# You may specify a format string as part of the
|
||||||
|
# filter. The string is composed of a `%' followed
|
||||||
|
# by a single format character, or followed by a set of format
|
||||||
|
# characters surrounded by `{' and `}' as separators. The format
|
||||||
|
# characters are:
|
||||||
|
#
|
||||||
|
# s = file name
|
||||||
|
# V = old version number (pre-checkin)
|
||||||
|
# v = new version number (post-checkin)
|
||||||
|
#
|
||||||
|
# For example:
|
||||||
|
#DEFAULT (echo ""; id; echo %s; date; cat) >> $CVSROOT/CVSROOT/commitlog
|
||||||
|
# or
|
||||||
|
#DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog
|
||||||
|
DEFAULT $CVSROOT/CVSROOT/log_accum.pl %s
|
26
CVSROOT/modules
Normal file
26
CVSROOT/modules
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
# Three different line formats are valid:
|
||||||
|
# key -a aliases...
|
||||||
|
# key [options] directory
|
||||||
|
# key [options] directory files...
|
||||||
|
#
|
||||||
|
# Where "options" are composed of:
|
||||||
|
# -i prog Run "prog" on "cvs commit" from top-level of module.
|
||||||
|
# -o prog Run "prog" on "cvs checkout" of module.
|
||||||
|
# -e prog Run "prog" on "cvs export" of module.
|
||||||
|
# -t prog Run "prog" on "cvs rtag" of module.
|
||||||
|
# -u prog Run "prog" on "cvs update" of module.
|
||||||
|
# -d dir Place module in directory "dir" instead of module name.
|
||||||
|
# -l Top-level directory only -- do not recurse.
|
||||||
|
#
|
||||||
|
# NOTE: If you change any of the "Run" options above, you'll have to
|
||||||
|
# release and re-checkout any working directories of these modules.
|
||||||
|
#
|
||||||
|
# And "directory" is a path to a directory relative to $CVSROOT.
|
||||||
|
#
|
||||||
|
# The "-a" option specifies an alias. An alias is interpreted as if
|
||||||
|
# everything on the right of the "-a" had been typed on the command line.
|
||||||
|
#
|
||||||
|
# You can encode a module within a module by using the special '&'
|
||||||
|
# character to interpose another module into the current module. This
|
||||||
|
# can be useful for creating a module that consists of many directories
|
||||||
|
# spread out over the entire source repository.
|
12
CVSROOT/notify
Normal file
12
CVSROOT/notify
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# The "notify" file controls where notifications from watches set by
|
||||||
|
# "cvs watch add" or "cvs edit" are sent. The first entry on a line is
|
||||||
|
# a regular expression which is tested against the directory that the
|
||||||
|
# change is being made to, relative to the $CVSROOT. If it matches,
|
||||||
|
# then the remainder of the line is a filter program that should contain
|
||||||
|
# one occurrence of %s for the user to notify, and information on its
|
||||||
|
# standard input.
|
||||||
|
#
|
||||||
|
# "ALL" or "DEFAULT" can be used in place of the regular expression.
|
||||||
|
#
|
||||||
|
# For example:
|
||||||
|
#ALL mail -s "CVS notification" %s
|
2
CVSROOT/options
Normal file
2
CVSROOT/options
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
tag=Schlepperbande=CVSHeader
|
||||||
|
tagexpand=iSchlepperbande
|
13
CVSROOT/rcsinfo
Normal file
13
CVSROOT/rcsinfo
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# The "rcsinfo" file is used to control templates with which the editor
|
||||||
|
# is invoked on commit and import.
|
||||||
|
#
|
||||||
|
# The first entry on a line is a regular expression which is tested
|
||||||
|
# against the directory that the change is being made to, relative to the
|
||||||
|
# $CVSROOT. For the first match that is found, then the remainder of the
|
||||||
|
# line is the name of the file that contains the template.
|
||||||
|
#
|
||||||
|
# If the repository name does not match any of the regular expressions in this
|
||||||
|
# file, the "DEFAULT" line is used, if it is specified.
|
||||||
|
#
|
||||||
|
# If the name "ALL" appears as a regular expression it is always used
|
||||||
|
# in addition to the first matching regex or "DEFAULT".
|
15
CVSROOT/rcstemplate
Normal file
15
CVSROOT/rcstemplate
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
|
||||||
|
PR:
|
||||||
|
Submitted by:
|
||||||
|
Reviewed by:
|
||||||
|
Approved by:
|
||||||
|
Obtained from:
|
||||||
|
MFC after:
|
||||||
|
CVS: ----------------------------------------------------------------------
|
||||||
|
CVS: PR: Fill this in if a GNATS PR is affected by the change.
|
||||||
|
CVS: Submitted by: Fill this in if someone else sent in the change.
|
||||||
|
CVS: Reviewed by: Fill this in if someone else reviewed your modification.
|
||||||
|
CVS: Approved by: Fill this in if you needed approval for this commit.
|
||||||
|
CVS: Obtained from: Fill this in if the change is from third party software.
|
||||||
|
CVS: MFC after: N [day[s]|week[s]|month[s]]
|
||||||
|
CVS: Fill in to get MFC notification later. (days assumed unless specified)
|
31
CVSROOT/tagcheck
Executable file
31
CVSROOT/tagcheck
Executable file
|
@ -0,0 +1,31 @@
|
||||||
|
#! /bin/sh
|
||||||
|
#
|
||||||
|
# $FreeBSD: tagcheck,v 1.10 2003/01/10 03:05:43 kris Exp $
|
||||||
|
|
||||||
|
# TAG add/mov/del repo files...
|
||||||
|
# $1 $2 $3 $4 ...
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
RELENG*)
|
||||||
|
;;
|
||||||
|
RELEASE*)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
exit 0 # not reserved, ok.
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
USER=`/usr/bin/id -un`
|
||||||
|
case "$USER" in
|
||||||
|
peter | jdp | markm | obrien | murray | jhb | bmah | scottl | kris | nik)
|
||||||
|
exit 0 # ok
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "$USER does not have permission to perform this tag operation!" 1>&2
|
||||||
|
echo "RELENG* tag operations are reserved for release engineering!" 1>&2
|
||||||
|
echo "RELEASE* tag operations are reserved for portmgr and doceng!" 1>&2
|
||||||
|
echo "Use 'cvs add' or 'cvs rm' to add/remove files from branches!" 1>&2
|
||||||
|
echo "$*" | /usr/bin/mail -s "NCVS TAG" cvs
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
20
CVSROOT/taginfo
Normal file
20
CVSROOT/taginfo
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# The "taginfo" file is used to control pre-tag checks.
|
||||||
|
# The filter on the right is invoked with the following arguments:
|
||||||
|
#
|
||||||
|
# $1 -- tagname
|
||||||
|
# $2 -- operation "add" for tag, "mov" for tag -F, and "del" for tag -d
|
||||||
|
# $3 -- repository
|
||||||
|
# $4-> file revision [file revision ...]
|
||||||
|
#
|
||||||
|
# A non-zero exit of the filter program will cause the tag to be aborted.
|
||||||
|
#
|
||||||
|
# The first entry on a line is a regular expression which is tested
|
||||||
|
# against the directory that the change is being committed to, relative
|
||||||
|
# to the $CVSROOT. For the first match that is found, then the remainder
|
||||||
|
# of the line is the name of the filter to run.
|
||||||
|
#
|
||||||
|
# If the repository name does not match any of the regular expressions in this
|
||||||
|
# file, the "DEFAULT" line is used, if it is specified.
|
||||||
|
#
|
||||||
|
# If the name "ALL" appears as a regular expression it is always used
|
||||||
|
# in addition to the first matching regex or "DEFAULT".
|
22
CVSROOT/unwrap
Executable file
22
CVSROOT/unwrap
Executable file
|
@ -0,0 +1,22 @@
|
||||||
|
#! /bin/sh
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
# $FreeBSD: unwrap,v 1.3 1999/08/27 22:46:57 peter Exp $
|
||||||
|
#
|
||||||
|
# unwrap - extract the combined package (created with wrap)
|
||||||
|
|
||||||
|
# move the file to a new name with an extension
|
||||||
|
rm -rf $1.cvswrap
|
||||||
|
mv $1 $1.cvswrap
|
||||||
|
|
||||||
|
# untar the file
|
||||||
|
|
||||||
|
if `gzip -t $1.cvswrap > /dev/null 2>&1`
|
||||||
|
then
|
||||||
|
zcat -d $1.cvswrap | tar --preserve --sparse -x -f -
|
||||||
|
else
|
||||||
|
tar --preserve -x -f $1.cvswrap
|
||||||
|
fi
|
||||||
|
|
||||||
|
# remove the original
|
||||||
|
rm -rf $1.cvswrap
|
21
CVSROOT/verifymsg
Normal file
21
CVSROOT/verifymsg
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# The "verifymsg" file is used to allow verification of logging
|
||||||
|
# information. It works best when a template (as specified in the
|
||||||
|
# rcsinfo file) is provided for the logging procedure. Given a
|
||||||
|
# template with locations for, a bug-id number, a list of people who
|
||||||
|
# reviewed the code before it can be checked in, and an external
|
||||||
|
# process to catalog the differences that were code reviewed, the
|
||||||
|
# following test can be applied to the code:
|
||||||
|
#
|
||||||
|
# Making sure that the entered bug-id number is correct.
|
||||||
|
# Validating that the code that was reviewed is indeed the code being
|
||||||
|
# checked in (using the bug-id number or a seperate review
|
||||||
|
# number to identify this particular code set.).
|
||||||
|
#
|
||||||
|
# If any of the above test failed, then the commit would be aborted.
|
||||||
|
#
|
||||||
|
# Actions such as mailing a copy of the report to each reviewer are
|
||||||
|
# better handled by an entry in the loginfo file.
|
||||||
|
#
|
||||||
|
# One thing that should be noted is the the ALL keyword is not
|
||||||
|
# supported. There can be only one entry that matches a given
|
||||||
|
# repository.
|
22
CVSROOT/wrap
Executable file
22
CVSROOT/wrap
Executable file
|
@ -0,0 +1,22 @@
|
||||||
|
#! /bin/sh
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
# $FreeBSD: wrap,v 1.3 1999/08/27 22:46:57 peter Exp $
|
||||||
|
#
|
||||||
|
# wrap - Combine a directory into a single tar package.
|
||||||
|
|
||||||
|
# This script is always called with the current directory set to
|
||||||
|
# where the file to be combined exists. but i may get called with a
|
||||||
|
# path to where cvs first started executing. (this probably should be
|
||||||
|
# fixed in cvs) so strip out all of the directory information. The
|
||||||
|
# first sed expression will only work if the path has a leading /
|
||||||
|
# if it doesn't the one in the if statement will work.
|
||||||
|
DIRNAME=`echo $1 | sed -e "s|/.*/||g"`
|
||||||
|
if [ ! -d $DIRNAME ] ; then
|
||||||
|
DIRNAME=`echo $1 | sed -e "s|.*/||g"`
|
||||||
|
fi
|
||||||
|
#
|
||||||
|
# Now tar up the directory but we now will only get a relative path
|
||||||
|
# even if the user did a cvs commit . at the top.
|
||||||
|
#
|
||||||
|
tar --preserve -cf - $DIRNAME | gzip --no-name --best -c > $2
|
85
README.md
85
README.md
|
@ -1,85 +0,0 @@
|
||||||
# tivomirror - Download recordings from a TiVo to the local disk
|
|
||||||
|
|
||||||
## Requirements
|
|
||||||
|
|
||||||
Python 3.4 or newer needs to be installed.
|
|
||||||
|
|
||||||
`tivodecode` needs to be available on the path. [wmcbrine/tivodecode-ng](https://github.com/wmcbrine/tivodecode-ng)
|
|
||||||
appears to be working well; the original
|
|
||||||
[TiVo File Decoder](http://tivodecode.sourceforge.net) has trouble
|
|
||||||
decoding some files and fails silently.
|
|
||||||
|
|
||||||
## Installing
|
|
||||||
|
|
||||||
Create a virtual environment and install the required packages:
|
|
||||||
|
|
||||||
* `python -m venv .venv` or `virtualenv .venv`
|
|
||||||
* `. .venv/bin/activate`
|
|
||||||
* `pip install -r requirements.txt`
|
|
||||||
|
|
||||||
## Shell Wrapper
|
|
||||||
|
|
||||||
To make it easier to run tivomirror from cron, the shell wrapper
|
|
||||||
[`tivomirror`](./tivomirror) will activate the venv and then run
|
|
||||||
`tivomirror.py`.
|
|
||||||
|
|
||||||
## Configuration
|
|
||||||
|
|
||||||
`tivomirror` reads a config file, by default `~/.tivo/config.yaml`. The
|
|
||||||
config file can contain the following keys:
|
|
||||||
* `cookies`: filename of the cookie jar, relative to `~/.tivo`.
|
|
||||||
* `host`: hostname of the Tivo.
|
|
||||||
* `ignoreepisodetitle`: Only use the series' title; default *false*. See
|
|
||||||
also command line paramter `-T`.
|
|
||||||
* `mak`: the Media Access Key for your Tivo account.
|
|
||||||
* `minfree`: if there's less space in `targetdir` than these many gigabytes,
|
|
||||||
do not download anything.
|
|
||||||
* `proxies`: hash of `http` and `https` proxy URLs to use for talking to the
|
|
||||||
Tivo. See the
|
|
||||||
[Requests](http://docs.python-requests.org/en/master/user/advanced/#proxies)
|
|
||||||
package for details.
|
|
||||||
* `shows`: a Hash of series' titles for which episodes should be downloaded.
|
|
||||||
Can contain an optional sub-hash, with these keys:
|
|
||||||
* `short`: a shorter name for the series, to be used when constructing the
|
|
||||||
file name for an episode to be downloaded.
|
|
||||||
* `targetdir`: store downloaded shows here.
|
|
||||||
* `tivodecode`: path to tivodecode binary; default `tivodecode`.
|
|
||||||
* `useragent`; the user agent to use when talking to the Tivo.
|
|
||||||
|
|
||||||
You will need to define at least one `shows` element for tivomirror to
|
|
||||||
download anything.
|
|
||||||
|
|
||||||
## Command Line Options
|
|
||||||
|
|
||||||
`tivomirror` accepts the following command line options:
|
|
||||||
* `-c` / `--config`: name of the config file; default `~/.tivo/config.yaml`.
|
|
||||||
* `-d`/ `--debug`: print debugging output to the log file at
|
|
||||||
`~/.tivo/tivomirror.log`.
|
|
||||||
* `-v` / `--verbose`: print output to stderr as well as to the log file.
|
|
||||||
* `-u` / `--update`: load new table of contents irrespective of the age of
|
|
||||||
the current cached copy.
|
|
||||||
* `-T` / `--ignoreepisodetitle`: Only use the series' title for the download
|
|
||||||
file name, not the combination of series and episode titles.
|
|
||||||
|
|
||||||
`tivomirror` accepts the following commands:
|
|
||||||
* `list`: list all episodes stored on the Tivo, with an indication of:
|
|
||||||
* `download`: episode will be downloaded the next time `mirror` runs.
|
|
||||||
* `already`: the episode was downloaded successfully previously.
|
|
||||||
* `not included`: the series has not been selected for download, that is,
|
|
||||||
there's no entry for it in the `shows` hash in the config.
|
|
||||||
* `recording`: this episode is currently being recorded; it can be
|
|
||||||
downloaded after the recording is finished.
|
|
||||||
* `not available`: the Tivo does not make this episode available for
|
|
||||||
download; it might be watchable directly on the Tivo.
|
|
||||||
* `mirror`: download all episodes selected through `shows` that haven't been
|
|
||||||
downloaded successfully previously.
|
|
||||||
* `mirrorone`: download the first show of all shows to be downloaded, exit
|
|
||||||
after.
|
|
||||||
|
|
||||||
## Database Utility
|
|
||||||
|
|
||||||
`tivodb` can be used to list, add or remove entries from the download database at
|
|
||||||
`~/.tivo/downloads.db`:
|
|
||||||
* `-a`: add the named entry to the database.
|
|
||||||
* `-d`: delete the named entry from the database.
|
|
||||||
* `-l`: list all entries in the database.
|
|
13
config.yaml
13
config.yaml
|
@ -1,13 +0,0 @@
|
||||||
---
|
|
||||||
shows:
|
|
||||||
- "College Football":
|
|
||||||
- "Conan":
|
|
||||||
- series: "Dirk Gently's Holistic Detective Agency"
|
|
||||||
short: "Dirk Gently"
|
|
||||||
unique: true
|
|
||||||
host: "wavehh.lassitu.de:30080"
|
|
||||||
postprocess: 'NQDIR=/home/stb/.tivo/nq nq archivevideo "{item.target}"'
|
|
||||||
proxies:
|
|
||||||
http: "http://us.lassitu.de:8888"
|
|
||||||
https: "http://us.lassitu.de:8888"
|
|
||||||
targetdir: /data/downloads
|
|
|
@ -1,4 +0,0 @@
|
||||||
berkeleydb
|
|
||||||
pytz
|
|
||||||
requests
|
|
||||||
pyyaml
|
|
4
src/tivomirror/.cvsignore
Normal file
4
src/tivomirror/.cvsignore
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
tivo
|
||||||
|
toc-formatted.xml
|
||||||
|
toc.xml
|
||||||
|
*.pyc
|
5
src/tivomirror/README
Normal file
5
src/tivomirror/README
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# $Schlepperbande$
|
||||||
|
|
||||||
|
tivodecode:
|
||||||
|
http://code.google.com/p/kmttg/downloads/list
|
||||||
|
http://kmttg.googlecode.com/files/tivodecode-0.3pre4.tar.gz
|
|
@ -1,33 +1,35 @@
|
||||||
#!/usr/local/bin/python
|
#!/usr/local/bin/python
|
||||||
|
|
||||||
import dbm
|
# $Schlepperbande: src/tivomirror/dbtool,v 1.4 2013/08/06 22:15:28 stb Exp $
|
||||||
|
|
||||||
|
import anydbm
|
||||||
import getopt
|
import getopt
|
||||||
import operator
|
import operator
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
print("usage: dbtool {-a entry|-d entry|-l}", file=sys.stderr)
|
print >>sys.stderr, "usage: dbtool {-a entry|-d entry|-l}"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
optlist, args = getopt.getopt(sys.argv[1:], "a:d:lk")
|
optlist, args = getopt.getopt(sys.argv[1:], "a:d:lk")
|
||||||
except getopt.GetoptError as err:
|
except getopt.GetoptError, err:
|
||||||
print(str(err), file=sys.stderr)
|
print >>sys.stderr, str(err)
|
||||||
usage()
|
usage()
|
||||||
sys.exit(64)
|
sys.exit(64)
|
||||||
if len(args) != 0 or len(optlist) != 1:
|
if len(args) != 0 or len(optlist) != 1:
|
||||||
usage()
|
usage()
|
||||||
sys.exit(64)
|
sys.exit(64)
|
||||||
|
|
||||||
downloaddb = dbm.open(os.path.expanduser("~") + "/.tivo/downloads.db", "c")
|
downloaddb = anydbm.open(os.path.expanduser("~") + "/.tivo/downloads.db", "c")
|
||||||
|
|
||||||
for (o, a) in optlist:
|
for (o, a) in optlist:
|
||||||
if o == "-l":
|
if o == "-l":
|
||||||
for i in sorted(downloaddb.keys()):
|
for i in sorted(downloaddb.keys()):
|
||||||
print("%s:\t%s" % (i.decode('utf-8'), downloaddb[i].decode('utf-8')))
|
print "%s:\t%s" % (i, downloaddb[i])
|
||||||
elif o == "-k":
|
elif o == "-k":
|
||||||
for (k, v) in sorted(list(downloaddb.items()), key=operator.itemgetter(1)):
|
for (k, v) in sorted(downloaddb.items(), key=operator.itemgetter(1)):
|
||||||
print("%s:\t%s" % (k, v))
|
print "%s:\t%s" % (k, v)
|
||||||
elif o == "-d":
|
elif o == "-d":
|
||||||
del downloaddb[a]
|
del downloaddb[a]
|
||||||
elif o == "-a":
|
elif o == "-a":
|
8
src/tivomirror/tivodecode/.cvsignore
Normal file
8
src/tivomirror/tivodecode/.cvsignore
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
.deps
|
||||||
|
Makefile
|
||||||
|
config.log
|
||||||
|
config.status
|
||||||
|
stamp-h1
|
||||||
|
tdcat
|
||||||
|
tdconfig.h
|
||||||
|
tivodecode
|
0
src/tivomirror/tivodecode/AUTHORS
Normal file
0
src/tivomirror/tivodecode/AUTHORS
Normal file
85
src/tivomirror/tivodecode/COPYING
Normal file
85
src/tivomirror/tivodecode/COPYING
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
Copyright (c) 2006, Jeremy Drake
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Portions derived from mpegcat, copyright 2006 Kees Cook, used with permission
|
||||||
|
|
||||||
|
This product includes software developed by the University of California,
|
||||||
|
Berkeley and its contributors.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the software nor the names of its contributors may
|
||||||
|
be used to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
|
This software incorporates the Turing encryption algorithm developed by
|
||||||
|
QUALCOMM Incorporated. Encryption by QUALCOMM.
|
||||||
|
|
||||||
|
1. Copyright remains vested in QUALCOMM Incorporated, and Copyright
|
||||||
|
notices in the code are not to be removed. If this package is used in
|
||||||
|
a product, QUALCOMM should be given attribution as the author of the
|
||||||
|
Turing encryption algorithm. This can be in the form of a textual
|
||||||
|
message at program startup or in documentation (online or textual)
|
||||||
|
provided with the package.
|
||||||
|
|
||||||
|
2. Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
a. Redistributions of source code must retain the copyright notice,
|
||||||
|
this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
b. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
|
||||||
|
c. All advertising materials mentioning features or use of this
|
||||||
|
software must display the following acknowledgement: This product
|
||||||
|
includes software developed by QUALCOMM Incorporated.
|
||||||
|
|
||||||
|
3. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND AGAINST
|
||||||
|
INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
|
||||||
|
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
4. The license and distribution terms for any publically available version
|
||||||
|
or derivative of this code cannot be changed, that is, this code cannot
|
||||||
|
simply be copied and put under another distribution license including
|
||||||
|
the GNU Public License.
|
||||||
|
|
||||||
|
5. The Turing family of encryption algorithms are covered by patents in
|
||||||
|
the United States of America and other countries. A free and
|
||||||
|
irrevocable license is hereby granted for the use of such patents to
|
||||||
|
the extent required to utilize the Turing family of encryption
|
||||||
|
algorithms for any purpose, subject to the condition that any
|
||||||
|
commercial product utilising any of the Turing family of encryption
|
||||||
|
algorithms should show the words "Encryption by QUALCOMM" either on the
|
||||||
|
product or in the associated documentation.
|
100
src/tivomirror/tivodecode/ChangeLog
Normal file
100
src/tivomirror/tivodecode/ChangeLog
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
0.3pre1:
|
||||||
|
* add support for TS files.
|
||||||
|
|
||||||
|
* known bug :
|
||||||
|
Packet N of PID XX starts a new series of PES headers, which spill over into
|
||||||
|
packet N+1 of PID XX, which has an encrypted payload. The problem is how to
|
||||||
|
cleanly make that "continuation" from packet N to N+1, such that the offset
|
||||||
|
into Packet N+1 can be determined where the decrypt needs to start.
|
||||||
|
|
||||||
|
0.2pre3:
|
||||||
|
|
||||||
|
* add an option to not process video - handy if all you want is to
|
||||||
|
dump the metadata
|
||||||
|
|
||||||
|
* fix error in logic rework to get prepare_frame to take stream_id and
|
||||||
|
block_id of 0, caused improper decryption of mpeg data
|
||||||
|
|
||||||
|
* add string.h include to md5 to make it work on solaris (seems
|
||||||
|
memmove comes from there), remove sys/param.h since I don't know why
|
||||||
|
it was there and don't know its portability
|
||||||
|
|
||||||
|
* add support to decrypt metadata and dump out to files. Needs some
|
||||||
|
work to make it easier to use
|
||||||
|
|
||||||
|
* add md5 routines from postgresql's pgcrypto contrib module, slightly
|
||||||
|
hacked so that it does not require a 64-bit integer type, which should
|
||||||
|
not be an issue for my uses. md5 is needed to generate the decryption
|
||||||
|
keys for the metadata
|
||||||
|
|
||||||
|
* fix turing_stream to work with stream_id of 0
|
||||||
|
(needed for work on metadata decrypting)
|
||||||
|
|
||||||
|
* refactor tivo file parsing to expose access to the rest of the data
|
||||||
|
in the headers and other data chunks
|
||||||
|
|
||||||
|
0.2pre2:
|
||||||
|
|
||||||
|
* fix merge error - some includes were in the wrong place, resulting
|
||||||
|
in broken builds due to missing defines from tdconfig.h
|
||||||
|
|
||||||
|
0.2pre1:
|
||||||
|
|
||||||
|
* port upstream changes from postgresql's getopt* files, which remove
|
||||||
|
the advertising clause from the license on the file
|
||||||
|
|
||||||
|
* add headers to Makefile.am for installation, clean up headers that
|
||||||
|
will be installed so that one just includes tivodecoder.h, clean up
|
||||||
|
tivodecoder.c so that it does not call exit() since it is called
|
||||||
|
from a lib and the caller may not want to exit, instead return -2
|
||||||
|
|
||||||
|
* copy changes to getopt_long.h from t2sami: don't declare extern vars
|
||||||
|
for getopt if using the system's getopt - rely on it taking care of
|
||||||
|
that. Caused issue for t2sami on cygwin, tivodecode worked fine,
|
||||||
|
but may as well fix it here too
|
||||||
|
|
||||||
|
* openbsd compile fixes - ntohl requires sys/types.h
|
||||||
|
|
||||||
|
* redo define for ftello/fseeko to be more robust, add warning if
|
||||||
|
falling back to ftell/fseek for questionable large file support
|
||||||
|
|
||||||
|
* clean up types to prevent warnings on windows. fix up large
|
||||||
|
file support for windows
|
||||||
|
|
||||||
|
* build a library capable of being called by something other than
|
||||||
|
the command line tivodecode program
|
||||||
|
|
||||||
|
* rewrite handling of encrypted packets to not have a hardcoded set of
|
||||||
|
stream_ids, but to keep track of an arbitrary number of states in a
|
||||||
|
circular linked list. There should never be more than 2 or 3 of
|
||||||
|
them, AFAIK, so this should be acceptable performance-wise
|
||||||
|
|
||||||
|
0.1.4:
|
||||||
|
|
||||||
|
* add support for storing MAK in a config file, ~/.tivodecode_mak, or
|
||||||
|
if HOME (or USERPROFILE on Windows) is not set, /.tivodecode_mak
|
||||||
|
(C:/.tivodecode_mak on Windows)
|
||||||
|
|
||||||
|
* tweak largefile support to be more correct for seek and tell, per
|
||||||
|
report in forum. This should not affect anyone, as in order for pipe
|
||||||
|
support to work I could not seek anyway.
|
||||||
|
|
||||||
|
0.1.3:
|
||||||
|
|
||||||
|
* implement support for encrypted packet type 0xbd, apparently used
|
||||||
|
for AC3 audio for 'Humax DVD-burning TiVos'
|
||||||
|
|
||||||
|
0.1.2:
|
||||||
|
|
||||||
|
* fix bug introduced recently while fixing signedness warnings on
|
||||||
|
gcc-4.1. Thanks to tateu for the fix
|
||||||
|
|
||||||
|
0.1.1:
|
||||||
|
|
||||||
|
* change include file for htonl after compile farm failure on Mac OSX
|
||||||
|
|
||||||
|
0.1.0:
|
||||||
|
|
||||||
|
* apply mak verification patch from Kees Cook
|
||||||
|
<kees@outflux.net>, fix signedness warnings in gcc 4.1, add
|
||||||
|
permission statement from Kees Cook to file derived from mpegcat
|
234
src/tivomirror/tivodecode/INSTALL
Normal file
234
src/tivomirror/tivodecode/INSTALL
Normal file
|
@ -0,0 +1,234 @@
|
||||||
|
Installation Instructions
|
||||||
|
*************************
|
||||||
|
|
||||||
|
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
|
||||||
|
2006 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is free documentation; the Free Software Foundation gives
|
||||||
|
unlimited permission to copy, distribute and modify it.
|
||||||
|
|
||||||
|
Basic Installation
|
||||||
|
==================
|
||||||
|
|
||||||
|
Briefly, the shell commands `./configure; make; make install' should
|
||||||
|
configure, build, and install this package. The following
|
||||||
|
more-detailed instructions are generic; see the `README' file for
|
||||||
|
instructions specific to this package.
|
||||||
|
|
||||||
|
The `configure' shell script attempts to guess correct values for
|
||||||
|
various system-dependent variables used during compilation. It uses
|
||||||
|
those values to create a `Makefile' in each directory of the package.
|
||||||
|
It may also create one or more `.h' files containing system-dependent
|
||||||
|
definitions. Finally, it creates a shell script `config.status' that
|
||||||
|
you can run in the future to recreate the current configuration, and a
|
||||||
|
file `config.log' containing compiler output (useful mainly for
|
||||||
|
debugging `configure').
|
||||||
|
|
||||||
|
It can also use an optional file (typically called `config.cache'
|
||||||
|
and enabled with `--cache-file=config.cache' or simply `-C') that saves
|
||||||
|
the results of its tests to speed up reconfiguring. Caching is
|
||||||
|
disabled by default to prevent problems with accidental use of stale
|
||||||
|
cache files.
|
||||||
|
|
||||||
|
If you need to do unusual things to compile the package, please try
|
||||||
|
to figure out how `configure' could check whether to do them, and mail
|
||||||
|
diffs or instructions to the address given in the `README' so they can
|
||||||
|
be considered for the next release. If you are using the cache, and at
|
||||||
|
some point `config.cache' contains results you don't want to keep, you
|
||||||
|
may remove or edit it.
|
||||||
|
|
||||||
|
The file `configure.ac' (or `configure.in') is used to create
|
||||||
|
`configure' by a program called `autoconf'. You need `configure.ac' if
|
||||||
|
you want to change it or regenerate `configure' using a newer version
|
||||||
|
of `autoconf'.
|
||||||
|
|
||||||
|
The simplest way to compile this package is:
|
||||||
|
|
||||||
|
1. `cd' to the directory containing the package's source code and type
|
||||||
|
`./configure' to configure the package for your system.
|
||||||
|
|
||||||
|
Running `configure' might take a while. While running, it prints
|
||||||
|
some messages telling which features it is checking for.
|
||||||
|
|
||||||
|
2. Type `make' to compile the package.
|
||||||
|
|
||||||
|
3. Optionally, type `make check' to run any self-tests that come with
|
||||||
|
the package.
|
||||||
|
|
||||||
|
4. Type `make install' to install the programs and any data files and
|
||||||
|
documentation.
|
||||||
|
|
||||||
|
5. You can remove the program binaries and object files from the
|
||||||
|
source code directory by typing `make clean'. To also remove the
|
||||||
|
files that `configure' created (so you can compile the package for
|
||||||
|
a different kind of computer), type `make distclean'. There is
|
||||||
|
also a `make maintainer-clean' target, but that is intended mainly
|
||||||
|
for the package's developers. If you use it, you may have to get
|
||||||
|
all sorts of other programs in order to regenerate files that came
|
||||||
|
with the distribution.
|
||||||
|
|
||||||
|
Compilers and Options
|
||||||
|
=====================
|
||||||
|
|
||||||
|
Some systems require unusual options for compilation or linking that the
|
||||||
|
`configure' script does not know about. Run `./configure --help' for
|
||||||
|
details on some of the pertinent environment variables.
|
||||||
|
|
||||||
|
You can give `configure' initial values for configuration parameters
|
||||||
|
by setting variables in the command line or in the environment. Here
|
||||||
|
is an example:
|
||||||
|
|
||||||
|
./configure CC=c99 CFLAGS=-g LIBS=-lposix
|
||||||
|
|
||||||
|
*Note Defining Variables::, for more details.
|
||||||
|
|
||||||
|
Compiling For Multiple Architectures
|
||||||
|
====================================
|
||||||
|
|
||||||
|
You can compile the package for more than one kind of computer at the
|
||||||
|
same time, by placing the object files for each architecture in their
|
||||||
|
own directory. To do this, you can use GNU `make'. `cd' to the
|
||||||
|
directory where you want the object files and executables to go and run
|
||||||
|
the `configure' script. `configure' automatically checks for the
|
||||||
|
source code in the directory that `configure' is in and in `..'.
|
||||||
|
|
||||||
|
With a non-GNU `make', it is safer to compile the package for one
|
||||||
|
architecture at a time in the source code directory. After you have
|
||||||
|
installed the package for one architecture, use `make distclean' before
|
||||||
|
reconfiguring for another architecture.
|
||||||
|
|
||||||
|
Installation Names
|
||||||
|
==================
|
||||||
|
|
||||||
|
By default, `make install' installs the package's commands under
|
||||||
|
`/usr/local/bin', include files under `/usr/local/include', etc. You
|
||||||
|
can specify an installation prefix other than `/usr/local' by giving
|
||||||
|
`configure' the option `--prefix=PREFIX'.
|
||||||
|
|
||||||
|
You can specify separate installation prefixes for
|
||||||
|
architecture-specific files and architecture-independent files. If you
|
||||||
|
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
|
||||||
|
PREFIX as the prefix for installing programs and libraries.
|
||||||
|
Documentation and other data files still use the regular prefix.
|
||||||
|
|
||||||
|
In addition, if you use an unusual directory layout you can give
|
||||||
|
options like `--bindir=DIR' to specify different values for particular
|
||||||
|
kinds of files. Run `configure --help' for a list of the directories
|
||||||
|
you can set and what kinds of files go in them.
|
||||||
|
|
||||||
|
If the package supports it, you can cause programs to be installed
|
||||||
|
with an extra prefix or suffix on their names by giving `configure' the
|
||||||
|
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||||
|
|
||||||
|
Optional Features
|
||||||
|
=================
|
||||||
|
|
||||||
|
Some packages pay attention to `--enable-FEATURE' options to
|
||||||
|
`configure', where FEATURE indicates an optional part of the package.
|
||||||
|
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||||
|
is something like `gnu-as' or `x' (for the X Window System). The
|
||||||
|
`README' should mention any `--enable-' and `--with-' options that the
|
||||||
|
package recognizes.
|
||||||
|
|
||||||
|
For packages that use the X Window System, `configure' can usually
|
||||||
|
find the X include and library files automatically, but if it doesn't,
|
||||||
|
you can use the `configure' options `--x-includes=DIR' and
|
||||||
|
`--x-libraries=DIR' to specify their locations.
|
||||||
|
|
||||||
|
Specifying the System Type
|
||||||
|
==========================
|
||||||
|
|
||||||
|
There may be some features `configure' cannot figure out automatically,
|
||||||
|
but needs to determine by the type of machine the package will run on.
|
||||||
|
Usually, assuming the package is built to be run on the _same_
|
||||||
|
architectures, `configure' can figure that out, but if it prints a
|
||||||
|
message saying it cannot guess the machine type, give it the
|
||||||
|
`--build=TYPE' option. TYPE can either be a short name for the system
|
||||||
|
type, such as `sun4', or a canonical name which has the form:
|
||||||
|
|
||||||
|
CPU-COMPANY-SYSTEM
|
||||||
|
|
||||||
|
where SYSTEM can have one of these forms:
|
||||||
|
|
||||||
|
OS KERNEL-OS
|
||||||
|
|
||||||
|
See the file `config.sub' for the possible values of each field. If
|
||||||
|
`config.sub' isn't included in this package, then this package doesn't
|
||||||
|
need to know the machine type.
|
||||||
|
|
||||||
|
If you are _building_ compiler tools for cross-compiling, you should
|
||||||
|
use the option `--target=TYPE' to select the type of system they will
|
||||||
|
produce code for.
|
||||||
|
|
||||||
|
If you want to _use_ a cross compiler, that generates code for a
|
||||||
|
platform different from the build platform, you should specify the
|
||||||
|
"host" platform (i.e., that on which the generated programs will
|
||||||
|
eventually be run) with `--host=TYPE'.
|
||||||
|
|
||||||
|
Sharing Defaults
|
||||||
|
================
|
||||||
|
|
||||||
|
If you want to set default values for `configure' scripts to share, you
|
||||||
|
can create a site shell script called `config.site' that gives default
|
||||||
|
values for variables like `CC', `cache_file', and `prefix'.
|
||||||
|
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||||
|
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||||
|
`CONFIG_SITE' environment variable to the location of the site script.
|
||||||
|
A warning: not all `configure' scripts look for a site script.
|
||||||
|
|
||||||
|
Defining Variables
|
||||||
|
==================
|
||||||
|
|
||||||
|
Variables not defined in a site shell script can be set in the
|
||||||
|
environment passed to `configure'. However, some packages may run
|
||||||
|
configure again during the build, and the customized values of these
|
||||||
|
variables may be lost. In order to avoid this problem, you should set
|
||||||
|
them in the `configure' command line, using `VAR=value'. For example:
|
||||||
|
|
||||||
|
./configure CC=/usr/local2/bin/gcc
|
||||||
|
|
||||||
|
causes the specified `gcc' to be used as the C compiler (unless it is
|
||||||
|
overridden in the site shell script).
|
||||||
|
|
||||||
|
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
|
||||||
|
an Autoconf bug. Until the bug is fixed you can use this workaround:
|
||||||
|
|
||||||
|
CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
|
||||||
|
|
||||||
|
`configure' Invocation
|
||||||
|
======================
|
||||||
|
|
||||||
|
`configure' recognizes the following options to control how it operates.
|
||||||
|
|
||||||
|
`--help'
|
||||||
|
`-h'
|
||||||
|
Print a summary of the options to `configure', and exit.
|
||||||
|
|
||||||
|
`--version'
|
||||||
|
`-V'
|
||||||
|
Print the version of Autoconf used to generate the `configure'
|
||||||
|
script, and exit.
|
||||||
|
|
||||||
|
`--cache-file=FILE'
|
||||||
|
Enable the cache: use and save the results of the tests in FILE,
|
||||||
|
traditionally `config.cache'. FILE defaults to `/dev/null' to
|
||||||
|
disable caching.
|
||||||
|
|
||||||
|
`--config-cache'
|
||||||
|
`-C'
|
||||||
|
Alias for `--cache-file=config.cache'.
|
||||||
|
|
||||||
|
`--quiet'
|
||||||
|
`--silent'
|
||||||
|
`-q'
|
||||||
|
Do not print messages saying which checks are being made. To
|
||||||
|
suppress all normal output, redirect it to `/dev/null' (any error
|
||||||
|
messages will still be shown).
|
||||||
|
|
||||||
|
`--srcdir=DIR'
|
||||||
|
Look for the package's source code in directory DIR. Usually
|
||||||
|
`configure' can determine that directory automatically.
|
||||||
|
|
||||||
|
`configure' also accepts some other, not widely useful, options. Run
|
||||||
|
`configure --help' for more details.
|
||||||
|
|
12
src/tivomirror/tivodecode/Makefile.am
Normal file
12
src/tivomirror/tivodecode/Makefile.am
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
bin_PROGRAMS = tivodecode tdcat
|
||||||
|
lib_LIBRARIES = libtivodecode.a
|
||||||
|
pkginclude_HEADERS = tivodecoder.h tivo-parse.h turing_stream.h Turing.h
|
||||||
|
nodist_pkginclude_HEADERS = tdconfig.h
|
||||||
|
libtivodecode_a_SOURCES=hexlib.c TuringFast.c sha1.c md5.c tivo-parse.c turing_stream.c tivodecoder.c QUTsbox.h TuringMultab.h TuringSbox.h hexlib.h sha1.h md5.h
|
||||||
|
tivodecode_SOURCES=cli_common.c happyfile.c tivodecode.c happyfile.h getopt_long.h fseeko.h cli_common.h
|
||||||
|
tivodecode_LDADD=$(LIBOBJS) -L. -ltivodecode
|
||||||
|
tivodecode_DEPENDENCIES=$(LIBOBJS) libtivodecode.a
|
||||||
|
tdcat_SOURCES=cli_common.c happyfile.c tdcat.c happyfile.h getopt_long.h fseeko.h cli_common.h
|
||||||
|
tdcat_LDADD=$(LIBOBJS) -L. -ltivodecode
|
||||||
|
tdcat_DEPENDENCIES=$(LIBOBJS) libtivodecode.a
|
||||||
|
EXTRA_DIST=libtivodecode.vcproj libtdcommon.vcproj tdcat.vcproj tdconfig.h.win32 tivodecode.rules tivodecode.sln tivodecode.vcproj
|
679
src/tivomirror/tivodecode/Makefile.in
Normal file
679
src/tivomirror/tivodecode/Makefile.in
Normal file
|
@ -0,0 +1,679 @@
|
||||||
|
# Makefile.in generated by automake 1.10 from Makefile.am.
|
||||||
|
# @configure_input@
|
||||||
|
|
||||||
|
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||||
|
# 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||||
|
# This Makefile.in is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||||
|
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||||
|
# PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
@SET_MAKE@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
VPATH = @srcdir@
|
||||||
|
pkgdatadir = $(datadir)/@PACKAGE@
|
||||||
|
pkglibdir = $(libdir)/@PACKAGE@
|
||||||
|
pkgincludedir = $(includedir)/@PACKAGE@
|
||||||
|
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||||
|
install_sh_DATA = $(install_sh) -c -m 644
|
||||||
|
install_sh_PROGRAM = $(install_sh) -c
|
||||||
|
install_sh_SCRIPT = $(install_sh) -c
|
||||||
|
INSTALL_HEADER = $(INSTALL_DATA)
|
||||||
|
transform = $(program_transform_name)
|
||||||
|
NORMAL_INSTALL = :
|
||||||
|
PRE_INSTALL = :
|
||||||
|
POST_INSTALL = :
|
||||||
|
NORMAL_UNINSTALL = :
|
||||||
|
PRE_UNINSTALL = :
|
||||||
|
POST_UNINSTALL = :
|
||||||
|
bin_PROGRAMS = tivodecode$(EXEEXT) tdcat$(EXEEXT)
|
||||||
|
subdir = .
|
||||||
|
DIST_COMMON = README $(am__configure_deps) $(pkginclude_HEADERS) \
|
||||||
|
$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
|
||||||
|
$(srcdir)/tdconfig.h.in $(top_srcdir)/configure AUTHORS \
|
||||||
|
COPYING ChangeLog INSTALL NEWS depcomp fseeko.c getopt.c \
|
||||||
|
getopt_long.c install-sh missing
|
||||||
|
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||||
|
am__aclocal_m4_deps = $(top_srcdir)/m4/c-compiler.m4 \
|
||||||
|
$(top_srcdir)/configure.in
|
||||||
|
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||||
|
$(ACLOCAL_M4)
|
||||||
|
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
|
||||||
|
configure.lineno config.status.lineno
|
||||||
|
mkinstalldirs = $(install_sh) -d
|
||||||
|
CONFIG_HEADER = tdconfig.h
|
||||||
|
CONFIG_CLEAN_FILES =
|
||||||
|
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
|
||||||
|
am__vpath_adj = case $$p in \
|
||||||
|
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
|
||||||
|
*) f=$$p;; \
|
||||||
|
esac;
|
||||||
|
am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
|
||||||
|
am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \
|
||||||
|
"$(DESTDIR)$(pkgincludedir)" "$(DESTDIR)$(pkgincludedir)"
|
||||||
|
libLIBRARIES_INSTALL = $(INSTALL_DATA)
|
||||||
|
LIBRARIES = $(lib_LIBRARIES)
|
||||||
|
AR = ar
|
||||||
|
ARFLAGS = cru
|
||||||
|
libtivodecode_a_AR = $(AR) $(ARFLAGS)
|
||||||
|
libtivodecode_a_LIBADD =
|
||||||
|
am_libtivodecode_a_OBJECTS = hexlib.$(OBJEXT) TuringFast.$(OBJEXT) \
|
||||||
|
sha1.$(OBJEXT) md5.$(OBJEXT) tivo-parse.$(OBJEXT) \
|
||||||
|
turing_stream.$(OBJEXT) tivodecoder.$(OBJEXT)
|
||||||
|
libtivodecode_a_OBJECTS = $(am_libtivodecode_a_OBJECTS)
|
||||||
|
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
|
||||||
|
PROGRAMS = $(bin_PROGRAMS)
|
||||||
|
am_tdcat_OBJECTS = cli_common.$(OBJEXT) happyfile.$(OBJEXT) \
|
||||||
|
tdcat.$(OBJEXT)
|
||||||
|
tdcat_OBJECTS = $(am_tdcat_OBJECTS)
|
||||||
|
am_tivodecode_OBJECTS = cli_common.$(OBJEXT) happyfile.$(OBJEXT) \
|
||||||
|
tivodecode.$(OBJEXT)
|
||||||
|
tivodecode_OBJECTS = $(am_tivodecode_OBJECTS)
|
||||||
|
DEFAULT_INCLUDES = -I.@am__isrc@
|
||||||
|
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
||||||
|
am__depfiles_maybe = depfiles
|
||||||
|
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||||
|
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||||
|
CCLD = $(CC)
|
||||||
|
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||||
|
SOURCES = $(libtivodecode_a_SOURCES) $(tdcat_SOURCES) \
|
||||||
|
$(tivodecode_SOURCES)
|
||||||
|
DIST_SOURCES = $(libtivodecode_a_SOURCES) $(tdcat_SOURCES) \
|
||||||
|
$(tivodecode_SOURCES)
|
||||||
|
nodist_pkgincludeHEADERS_INSTALL = $(INSTALL_HEADER)
|
||||||
|
pkgincludeHEADERS_INSTALL = $(INSTALL_HEADER)
|
||||||
|
HEADERS = $(nodist_pkginclude_HEADERS) $(pkginclude_HEADERS)
|
||||||
|
ETAGS = etags
|
||||||
|
CTAGS = ctags
|
||||||
|
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||||
|
distdir = $(PACKAGE)-$(VERSION)
|
||||||
|
top_distdir = $(distdir)
|
||||||
|
am__remove_distdir = \
|
||||||
|
{ test ! -d $(distdir) \
|
||||||
|
|| { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
|
||||||
|
&& rm -fr $(distdir); }; }
|
||||||
|
DIST_ARCHIVES = $(distdir).tar.gz
|
||||||
|
GZIP_ENV = --best
|
||||||
|
distuninstallcheck_listfiles = find . -type f -print
|
||||||
|
distcleancheck_listfiles = find . -type f -print
|
||||||
|
ACLOCAL = @ACLOCAL@
|
||||||
|
AMTAR = @AMTAR@
|
||||||
|
AUTOCONF = @AUTOCONF@
|
||||||
|
AUTOHEADER = @AUTOHEADER@
|
||||||
|
AUTOMAKE = @AUTOMAKE@
|
||||||
|
AWK = @AWK@
|
||||||
|
CC = @CC@
|
||||||
|
CCDEPMODE = @CCDEPMODE@
|
||||||
|
CFLAGS = @CFLAGS@
|
||||||
|
CPP = @CPP@
|
||||||
|
CPPFLAGS = @CPPFLAGS@
|
||||||
|
CYGPATH_W = @CYGPATH_W@
|
||||||
|
DEFS = @DEFS@
|
||||||
|
DEPDIR = @DEPDIR@
|
||||||
|
ECHO_C = @ECHO_C@
|
||||||
|
ECHO_N = @ECHO_N@
|
||||||
|
ECHO_T = @ECHO_T@
|
||||||
|
EGREP = @EGREP@
|
||||||
|
EXEEXT = @EXEEXT@
|
||||||
|
GREP = @GREP@
|
||||||
|
INSTALL = @INSTALL@
|
||||||
|
INSTALL_DATA = @INSTALL_DATA@
|
||||||
|
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||||
|
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||||
|
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||||
|
LDFLAGS = @LDFLAGS@
|
||||||
|
LIBOBJS = @LIBOBJS@
|
||||||
|
LIBS = @LIBS@
|
||||||
|
LTLIBOBJS = @LTLIBOBJS@
|
||||||
|
MAINT = @MAINT@
|
||||||
|
MAKEINFO = @MAKEINFO@
|
||||||
|
MKDIR_P = @MKDIR_P@
|
||||||
|
OBJEXT = @OBJEXT@
|
||||||
|
PACKAGE = @PACKAGE@
|
||||||
|
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||||
|
PACKAGE_NAME = @PACKAGE_NAME@
|
||||||
|
PACKAGE_STRING = @PACKAGE_STRING@
|
||||||
|
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||||
|
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||||
|
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||||
|
RANLIB = @RANLIB@
|
||||||
|
SET_MAKE = @SET_MAKE@
|
||||||
|
SHELL = @SHELL@
|
||||||
|
STRIP = @STRIP@
|
||||||
|
VERSION = @VERSION@
|
||||||
|
abs_builddir = @abs_builddir@
|
||||||
|
abs_srcdir = @abs_srcdir@
|
||||||
|
abs_top_builddir = @abs_top_builddir@
|
||||||
|
abs_top_srcdir = @abs_top_srcdir@
|
||||||
|
ac_ct_CC = @ac_ct_CC@
|
||||||
|
am__include = @am__include@
|
||||||
|
am__leading_dot = @am__leading_dot@
|
||||||
|
am__quote = @am__quote@
|
||||||
|
am__tar = @am__tar@
|
||||||
|
am__untar = @am__untar@
|
||||||
|
bindir = @bindir@
|
||||||
|
build_alias = @build_alias@
|
||||||
|
builddir = @builddir@
|
||||||
|
datadir = @datadir@
|
||||||
|
datarootdir = @datarootdir@
|
||||||
|
docdir = @docdir@
|
||||||
|
dvidir = @dvidir@
|
||||||
|
exec_prefix = @exec_prefix@
|
||||||
|
host_alias = @host_alias@
|
||||||
|
htmldir = @htmldir@
|
||||||
|
includedir = @includedir@
|
||||||
|
infodir = @infodir@
|
||||||
|
install_sh = @install_sh@
|
||||||
|
libdir = @libdir@
|
||||||
|
libexecdir = @libexecdir@
|
||||||
|
localedir = @localedir@
|
||||||
|
localstatedir = @localstatedir@
|
||||||
|
mandir = @mandir@
|
||||||
|
mkdir_p = @mkdir_p@
|
||||||
|
oldincludedir = @oldincludedir@
|
||||||
|
pdfdir = @pdfdir@
|
||||||
|
prefix = @prefix@
|
||||||
|
program_transform_name = @program_transform_name@
|
||||||
|
psdir = @psdir@
|
||||||
|
sbindir = @sbindir@
|
||||||
|
sharedstatedir = @sharedstatedir@
|
||||||
|
srcdir = @srcdir@
|
||||||
|
sysconfdir = @sysconfdir@
|
||||||
|
target_alias = @target_alias@
|
||||||
|
top_builddir = @top_builddir@
|
||||||
|
top_srcdir = @top_srcdir@
|
||||||
|
lib_LIBRARIES = libtivodecode.a
|
||||||
|
pkginclude_HEADERS = tivodecoder.h tivo-parse.h turing_stream.h Turing.h
|
||||||
|
nodist_pkginclude_HEADERS = tdconfig.h
|
||||||
|
libtivodecode_a_SOURCES = hexlib.c TuringFast.c sha1.c md5.c tivo-parse.c turing_stream.c tivodecoder.c QUTsbox.h TuringMultab.h TuringSbox.h hexlib.h sha1.h md5.h
|
||||||
|
tivodecode_SOURCES = cli_common.c happyfile.c tivodecode.c happyfile.h getopt_long.h fseeko.h cli_common.h
|
||||||
|
tivodecode_LDADD = $(LIBOBJS) -L. -ltivodecode
|
||||||
|
tivodecode_DEPENDENCIES = $(LIBOBJS) libtivodecode.a
|
||||||
|
tdcat_SOURCES = cli_common.c happyfile.c tdcat.c happyfile.h getopt_long.h fseeko.h cli_common.h
|
||||||
|
tdcat_LDADD = $(LIBOBJS) -L. -ltivodecode
|
||||||
|
tdcat_DEPENDENCIES = $(LIBOBJS) libtivodecode.a
|
||||||
|
EXTRA_DIST = libtivodecode.vcproj libtdcommon.vcproj tdcat.vcproj tdconfig.h.win32 tivodecode.rules tivodecode.sln tivodecode.vcproj
|
||||||
|
all: tdconfig.h
|
||||||
|
$(MAKE) $(AM_MAKEFLAGS) all-am
|
||||||
|
|
||||||
|
.SUFFIXES:
|
||||||
|
.SUFFIXES: .c .o .obj
|
||||||
|
am--refresh:
|
||||||
|
@:
|
||||||
|
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
|
||||||
|
@for dep in $?; do \
|
||||||
|
case '$(am__configure_deps)' in \
|
||||||
|
*$$dep*) \
|
||||||
|
echo ' cd $(srcdir) && $(AUTOMAKE) --gnu '; \
|
||||||
|
cd $(srcdir) && $(AUTOMAKE) --gnu \
|
||||||
|
&& exit 0; \
|
||||||
|
exit 1;; \
|
||||||
|
esac; \
|
||||||
|
done; \
|
||||||
|
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
|
||||||
|
cd $(top_srcdir) && \
|
||||||
|
$(AUTOMAKE) --gnu Makefile
|
||||||
|
.PRECIOUS: Makefile
|
||||||
|
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||||
|
@case '$?' in \
|
||||||
|
*config.status*) \
|
||||||
|
echo ' $(SHELL) ./config.status'; \
|
||||||
|
$(SHELL) ./config.status;; \
|
||||||
|
*) \
|
||||||
|
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
|
||||||
|
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
|
||||||
|
esac;
|
||||||
|
|
||||||
|
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||||
|
$(SHELL) ./config.status --recheck
|
||||||
|
|
||||||
|
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
|
||||||
|
cd $(srcdir) && $(AUTOCONF)
|
||||||
|
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
|
||||||
|
cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
|
||||||
|
|
||||||
|
tdconfig.h: stamp-h1
|
||||||
|
@if test ! -f $@; then \
|
||||||
|
rm -f stamp-h1; \
|
||||||
|
$(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
|
||||||
|
else :; fi
|
||||||
|
|
||||||
|
stamp-h1: $(srcdir)/tdconfig.h.in $(top_builddir)/config.status
|
||||||
|
@rm -f stamp-h1
|
||||||
|
cd $(top_builddir) && $(SHELL) ./config.status tdconfig.h
|
||||||
|
$(srcdir)/tdconfig.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
|
||||||
|
cd $(top_srcdir) && $(AUTOHEADER)
|
||||||
|
rm -f stamp-h1
|
||||||
|
touch $@
|
||||||
|
|
||||||
|
distclean-hdr:
|
||||||
|
-rm -f tdconfig.h stamp-h1
|
||||||
|
install-libLIBRARIES: $(lib_LIBRARIES)
|
||||||
|
@$(NORMAL_INSTALL)
|
||||||
|
test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
|
||||||
|
@list='$(lib_LIBRARIES)'; for p in $$list; do \
|
||||||
|
if test -f $$p; then \
|
||||||
|
f=$(am__strip_dir) \
|
||||||
|
echo " $(libLIBRARIES_INSTALL) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
|
||||||
|
$(libLIBRARIES_INSTALL) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
|
||||||
|
else :; fi; \
|
||||||
|
done
|
||||||
|
@$(POST_INSTALL)
|
||||||
|
@list='$(lib_LIBRARIES)'; for p in $$list; do \
|
||||||
|
if test -f $$p; then \
|
||||||
|
p=$(am__strip_dir) \
|
||||||
|
echo " $(RANLIB) '$(DESTDIR)$(libdir)/$$p'"; \
|
||||||
|
$(RANLIB) "$(DESTDIR)$(libdir)/$$p"; \
|
||||||
|
else :; fi; \
|
||||||
|
done
|
||||||
|
|
||||||
|
uninstall-libLIBRARIES:
|
||||||
|
@$(NORMAL_UNINSTALL)
|
||||||
|
@list='$(lib_LIBRARIES)'; for p in $$list; do \
|
||||||
|
p=$(am__strip_dir) \
|
||||||
|
echo " rm -f '$(DESTDIR)$(libdir)/$$p'"; \
|
||||||
|
rm -f "$(DESTDIR)$(libdir)/$$p"; \
|
||||||
|
done
|
||||||
|
|
||||||
|
clean-libLIBRARIES:
|
||||||
|
-test -z "$(lib_LIBRARIES)" || rm -f $(lib_LIBRARIES)
|
||||||
|
libtivodecode.a: $(libtivodecode_a_OBJECTS) $(libtivodecode_a_DEPENDENCIES)
|
||||||
|
-rm -f libtivodecode.a
|
||||||
|
$(libtivodecode_a_AR) libtivodecode.a $(libtivodecode_a_OBJECTS) $(libtivodecode_a_LIBADD)
|
||||||
|
$(RANLIB) libtivodecode.a
|
||||||
|
install-binPROGRAMS: $(bin_PROGRAMS)
|
||||||
|
@$(NORMAL_INSTALL)
|
||||||
|
test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
|
||||||
|
@list='$(bin_PROGRAMS)'; for p in $$list; do \
|
||||||
|
p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
|
||||||
|
if test -f $$p \
|
||||||
|
; then \
|
||||||
|
f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
|
||||||
|
echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
|
||||||
|
$(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
|
||||||
|
else :; fi; \
|
||||||
|
done
|
||||||
|
|
||||||
|
uninstall-binPROGRAMS:
|
||||||
|
@$(NORMAL_UNINSTALL)
|
||||||
|
@list='$(bin_PROGRAMS)'; for p in $$list; do \
|
||||||
|
f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
|
||||||
|
echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
|
||||||
|
rm -f "$(DESTDIR)$(bindir)/$$f"; \
|
||||||
|
done
|
||||||
|
|
||||||
|
clean-binPROGRAMS:
|
||||||
|
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
|
||||||
|
tdcat$(EXEEXT): $(tdcat_OBJECTS) $(tdcat_DEPENDENCIES)
|
||||||
|
@rm -f tdcat$(EXEEXT)
|
||||||
|
$(LINK) $(tdcat_OBJECTS) $(tdcat_LDADD) $(LIBS)
|
||||||
|
tivodecode$(EXEEXT): $(tivodecode_OBJECTS) $(tivodecode_DEPENDENCIES)
|
||||||
|
@rm -f tivodecode$(EXEEXT)
|
||||||
|
$(LINK) $(tivodecode_OBJECTS) $(tivodecode_LDADD) $(LIBS)
|
||||||
|
|
||||||
|
mostlyclean-compile:
|
||||||
|
-rm -f *.$(OBJEXT)
|
||||||
|
|
||||||
|
distclean-compile:
|
||||||
|
-rm -f *.tab.c
|
||||||
|
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/fseeko.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getopt.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getopt_long.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TuringFast.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cli_common.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/happyfile.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hexlib.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha1.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tdcat.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tivo-parse.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tivodecode.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tivodecoder.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/turing_stream.Po@am__quote@
|
||||||
|
|
||||||
|
.c.o:
|
||||||
|
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||||
|
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||||
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||||
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||||
|
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
|
||||||
|
|
||||||
|
.c.obj:
|
||||||
|
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
|
||||||
|
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||||
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||||
|
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||||
|
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
|
||||||
|
install-nodist_pkgincludeHEADERS: $(nodist_pkginclude_HEADERS)
|
||||||
|
@$(NORMAL_INSTALL)
|
||||||
|
test -z "$(pkgincludedir)" || $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)"
|
||||||
|
@list='$(nodist_pkginclude_HEADERS)'; for p in $$list; do \
|
||||||
|
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
|
||||||
|
f=$(am__strip_dir) \
|
||||||
|
echo " $(nodist_pkgincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgincludedir)/$$f'"; \
|
||||||
|
$(nodist_pkgincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgincludedir)/$$f"; \
|
||||||
|
done
|
||||||
|
|
||||||
|
uninstall-nodist_pkgincludeHEADERS:
|
||||||
|
@$(NORMAL_UNINSTALL)
|
||||||
|
@list='$(nodist_pkginclude_HEADERS)'; for p in $$list; do \
|
||||||
|
f=$(am__strip_dir) \
|
||||||
|
echo " rm -f '$(DESTDIR)$(pkgincludedir)/$$f'"; \
|
||||||
|
rm -f "$(DESTDIR)$(pkgincludedir)/$$f"; \
|
||||||
|
done
|
||||||
|
install-pkgincludeHEADERS: $(pkginclude_HEADERS)
|
||||||
|
@$(NORMAL_INSTALL)
|
||||||
|
test -z "$(pkgincludedir)" || $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)"
|
||||||
|
@list='$(pkginclude_HEADERS)'; for p in $$list; do \
|
||||||
|
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
|
||||||
|
f=$(am__strip_dir) \
|
||||||
|
echo " $(pkgincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgincludedir)/$$f'"; \
|
||||||
|
$(pkgincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgincludedir)/$$f"; \
|
||||||
|
done
|
||||||
|
|
||||||
|
uninstall-pkgincludeHEADERS:
|
||||||
|
@$(NORMAL_UNINSTALL)
|
||||||
|
@list='$(pkginclude_HEADERS)'; for p in $$list; do \
|
||||||
|
f=$(am__strip_dir) \
|
||||||
|
echo " rm -f '$(DESTDIR)$(pkgincludedir)/$$f'"; \
|
||||||
|
rm -f "$(DESTDIR)$(pkgincludedir)/$$f"; \
|
||||||
|
done
|
||||||
|
|
||||||
|
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
||||||
|
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||||
|
unique=`for i in $$list; do \
|
||||||
|
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||||
|
done | \
|
||||||
|
$(AWK) ' { files[$$0] = 1; } \
|
||||||
|
END { for (i in files) print i; }'`; \
|
||||||
|
mkid -fID $$unique
|
||||||
|
tags: TAGS
|
||||||
|
|
||||||
|
TAGS: $(HEADERS) $(SOURCES) tdconfig.h.in $(TAGS_DEPENDENCIES) \
|
||||||
|
$(TAGS_FILES) $(LISP)
|
||||||
|
tags=; \
|
||||||
|
here=`pwd`; \
|
||||||
|
list='$(SOURCES) $(HEADERS) tdconfig.h.in $(LISP) $(TAGS_FILES)'; \
|
||||||
|
unique=`for i in $$list; do \
|
||||||
|
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||||
|
done | \
|
||||||
|
$(AWK) ' { files[$$0] = 1; } \
|
||||||
|
END { for (i in files) print i; }'`; \
|
||||||
|
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
|
||||||
|
test -n "$$unique" || unique=$$empty_fix; \
|
||||||
|
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||||
|
$$tags $$unique; \
|
||||||
|
fi
|
||||||
|
ctags: CTAGS
|
||||||
|
CTAGS: $(HEADERS) $(SOURCES) tdconfig.h.in $(TAGS_DEPENDENCIES) \
|
||||||
|
$(TAGS_FILES) $(LISP)
|
||||||
|
tags=; \
|
||||||
|
here=`pwd`; \
|
||||||
|
list='$(SOURCES) $(HEADERS) tdconfig.h.in $(LISP) $(TAGS_FILES)'; \
|
||||||
|
unique=`for i in $$list; do \
|
||||||
|
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||||
|
done | \
|
||||||
|
$(AWK) ' { files[$$0] = 1; } \
|
||||||
|
END { for (i in files) print i; }'`; \
|
||||||
|
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|
||||||
|
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||||
|
$$tags $$unique
|
||||||
|
|
||||||
|
GTAGS:
|
||||||
|
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||||
|
&& cd $(top_srcdir) \
|
||||||
|
&& gtags -i $(GTAGS_ARGS) $$here
|
||||||
|
|
||||||
|
distclean-tags:
|
||||||
|
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||||
|
|
||||||
|
distdir: $(DISTFILES)
|
||||||
|
$(am__remove_distdir)
|
||||||
|
test -d $(distdir) || mkdir $(distdir)
|
||||||
|
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||||
|
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||||
|
list='$(DISTFILES)'; \
|
||||||
|
dist_files=`for file in $$list; do echo $$file; done | \
|
||||||
|
sed -e "s|^$$srcdirstrip/||;t" \
|
||||||
|
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
||||||
|
case $$dist_files in \
|
||||||
|
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
||||||
|
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
||||||
|
sort -u` ;; \
|
||||||
|
esac; \
|
||||||
|
for file in $$dist_files; do \
|
||||||
|
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||||
|
if test -d $$d/$$file; then \
|
||||||
|
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||||
|
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||||
|
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
|
||||||
|
fi; \
|
||||||
|
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
|
||||||
|
else \
|
||||||
|
test -f $(distdir)/$$file \
|
||||||
|
|| cp -p $$d/$$file $(distdir)/$$file \
|
||||||
|
|| exit 1; \
|
||||||
|
fi; \
|
||||||
|
done
|
||||||
|
-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
|
||||||
|
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
|
||||||
|
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
|
||||||
|
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|
||||||
|
|| chmod -R a+r $(distdir)
|
||||||
|
dist-gzip: distdir
|
||||||
|
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
|
||||||
|
$(am__remove_distdir)
|
||||||
|
|
||||||
|
dist-bzip2: distdir
|
||||||
|
tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
|
||||||
|
$(am__remove_distdir)
|
||||||
|
|
||||||
|
dist-tarZ: distdir
|
||||||
|
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
|
||||||
|
$(am__remove_distdir)
|
||||||
|
|
||||||
|
dist-shar: distdir
|
||||||
|
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
|
||||||
|
$(am__remove_distdir)
|
||||||
|
|
||||||
|
dist-zip: distdir
|
||||||
|
-rm -f $(distdir).zip
|
||||||
|
zip -rq $(distdir).zip $(distdir)
|
||||||
|
$(am__remove_distdir)
|
||||||
|
|
||||||
|
dist dist-all: distdir
|
||||||
|
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
|
||||||
|
$(am__remove_distdir)
|
||||||
|
|
||||||
|
# This target untars the dist file and tries a VPATH configuration. Then
|
||||||
|
# it guarantees that the distribution is self-contained by making another
|
||||||
|
# tarfile.
|
||||||
|
distcheck: dist
|
||||||
|
case '$(DIST_ARCHIVES)' in \
|
||||||
|
*.tar.gz*) \
|
||||||
|
GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
|
||||||
|
*.tar.bz2*) \
|
||||||
|
bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
|
||||||
|
*.tar.Z*) \
|
||||||
|
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
|
||||||
|
*.shar.gz*) \
|
||||||
|
GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
|
||||||
|
*.zip*) \
|
||||||
|
unzip $(distdir).zip ;;\
|
||||||
|
esac
|
||||||
|
chmod -R a-w $(distdir); chmod a+w $(distdir)
|
||||||
|
mkdir $(distdir)/_build
|
||||||
|
mkdir $(distdir)/_inst
|
||||||
|
chmod a-w $(distdir)
|
||||||
|
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
|
||||||
|
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
|
||||||
|
&& cd $(distdir)/_build \
|
||||||
|
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
|
||||||
|
$(DISTCHECK_CONFIGURE_FLAGS) \
|
||||||
|
&& $(MAKE) $(AM_MAKEFLAGS) \
|
||||||
|
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
|
||||||
|
&& $(MAKE) $(AM_MAKEFLAGS) check \
|
||||||
|
&& $(MAKE) $(AM_MAKEFLAGS) install \
|
||||||
|
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
|
||||||
|
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
|
||||||
|
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
|
||||||
|
distuninstallcheck \
|
||||||
|
&& chmod -R a-w "$$dc_install_base" \
|
||||||
|
&& ({ \
|
||||||
|
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
|
||||||
|
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
|
||||||
|
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
|
||||||
|
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
|
||||||
|
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
|
||||||
|
} || { rm -rf "$$dc_destdir"; exit 1; }) \
|
||||||
|
&& rm -rf "$$dc_destdir" \
|
||||||
|
&& $(MAKE) $(AM_MAKEFLAGS) dist \
|
||||||
|
&& rm -rf $(DIST_ARCHIVES) \
|
||||||
|
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck
|
||||||
|
$(am__remove_distdir)
|
||||||
|
@(echo "$(distdir) archives ready for distribution: "; \
|
||||||
|
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
|
||||||
|
sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
|
||||||
|
distuninstallcheck:
|
||||||
|
@cd $(distuninstallcheck_dir) \
|
||||||
|
&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
|
||||||
|
|| { echo "ERROR: files left after uninstall:" ; \
|
||||||
|
if test -n "$(DESTDIR)"; then \
|
||||||
|
echo " (check DESTDIR support)"; \
|
||||||
|
fi ; \
|
||||||
|
$(distuninstallcheck_listfiles) ; \
|
||||||
|
exit 1; } >&2
|
||||||
|
distcleancheck: distclean
|
||||||
|
@if test '$(srcdir)' = . ; then \
|
||||||
|
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
|
||||||
|
exit 1 ; \
|
||||||
|
fi
|
||||||
|
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|
||||||
|
|| { echo "ERROR: files left in build directory after distclean:" ; \
|
||||||
|
$(distcleancheck_listfiles) ; \
|
||||||
|
exit 1; } >&2
|
||||||
|
check-am: all-am
|
||||||
|
check: check-am
|
||||||
|
all-am: Makefile $(LIBRARIES) $(PROGRAMS) $(HEADERS) tdconfig.h
|
||||||
|
installdirs:
|
||||||
|
for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkgincludedir)" "$(DESTDIR)$(pkgincludedir)"; do \
|
||||||
|
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||||
|
done
|
||||||
|
install: install-am
|
||||||
|
install-exec: install-exec-am
|
||||||
|
install-data: install-data-am
|
||||||
|
uninstall: uninstall-am
|
||||||
|
|
||||||
|
install-am: all-am
|
||||||
|
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||||
|
|
||||||
|
installcheck: installcheck-am
|
||||||
|
install-strip:
|
||||||
|
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||||
|
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||||
|
`test -z '$(STRIP)' || \
|
||||||
|
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
|
||||||
|
mostlyclean-generic:
|
||||||
|
|
||||||
|
clean-generic:
|
||||||
|
|
||||||
|
distclean-generic:
|
||||||
|
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||||
|
|
||||||
|
maintainer-clean-generic:
|
||||||
|
@echo "This command is intended for maintainers to use"
|
||||||
|
@echo "it deletes files that may require special tools to rebuild."
|
||||||
|
clean: clean-am
|
||||||
|
|
||||||
|
clean-am: clean-binPROGRAMS clean-generic clean-libLIBRARIES \
|
||||||
|
mostlyclean-am
|
||||||
|
|
||||||
|
distclean: distclean-am
|
||||||
|
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
|
||||||
|
-rm -rf $(DEPDIR) ./$(DEPDIR)
|
||||||
|
-rm -f Makefile
|
||||||
|
distclean-am: clean-am distclean-compile distclean-generic \
|
||||||
|
distclean-hdr distclean-tags
|
||||||
|
|
||||||
|
dvi: dvi-am
|
||||||
|
|
||||||
|
dvi-am:
|
||||||
|
|
||||||
|
html: html-am
|
||||||
|
|
||||||
|
info: info-am
|
||||||
|
|
||||||
|
info-am:
|
||||||
|
|
||||||
|
install-data-am: install-nodist_pkgincludeHEADERS \
|
||||||
|
install-pkgincludeHEADERS
|
||||||
|
|
||||||
|
install-dvi: install-dvi-am
|
||||||
|
|
||||||
|
install-exec-am: install-binPROGRAMS install-libLIBRARIES
|
||||||
|
|
||||||
|
install-html: install-html-am
|
||||||
|
|
||||||
|
install-info: install-info-am
|
||||||
|
|
||||||
|
install-man:
|
||||||
|
|
||||||
|
install-pdf: install-pdf-am
|
||||||
|
|
||||||
|
install-ps: install-ps-am
|
||||||
|
|
||||||
|
installcheck-am:
|
||||||
|
|
||||||
|
maintainer-clean: maintainer-clean-am
|
||||||
|
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
|
||||||
|
-rm -rf $(top_srcdir)/autom4te.cache
|
||||||
|
-rm -rf $(DEPDIR) ./$(DEPDIR)
|
||||||
|
-rm -f Makefile
|
||||||
|
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||||
|
|
||||||
|
mostlyclean: mostlyclean-am
|
||||||
|
|
||||||
|
mostlyclean-am: mostlyclean-compile mostlyclean-generic
|
||||||
|
|
||||||
|
pdf: pdf-am
|
||||||
|
|
||||||
|
pdf-am:
|
||||||
|
|
||||||
|
ps: ps-am
|
||||||
|
|
||||||
|
ps-am:
|
||||||
|
|
||||||
|
uninstall-am: uninstall-binPROGRAMS uninstall-libLIBRARIES \
|
||||||
|
uninstall-nodist_pkgincludeHEADERS uninstall-pkgincludeHEADERS
|
||||||
|
|
||||||
|
.MAKE: install-am install-strip
|
||||||
|
|
||||||
|
.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \
|
||||||
|
clean-binPROGRAMS clean-generic clean-libLIBRARIES ctags dist \
|
||||||
|
dist-all dist-bzip2 dist-gzip dist-shar dist-tarZ dist-zip \
|
||||||
|
distcheck distclean distclean-compile distclean-generic \
|
||||||
|
distclean-hdr distclean-tags distcleancheck distdir \
|
||||||
|
distuninstallcheck dvi dvi-am html html-am info info-am \
|
||||||
|
install install-am install-binPROGRAMS install-data \
|
||||||
|
install-data-am install-dvi install-dvi-am install-exec \
|
||||||
|
install-exec-am install-html install-html-am install-info \
|
||||||
|
install-info-am install-libLIBRARIES install-man \
|
||||||
|
install-nodist_pkgincludeHEADERS install-pdf install-pdf-am \
|
||||||
|
install-pkgincludeHEADERS install-ps install-ps-am \
|
||||||
|
install-strip installcheck installcheck-am installdirs \
|
||||||
|
maintainer-clean maintainer-clean-generic mostlyclean \
|
||||||
|
mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \
|
||||||
|
tags uninstall uninstall-am uninstall-binPROGRAMS \
|
||||||
|
uninstall-libLIBRARIES uninstall-nodist_pkgincludeHEADERS \
|
||||||
|
uninstall-pkgincludeHEADERS
|
||||||
|
|
||||||
|
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||||
|
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||||
|
.NOEXPORT:
|
0
src/tivomirror/tivodecode/NEWS
Normal file
0
src/tivomirror/tivodecode/NEWS
Normal file
74
src/tivomirror/tivodecode/QUTsbox.h
Normal file
74
src/tivomirror/tivodecode/QUTsbox.h
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
/* %W% (QUALCOMM) %E% */
|
||||||
|
/*
|
||||||
|
* 8->32 Sbox generated by Millan et. al. at Queensland University of
|
||||||
|
* Technology. See: E. Dawson, W. Millan, L. Burnett, G. Carter,
|
||||||
|
* "On the Design of 8*32 S-boxes". Unpublished report, by the
|
||||||
|
* Information Systems Research Centre,
|
||||||
|
* Queensland University of Technology, 1999.
|
||||||
|
*/
|
||||||
|
WORD Qbox[256] = {
|
||||||
|
0x1faa1887, 0x4e5e435c, 0x9165c042, 0x250e6ef4,
|
||||||
|
0x5957ee20, 0xd484fed3, 0xa666c502, 0x7e54e8ae,
|
||||||
|
0xd12ee9d9, 0xfc1f38d4, 0x49829b5d, 0x1b5cdf3c,
|
||||||
|
0x74864249, 0xda2e3963, 0x28f4429f, 0xc8432c35,
|
||||||
|
0x4af40325, 0x9fc0dd70, 0xd8973ded, 0x1a02dc5e,
|
||||||
|
0xcd175b42, 0xf10012bf, 0x6694d78c, 0xacaab26b,
|
||||||
|
0x4ec11b9a, 0x3f168146, 0xc0ea8ec5, 0xb38ac28f,
|
||||||
|
0x1fed5c0f, 0xaab4101c, 0xea2db082, 0x470929e1,
|
||||||
|
0xe71843de, 0x508299fc, 0xe72fbc4b, 0x2e3915dd,
|
||||||
|
0x9fa803fa, 0x9546b2de, 0x3c233342, 0x0fcee7c3,
|
||||||
|
0x24d607ef, 0x8f97ebab, 0xf37f859b, 0xcd1f2e2f,
|
||||||
|
0xc25b71da, 0x75e2269a, 0x1e39c3d1, 0xeda56b36,
|
||||||
|
0xf8c9def2, 0x46c9fc5f, 0x1827b3a3, 0x70a56ddf,
|
||||||
|
0x0d25b510, 0x000f85a7, 0xb2e82e71, 0x68cb8816,
|
||||||
|
0x8f951e2a, 0x72f5f6af, 0xe4cbc2b3, 0xd34ff55d,
|
||||||
|
0x2e6b6214, 0x220b83e3, 0xd39ea6f5, 0x6fe041af,
|
||||||
|
0x6b2f1f17, 0xad3b99ee, 0x16a65ec0, 0x757016c6,
|
||||||
|
0xba7709a4, 0xb0326e01, 0xf4b280d9, 0x4bfb1418,
|
||||||
|
0xd6aff227, 0xfd548203, 0xf56b9d96, 0x6717a8c0,
|
||||||
|
0x00d5bf6e, 0x10ee7888, 0xedfcfe64, 0x1ba193cd,
|
||||||
|
0x4b0d0184, 0x89ae4930, 0x1c014f36, 0x82a87088,
|
||||||
|
0x5ead6c2a, 0xef22c678, 0x31204de7, 0xc9c2e759,
|
||||||
|
0xd200248e, 0x303b446b, 0xb00d9fc2, 0x9914a895,
|
||||||
|
0x906cc3a1, 0x54fef170, 0x34c19155, 0xe27b8a66,
|
||||||
|
0x131b5e69, 0xc3a8623e, 0x27bdfa35, 0x97f068cc,
|
||||||
|
0xca3a6acd, 0x4b55e936, 0x86602db9, 0x51df13c1,
|
||||||
|
0x390bb16d, 0x5a80b83c, 0x22b23763, 0x39d8a911,
|
||||||
|
0x2cb6bc13, 0xbf5579d7, 0x6c5c2fa8, 0xa8f4196e,
|
||||||
|
0xbcdb5476, 0x6864a866, 0x416e16ad, 0x897fc515,
|
||||||
|
0x956feb3c, 0xf6c8a306, 0x216799d9, 0x171a9133,
|
||||||
|
0x6c2466dd, 0x75eb5dcd, 0xdf118f50, 0xe4afb226,
|
||||||
|
0x26b9cef3, 0xadb36189, 0x8a7a19b1, 0xe2c73084,
|
||||||
|
0xf77ded5c, 0x8b8bc58f, 0x06dde421, 0xb41e47fb,
|
||||||
|
0xb1cc715e, 0x68c0ff99, 0x5d122f0f, 0xa4d25184,
|
||||||
|
0x097a5e6c, 0x0cbf18bc, 0xc2d7c6e0, 0x8bb7e420,
|
||||||
|
0xa11f523f, 0x35d9b8a2, 0x03da1a6b, 0x06888c02,
|
||||||
|
0x7dd1e354, 0x6bba7d79, 0x32cc7753, 0xe52d9655,
|
||||||
|
0xa9829da1, 0x301590a7, 0x9bc1c149, 0x13537f1c,
|
||||||
|
0xd3779b69, 0x2d71f2b7, 0x183c58fa, 0xacdc4418,
|
||||||
|
0x8d8c8c76, 0x2620d9f0, 0x71a80d4d, 0x7a74c473,
|
||||||
|
0x449410e9, 0xa20e4211, 0xf9c8082b, 0x0a6b334a,
|
||||||
|
0xb5f68ed2, 0x8243cc1b, 0x453c0ff3, 0x9be564a0,
|
||||||
|
0x4ff55a4f, 0x8740f8e7, 0xcca7f15f, 0xe300fe21,
|
||||||
|
0x786d37d6, 0xdfd506f1, 0x8ee00973, 0x17bbde36,
|
||||||
|
0x7a670fa8, 0x5c31ab9e, 0xd4dab618, 0xcc1f52f5,
|
||||||
|
0xe358eb4f, 0x19b9e343, 0x3a8d77dd, 0xcdb93da6,
|
||||||
|
0x140fd52d, 0x395412f8, 0x2ba63360, 0x37e53ad0,
|
||||||
|
0x80700f1c, 0x7624ed0b, 0x703dc1ec, 0xb7366795,
|
||||||
|
0xd6549d15, 0x66ce46d7, 0xd17abe76, 0xa448e0a0,
|
||||||
|
0x28f07c02, 0xc31249b7, 0x6e9ed6ba, 0xeaa47f78,
|
||||||
|
0xbbcfffbd, 0xc507ca84, 0xe965f4da, 0x8e9f35da,
|
||||||
|
0x6ad2aa44, 0x577452ac, 0xb5d674a7, 0x5461a46a,
|
||||||
|
0x6763152a, 0x9c12b7aa, 0x12615927, 0x7b4fb118,
|
||||||
|
0xc351758d, 0x7e81687b, 0x5f52f0b3, 0x2d4254ed,
|
||||||
|
0xd4c77271, 0x0431acab, 0xbef94aec, 0xfee994cd,
|
||||||
|
0x9c4d9e81, 0xed623730, 0xcf8a21e8, 0x51917f0b,
|
||||||
|
0xa7a9b5d6, 0xb297adf8, 0xeed30431, 0x68cac921,
|
||||||
|
0xf1b35d46, 0x7a430a36, 0x51194022, 0x9abca65e,
|
||||||
|
0x85ec70ba, 0x39aea8cc, 0x737bae8b, 0x582924d5,
|
||||||
|
0x03098a5a, 0x92396b81, 0x18de2522, 0x745c1cb8,
|
||||||
|
0xa1b8fe1d, 0x5db3c697, 0x29164f83, 0x97c16376,
|
||||||
|
0x8419224c, 0x21203b35, 0x833ac0fe, 0xd966a19a,
|
||||||
|
0xaaf0b24f, 0x40fda998, 0xe7d52d71, 0x390896a8,
|
||||||
|
0xcee6053f, 0xd0b0d300, 0xff99cbcc, 0x065e3d40,
|
||||||
|
};
|
40
src/tivomirror/tivodecode/README
Normal file
40
src/tivomirror/tivodecode/README
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
tivodecode (c) 2006-2007, Jeremy Drake
|
||||||
|
Version 0.3pre4
|
||||||
|
See COPYING for license terms.
|
||||||
|
|
||||||
|
This project now uses autoconf for its build system. See the INSTALL file for
|
||||||
|
generic autoconf instructions, or just run:
|
||||||
|
./configure
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
|
||||||
|
To build on Windows, a Visual C++ Express 2005 solution file is included. If
|
||||||
|
you have a working installation of this compiler, building should be as simple
|
||||||
|
as opening this solution file and building the tivodecode project.
|
||||||
|
|
||||||
|
If you are using the Windows binary download, you may need the Visual Studio
|
||||||
|
2005 Redisributables from Microsoft, if you do not already have MSVCR80.DLL
|
||||||
|
installed from some other software.
|
||||||
|
|
||||||
|
You now have the option to, rather than specifying the MAK on the command line
|
||||||
|
every time, to specify it in a config file in your home directory. Simply put
|
||||||
|
your MAK in a file called ~/.tivodecode_mak and it will be automatically used
|
||||||
|
if a MAK is not specified on the command line. On Windows, the file should be
|
||||||
|
in your %USERPROFILE% directory, or in c:\ if there is no %USERPROFILE% set.
|
||||||
|
|
||||||
|
The parameters (from --help) are documented below.
|
||||||
|
|
||||||
|
|
||||||
|
Usage: ./tivodecode [--help] [--verbose|-v] [--no-verify|-n] {--mak|-m} mak [{--out|-o} outfile] <tivofile>
|
||||||
|
|
||||||
|
--mak, -m media access key (required)
|
||||||
|
--out, -o output file (default stdout)
|
||||||
|
--verbose, -v verbose (add more v's for more verbosity)
|
||||||
|
--no-verify, -n do not verify MAK while decoding
|
||||||
|
--no-video, -x don't decode video, exit after metadata
|
||||||
|
--version, -V print the version information and exit
|
||||||
|
--help, -h print this help and exit
|
||||||
|
|
||||||
|
The file names specified for the output file or the tivo file may be -, which
|
||||||
|
means stdout or stdin respectively
|
||||||
|
|
232
src/tivomirror/tivodecode/TiVo-Decrypt-Notes.txt
Normal file
232
src/tivomirror/tivodecode/TiVo-Decrypt-Notes.txt
Normal file
|
@ -0,0 +1,232 @@
|
||||||
|
|
||||||
|
TiVo TS header structure
|
||||||
|
========================
|
||||||
|
|
||||||
|
The TS file maintains the same overall file layout as the PS files.
|
||||||
|
There is a small header, followed by three "chunks" of info at the
|
||||||
|
beginning of the TS .TiVo file.
|
||||||
|
|
||||||
|
The header :
|
||||||
|
|
||||||
|
struct {
|
||||||
|
char filetype[4];
|
||||||
|
/* all fields are in network byte order */
|
||||||
|
unsigned short dummy_0004;
|
||||||
|
unsigned short dummy_0006;
|
||||||
|
unsigned short dummy_0008;
|
||||||
|
unsigned char mpeg_offset[4]; /* unsigned int */
|
||||||
|
unsigned short chunks;
|
||||||
|
} raw_tivo_header;
|
||||||
|
|
||||||
|
Points of interest :
|
||||||
|
"filetype" is always "TiVo".
|
||||||
|
dummy_0004 is unknown, at the moment.
|
||||||
|
dummy_0006 :
|
||||||
|
|
||||||
|
Bit 1 is always 0
|
||||||
|
|
||||||
|
Bit 2 is always 0 for US TiVo files and 1 for NZ/AUS files.
|
||||||
|
|
||||||
|
This does NOT seem to indicate H.264 vs MPEG-2 as I have one
|
||||||
|
of each from a NZ TiVo and they both have it set to 1.
|
||||||
|
|
||||||
|
Bit 3 is 0 if the file is PS and 1 if the file is TS
|
||||||
|
|
||||||
|
Bit 4 is 0 if the file is SD and 1 if the files is HD
|
||||||
|
* There are more values folded into "dummy_006" that are yet to be determined.
|
||||||
|
|
||||||
|
"mpeg_offset" is the offset at which the real MPEG data starts (typically around 14336)
|
||||||
|
"chunks" denotes the number of TiVo-specific chunks of data that follow (typically 3).
|
||||||
|
|
||||||
|
The chunks :
|
||||||
|
|
||||||
|
#define SIZEOF_STREAM_CHUNK 12
|
||||||
|
typedef struct tivo_stream_chunk_s {
|
||||||
|
unsigned int chunk_size; /* Size of chunk */
|
||||||
|
unsigned int data_size; /* Length of the payload */
|
||||||
|
unsigned short id; /* Chunk ID */
|
||||||
|
unsigned short type; /* Subtype */
|
||||||
|
unsigned char data[1]; /* Variable length data */
|
||||||
|
} tivo_stream_chunk;
|
||||||
|
|
||||||
|
Chunk size denotes the size of the current chunk.
|
||||||
|
Data size is the size of the current chunk, less the chunk header.
|
||||||
|
ID is the sequential chunk number of the current chunk (0-based).
|
||||||
|
|
||||||
|
type==0 is a clear-text copyright notice.
|
||||||
|
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<license xmlns="http://www.tivo.com/developer/xml/license-1.0">
|
||||||
|
<notice>
|
||||||
|
TiVo takes copyright violations seriously. This file may contain
|
||||||
|
content protected by copyright laws. If you are not the owner or rights
|
||||||
|
holder of such content, you should be aware that if you distribute this
|
||||||
|
file or otherwise make it available to anyone else, you may be violating the
|
||||||
|
intellectual property rights of the owners of the content contained in this
|
||||||
|
file. If you are not the owner or rights holder of such content, and if you
|
||||||
|
are a TiVo customer, and if you distribute this file or otherwise make it
|
||||||
|
available to anyone else, you may be violating the service agreement.
|
||||||
|
We may permanently discontinue your TiVo service as a result.
|
||||||
|
</notice>
|
||||||
|
<created>
|
||||||
|
01/12/2005 11:22:01
|
||||||
|
</created>
|
||||||
|
<fingerprint>
|
||||||
|
... hex string that is 224 hex digits long ....
|
||||||
|
</fingerprint>
|
||||||
|
<salt>
|
||||||
|
... hex string that is 32 hex digits long...
|
||||||
|
</salt>
|
||||||
|
</license>
|
||||||
|
|
||||||
|
type==1 is an encrypted copy of the TiVo XML metadata for this file.
|
||||||
|
|
||||||
|
The encryption scheme used here is the metadata variant (see "Crytpo" below)
|
||||||
|
of the Turing stream cipher.
|
||||||
|
|
||||||
|
Typically, there are two chunks of this type, and the two are nearly identical.
|
||||||
|
The only variations I can see are that the second one includes the "uniqueId"
|
||||||
|
field, which is the unique seriesId (i.e. SH01234567) used by TiVo to perform
|
||||||
|
grouping in the Now Playing List.
|
||||||
|
|
||||||
|
|
||||||
|
Crypto
|
||||||
|
======
|
||||||
|
|
||||||
|
The encryption method utilized by TiVo is the open source Turing stream cipher, by Qualcomm.
|
||||||
|
|
||||||
|
https://opensource.qualcomm.com/index.php?turing
|
||||||
|
|
||||||
|
It follows the usual crypto usage pattern :
|
||||||
|
- initialize crypto session (to zero)
|
||||||
|
- "salt" the crypto session with predefined values (MAK, etc)
|
||||||
|
- pass blocks of the stream data through the cipher to encrypt/decrypt it
|
||||||
|
|
||||||
|
The metadata chunks use an initial MD5 pass to generate its Turing salt value.
|
||||||
|
The transport stream data packets use an initial SHA-1 pass to generate its Turing salt value.
|
||||||
|
|
||||||
|
|
||||||
|
Acquiring TiVo TS crypto info
|
||||||
|
=============================
|
||||||
|
|
||||||
|
- We must first acquire the MPEG TS "Program Association Table" (PAT).
|
||||||
|
This packet's only useful data element is the "program_MAP_pid" field,
|
||||||
|
which instructs us as the to PID of the "Program Map Table" (PMT) packet.
|
||||||
|
The PAT is always located at PID 0.
|
||||||
|
|
||||||
|
- Then, we must acquire the MPEG TS "Program Map Table" (PMT). The PMT
|
||||||
|
is a table of the elementary stream pids within the MPEG file, and their
|
||||||
|
types. The PMT may be located at PID identified in the PAT, or (more
|
||||||
|
likely) may be encapsulated in an audio/video packet. Typically, a TiVo
|
||||||
|
file will contain three streams.
|
||||||
|
0x21 = video
|
||||||
|
0x22 = audio
|
||||||
|
0x23 = private data : this is where TiVo puts the crypto goodies
|
||||||
|
|
||||||
|
- Not all packets in the audio and video streams are encrypted. This is
|
||||||
|
verified by comparing encrypted TS files and decrypted MPEG files as
|
||||||
|
generated by DirectShowDump. As such, we only need to worry about the
|
||||||
|
packets that are encrypted (which is denoted by the packet's TS header
|
||||||
|
transport_scrambling_control field being set to a non-zero value, usually 0x3).
|
||||||
|
|
||||||
|
- Packets in the "private data" stream contain the necessary info to decrypt
|
||||||
|
the audio and video streams within the TiVo MPEG TS file. They appear
|
||||||
|
periodically within the packet stream, and the Turing key value changes
|
||||||
|
with each new private data packet.
|
||||||
|
|
||||||
|
TiVo Private Data format
|
||||||
|
typedef struct TiVo_Private_Data_s
|
||||||
|
{
|
||||||
|
unsigned int filetype;
|
||||||
|
unsigned int unknown;
|
||||||
|
unsigned short num_streams;
|
||||||
|
TiVo_Private_Data_Stream data_streams[N];
|
||||||
|
} TiVo_Private_Data;
|
||||||
|
|
||||||
|
The filetype is always "TiVo".
|
||||||
|
The unknown field is exactly that, although its value is always 0x81037d00.
|
||||||
|
The num_streams indicates how many TiVo_Private_Data_Stream elements follow.
|
||||||
|
|
||||||
|
typedef struct TiVo_Private_Data_Stream_s
|
||||||
|
{
|
||||||
|
unsigned short pid;
|
||||||
|
unsigned char stream_id;
|
||||||
|
unsigned char reserved;
|
||||||
|
unsigned char key[16];
|
||||||
|
} TiVo_Private_Data_Stream;
|
||||||
|
|
||||||
|
The pid is the Packet ID for this stream (0x21, 0x22, etc).
|
||||||
|
The stream_id is the TS Stream ID (0xE0 video, 0xC0 audio, etc).
|
||||||
|
The reserved field is always 0x10.
|
||||||
|
The key is the 16-byte Turing key used to decrypt this particular stream.
|
||||||
|
|
||||||
|
The Turing key has two additional values folded into it for later use in
|
||||||
|
the decrypt process :
|
||||||
|
|
||||||
|
The first value is the "block_no" value, and indicates the Turing block
|
||||||
|
number for this portion of the cipher process. It increments over time
|
||||||
|
within the stream.
|
||||||
|
|
||||||
|
The second value is the "crypted" value, which appears to be some sort
|
||||||
|
of checksum value used by the stream cipher. In PS files, this number
|
||||||
|
appears to be a usable hexadecimal value, and as such is used in the
|
||||||
|
decrypt process. However, in the TS files, this number is always zero,
|
||||||
|
and is not used in the decrypt process.
|
||||||
|
|
||||||
|
When a TiVo private data packet is encountered, we must update our session's
|
||||||
|
Turing values (key, block_no) to the newer values. Each packet stream
|
||||||
|
(i.e. audio, video) within the transport stream will have it's own Turing
|
||||||
|
session. So, we must maintain these separate Turing sessions across packets.
|
||||||
|
|
||||||
|
When an audio/video packet is encountered, we must first verify if it is
|
||||||
|
indeed encrypted by checking the TS header's transport_scrambling_control
|
||||||
|
field. Any non-zero value (typically 0x3) denotes an encrypted packet.
|
||||||
|
|
||||||
|
We must take care to only decrypt payload data, and not packet stream control
|
||||||
|
data. As such, we must pass over other MPEG TS headers, such as the
|
||||||
|
Adaptation field or PES headers.
|
||||||
|
|
||||||
|
When we've finally located the beginning of the encrypted payload data, we
|
||||||
|
must regenerate our Turing cipher for this particular session. For this
|
||||||
|
packet, we must :
|
||||||
|
- locate this particular PID's Turing session
|
||||||
|
- extract the "block_no" and "crypted" values from the Turing key using by
|
||||||
|
calling do_header()
|
||||||
|
- prepare the Turing frame for decrypt by calling prepare_frame() and
|
||||||
|
pass it the PID and block_no.
|
||||||
|
- decrypt the payload by calling decrypt_buffer(), passing in a pointer
|
||||||
|
to the start of the encrypted payload, and the size of the payload to
|
||||||
|
be decrypted.
|
||||||
|
|
||||||
|
|
||||||
|
TiVo PS decrypt methodology
|
||||||
|
===========================
|
||||||
|
|
||||||
|
- Identify in the stream where private data is located (inside the private
|
||||||
|
data packets identified as PID 0x23). This is the crypto key.
|
||||||
|
|
||||||
|
- Prepare for Turing decrypt operations by passing in this key, along with two
|
||||||
|
values (block_no and crypted) into the do_header() function. This does some
|
||||||
|
bitfield math on these three elements, and results in new values being inserted into
|
||||||
|
the block_no and crypted fields. The do_header() function was reconstructed
|
||||||
|
from the TiVo DLL by other individuals, and the understanding behind it is
|
||||||
|
incomplete. There is some stuff going on in there that is unknown. Although,
|
||||||
|
it's obviously doing the right stuff (at least for PS operations).
|
||||||
|
|
||||||
|
- We then pass the new block_no and stream_id values into the prepare_frame()
|
||||||
|
function to prep the Turing structures for data decryption.
|
||||||
|
|
||||||
|
- We then pass the new crypted value (4 bytes worth) into the decrypt_buffer()
|
||||||
|
function to get the Turing goodies ready for real data.
|
||||||
|
|
||||||
|
- We then pass the entire amount of decrypted data through the decrypt_buffer()
|
||||||
|
function to decrypt the data. Since this is a data stream, the size of this
|
||||||
|
operation can be anywhere from 1000 to 15000 bytes.
|
||||||
|
|
||||||
|
- Rinse and repeat.
|
||||||
|
|
||||||
|
|
||||||
|
Notes on the code
|
||||||
|
=================
|
||||||
|
Since I was not an MPEG expert, I was quite verbose in my packet decode and debug output.
|
||||||
|
Much of this code can probably be cleaned up, or outright removed as needed.
|
107
src/tivomirror/tivodecode/Turing.h
Normal file
107
src/tivomirror/tivodecode/Turing.h
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
/* @(#)Turing.h 1.4 (QUALCOMM) 03/02/24 */
|
||||||
|
/*
|
||||||
|
* Interface definition of Turing
|
||||||
|
*
|
||||||
|
* Copyright C 2002, Qualcomm Inc. Written by Greg Rose
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
This software is free for commercial and non-commercial use subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
1. Copyright remains vested in QUALCOMM Incorporated, and Copyright
|
||||||
|
notices in the code are not to be removed. If this package is used in
|
||||||
|
a product, QUALCOMM should be given attribution as the author of the
|
||||||
|
Turing encryption algorithm. This can be in the form of a textual
|
||||||
|
message at program startup or in documentation (online or textual)
|
||||||
|
provided with the package.
|
||||||
|
|
||||||
|
2. Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
a. Redistributions of source code must retain the copyright notice,
|
||||||
|
this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
b. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
|
||||||
|
c. All advertising materials mentioning features or use of this
|
||||||
|
software must display the following acknowledgement: This product
|
||||||
|
includes software developed by QUALCOMM Incorporated.
|
||||||
|
|
||||||
|
3. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND AGAINST
|
||||||
|
INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
|
||||||
|
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
4. The license and distribution terms for any publically available version
|
||||||
|
or derivative of this code cannot be changed, that is, this code cannot
|
||||||
|
simply be copied and put under another distribution license including
|
||||||
|
the GNU Public License.
|
||||||
|
|
||||||
|
5. The Turing family of encryption algorithms are covered by patents in
|
||||||
|
the United States of America and other countries. A free and
|
||||||
|
irrevocable license is hereby granted for the use of such patents to
|
||||||
|
the extent required to utilize the Turing family of encryption
|
||||||
|
algorithms for any purpose, subject to the condition that any
|
||||||
|
commercial product utilising any of the Turing family of encryption
|
||||||
|
algorithms should show the words "Encryption by QUALCOMM" either on the
|
||||||
|
product or in the associated documentation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TURING_H
|
||||||
|
#define TURING_H 1
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef unsigned char BYTE;
|
||||||
|
typedef unsigned long WORD;
|
||||||
|
|
||||||
|
#define MAXKEY 32 /*bytes*/
|
||||||
|
#define MAXKIV 48 /*bytes*/
|
||||||
|
#define MAXSTREAM 340 /* bytes, maximum stream generated by one call */
|
||||||
|
#define LFSRLEN 17 /*words*/
|
||||||
|
#define OUTLEN 20 /*bytes*/
|
||||||
|
#define POLY 0x4D /* x^8 + x^6 + x^3 + x^2 + 1 */
|
||||||
|
|
||||||
|
void * TuringAlloc();
|
||||||
|
void TuringFree(void * internal);
|
||||||
|
void TuringKey(void * internal, const BYTE key[], const int keylength);
|
||||||
|
void TuringIV(void * internal, const BYTE iv[], const int ivlength);
|
||||||
|
int TuringGen(void * internal, BYTE *buf); /* returns number of bytes of mask generated */
|
||||||
|
|
||||||
|
/* some useful macros -- big-endian */
|
||||||
|
#define B(x,i) ((BYTE)(((x) >> (24 - 8*i)) & 0xFF))
|
||||||
|
|
||||||
|
#define WORD2BYTE(w, b) { \
|
||||||
|
(b)[3] = B(w,3); \
|
||||||
|
(b)[2] = B(w,2); \
|
||||||
|
(b)[1] = B(w,1); \
|
||||||
|
(b)[0] = B(w,0); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define BYTE2WORD(b) ( \
|
||||||
|
(((WORD)(b)[0] & 0xFF)<<24) | \
|
||||||
|
(((WORD)(b)[1] & 0xFF)<<16) | \
|
||||||
|
(((WORD)(b)[2] & 0xFF)<<8) | \
|
||||||
|
(((WORD)(b)[3] & 0xFF)) \
|
||||||
|
)
|
||||||
|
|
||||||
|
#define ROTL(w,x) (((w) << (x))|((w) >> (32 - (x))))
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
303
src/tivomirror/tivodecode/TuringFast.c
Normal file
303
src/tivomirror/tivodecode/TuringFast.c
Normal file
|
@ -0,0 +1,303 @@
|
||||||
|
/* @(#)TuringFast.c 1.6 (QUALCOMM Turing) 03/02/24 */
|
||||||
|
/*
|
||||||
|
* Fast (unrolled) implementation of Turing
|
||||||
|
*
|
||||||
|
* Copyright C 2002, Qualcomm Inc. Written by Greg Rose
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
This software is free for commercial and non-commercial use subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
1. Copyright remains vested in QUALCOMM Incorporated, and Copyright
|
||||||
|
notices in the code are not to be removed. If this package is used in
|
||||||
|
a product, QUALCOMM should be given attribution as the author of the
|
||||||
|
Turing encryption algorithm. This can be in the form of a textual
|
||||||
|
message at program startup or in documentation (online or textual)
|
||||||
|
provided with the package.
|
||||||
|
|
||||||
|
2. Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
a. Redistributions of source code must retain the copyright notice,
|
||||||
|
this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
b. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
|
||||||
|
c. All advertising materials mentioning features or use of this
|
||||||
|
software must display the following acknowledgement: This product
|
||||||
|
includes software developed by QUALCOMM Incorporated.
|
||||||
|
|
||||||
|
3. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND AGAINST
|
||||||
|
INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
|
||||||
|
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
4. The license and distribution terms for any publically available version
|
||||||
|
or derivative of this code cannot be changed, that is, this code cannot
|
||||||
|
simply be copied and put under another distribution license including
|
||||||
|
the GNU Public License.
|
||||||
|
|
||||||
|
5. The Turing family of encryption algorithms are covered by patents in
|
||||||
|
the United States of America and other countries. A free and
|
||||||
|
irrevocable license is hereby granted for the use of such patents to
|
||||||
|
the extent required to utilize the Turing family of encryption
|
||||||
|
algorithms for any purpose, subject to the condition that any
|
||||||
|
commercial product utilising any of the Turing family of encryption
|
||||||
|
algorithms should show the words "Encryption by QUALCOMM" either on the
|
||||||
|
product or in the associated documentation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "tdconfig.h"
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STDLIB_H
|
||||||
|
# include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
#include "Turing.h" /* interface definitions */
|
||||||
|
#include "TuringSbox.h"
|
||||||
|
#include "QUTsbox.h"
|
||||||
|
#include "TuringMultab.h"
|
||||||
|
|
||||||
|
struct turing_internal
|
||||||
|
{
|
||||||
|
int keylen; /* adjusted to count WORDs */
|
||||||
|
WORD K[MAXKEY/4]; /* storage for mixed key */
|
||||||
|
WORD R[LFSRLEN]; /* the shift register */
|
||||||
|
/* precalculated S-boxes */
|
||||||
|
WORD S0[256], S1[256], S2[256], S3[256];
|
||||||
|
};
|
||||||
|
|
||||||
|
/* give correct offset for the current position of the register,
|
||||||
|
* where logically turing->R[0] is at position "zero".
|
||||||
|
*/
|
||||||
|
#define OFF(zero, i) (((zero)+(i)) % LFSRLEN)
|
||||||
|
|
||||||
|
/* step the LFSR */
|
||||||
|
/* After stepping, "zero" moves right one place */
|
||||||
|
#define STEP(z) \
|
||||||
|
turing->R[OFF(z,0)] = turing->R[OFF(z,15)] ^ turing->R[OFF(z,4)] ^ \
|
||||||
|
(turing->R[OFF(z,0)] << 8) ^ Multab[(turing->R[OFF(z,0)] >> 24) & 0xFF]
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This does a reversible transformation of a word, based on the S-boxes.
|
||||||
|
* The reversibility isn't used, but it guarantees no loss of information,
|
||||||
|
* and hence no equivalent keys or IVs.
|
||||||
|
*/
|
||||||
|
static WORD
|
||||||
|
fixedS(WORD w)
|
||||||
|
{
|
||||||
|
WORD b;
|
||||||
|
|
||||||
|
b = Sbox[B(w, 0)]; w = ((w ^ Qbox[b]) & 0x00FFFFFF) | (b << 24);
|
||||||
|
b = Sbox[B(w, 1)]; w = ((w ^ ROTL(Qbox[b],8)) & 0xFF00FFFF) | (b << 16);
|
||||||
|
b = Sbox[B(w, 2)]; w = ((w ^ ROTL(Qbox[b],16)) & 0xFFFF00FF) | (b << 8);
|
||||||
|
b = Sbox[B(w, 3)]; w = ((w ^ ROTL(Qbox[b],24)) & 0xFFFFFF00) | b;
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Push a word through the keyed S-boxes.
|
||||||
|
*/
|
||||||
|
#define S(w,b) (turing->S0[B((w), ((0+b)&0x3))] \
|
||||||
|
^ turing->S1[B((w), ((1+b)&0x3))] \
|
||||||
|
^ turing->S2[B((w), ((2+b)&0x3))] \
|
||||||
|
^ turing->S3[B((w), ((3+b)&0x3))])
|
||||||
|
|
||||||
|
/* two variants of the Pseudo-Hadamard Transform */
|
||||||
|
|
||||||
|
/* Mix 5 words in place */
|
||||||
|
#define PHT(A,B,C,D,E) { \
|
||||||
|
(E) += (A) + (B) + (C) + (D); \
|
||||||
|
(A) += (E); \
|
||||||
|
(B) += (E); \
|
||||||
|
(C) += (E); \
|
||||||
|
(D) += (E); \
|
||||||
|
}
|
||||||
|
|
||||||
|
/* General word-wide n-PHT */
|
||||||
|
void
|
||||||
|
mixwords(WORD w[], int n)
|
||||||
|
{
|
||||||
|
register WORD sum;
|
||||||
|
register int i;
|
||||||
|
|
||||||
|
for (sum = i = 0; i < n-1; ++i)
|
||||||
|
sum += w[i];
|
||||||
|
w[n-1] += sum;
|
||||||
|
sum = w[n-1];
|
||||||
|
for (i = 0; i < n-1; ++i)
|
||||||
|
w[i] += sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Key the cipher.
|
||||||
|
* Table version; gathers words, mixes them, saves them.
|
||||||
|
* Then compiles lookup tables for the keyed S-boxes.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
TuringKey(void * internal, const BYTE key[], const int keylength)
|
||||||
|
{
|
||||||
|
struct turing_internal * turing = internal;
|
||||||
|
register int i, j, k;
|
||||||
|
register WORD w;
|
||||||
|
|
||||||
|
if ((keylength & 0x03) != 0 || keylength > MAXKEY)
|
||||||
|
abort();
|
||||||
|
turing->keylen = 0;
|
||||||
|
for (i = 0; i < keylength; i += 4)
|
||||||
|
turing->K[turing->keylen++] = fixedS(BYTE2WORD(&key[i]));
|
||||||
|
mixwords(turing->K, turing->keylen);
|
||||||
|
|
||||||
|
/* build S-box lookup tables */
|
||||||
|
for (j = 0; j < 256; ++j) {
|
||||||
|
w = 0;
|
||||||
|
k = j;
|
||||||
|
for (i = 0; i < turing->keylen; ++i) {
|
||||||
|
k = Sbox[B(turing->K[i], 0) ^ k];
|
||||||
|
w ^= ROTL(Qbox[k], i + 0);
|
||||||
|
}
|
||||||
|
turing->S0[j] = (w & 0x00FFFFFFUL) | (k << 24);
|
||||||
|
}
|
||||||
|
for (j = 0; j < 256; ++j) {
|
||||||
|
w = 0;
|
||||||
|
k = j;
|
||||||
|
for (i = 0; i < turing->keylen; ++i) {
|
||||||
|
k = Sbox[B(turing->K[i], 1) ^ k];
|
||||||
|
w ^= ROTL(Qbox[k], i + 8);
|
||||||
|
}
|
||||||
|
turing->S1[j] = (w & 0xFF00FFFFUL) | (k << 16);
|
||||||
|
}
|
||||||
|
for (j = 0; j < 256; ++j) {
|
||||||
|
w = 0;
|
||||||
|
k = j;
|
||||||
|
for (i = 0; i < turing->keylen; ++i) {
|
||||||
|
k = Sbox[B(turing->K[i], 2) ^ k];
|
||||||
|
w ^= ROTL(Qbox[k], i + 16);
|
||||||
|
}
|
||||||
|
turing->S2[j] = (w & 0xFFFF00FFUL) | (k << 8);
|
||||||
|
}
|
||||||
|
for (j = 0; j < 256; ++j) {
|
||||||
|
w = 0;
|
||||||
|
k = j;
|
||||||
|
for (i = 0; i < turing->keylen; ++i) {
|
||||||
|
k = Sbox[B(turing->K[i], 3) ^ k];
|
||||||
|
w ^= ROTL(Qbox[k], i + 24);
|
||||||
|
}
|
||||||
|
turing->S3[j] = (w & 0xFFFFFF00UL) | k;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load the Initialization Vector.
|
||||||
|
* Actually, this fills the LFSR, with IV, key, length, and more.
|
||||||
|
* IV goes through the fixed S-box, key is premixed, the rest go through
|
||||||
|
* the keyed S-boxes. The reason for this is to avoid nasty interactions
|
||||||
|
* between the mixed key and the S-boxes that depend on them, and also
|
||||||
|
* to avoid any "chosen-IV" interactions with the keyed S-boxes, not that I
|
||||||
|
* can think of any.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
TuringIV(void * internal, const BYTE iv[], const int ivlength)
|
||||||
|
{
|
||||||
|
struct turing_internal * turing = internal;
|
||||||
|
register int i, j;
|
||||||
|
|
||||||
|
/* check args */
|
||||||
|
if ((ivlength & 0x03) != 0 || (ivlength + 4*turing->keylen) > MAXKIV)
|
||||||
|
abort();
|
||||||
|
/* first copy in the IV, mixing as we go */
|
||||||
|
for (i = j = 0; j < ivlength; j +=4)
|
||||||
|
turing->R[i++] = fixedS(BYTE2WORD(&iv[j]));
|
||||||
|
/* now continue with the premixed key */
|
||||||
|
for (j = 0 /* i continues */; j < turing->keylen; ++j)
|
||||||
|
turing->R[i++] = turing->K[j];
|
||||||
|
/* now the length-dependent word */
|
||||||
|
turing->R[i++] = (turing->keylen << 4) | (ivlength >> 2) | 0x01020300UL;
|
||||||
|
/* ... and fill the rest of the register */
|
||||||
|
for (j = 0 /* i continues */; i < LFSRLEN; ++i, ++j)
|
||||||
|
turing->R[i] = S(turing->R[j] + turing->R[i-1], 0);
|
||||||
|
/* finally mix all the words */
|
||||||
|
mixwords(turing->R, LFSRLEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* a single round */
|
||||||
|
#define ROUND(z,b) \
|
||||||
|
{ \
|
||||||
|
STEP(z); \
|
||||||
|
A = turing->R[OFF(z+1,16)]; \
|
||||||
|
B = turing->R[OFF(z+1,13)]; \
|
||||||
|
C = turing->R[OFF(z+1,6)]; \
|
||||||
|
D = turing->R[OFF(z+1,1)]; \
|
||||||
|
E = turing->R[OFF(z+1,0)]; \
|
||||||
|
PHT(A, B, C, D, E); \
|
||||||
|
A = S(A,0); B = S(B,1); C = S(C,2); D = S(D,3); E = S(E,0); \
|
||||||
|
PHT(A, B, C, D, E); \
|
||||||
|
STEP(z+1); \
|
||||||
|
STEP(z+2); \
|
||||||
|
STEP(z+3); \
|
||||||
|
A += turing->R[OFF(z+4,14)]; \
|
||||||
|
B += turing->R[OFF(z+4,12)]; \
|
||||||
|
C += turing->R[OFF(z+4,8)]; \
|
||||||
|
D += turing->R[OFF(z+4,1)]; \
|
||||||
|
E += turing->R[OFF(z+4,0)]; \
|
||||||
|
WORD2BYTE(A, b); \
|
||||||
|
WORD2BYTE(B, b+4); \
|
||||||
|
WORD2BYTE(C, b+8); \
|
||||||
|
WORD2BYTE(D, b+12); \
|
||||||
|
WORD2BYTE(E, b+16); \
|
||||||
|
STEP(z+4); \
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Generate 17 5-word blocks of output.
|
||||||
|
* This ensures that the register is resynchronised and avoids state.
|
||||||
|
* Buffering issues are outside the scope of this implementation.
|
||||||
|
* Returns the number of bytes of stream generated.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
TuringGen(void * internal, BYTE *buf)
|
||||||
|
{
|
||||||
|
struct turing_internal * turing = internal;
|
||||||
|
WORD A, B, C, D, E;
|
||||||
|
|
||||||
|
ROUND(0,buf);
|
||||||
|
ROUND(5,buf+20);
|
||||||
|
ROUND(10,buf+40);
|
||||||
|
ROUND(15,buf+60);
|
||||||
|
ROUND(3,buf+80);
|
||||||
|
ROUND(8,buf+100);
|
||||||
|
ROUND(13,buf+120);
|
||||||
|
ROUND(1,buf+140);
|
||||||
|
ROUND(6,buf+160);
|
||||||
|
ROUND(11,buf+180);
|
||||||
|
ROUND(16,buf+200);
|
||||||
|
ROUND(4,buf+220);
|
||||||
|
ROUND(9,buf+240);
|
||||||
|
ROUND(14,buf+260);
|
||||||
|
ROUND(2,buf+280);
|
||||||
|
ROUND(7,buf+300);
|
||||||
|
ROUND(12,buf+320);
|
||||||
|
return 17*20;
|
||||||
|
}
|
||||||
|
|
||||||
|
void * TuringAlloc()
|
||||||
|
{
|
||||||
|
return calloc(1, sizeof(struct turing_internal));
|
||||||
|
}
|
||||||
|
|
||||||
|
void TuringFree(void * internal)
|
||||||
|
{
|
||||||
|
free(internal);
|
||||||
|
}
|
68
src/tivomirror/tivodecode/TuringMultab.h
Normal file
68
src/tivomirror/tivodecode/TuringMultab.h
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
/* @(#)TuringMultab.h 1.3 (QUALCOMM) 02/09/03 */
|
||||||
|
/* Multiplication table for Turing using 0xD02B4367 */
|
||||||
|
unsigned long Multab[256] = {
|
||||||
|
0x00000000, 0xD02B4367, 0xED5686CE, 0x3D7DC5A9,
|
||||||
|
0x97AC41D1, 0x478702B6, 0x7AFAC71F, 0xAAD18478,
|
||||||
|
0x631582EF, 0xB33EC188, 0x8E430421, 0x5E684746,
|
||||||
|
0xF4B9C33E, 0x24928059, 0x19EF45F0, 0xC9C40697,
|
||||||
|
0xC62A4993, 0x16010AF4, 0x2B7CCF5D, 0xFB578C3A,
|
||||||
|
0x51860842, 0x81AD4B25, 0xBCD08E8C, 0x6CFBCDEB,
|
||||||
|
0xA53FCB7C, 0x7514881B, 0x48694DB2, 0x98420ED5,
|
||||||
|
0x32938AAD, 0xE2B8C9CA, 0xDFC50C63, 0x0FEE4F04,
|
||||||
|
0xC154926B, 0x117FD10C, 0x2C0214A5, 0xFC2957C2,
|
||||||
|
0x56F8D3BA, 0x86D390DD, 0xBBAE5574, 0x6B851613,
|
||||||
|
0xA2411084, 0x726A53E3, 0x4F17964A, 0x9F3CD52D,
|
||||||
|
0x35ED5155, 0xE5C61232, 0xD8BBD79B, 0x089094FC,
|
||||||
|
0x077EDBF8, 0xD755989F, 0xEA285D36, 0x3A031E51,
|
||||||
|
0x90D29A29, 0x40F9D94E, 0x7D841CE7, 0xADAF5F80,
|
||||||
|
0x646B5917, 0xB4401A70, 0x893DDFD9, 0x59169CBE,
|
||||||
|
0xF3C718C6, 0x23EC5BA1, 0x1E919E08, 0xCEBADD6F,
|
||||||
|
0xCFA869D6, 0x1F832AB1, 0x22FEEF18, 0xF2D5AC7F,
|
||||||
|
0x58042807, 0x882F6B60, 0xB552AEC9, 0x6579EDAE,
|
||||||
|
0xACBDEB39, 0x7C96A85E, 0x41EB6DF7, 0x91C02E90,
|
||||||
|
0x3B11AAE8, 0xEB3AE98F, 0xD6472C26, 0x066C6F41,
|
||||||
|
0x09822045, 0xD9A96322, 0xE4D4A68B, 0x34FFE5EC,
|
||||||
|
0x9E2E6194, 0x4E0522F3, 0x7378E75A, 0xA353A43D,
|
||||||
|
0x6A97A2AA, 0xBABCE1CD, 0x87C12464, 0x57EA6703,
|
||||||
|
0xFD3BE37B, 0x2D10A01C, 0x106D65B5, 0xC04626D2,
|
||||||
|
0x0EFCFBBD, 0xDED7B8DA, 0xE3AA7D73, 0x33813E14,
|
||||||
|
0x9950BA6C, 0x497BF90B, 0x74063CA2, 0xA42D7FC5,
|
||||||
|
0x6DE97952, 0xBDC23A35, 0x80BFFF9C, 0x5094BCFB,
|
||||||
|
0xFA453883, 0x2A6E7BE4, 0x1713BE4D, 0xC738FD2A,
|
||||||
|
0xC8D6B22E, 0x18FDF149, 0x258034E0, 0xF5AB7787,
|
||||||
|
0x5F7AF3FF, 0x8F51B098, 0xB22C7531, 0x62073656,
|
||||||
|
0xABC330C1, 0x7BE873A6, 0x4695B60F, 0x96BEF568,
|
||||||
|
0x3C6F7110, 0xEC443277, 0xD139F7DE, 0x0112B4B9,
|
||||||
|
0xD31DD2E1, 0x03369186, 0x3E4B542F, 0xEE601748,
|
||||||
|
0x44B19330, 0x949AD057, 0xA9E715FE, 0x79CC5699,
|
||||||
|
0xB008500E, 0x60231369, 0x5D5ED6C0, 0x8D7595A7,
|
||||||
|
0x27A411DF, 0xF78F52B8, 0xCAF29711, 0x1AD9D476,
|
||||||
|
0x15379B72, 0xC51CD815, 0xF8611DBC, 0x284A5EDB,
|
||||||
|
0x829BDAA3, 0x52B099C4, 0x6FCD5C6D, 0xBFE61F0A,
|
||||||
|
0x7622199D, 0xA6095AFA, 0x9B749F53, 0x4B5FDC34,
|
||||||
|
0xE18E584C, 0x31A51B2B, 0x0CD8DE82, 0xDCF39DE5,
|
||||||
|
0x1249408A, 0xC26203ED, 0xFF1FC644, 0x2F348523,
|
||||||
|
0x85E5015B, 0x55CE423C, 0x68B38795, 0xB898C4F2,
|
||||||
|
0x715CC265, 0xA1778102, 0x9C0A44AB, 0x4C2107CC,
|
||||||
|
0xE6F083B4, 0x36DBC0D3, 0x0BA6057A, 0xDB8D461D,
|
||||||
|
0xD4630919, 0x04484A7E, 0x39358FD7, 0xE91ECCB0,
|
||||||
|
0x43CF48C8, 0x93E40BAF, 0xAE99CE06, 0x7EB28D61,
|
||||||
|
0xB7768BF6, 0x675DC891, 0x5A200D38, 0x8A0B4E5F,
|
||||||
|
0x20DACA27, 0xF0F18940, 0xCD8C4CE9, 0x1DA70F8E,
|
||||||
|
0x1CB5BB37, 0xCC9EF850, 0xF1E33DF9, 0x21C87E9E,
|
||||||
|
0x8B19FAE6, 0x5B32B981, 0x664F7C28, 0xB6643F4F,
|
||||||
|
0x7FA039D8, 0xAF8B7ABF, 0x92F6BF16, 0x42DDFC71,
|
||||||
|
0xE80C7809, 0x38273B6E, 0x055AFEC7, 0xD571BDA0,
|
||||||
|
0xDA9FF2A4, 0x0AB4B1C3, 0x37C9746A, 0xE7E2370D,
|
||||||
|
0x4D33B375, 0x9D18F012, 0xA06535BB, 0x704E76DC,
|
||||||
|
0xB98A704B, 0x69A1332C, 0x54DCF685, 0x84F7B5E2,
|
||||||
|
0x2E26319A, 0xFE0D72FD, 0xC370B754, 0x135BF433,
|
||||||
|
0xDDE1295C, 0x0DCA6A3B, 0x30B7AF92, 0xE09CECF5,
|
||||||
|
0x4A4D688D, 0x9A662BEA, 0xA71BEE43, 0x7730AD24,
|
||||||
|
0xBEF4ABB3, 0x6EDFE8D4, 0x53A22D7D, 0x83896E1A,
|
||||||
|
0x2958EA62, 0xF973A905, 0xC40E6CAC, 0x14252FCB,
|
||||||
|
0x1BCB60CF, 0xCBE023A8, 0xF69DE601, 0x26B6A566,
|
||||||
|
0x8C67211E, 0x5C4C6279, 0x6131A7D0, 0xB11AE4B7,
|
||||||
|
0x78DEE220, 0xA8F5A147, 0x958864EE, 0x45A32789,
|
||||||
|
0xEF72A3F1, 0x3F59E096, 0x0224253F, 0xD20F6658,
|
||||||
|
};
|
48
src/tivomirror/tivodecode/TuringSbox.h
Normal file
48
src/tivomirror/tivodecode/TuringSbox.h
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
/* @(#)TuringSbox.h 1.2 (QUALCOMM) 02/08/23 */
|
||||||
|
/*
|
||||||
|
* Basic Sbox for Turing.
|
||||||
|
*
|
||||||
|
* This was generated by keying RC4 with the 11-character string
|
||||||
|
* "Alan Turing", and then ignoring 256 generated bytes.
|
||||||
|
* Then the current permutation was tested for nonlinearity, another byte
|
||||||
|
* generated, etc., until a total
|
||||||
|
* of 10000 bytes had been generated. The best observed min nonlinearity was
|
||||||
|
* 104, which first occurred after 736 bytes had been generated. The
|
||||||
|
* corresponding state table is used in Turing. By happy coincidence it
|
||||||
|
* also has no fixed points (ie. Sbox[x] != x for all x).
|
||||||
|
*/
|
||||||
|
|
||||||
|
unsigned char Sbox[256] = {
|
||||||
|
0x61, 0x51, 0xeb, 0x19, 0xb9, 0x5d, 0x60, 0x38,
|
||||||
|
0x7c, 0xb2, 0x06, 0x12, 0xc4, 0x5b, 0x16, 0x3b,
|
||||||
|
0x2b, 0x18, 0x83, 0xb0, 0x7f, 0x75, 0xfa, 0xa0,
|
||||||
|
0xe9, 0xdd, 0x6d, 0x7a, 0x6b, 0x68, 0x2d, 0x49,
|
||||||
|
0xb5, 0x1c, 0x90, 0xf7, 0xed, 0x9f, 0xe8, 0xce,
|
||||||
|
0xae, 0x77, 0xc2, 0x13, 0xfd, 0xcd, 0x3e, 0xcf,
|
||||||
|
0x37, 0x6a, 0xd4, 0xdb, 0x8e, 0x65, 0x1f, 0x1a,
|
||||||
|
0x87, 0xcb, 0x40, 0x15, 0x88, 0x0d, 0x35, 0xb3,
|
||||||
|
0x11, 0x0f, 0xd0, 0x30, 0x48, 0xf9, 0xa8, 0xac,
|
||||||
|
0x85, 0x27, 0x0e, 0x8a, 0xe0, 0x50, 0x64, 0xa7,
|
||||||
|
0xcc, 0xe4, 0xf1, 0x98, 0xff, 0xa1, 0x04, 0xda,
|
||||||
|
0xd5, 0xbc, 0x1b, 0xbb, 0xd1, 0xfe, 0x31, 0xca,
|
||||||
|
0xba, 0xd9, 0x2e, 0xf3, 0x1d, 0x47, 0x4a, 0x3d,
|
||||||
|
0x71, 0x4c, 0xab, 0x7d, 0x8d, 0xc7, 0x59, 0xb8,
|
||||||
|
0xc1, 0x96, 0x1e, 0xfc, 0x44, 0xc8, 0x7b, 0xdc,
|
||||||
|
0x5c, 0x78, 0x2a, 0x9d, 0xa5, 0xf0, 0x73, 0x22,
|
||||||
|
0x89, 0x05, 0xf4, 0x07, 0x21, 0x52, 0xa6, 0x28,
|
||||||
|
0x9a, 0x92, 0x69, 0x8f, 0xc5, 0xc3, 0xf5, 0xe1,
|
||||||
|
0xde, 0xec, 0x09, 0xf2, 0xd3, 0xaf, 0x34, 0x23,
|
||||||
|
0xaa, 0xdf, 0x7e, 0x82, 0x29, 0xc0, 0x24, 0x14,
|
||||||
|
0x03, 0x32, 0x4e, 0x39, 0x6f, 0xc6, 0xb1, 0x9b,
|
||||||
|
0xea, 0x72, 0x79, 0x41, 0xd8, 0x26, 0x6c, 0x5e,
|
||||||
|
0x2c, 0xb4, 0xa2, 0x53, 0x57, 0xe2, 0x9c, 0x86,
|
||||||
|
0x54, 0x95, 0xb6, 0x80, 0x8c, 0x36, 0x67, 0xbd,
|
||||||
|
0x08, 0x93, 0x2f, 0x99, 0x5a, 0xf8, 0x3a, 0xd7,
|
||||||
|
0x56, 0x84, 0xd2, 0x01, 0xf6, 0x66, 0x4d, 0x55,
|
||||||
|
0x8b, 0x0c, 0x0b, 0x46, 0xb7, 0x3c, 0x45, 0x91,
|
||||||
|
0xa4, 0xe3, 0x70, 0xd6, 0xfb, 0xe6, 0x10, 0xa9,
|
||||||
|
0xc9, 0x00, 0x9e, 0xe7, 0x4f, 0x76, 0x25, 0x3f,
|
||||||
|
0x5f, 0xa3, 0x33, 0x20, 0x02, 0xef, 0x62, 0x74,
|
||||||
|
0xee, 0x17, 0x81, 0x42, 0x58, 0x0a, 0x4b, 0x63,
|
||||||
|
0xe5, 0xbe, 0x6e, 0xad, 0xbf, 0x43, 0x94, 0x97,
|
||||||
|
};
|
22
src/tivomirror/tivodecode/UpgradeLog.XML
Normal file
22
src/tivomirror/tivodecode/UpgradeLog.XML
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type='text/xsl' href='_UpgradeReport_Files/UpgradeReport.xslt'?><UpgradeLog>
|
||||||
|
<Properties><Property Name="Solution" Value="tivodecode">
|
||||||
|
</Property><Property Name="Solution File" Value="S:\psimoneau\test\tivo\tivodecode-0.3\tivodecode.sln">
|
||||||
|
</Property><Property Name="Date" Value="Monday, December 21, 2009">
|
||||||
|
</Property><Property Name="Time" Value="16:03 PM">
|
||||||
|
</Property></Properties><Event ErrorLevel="0" Project="tivodecode" Source="tivodecode.vcproj" Description="Web deployment to the local IIS server is no longer supported. The Web Deployment build tool has been removed from your project settings.">
|
||||||
|
</Event><Event ErrorLevel="1" Project="tivodecode" Source="tivodecode.vcproj" Description="This application has been updated to include settings related to the User Account Control (UAC) feature of Windows Vista. By default, when run on Windows Vista with UAC enabled, this application is marked to run with the same privileges as the process that launched it. This marking also disables the application from running with virtualization. You can change UAC related settings from the Property Pages of the project.">
|
||||||
|
</Event><Event ErrorLevel="0" Project="tivodecode" Source="tivodecode.vcproj" Description="Project upgraded successfully.">
|
||||||
|
</Event><Event ErrorLevel="3" Project="tivodecode" Source="tivodecode.vcproj" Description="Converted">
|
||||||
|
</Event><Event ErrorLevel="1" Project="libtivodecode" Source="libtivodecode.vcproj" Description="This application has been updated to include settings related to the User Account Control (UAC) feature of Windows Vista. By default, when run on Windows Vista with UAC enabled, this application is marked to run with the same privileges as the process that launched it. This marking also disables the application from running with virtualization. You can change UAC related settings from the Property Pages of the project.">
|
||||||
|
</Event><Event ErrorLevel="0" Project="libtivodecode" Source="libtivodecode.vcproj" Description="Project upgraded successfully.">
|
||||||
|
</Event><Event ErrorLevel="3" Project="libtivodecode" Source="libtivodecode.vcproj" Description="Converted">
|
||||||
|
</Event><Event ErrorLevel="0" Project="tdcat" Source="tdcat.vcproj" Description="Web deployment to the local IIS server is no longer supported. The Web Deployment build tool has been removed from your project settings.">
|
||||||
|
</Event><Event ErrorLevel="1" Project="tdcat" Source="tdcat.vcproj" Description="This application has been updated to include settings related to the User Account Control (UAC) feature of Windows Vista. By default, when run on Windows Vista with UAC enabled, this application is marked to run with the same privileges as the process that launched it. This marking also disables the application from running with virtualization. You can change UAC related settings from the Property Pages of the project.">
|
||||||
|
</Event><Event ErrorLevel="0" Project="tdcat" Source="tdcat.vcproj" Description="Project upgraded successfully.">
|
||||||
|
</Event><Event ErrorLevel="3" Project="tdcat" Source="tdcat.vcproj" Description="Converted">
|
||||||
|
</Event><Event ErrorLevel="1" Project="libtdcommon" Source="libtdcommon.vcproj" Description="This application has been updated to include settings related to the User Account Control (UAC) feature of Windows Vista. By default, when run on Windows Vista with UAC enabled, this application is marked to run with the same privileges as the process that launched it. This marking also disables the application from running with virtualization. You can change UAC related settings from the Property Pages of the project.">
|
||||||
|
</Event><Event ErrorLevel="0" Project="libtdcommon" Source="libtdcommon.vcproj" Description="Project upgraded successfully.">
|
||||||
|
</Event><Event ErrorLevel="3" Project="libtdcommon" Source="libtdcommon.vcproj" Description="Converted">
|
||||||
|
</Event><Event ErrorLevel="0" Project="" Source="tivodecode.sln" Description="Solution converted successfully">
|
||||||
|
</Event><Event ErrorLevel="3" Project="" Source="tivodecode.sln" Description="Converted">
|
||||||
|
</Event></UpgradeLog>
|
892
src/tivomirror/tivodecode/aclocal.m4
vendored
Normal file
892
src/tivomirror/tivodecode/aclocal.m4
vendored
Normal file
|
@ -0,0 +1,892 @@
|
||||||
|
# generated automatically by aclocal 1.10 -*- Autoconf -*-
|
||||||
|
|
||||||
|
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
||||||
|
# 2005, 2006 Free Software Foundation, Inc.
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||||
|
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||||
|
# PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
m4_if(m4_PACKAGE_VERSION, [2.61],,
|
||||||
|
[m4_fatal([this file was generated for autoconf 2.61.
|
||||||
|
You have another version of autoconf. If you want to use that,
|
||||||
|
you should regenerate the build system entirely.], [63])])
|
||||||
|
|
||||||
|
# Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# AM_AUTOMAKE_VERSION(VERSION)
|
||||||
|
# ----------------------------
|
||||||
|
# Automake X.Y traces this macro to ensure aclocal.m4 has been
|
||||||
|
# generated from the m4 files accompanying Automake X.Y.
|
||||||
|
# (This private macro should not be called outside this file.)
|
||||||
|
AC_DEFUN([AM_AUTOMAKE_VERSION],
|
||||||
|
[am__api_version='1.10'
|
||||||
|
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
|
||||||
|
dnl require some minimum version. Point them to the right macro.
|
||||||
|
m4_if([$1], [1.10], [],
|
||||||
|
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
# _AM_AUTOCONF_VERSION(VERSION)
|
||||||
|
# -----------------------------
|
||||||
|
# aclocal traces this macro to find the Autoconf version.
|
||||||
|
# This is a private macro too. Using m4_define simplifies
|
||||||
|
# the logic in aclocal, which can simply ignore this definition.
|
||||||
|
m4_define([_AM_AUTOCONF_VERSION], [])
|
||||||
|
|
||||||
|
# AM_SET_CURRENT_AUTOMAKE_VERSION
|
||||||
|
# -------------------------------
|
||||||
|
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
|
||||||
|
# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
|
||||||
|
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
|
||||||
|
[AM_AUTOMAKE_VERSION([1.10])dnl
|
||||||
|
_AM_AUTOCONF_VERSION(m4_PACKAGE_VERSION)])
|
||||||
|
|
||||||
|
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
|
||||||
|
|
||||||
|
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
|
||||||
|
# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to
|
||||||
|
# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
|
||||||
|
#
|
||||||
|
# Of course, Automake must honor this variable whenever it calls a
|
||||||
|
# tool from the auxiliary directory. The problem is that $srcdir (and
|
||||||
|
# therefore $ac_aux_dir as well) can be either absolute or relative,
|
||||||
|
# depending on how configure is run. This is pretty annoying, since
|
||||||
|
# it makes $ac_aux_dir quite unusable in subdirectories: in the top
|
||||||
|
# source directory, any form will work fine, but in subdirectories a
|
||||||
|
# relative path needs to be adjusted first.
|
||||||
|
#
|
||||||
|
# $ac_aux_dir/missing
|
||||||
|
# fails when called from a subdirectory if $ac_aux_dir is relative
|
||||||
|
# $top_srcdir/$ac_aux_dir/missing
|
||||||
|
# fails if $ac_aux_dir is absolute,
|
||||||
|
# fails when called from a subdirectory in a VPATH build with
|
||||||
|
# a relative $ac_aux_dir
|
||||||
|
#
|
||||||
|
# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
|
||||||
|
# are both prefixed by $srcdir. In an in-source build this is usually
|
||||||
|
# harmless because $srcdir is `.', but things will broke when you
|
||||||
|
# start a VPATH build or use an absolute $srcdir.
|
||||||
|
#
|
||||||
|
# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
|
||||||
|
# iff we strip the leading $srcdir from $ac_aux_dir. That would be:
|
||||||
|
# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
|
||||||
|
# and then we would define $MISSING as
|
||||||
|
# MISSING="\${SHELL} $am_aux_dir/missing"
|
||||||
|
# This will work as long as MISSING is not called from configure, because
|
||||||
|
# unfortunately $(top_srcdir) has no meaning in configure.
|
||||||
|
# However there are other variables, like CC, which are often used in
|
||||||
|
# configure, and could therefore not use this "fixed" $ac_aux_dir.
|
||||||
|
#
|
||||||
|
# Another solution, used here, is to always expand $ac_aux_dir to an
|
||||||
|
# absolute PATH. The drawback is that using absolute paths prevent a
|
||||||
|
# configured tree to be moved without reconfiguration.
|
||||||
|
|
||||||
|
AC_DEFUN([AM_AUX_DIR_EXPAND],
|
||||||
|
[dnl Rely on autoconf to set up CDPATH properly.
|
||||||
|
AC_PREREQ([2.50])dnl
|
||||||
|
# expand $ac_aux_dir to an absolute path
|
||||||
|
am_aux_dir=`cd $ac_aux_dir && pwd`
|
||||||
|
])
|
||||||
|
|
||||||
|
# AM_CONDITIONAL -*- Autoconf -*-
|
||||||
|
|
||||||
|
# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006
|
||||||
|
# Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# serial 8
|
||||||
|
|
||||||
|
# AM_CONDITIONAL(NAME, SHELL-CONDITION)
|
||||||
|
# -------------------------------------
|
||||||
|
# Define a conditional.
|
||||||
|
AC_DEFUN([AM_CONDITIONAL],
|
||||||
|
[AC_PREREQ(2.52)dnl
|
||||||
|
ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
|
||||||
|
[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
|
||||||
|
AC_SUBST([$1_TRUE])dnl
|
||||||
|
AC_SUBST([$1_FALSE])dnl
|
||||||
|
_AM_SUBST_NOTMAKE([$1_TRUE])dnl
|
||||||
|
_AM_SUBST_NOTMAKE([$1_FALSE])dnl
|
||||||
|
if $2; then
|
||||||
|
$1_TRUE=
|
||||||
|
$1_FALSE='#'
|
||||||
|
else
|
||||||
|
$1_TRUE='#'
|
||||||
|
$1_FALSE=
|
||||||
|
fi
|
||||||
|
AC_CONFIG_COMMANDS_PRE(
|
||||||
|
[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
|
||||||
|
AC_MSG_ERROR([[conditional "$1" was never defined.
|
||||||
|
Usually this means the macro was only invoked conditionally.]])
|
||||||
|
fi])])
|
||||||
|
|
||||||
|
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||||
|
# Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# serial 9
|
||||||
|
|
||||||
|
# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
|
||||||
|
# written in clear, in which case automake, when reading aclocal.m4,
|
||||||
|
# will think it sees a *use*, and therefore will trigger all it's
|
||||||
|
# C support machinery. Also note that it means that autoscan, seeing
|
||||||
|
# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
|
||||||
|
|
||||||
|
|
||||||
|
# _AM_DEPENDENCIES(NAME)
|
||||||
|
# ----------------------
|
||||||
|
# See how the compiler implements dependency checking.
|
||||||
|
# NAME is "CC", "CXX", "GCJ", or "OBJC".
|
||||||
|
# We try a few techniques and use that to set a single cache variable.
|
||||||
|
#
|
||||||
|
# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
|
||||||
|
# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
|
||||||
|
# dependency, and given that the user is not expected to run this macro,
|
||||||
|
# just rely on AC_PROG_CC.
|
||||||
|
AC_DEFUN([_AM_DEPENDENCIES],
|
||||||
|
[AC_REQUIRE([AM_SET_DEPDIR])dnl
|
||||||
|
AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
|
||||||
|
AC_REQUIRE([AM_MAKE_INCLUDE])dnl
|
||||||
|
AC_REQUIRE([AM_DEP_TRACK])dnl
|
||||||
|
|
||||||
|
ifelse([$1], CC, [depcc="$CC" am_compiler_list=],
|
||||||
|
[$1], CXX, [depcc="$CXX" am_compiler_list=],
|
||||||
|
[$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
|
||||||
|
[$1], UPC, [depcc="$UPC" am_compiler_list=],
|
||||||
|
[$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
|
||||||
|
[depcc="$$1" am_compiler_list=])
|
||||||
|
|
||||||
|
AC_CACHE_CHECK([dependency style of $depcc],
|
||||||
|
[am_cv_$1_dependencies_compiler_type],
|
||||||
|
[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
|
||||||
|
# We make a subdir and do the tests there. Otherwise we can end up
|
||||||
|
# making bogus files that we don't know about and never remove. For
|
||||||
|
# instance it was reported that on HP-UX the gcc test will end up
|
||||||
|
# making a dummy file named `D' -- because `-MD' means `put the output
|
||||||
|
# in D'.
|
||||||
|
mkdir conftest.dir
|
||||||
|
# Copy depcomp to subdir because otherwise we won't find it if we're
|
||||||
|
# using a relative directory.
|
||||||
|
cp "$am_depcomp" conftest.dir
|
||||||
|
cd conftest.dir
|
||||||
|
# We will build objects and dependencies in a subdirectory because
|
||||||
|
# it helps to detect inapplicable dependency modes. For instance
|
||||||
|
# both Tru64's cc and ICC support -MD to output dependencies as a
|
||||||
|
# side effect of compilation, but ICC will put the dependencies in
|
||||||
|
# the current directory while Tru64 will put them in the object
|
||||||
|
# directory.
|
||||||
|
mkdir sub
|
||||||
|
|
||||||
|
am_cv_$1_dependencies_compiler_type=none
|
||||||
|
if test "$am_compiler_list" = ""; then
|
||||||
|
am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
|
||||||
|
fi
|
||||||
|
for depmode in $am_compiler_list; do
|
||||||
|
# Setup a source with many dependencies, because some compilers
|
||||||
|
# like to wrap large dependency lists on column 80 (with \), and
|
||||||
|
# we should not choose a depcomp mode which is confused by this.
|
||||||
|
#
|
||||||
|
# We need to recreate these files for each test, as the compiler may
|
||||||
|
# overwrite some of them when testing with obscure command lines.
|
||||||
|
# This happens at least with the AIX C compiler.
|
||||||
|
: > sub/conftest.c
|
||||||
|
for i in 1 2 3 4 5 6; do
|
||||||
|
echo '#include "conftst'$i'.h"' >> sub/conftest.c
|
||||||
|
# Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
|
||||||
|
# Solaris 8's {/usr,}/bin/sh.
|
||||||
|
touch sub/conftst$i.h
|
||||||
|
done
|
||||||
|
echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
|
||||||
|
|
||||||
|
case $depmode in
|
||||||
|
nosideeffect)
|
||||||
|
# after this tag, mechanisms are not by side-effect, so they'll
|
||||||
|
# only be used when explicitly requested
|
||||||
|
if test "x$enable_dependency_tracking" = xyes; then
|
||||||
|
continue
|
||||||
|
else
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
none) break ;;
|
||||||
|
esac
|
||||||
|
# We check with `-c' and `-o' for the sake of the "dashmstdout"
|
||||||
|
# mode. It turns out that the SunPro C++ compiler does not properly
|
||||||
|
# handle `-M -o', and we need to detect this.
|
||||||
|
if depmode=$depmode \
|
||||||
|
source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
|
||||||
|
depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
|
||||||
|
$SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
|
||||||
|
>/dev/null 2>conftest.err &&
|
||||||
|
grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
|
||||||
|
grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
|
||||||
|
grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
|
||||||
|
${MAKE-make} -s -f confmf > /dev/null 2>&1; then
|
||||||
|
# icc doesn't choke on unknown options, it will just issue warnings
|
||||||
|
# or remarks (even with -Werror). So we grep stderr for any message
|
||||||
|
# that says an option was ignored or not supported.
|
||||||
|
# When given -MP, icc 7.0 and 7.1 complain thusly:
|
||||||
|
# icc: Command line warning: ignoring option '-M'; no argument required
|
||||||
|
# The diagnosis changed in icc 8.0:
|
||||||
|
# icc: Command line remark: option '-MP' not supported
|
||||||
|
if (grep 'ignoring option' conftest.err ||
|
||||||
|
grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
|
||||||
|
am_cv_$1_dependencies_compiler_type=$depmode
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
rm -rf conftest.dir
|
||||||
|
else
|
||||||
|
am_cv_$1_dependencies_compiler_type=none
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
|
||||||
|
AM_CONDITIONAL([am__fastdep$1], [
|
||||||
|
test "x$enable_dependency_tracking" != xno \
|
||||||
|
&& test "$am_cv_$1_dependencies_compiler_type" = gcc3])
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
# AM_SET_DEPDIR
|
||||||
|
# -------------
|
||||||
|
# Choose a directory name for dependency files.
|
||||||
|
# This macro is AC_REQUIREd in _AM_DEPENDENCIES
|
||||||
|
AC_DEFUN([AM_SET_DEPDIR],
|
||||||
|
[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
|
||||||
|
AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
# AM_DEP_TRACK
|
||||||
|
# ------------
|
||||||
|
AC_DEFUN([AM_DEP_TRACK],
|
||||||
|
[AC_ARG_ENABLE(dependency-tracking,
|
||||||
|
[ --disable-dependency-tracking speeds up one-time build
|
||||||
|
--enable-dependency-tracking do not reject slow dependency extractors])
|
||||||
|
if test "x$enable_dependency_tracking" != xno; then
|
||||||
|
am_depcomp="$ac_aux_dir/depcomp"
|
||||||
|
AMDEPBACKSLASH='\'
|
||||||
|
fi
|
||||||
|
AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
|
||||||
|
AC_SUBST([AMDEPBACKSLASH])dnl
|
||||||
|
_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
# Generate code to set up dependency tracking. -*- Autoconf -*-
|
||||||
|
|
||||||
|
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
|
||||||
|
# Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
#serial 3
|
||||||
|
|
||||||
|
# _AM_OUTPUT_DEPENDENCY_COMMANDS
|
||||||
|
# ------------------------------
|
||||||
|
AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
|
||||||
|
[for mf in $CONFIG_FILES; do
|
||||||
|
# Strip MF so we end up with the name of the file.
|
||||||
|
mf=`echo "$mf" | sed -e 's/:.*$//'`
|
||||||
|
# Check whether this is an Automake generated Makefile or not.
|
||||||
|
# We used to match only the files named `Makefile.in', but
|
||||||
|
# some people rename them; so instead we look at the file content.
|
||||||
|
# Grep'ing the first line is not enough: some people post-process
|
||||||
|
# each Makefile.in and add a new line on top of each file to say so.
|
||||||
|
# Grep'ing the whole file is not good either: AIX grep has a line
|
||||||
|
# limit of 2048, but all sed's we know have understand at least 4000.
|
||||||
|
if sed 10q "$mf" | grep '^#.*generated by automake' > /dev/null 2>&1; then
|
||||||
|
dirpart=`AS_DIRNAME("$mf")`
|
||||||
|
else
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
# Extract the definition of DEPDIR, am__include, and am__quote
|
||||||
|
# from the Makefile without running `make'.
|
||||||
|
DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
|
||||||
|
test -z "$DEPDIR" && continue
|
||||||
|
am__include=`sed -n 's/^am__include = //p' < "$mf"`
|
||||||
|
test -z "am__include" && continue
|
||||||
|
am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
|
||||||
|
# When using ansi2knr, U may be empty or an underscore; expand it
|
||||||
|
U=`sed -n 's/^U = //p' < "$mf"`
|
||||||
|
# Find all dependency output files, they are included files with
|
||||||
|
# $(DEPDIR) in their names. We invoke sed twice because it is the
|
||||||
|
# simplest approach to changing $(DEPDIR) to its actual value in the
|
||||||
|
# expansion.
|
||||||
|
for file in `sed -n "
|
||||||
|
s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
|
||||||
|
sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
|
||||||
|
# Make sure the directory exists.
|
||||||
|
test -f "$dirpart/$file" && continue
|
||||||
|
fdir=`AS_DIRNAME(["$file"])`
|
||||||
|
AS_MKDIR_P([$dirpart/$fdir])
|
||||||
|
# echo "creating $dirpart/$file"
|
||||||
|
echo '# dummy' > "$dirpart/$file"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
])# _AM_OUTPUT_DEPENDENCY_COMMANDS
|
||||||
|
|
||||||
|
|
||||||
|
# AM_OUTPUT_DEPENDENCY_COMMANDS
|
||||||
|
# -----------------------------
|
||||||
|
# This macro should only be invoked once -- use via AC_REQUIRE.
|
||||||
|
#
|
||||||
|
# This code is only required when automatic dependency tracking
|
||||||
|
# is enabled. FIXME. This creates each `.P' file that we will
|
||||||
|
# need in order to bootstrap the dependency handling code.
|
||||||
|
AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
|
||||||
|
[AC_CONFIG_COMMANDS([depfiles],
|
||||||
|
[test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
|
||||||
|
[AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
|
||||||
|
])
|
||||||
|
|
||||||
|
# Do all the work for Automake. -*- Autoconf -*-
|
||||||
|
|
||||||
|
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
||||||
|
# 2005, 2006 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# serial 12
|
||||||
|
|
||||||
|
# This macro actually does too much. Some checks are only needed if
|
||||||
|
# your package does certain things. But this isn't really a big deal.
|
||||||
|
|
||||||
|
# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
|
||||||
|
# AM_INIT_AUTOMAKE([OPTIONS])
|
||||||
|
# -----------------------------------------------
|
||||||
|
# The call with PACKAGE and VERSION arguments is the old style
|
||||||
|
# call (pre autoconf-2.50), which is being phased out. PACKAGE
|
||||||
|
# and VERSION should now be passed to AC_INIT and removed from
|
||||||
|
# the call to AM_INIT_AUTOMAKE.
|
||||||
|
# We support both call styles for the transition. After
|
||||||
|
# the next Automake release, Autoconf can make the AC_INIT
|
||||||
|
# arguments mandatory, and then we can depend on a new Autoconf
|
||||||
|
# release and drop the old call support.
|
||||||
|
AC_DEFUN([AM_INIT_AUTOMAKE],
|
||||||
|
[AC_PREREQ([2.60])dnl
|
||||||
|
dnl Autoconf wants to disallow AM_ names. We explicitly allow
|
||||||
|
dnl the ones we care about.
|
||||||
|
m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
|
||||||
|
AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
|
||||||
|
AC_REQUIRE([AC_PROG_INSTALL])dnl
|
||||||
|
if test "`cd $srcdir && pwd`" != "`pwd`"; then
|
||||||
|
# Use -I$(srcdir) only when $(srcdir) != ., so that make's output
|
||||||
|
# is not polluted with repeated "-I."
|
||||||
|
AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
|
||||||
|
# test to see if srcdir already configured
|
||||||
|
if test -f $srcdir/config.status; then
|
||||||
|
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# test whether we have cygpath
|
||||||
|
if test -z "$CYGPATH_W"; then
|
||||||
|
if (cygpath --version) >/dev/null 2>/dev/null; then
|
||||||
|
CYGPATH_W='cygpath -w'
|
||||||
|
else
|
||||||
|
CYGPATH_W=echo
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
AC_SUBST([CYGPATH_W])
|
||||||
|
|
||||||
|
# Define the identity of the package.
|
||||||
|
dnl Distinguish between old-style and new-style calls.
|
||||||
|
m4_ifval([$2],
|
||||||
|
[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
|
||||||
|
AC_SUBST([PACKAGE], [$1])dnl
|
||||||
|
AC_SUBST([VERSION], [$2])],
|
||||||
|
[_AM_SET_OPTIONS([$1])dnl
|
||||||
|
dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
|
||||||
|
m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,,
|
||||||
|
[m4_fatal([AC_INIT should be called with package and version arguments])])dnl
|
||||||
|
AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
|
||||||
|
AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
|
||||||
|
|
||||||
|
_AM_IF_OPTION([no-define],,
|
||||||
|
[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
|
||||||
|
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
|
||||||
|
|
||||||
|
# Some tools Automake needs.
|
||||||
|
AC_REQUIRE([AM_SANITY_CHECK])dnl
|
||||||
|
AC_REQUIRE([AC_ARG_PROGRAM])dnl
|
||||||
|
AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
|
||||||
|
AM_MISSING_PROG(AUTOCONF, autoconf)
|
||||||
|
AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
|
||||||
|
AM_MISSING_PROG(AUTOHEADER, autoheader)
|
||||||
|
AM_MISSING_PROG(MAKEINFO, makeinfo)
|
||||||
|
AM_PROG_INSTALL_SH
|
||||||
|
AM_PROG_INSTALL_STRIP
|
||||||
|
AC_REQUIRE([AM_PROG_MKDIR_P])dnl
|
||||||
|
# We need awk for the "check" target. The system "awk" is bad on
|
||||||
|
# some platforms.
|
||||||
|
AC_REQUIRE([AC_PROG_AWK])dnl
|
||||||
|
AC_REQUIRE([AC_PROG_MAKE_SET])dnl
|
||||||
|
AC_REQUIRE([AM_SET_LEADING_DOT])dnl
|
||||||
|
_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
|
||||||
|
[_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
|
||||||
|
[_AM_PROG_TAR([v7])])])
|
||||||
|
_AM_IF_OPTION([no-dependencies],,
|
||||||
|
[AC_PROVIDE_IFELSE([AC_PROG_CC],
|
||||||
|
[_AM_DEPENDENCIES(CC)],
|
||||||
|
[define([AC_PROG_CC],
|
||||||
|
defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
|
||||||
|
AC_PROVIDE_IFELSE([AC_PROG_CXX],
|
||||||
|
[_AM_DEPENDENCIES(CXX)],
|
||||||
|
[define([AC_PROG_CXX],
|
||||||
|
defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
|
||||||
|
AC_PROVIDE_IFELSE([AC_PROG_OBJC],
|
||||||
|
[_AM_DEPENDENCIES(OBJC)],
|
||||||
|
[define([AC_PROG_OBJC],
|
||||||
|
defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
|
||||||
|
])
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
# When config.status generates a header, we must update the stamp-h file.
|
||||||
|
# This file resides in the same directory as the config header
|
||||||
|
# that is generated. The stamp files are numbered to have different names.
|
||||||
|
|
||||||
|
# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
|
||||||
|
# loop where config.status creates the headers, so we can generate
|
||||||
|
# our stamp files there.
|
||||||
|
AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
|
||||||
|
[# Compute $1's index in $config_headers.
|
||||||
|
_am_stamp_count=1
|
||||||
|
for _am_header in $config_headers :; do
|
||||||
|
case $_am_header in
|
||||||
|
$1 | $1:* )
|
||||||
|
break ;;
|
||||||
|
* )
|
||||||
|
_am_stamp_count=`expr $_am_stamp_count + 1` ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
|
||||||
|
|
||||||
|
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# AM_PROG_INSTALL_SH
|
||||||
|
# ------------------
|
||||||
|
# Define $install_sh.
|
||||||
|
AC_DEFUN([AM_PROG_INSTALL_SH],
|
||||||
|
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
|
||||||
|
install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"}
|
||||||
|
AC_SUBST(install_sh)])
|
||||||
|
|
||||||
|
# Copyright (C) 2003, 2005 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# serial 2
|
||||||
|
|
||||||
|
# Check whether the underlying file-system supports filenames
|
||||||
|
# with a leading dot. For instance MS-DOS doesn't.
|
||||||
|
AC_DEFUN([AM_SET_LEADING_DOT],
|
||||||
|
[rm -rf .tst 2>/dev/null
|
||||||
|
mkdir .tst 2>/dev/null
|
||||||
|
if test -d .tst; then
|
||||||
|
am__leading_dot=.
|
||||||
|
else
|
||||||
|
am__leading_dot=_
|
||||||
|
fi
|
||||||
|
rmdir .tst 2>/dev/null
|
||||||
|
AC_SUBST([am__leading_dot])])
|
||||||
|
|
||||||
|
# Add --enable-maintainer-mode option to configure. -*- Autoconf -*-
|
||||||
|
# From Jim Meyering
|
||||||
|
|
||||||
|
# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005
|
||||||
|
# Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# serial 4
|
||||||
|
|
||||||
|
AC_DEFUN([AM_MAINTAINER_MODE],
|
||||||
|
[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
|
||||||
|
dnl maintainer-mode is disabled by default
|
||||||
|
AC_ARG_ENABLE(maintainer-mode,
|
||||||
|
[ --enable-maintainer-mode enable make rules and dependencies not useful
|
||||||
|
(and sometimes confusing) to the casual installer],
|
||||||
|
USE_MAINTAINER_MODE=$enableval,
|
||||||
|
USE_MAINTAINER_MODE=no)
|
||||||
|
AC_MSG_RESULT([$USE_MAINTAINER_MODE])
|
||||||
|
AM_CONDITIONAL(MAINTAINER_MODE, [test $USE_MAINTAINER_MODE = yes])
|
||||||
|
MAINT=$MAINTAINER_MODE_TRUE
|
||||||
|
AC_SUBST(MAINT)dnl
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE])
|
||||||
|
|
||||||
|
# Check to see how 'make' treats includes. -*- Autoconf -*-
|
||||||
|
|
||||||
|
# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# serial 3
|
||||||
|
|
||||||
|
# AM_MAKE_INCLUDE()
|
||||||
|
# -----------------
|
||||||
|
# Check to see how make treats includes.
|
||||||
|
AC_DEFUN([AM_MAKE_INCLUDE],
|
||||||
|
[am_make=${MAKE-make}
|
||||||
|
cat > confinc << 'END'
|
||||||
|
am__doit:
|
||||||
|
@echo done
|
||||||
|
.PHONY: am__doit
|
||||||
|
END
|
||||||
|
# If we don't find an include directive, just comment out the code.
|
||||||
|
AC_MSG_CHECKING([for style of include used by $am_make])
|
||||||
|
am__include="#"
|
||||||
|
am__quote=
|
||||||
|
_am_result=none
|
||||||
|
# First try GNU make style include.
|
||||||
|
echo "include confinc" > confmf
|
||||||
|
# We grep out `Entering directory' and `Leaving directory'
|
||||||
|
# messages which can occur if `w' ends up in MAKEFLAGS.
|
||||||
|
# In particular we don't look at `^make:' because GNU make might
|
||||||
|
# be invoked under some other name (usually "gmake"), in which
|
||||||
|
# case it prints its new name instead of `make'.
|
||||||
|
if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
|
||||||
|
am__include=include
|
||||||
|
am__quote=
|
||||||
|
_am_result=GNU
|
||||||
|
fi
|
||||||
|
# Now try BSD make style include.
|
||||||
|
if test "$am__include" = "#"; then
|
||||||
|
echo '.include "confinc"' > confmf
|
||||||
|
if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
|
||||||
|
am__include=.include
|
||||||
|
am__quote="\""
|
||||||
|
_am_result=BSD
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
AC_SUBST([am__include])
|
||||||
|
AC_SUBST([am__quote])
|
||||||
|
AC_MSG_RESULT([$_am_result])
|
||||||
|
rm -f confinc confmf
|
||||||
|
])
|
||||||
|
|
||||||
|
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
|
||||||
|
|
||||||
|
# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005
|
||||||
|
# Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# serial 5
|
||||||
|
|
||||||
|
# AM_MISSING_PROG(NAME, PROGRAM)
|
||||||
|
# ------------------------------
|
||||||
|
AC_DEFUN([AM_MISSING_PROG],
|
||||||
|
[AC_REQUIRE([AM_MISSING_HAS_RUN])
|
||||||
|
$1=${$1-"${am_missing_run}$2"}
|
||||||
|
AC_SUBST($1)])
|
||||||
|
|
||||||
|
|
||||||
|
# AM_MISSING_HAS_RUN
|
||||||
|
# ------------------
|
||||||
|
# Define MISSING if not defined so far and test if it supports --run.
|
||||||
|
# If it does, set am_missing_run to use it, otherwise, to nothing.
|
||||||
|
AC_DEFUN([AM_MISSING_HAS_RUN],
|
||||||
|
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
|
||||||
|
AC_REQUIRE_AUX_FILE([missing])dnl
|
||||||
|
test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
|
||||||
|
# Use eval to expand $SHELL
|
||||||
|
if eval "$MISSING --run true"; then
|
||||||
|
am_missing_run="$MISSING --run "
|
||||||
|
else
|
||||||
|
am_missing_run=
|
||||||
|
AC_MSG_WARN([`missing' script is too old or missing])
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
|
||||||
|
# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# AM_PROG_MKDIR_P
|
||||||
|
# ---------------
|
||||||
|
# Check for `mkdir -p'.
|
||||||
|
AC_DEFUN([AM_PROG_MKDIR_P],
|
||||||
|
[AC_PREREQ([2.60])dnl
|
||||||
|
AC_REQUIRE([AC_PROG_MKDIR_P])dnl
|
||||||
|
dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P,
|
||||||
|
dnl while keeping a definition of mkdir_p for backward compatibility.
|
||||||
|
dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile.
|
||||||
|
dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of
|
||||||
|
dnl Makefile.ins that do not define MKDIR_P, so we do our own
|
||||||
|
dnl adjustment using top_builddir (which is defined more often than
|
||||||
|
dnl MKDIR_P).
|
||||||
|
AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl
|
||||||
|
case $mkdir_p in
|
||||||
|
[[\\/$]]* | ?:[[\\/]]*) ;;
|
||||||
|
*/*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
|
||||||
|
esac
|
||||||
|
])
|
||||||
|
|
||||||
|
# Helper functions for option handling. -*- Autoconf -*-
|
||||||
|
|
||||||
|
# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# serial 3
|
||||||
|
|
||||||
|
# _AM_MANGLE_OPTION(NAME)
|
||||||
|
# -----------------------
|
||||||
|
AC_DEFUN([_AM_MANGLE_OPTION],
|
||||||
|
[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
|
||||||
|
|
||||||
|
# _AM_SET_OPTION(NAME)
|
||||||
|
# ------------------------------
|
||||||
|
# Set option NAME. Presently that only means defining a flag for this option.
|
||||||
|
AC_DEFUN([_AM_SET_OPTION],
|
||||||
|
[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
|
||||||
|
|
||||||
|
# _AM_SET_OPTIONS(OPTIONS)
|
||||||
|
# ----------------------------------
|
||||||
|
# OPTIONS is a space-separated list of Automake options.
|
||||||
|
AC_DEFUN([_AM_SET_OPTIONS],
|
||||||
|
[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
|
||||||
|
|
||||||
|
# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
|
||||||
|
# -------------------------------------------
|
||||||
|
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
|
||||||
|
AC_DEFUN([_AM_IF_OPTION],
|
||||||
|
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
|
||||||
|
|
||||||
|
# Check to make sure that the build environment is sane. -*- Autoconf -*-
|
||||||
|
|
||||||
|
# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
|
||||||
|
# Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# serial 4
|
||||||
|
|
||||||
|
# AM_SANITY_CHECK
|
||||||
|
# ---------------
|
||||||
|
AC_DEFUN([AM_SANITY_CHECK],
|
||||||
|
[AC_MSG_CHECKING([whether build environment is sane])
|
||||||
|
# Just in case
|
||||||
|
sleep 1
|
||||||
|
echo timestamp > conftest.file
|
||||||
|
# Do `set' in a subshell so we don't clobber the current shell's
|
||||||
|
# arguments. Must try -L first in case configure is actually a
|
||||||
|
# symlink; some systems play weird games with the mod time of symlinks
|
||||||
|
# (eg FreeBSD returns the mod time of the symlink's containing
|
||||||
|
# directory).
|
||||||
|
if (
|
||||||
|
set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
|
||||||
|
if test "$[*]" = "X"; then
|
||||||
|
# -L didn't work.
|
||||||
|
set X `ls -t $srcdir/configure conftest.file`
|
||||||
|
fi
|
||||||
|
rm -f conftest.file
|
||||||
|
if test "$[*]" != "X $srcdir/configure conftest.file" \
|
||||||
|
&& test "$[*]" != "X conftest.file $srcdir/configure"; then
|
||||||
|
|
||||||
|
# If neither matched, then we have a broken ls. This can happen
|
||||||
|
# if, for instance, CONFIG_SHELL is bash and it inherits a
|
||||||
|
# broken ls alias from the environment. This has actually
|
||||||
|
# happened. Such a system could not be considered "sane".
|
||||||
|
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
|
||||||
|
alias in your environment])
|
||||||
|
fi
|
||||||
|
|
||||||
|
test "$[2]" = conftest.file
|
||||||
|
)
|
||||||
|
then
|
||||||
|
# Ok.
|
||||||
|
:
|
||||||
|
else
|
||||||
|
AC_MSG_ERROR([newly created file is older than distributed files!
|
||||||
|
Check your system clock])
|
||||||
|
fi
|
||||||
|
AC_MSG_RESULT(yes)])
|
||||||
|
|
||||||
|
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# AM_PROG_INSTALL_STRIP
|
||||||
|
# ---------------------
|
||||||
|
# One issue with vendor `install' (even GNU) is that you can't
|
||||||
|
# specify the program used to strip binaries. This is especially
|
||||||
|
# annoying in cross-compiling environments, where the build's strip
|
||||||
|
# is unlikely to handle the host's binaries.
|
||||||
|
# Fortunately install-sh will honor a STRIPPROG variable, so we
|
||||||
|
# always use install-sh in `make install-strip', and initialize
|
||||||
|
# STRIPPROG with the value of the STRIP variable (set by the user).
|
||||||
|
AC_DEFUN([AM_PROG_INSTALL_STRIP],
|
||||||
|
[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
|
||||||
|
# Installed binaries are usually stripped using `strip' when the user
|
||||||
|
# run `make install-strip'. However `strip' might not be the right
|
||||||
|
# tool to use in cross-compilation environments, therefore Automake
|
||||||
|
# will honor the `STRIP' environment variable to overrule this program.
|
||||||
|
dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
|
||||||
|
if test "$cross_compiling" != no; then
|
||||||
|
AC_CHECK_TOOL([STRIP], [strip], :)
|
||||||
|
fi
|
||||||
|
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
|
||||||
|
AC_SUBST([INSTALL_STRIP_PROGRAM])])
|
||||||
|
|
||||||
|
# Copyright (C) 2006 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# _AM_SUBST_NOTMAKE(VARIABLE)
|
||||||
|
# ---------------------------
|
||||||
|
# Prevent Automake from outputing VARIABLE = @VARIABLE@ in Makefile.in.
|
||||||
|
# This macro is traced by Automake.
|
||||||
|
AC_DEFUN([_AM_SUBST_NOTMAKE])
|
||||||
|
|
||||||
|
# Check how to create a tarball. -*- Autoconf -*-
|
||||||
|
|
||||||
|
# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
|
||||||
|
#
|
||||||
|
# This file is free software; the Free Software Foundation
|
||||||
|
# gives unlimited permission to copy and/or distribute it,
|
||||||
|
# with or without modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
# serial 2
|
||||||
|
|
||||||
|
# _AM_PROG_TAR(FORMAT)
|
||||||
|
# --------------------
|
||||||
|
# Check how to create a tarball in format FORMAT.
|
||||||
|
# FORMAT should be one of `v7', `ustar', or `pax'.
|
||||||
|
#
|
||||||
|
# Substitute a variable $(am__tar) that is a command
|
||||||
|
# writing to stdout a FORMAT-tarball containing the directory
|
||||||
|
# $tardir.
|
||||||
|
# tardir=directory && $(am__tar) > result.tar
|
||||||
|
#
|
||||||
|
# Substitute a variable $(am__untar) that extract such
|
||||||
|
# a tarball read from stdin.
|
||||||
|
# $(am__untar) < result.tar
|
||||||
|
AC_DEFUN([_AM_PROG_TAR],
|
||||||
|
[# Always define AMTAR for backward compatibility.
|
||||||
|
AM_MISSING_PROG([AMTAR], [tar])
|
||||||
|
m4_if([$1], [v7],
|
||||||
|
[am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
|
||||||
|
[m4_case([$1], [ustar],, [pax],,
|
||||||
|
[m4_fatal([Unknown tar format])])
|
||||||
|
AC_MSG_CHECKING([how to create a $1 tar archive])
|
||||||
|
# Loop over all known methods to create a tar archive until one works.
|
||||||
|
_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
|
||||||
|
_am_tools=${am_cv_prog_tar_$1-$_am_tools}
|
||||||
|
# Do not fold the above two line into one, because Tru64 sh and
|
||||||
|
# Solaris sh will not grok spaces in the rhs of `-'.
|
||||||
|
for _am_tool in $_am_tools
|
||||||
|
do
|
||||||
|
case $_am_tool in
|
||||||
|
gnutar)
|
||||||
|
for _am_tar in tar gnutar gtar;
|
||||||
|
do
|
||||||
|
AM_RUN_LOG([$_am_tar --version]) && break
|
||||||
|
done
|
||||||
|
am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
|
||||||
|
am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
|
||||||
|
am__untar="$_am_tar -xf -"
|
||||||
|
;;
|
||||||
|
plaintar)
|
||||||
|
# Must skip GNU tar: if it does not support --format= it doesn't create
|
||||||
|
# ustar tarball either.
|
||||||
|
(tar --version) >/dev/null 2>&1 && continue
|
||||||
|
am__tar='tar chf - "$$tardir"'
|
||||||
|
am__tar_='tar chf - "$tardir"'
|
||||||
|
am__untar='tar xf -'
|
||||||
|
;;
|
||||||
|
pax)
|
||||||
|
am__tar='pax -L -x $1 -w "$$tardir"'
|
||||||
|
am__tar_='pax -L -x $1 -w "$tardir"'
|
||||||
|
am__untar='pax -r'
|
||||||
|
;;
|
||||||
|
cpio)
|
||||||
|
am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
|
||||||
|
am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
|
||||||
|
am__untar='cpio -i -H $1 -d'
|
||||||
|
;;
|
||||||
|
none)
|
||||||
|
am__tar=false
|
||||||
|
am__tar_=false
|
||||||
|
am__untar=false
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# If the value was cached, stop now. We just wanted to have am__tar
|
||||||
|
# and am__untar set.
|
||||||
|
test -n "${am_cv_prog_tar_$1}" && break
|
||||||
|
|
||||||
|
# tar/untar a dummy directory, and stop if the command works
|
||||||
|
rm -rf conftest.dir
|
||||||
|
mkdir conftest.dir
|
||||||
|
echo GrepMe > conftest.dir/file
|
||||||
|
AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
|
||||||
|
rm -rf conftest.dir
|
||||||
|
if test -s conftest.tar; then
|
||||||
|
AM_RUN_LOG([$am__untar <conftest.tar])
|
||||||
|
grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
rm -rf conftest.dir
|
||||||
|
|
||||||
|
AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
|
||||||
|
AC_MSG_RESULT([$am_cv_prog_tar_$1])])
|
||||||
|
AC_SUBST([am__tar])
|
||||||
|
AC_SUBST([am__untar])
|
||||||
|
]) # _AM_PROG_TAR
|
||||||
|
|
||||||
|
m4_include([m4/c-compiler.m4])
|
0
src/tivomirror/tivodecode/autom4te.cache/output.0t
Normal file
0
src/tivomirror/tivodecode/autom4te.cache/output.0t
Normal file
0
src/tivomirror/tivodecode/autom4te.cache/requests
Normal file
0
src/tivomirror/tivodecode/autom4te.cache/requests
Normal file
0
src/tivomirror/tivodecode/autom4te.cache/traces.0t
Normal file
0
src/tivomirror/tivodecode/autom4te.cache/traces.0t
Normal file
15
src/tivomirror/tivodecode/byteswap.c
Normal file
15
src/tivomirror/tivodecode/byteswap.c
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int isBigEndian()
|
||||||
|
{
|
||||||
|
unsigned char EndianTest[2] = {1,0};
|
||||||
|
short x = *(short *)EndianTest;
|
||||||
|
|
||||||
|
if( x == 1 )
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
1
src/tivomirror/tivodecode/byteswap.h
Normal file
1
src/tivomirror/tivodecode/byteswap.h
Normal file
|
@ -0,0 +1 @@
|
||||||
|
extern int isBigEndian();
|
100
src/tivomirror/tivodecode/cli_common.c
Normal file
100
src/tivomirror/tivodecode/cli_common.c
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
#include "tdconfig.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#ifdef HAVE_STDLIB_H
|
||||||
|
# include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
|
# include <string.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_CTYPE_H
|
||||||
|
# include <ctype.h>
|
||||||
|
#endif
|
||||||
|
#include "cli_common.h"
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
# define HOME_ENV_NAME "USERPROFILE"
|
||||||
|
# define DEFAULT_EMPTY_HOME "C:"
|
||||||
|
#else
|
||||||
|
# define HOME_ENV_NAME "HOME"
|
||||||
|
# define DEFAULT_EMPTY_HOME ""
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static const char MAK_DOTFILE_NAME[] = "/.tivodecode_mak";
|
||||||
|
|
||||||
|
/* TODO: make these not need to be globals */
|
||||||
|
int o_verbose = 0;
|
||||||
|
int o_no_verify = 0;
|
||||||
|
|
||||||
|
int get_mak_from_conf_file(char * mak)
|
||||||
|
{
|
||||||
|
char * mak_fname = NULL;
|
||||||
|
FILE * mak_file = NULL;
|
||||||
|
const char * home_dir = getenv(HOME_ENV_NAME);
|
||||||
|
size_t home_dir_len;
|
||||||
|
|
||||||
|
if (!home_dir)
|
||||||
|
home_dir = DEFAULT_EMPTY_HOME;
|
||||||
|
|
||||||
|
home_dir_len = strlen(home_dir);
|
||||||
|
|
||||||
|
mak_fname = malloc (home_dir_len + sizeof(MAK_DOTFILE_NAME));
|
||||||
|
if (!mak_fname)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "error allocing string for mak config file name\n");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy (mak_fname, home_dir, home_dir_len);
|
||||||
|
memcpy (mak_fname + home_dir_len, MAK_DOTFILE_NAME, sizeof(MAK_DOTFILE_NAME));
|
||||||
|
|
||||||
|
if ((mak_file = fopen(mak_fname, "r")))
|
||||||
|
{
|
||||||
|
if (fread(mak, 1, 11, mak_file) >= 10)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 11; i >= 10 && (mak[i] == '\0' || isspace((int)mak[i])); --i)
|
||||||
|
{
|
||||||
|
mak[i] = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (ferror(mak_file))
|
||||||
|
{
|
||||||
|
perror ("reading mak config file");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "mak too short in mak config file\n");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose (mak_file);
|
||||||
|
mak_file = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
free(mak_fname);
|
||||||
|
mak_fname = NULL;
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
if (mak_file)
|
||||||
|
fclose(mak_file);
|
||||||
|
if (mak_fname)
|
||||||
|
free(mak_fname);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void do_version(int exitval)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "%s\n", PACKAGE_STRING);
|
||||||
|
fprintf (stderr, "Copyright (c) 2006-2007, Jeremy Drake\n");
|
||||||
|
fprintf (stderr, "See COPYING file in distribution for details\n\n");
|
||||||
|
PRINT_QUALCOMM_MSG();
|
||||||
|
|
||||||
|
exit (exitval);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* vi:set ai ts=4 sw=4 expandtab: */
|
18
src/tivomirror/tivodecode/cli_common.h
Normal file
18
src/tivomirror/tivodecode/cli_common.h
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#ifndef TD_CLI_COMMON_H__
|
||||||
|
#define TD_CLI_COMMON_H__
|
||||||
|
#ifdef WIN32
|
||||||
|
# include <fcntl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define PRINT_QUALCOMM_MSG() fprintf (stderr, "Encryption by QUALCOMM ;)\n\n")
|
||||||
|
|
||||||
|
/* TODO: make these not need to be globals */
|
||||||
|
extern int o_verbose;
|
||||||
|
extern int o_no_verify;
|
||||||
|
|
||||||
|
/* mak better be a 12-byte buffer */
|
||||||
|
int get_mak_from_conf_file(char * mak);
|
||||||
|
|
||||||
|
void do_version(int exitval);
|
||||||
|
|
||||||
|
#endif // TD_CLI_COMMON_H__
|
9413
src/tivomirror/tivodecode/configure
vendored
Executable file
9413
src/tivomirror/tivodecode/configure
vendored
Executable file
File diff suppressed because it is too large
Load diff
110
src/tivomirror/tivodecode/configure.in
Normal file
110
src/tivomirror/tivodecode/configure.in
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
AC_INIT(tivodecode, 0.3pre4)
|
||||||
|
AC_CONFIG_SRCDIR(tivodecode.c)
|
||||||
|
AM_INIT_AUTOMAKE
|
||||||
|
AM_MAINTAINER_MODE
|
||||||
|
AC_CONFIG_HEADERS(tdconfig.h)
|
||||||
|
AC_PROG_CC
|
||||||
|
AC_PROG_CPP
|
||||||
|
AC_AIX
|
||||||
|
AC_ISC_POSIX
|
||||||
|
AC_MINIX
|
||||||
|
AC_HEADER_STDC
|
||||||
|
AC_C_BIGENDIAN
|
||||||
|
AC_C_INLINE
|
||||||
|
AC_PROG_RANLIB
|
||||||
|
AC_PROG_INSTALL
|
||||||
|
|
||||||
|
if test x"$ac_cv_c_compiler_gnu" = x"yes"; then
|
||||||
|
# ICC pretends to be GCC but it's lying; it doesn't support these options.
|
||||||
|
# So we have to check if "GCC" is really ICC.
|
||||||
|
AC_TRY_COMPILE([], [@%:@ifndef __INTEL_COMPILER
|
||||||
|
choke me
|
||||||
|
@%:@endif], [ICC=[yes]], [ICC=[no]])
|
||||||
|
|
||||||
|
if test "$ICC" = no; then
|
||||||
|
CFLAGS="$CFLAGS -Wall -Wpointer-arith -Winline"
|
||||||
|
|
||||||
|
PGAC_PROG_CC_CFLAGS_OPT([-Wdeclaration-after-statement])
|
||||||
|
PGAC_PROG_CC_CFLAGS_OPT([-Wendif-labels])
|
||||||
|
PGAC_PROG_CC_CFLAGS_OPT([-Werror-implicit-function-declaration])
|
||||||
|
fi
|
||||||
|
PGAC_PROG_CC_CFLAGS_OPT([-fno-strict-aliasing])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_SYS_LARGEFILE
|
||||||
|
AC_FUNC_FSEEKO
|
||||||
|
AC_TYPE_OFF_T
|
||||||
|
AC_CHECK_SIZEOF(off_t)
|
||||||
|
AC_CHECK_TYPES([size_t], [AC_CHECK_SIZEOF([size_t])])
|
||||||
|
AC_CHECK_TYPES([unsigned long], [AC_CHECK_SIZEOF([unsigned long])])
|
||||||
|
AC_CHECK_TYPES([unsigned long long], [AC_CHECK_SIZEOF([unsigned long long])])
|
||||||
|
|
||||||
|
AC_CHECK_HEADERS([netinet/in.h winsock2.h getopt.h ctype.h], [], [], AC_INCLUDES_DEFAULT([]))
|
||||||
|
AC_SEARCH_LIBS(getopt_long, [getopt gnugetopt])
|
||||||
|
|
||||||
|
dnl BEGIN check for library containing ntohl - based on AC_SEARCH_LIBS
|
||||||
|
dnl but specific for ntohl to make it work on win32
|
||||||
|
dnl ntohl check {{{
|
||||||
|
AC_PREREQ([2.13])
|
||||||
|
AC_CACHE_CHECK([for library containing ntohl], [ac_cv_search_ntohl],
|
||||||
|
[ac_func_search_save_LIBS="$LIBS"
|
||||||
|
ac_cv_search_ntohl="no"
|
||||||
|
AC_TRY_LINK(dnl
|
||||||
|
[#ifdef HAVE_SYS_TYPES_H
|
||||||
|
#include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_NETINET_IN_H
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_WINSOCK2_H
|
||||||
|
#include <winsock2.h>
|
||||||
|
#endif
|
||||||
|
],
|
||||||
|
[ntohl(42)],
|
||||||
|
[ac_cv_search_ntohl="none required"])
|
||||||
|
test "$ac_cv_search_ntohl" = "no" && for i in socket wsock32; do
|
||||||
|
LIBS="-l$i $ac_func_search_save_LIBS"
|
||||||
|
AC_TRY_LINK(dnl
|
||||||
|
[#ifdef HAVE_SYS_TYPES_H
|
||||||
|
#include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_NETINET_IN_H
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_WINSOCK2_H
|
||||||
|
#include <winsock2.h>
|
||||||
|
#endif
|
||||||
|
],
|
||||||
|
[ntohl(42)],
|
||||||
|
[ac_cv_search_ntohl="-l$i"
|
||||||
|
break])
|
||||||
|
done
|
||||||
|
LIBS="$ac_func_search_save_LIBS"])
|
||||||
|
if test "$ac_cv_search_ntohl" != "no"; then
|
||||||
|
test "$ac_cv_search_ntohl" = "none required" || LIBS="$ac_cv_search_ntohl $LIBS"
|
||||||
|
fi
|
||||||
|
dnl }}} END check for library containing ntohl
|
||||||
|
|
||||||
|
AC_CHECK_TYPES([struct option], [], [],
|
||||||
|
[#ifdef HAVE_GETOPT_H
|
||||||
|
#include <getopt.h>
|
||||||
|
#endif])
|
||||||
|
|
||||||
|
AC_CACHE_CHECK([for optreset], pgac_cv_var_int_optreset,
|
||||||
|
[AC_TRY_LINK([#include <unistd.h>],
|
||||||
|
[extern int optreset; optreset = 1;],
|
||||||
|
[pgac_cv_var_int_optreset=yes],
|
||||||
|
[pgac_cv_var_int_optreset=no])])
|
||||||
|
if test x"$pgac_cv_var_int_optreset" = x"yes"; then
|
||||||
|
AC_DEFINE(HAVE_INT_OPTRESET, 1, [Define to 1 if you have the global variable 'int optreset'.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_REPLACE_FUNCS([getopt fseeko])
|
||||||
|
|
||||||
|
if test x"$ac_cv_type_struct_option" = xyes ; then
|
||||||
|
AC_REPLACE_FUNCS([getopt_long])
|
||||||
|
else
|
||||||
|
AC_LIBOBJ(getopt_long)
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_OUTPUT(Makefile)
|
584
src/tivomirror/tivodecode/depcomp
Executable file
584
src/tivomirror/tivodecode/depcomp
Executable file
|
@ -0,0 +1,584 @@
|
||||||
|
#! /bin/sh
|
||||||
|
# depcomp - compile a program generating dependencies as side-effects
|
||||||
|
|
||||||
|
scriptversion=2006-10-15.18
|
||||||
|
|
||||||
|
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software
|
||||||
|
# Foundation, Inc.
|
||||||
|
|
||||||
|
# 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, 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.
|
||||||
|
|
||||||
|
# As a special exception to the GNU General Public License, if you
|
||||||
|
# distribute this file as part of a program that contains a
|
||||||
|
# configuration script generated by Autoconf, you may include it under
|
||||||
|
# the same distribution terms that you use for the rest of that program.
|
||||||
|
|
||||||
|
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
'')
|
||||||
|
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
|
||||||
|
exit 1;
|
||||||
|
;;
|
||||||
|
-h | --h*)
|
||||||
|
cat <<\EOF
|
||||||
|
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
|
||||||
|
|
||||||
|
Run PROGRAMS ARGS to compile a file, generating dependencies
|
||||||
|
as side-effects.
|
||||||
|
|
||||||
|
Environment variables:
|
||||||
|
depmode Dependency tracking mode.
|
||||||
|
source Source file read by `PROGRAMS ARGS'.
|
||||||
|
object Object file output by `PROGRAMS ARGS'.
|
||||||
|
DEPDIR directory where to store dependencies.
|
||||||
|
depfile Dependency file to output.
|
||||||
|
tmpdepfile Temporary file to use when outputing dependencies.
|
||||||
|
libtool Whether libtool is used (yes/no).
|
||||||
|
|
||||||
|
Report bugs to <bug-automake@gnu.org>.
|
||||||
|
EOF
|
||||||
|
exit $?
|
||||||
|
;;
|
||||||
|
-v | --v*)
|
||||||
|
echo "depcomp $scriptversion"
|
||||||
|
exit $?
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
|
||||||
|
echo "depcomp: Variables source, object and depmode must be set" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
|
||||||
|
depfile=${depfile-`echo "$object" |
|
||||||
|
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
|
||||||
|
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
|
||||||
|
|
||||||
|
rm -f "$tmpdepfile"
|
||||||
|
|
||||||
|
# Some modes work just like other modes, but use different flags. We
|
||||||
|
# parameterize here, but still list the modes in the big case below,
|
||||||
|
# to make depend.m4 easier to write. Note that we *cannot* use a case
|
||||||
|
# here, because this file can only contain one case statement.
|
||||||
|
if test "$depmode" = hp; then
|
||||||
|
# HP compiler uses -M and no extra arg.
|
||||||
|
gccflag=-M
|
||||||
|
depmode=gcc
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test "$depmode" = dashXmstdout; then
|
||||||
|
# This is just like dashmstdout with a different argument.
|
||||||
|
dashmflag=-xM
|
||||||
|
depmode=dashmstdout
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$depmode" in
|
||||||
|
gcc3)
|
||||||
|
## gcc 3 implements dependency tracking that does exactly what
|
||||||
|
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
|
||||||
|
## it if -MD -MP comes after the -MF stuff. Hmm.
|
||||||
|
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
|
||||||
|
## the command line argument order; so add the flags where they
|
||||||
|
## appear in depend2.am. Note that the slowdown incurred here
|
||||||
|
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
|
||||||
|
for arg
|
||||||
|
do
|
||||||
|
case $arg in
|
||||||
|
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
|
||||||
|
*) set fnord "$@" "$arg" ;;
|
||||||
|
esac
|
||||||
|
shift # fnord
|
||||||
|
shift # $arg
|
||||||
|
done
|
||||||
|
"$@"
|
||||||
|
stat=$?
|
||||||
|
if test $stat -eq 0; then :
|
||||||
|
else
|
||||||
|
rm -f "$tmpdepfile"
|
||||||
|
exit $stat
|
||||||
|
fi
|
||||||
|
mv "$tmpdepfile" "$depfile"
|
||||||
|
;;
|
||||||
|
|
||||||
|
gcc)
|
||||||
|
## There are various ways to get dependency output from gcc. Here's
|
||||||
|
## why we pick this rather obscure method:
|
||||||
|
## - Don't want to use -MD because we'd like the dependencies to end
|
||||||
|
## up in a subdir. Having to rename by hand is ugly.
|
||||||
|
## (We might end up doing this anyway to support other compilers.)
|
||||||
|
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
|
||||||
|
## -MM, not -M (despite what the docs say).
|
||||||
|
## - Using -M directly means running the compiler twice (even worse
|
||||||
|
## than renaming).
|
||||||
|
if test -z "$gccflag"; then
|
||||||
|
gccflag=-MD,
|
||||||
|
fi
|
||||||
|
"$@" -Wp,"$gccflag$tmpdepfile"
|
||||||
|
stat=$?
|
||||||
|
if test $stat -eq 0; then :
|
||||||
|
else
|
||||||
|
rm -f "$tmpdepfile"
|
||||||
|
exit $stat
|
||||||
|
fi
|
||||||
|
rm -f "$depfile"
|
||||||
|
echo "$object : \\" > "$depfile"
|
||||||
|
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
|
||||||
|
## The second -e expression handles DOS-style file names with drive letters.
|
||||||
|
sed -e 's/^[^:]*: / /' \
|
||||||
|
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
|
||||||
|
## This next piece of magic avoids the `deleted header file' problem.
|
||||||
|
## The problem is that when a header file which appears in a .P file
|
||||||
|
## is deleted, the dependency causes make to die (because there is
|
||||||
|
## typically no way to rebuild the header). We avoid this by adding
|
||||||
|
## dummy dependencies for each header file. Too bad gcc doesn't do
|
||||||
|
## this for us directly.
|
||||||
|
tr ' ' '
|
||||||
|
' < "$tmpdepfile" |
|
||||||
|
## Some versions of gcc put a space before the `:'. On the theory
|
||||||
|
## that the space means something, we add a space to the output as
|
||||||
|
## well.
|
||||||
|
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||||
|
## correctly. Breaking it into two sed invocations is a workaround.
|
||||||
|
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||||
|
rm -f "$tmpdepfile"
|
||||||
|
;;
|
||||||
|
|
||||||
|
hp)
|
||||||
|
# This case exists only to let depend.m4 do its work. It works by
|
||||||
|
# looking at the text of this script. This case will never be run,
|
||||||
|
# since it is checked for above.
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
|
||||||
|
sgi)
|
||||||
|
if test "$libtool" = yes; then
|
||||||
|
"$@" "-Wp,-MDupdate,$tmpdepfile"
|
||||||
|
else
|
||||||
|
"$@" -MDupdate "$tmpdepfile"
|
||||||
|
fi
|
||||||
|
stat=$?
|
||||||
|
if test $stat -eq 0; then :
|
||||||
|
else
|
||||||
|
rm -f "$tmpdepfile"
|
||||||
|
exit $stat
|
||||||
|
fi
|
||||||
|
rm -f "$depfile"
|
||||||
|
|
||||||
|
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
|
||||||
|
echo "$object : \\" > "$depfile"
|
||||||
|
|
||||||
|
# Clip off the initial element (the dependent). Don't try to be
|
||||||
|
# clever and replace this with sed code, as IRIX sed won't handle
|
||||||
|
# lines with more than a fixed number of characters (4096 in
|
||||||
|
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
|
||||||
|
# the IRIX cc adds comments like `#:fec' to the end of the
|
||||||
|
# dependency line.
|
||||||
|
tr ' ' '
|
||||||
|
' < "$tmpdepfile" \
|
||||||
|
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
|
||||||
|
tr '
|
||||||
|
' ' ' >> $depfile
|
||||||
|
echo >> $depfile
|
||||||
|
|
||||||
|
# The second pass generates a dummy entry for each header file.
|
||||||
|
tr ' ' '
|
||||||
|
' < "$tmpdepfile" \
|
||||||
|
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
|
||||||
|
>> $depfile
|
||||||
|
else
|
||||||
|
# The sourcefile does not contain any dependencies, so just
|
||||||
|
# store a dummy comment line, to avoid errors with the Makefile
|
||||||
|
# "include basename.Plo" scheme.
|
||||||
|
echo "#dummy" > "$depfile"
|
||||||
|
fi
|
||||||
|
rm -f "$tmpdepfile"
|
||||||
|
;;
|
||||||
|
|
||||||
|
aix)
|
||||||
|
# The C for AIX Compiler uses -M and outputs the dependencies
|
||||||
|
# in a .u file. In older versions, this file always lives in the
|
||||||
|
# current directory. Also, the AIX compiler puts `$object:' at the
|
||||||
|
# start of each line; $object doesn't have directory information.
|
||||||
|
# Version 6 uses the directory in both cases.
|
||||||
|
stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
|
||||||
|
tmpdepfile="$stripped.u"
|
||||||
|
if test "$libtool" = yes; then
|
||||||
|
"$@" -Wc,-M
|
||||||
|
else
|
||||||
|
"$@" -M
|
||||||
|
fi
|
||||||
|
stat=$?
|
||||||
|
|
||||||
|
if test -f "$tmpdepfile"; then :
|
||||||
|
else
|
||||||
|
stripped=`echo "$stripped" | sed 's,^.*/,,'`
|
||||||
|
tmpdepfile="$stripped.u"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test $stat -eq 0; then :
|
||||||
|
else
|
||||||
|
rm -f "$tmpdepfile"
|
||||||
|
exit $stat
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test -f "$tmpdepfile"; then
|
||||||
|
outname="$stripped.o"
|
||||||
|
# Each line is of the form `foo.o: dependent.h'.
|
||||||
|
# Do two passes, one to just change these to
|
||||||
|
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||||
|
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
|
||||||
|
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
|
||||||
|
else
|
||||||
|
# The sourcefile does not contain any dependencies, so just
|
||||||
|
# store a dummy comment line, to avoid errors with the Makefile
|
||||||
|
# "include basename.Plo" scheme.
|
||||||
|
echo "#dummy" > "$depfile"
|
||||||
|
fi
|
||||||
|
rm -f "$tmpdepfile"
|
||||||
|
;;
|
||||||
|
|
||||||
|
icc)
|
||||||
|
# Intel's C compiler understands `-MD -MF file'. However on
|
||||||
|
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
|
||||||
|
# ICC 7.0 will fill foo.d with something like
|
||||||
|
# foo.o: sub/foo.c
|
||||||
|
# foo.o: sub/foo.h
|
||||||
|
# which is wrong. We want:
|
||||||
|
# sub/foo.o: sub/foo.c
|
||||||
|
# sub/foo.o: sub/foo.h
|
||||||
|
# sub/foo.c:
|
||||||
|
# sub/foo.h:
|
||||||
|
# ICC 7.1 will output
|
||||||
|
# foo.o: sub/foo.c sub/foo.h
|
||||||
|
# and will wrap long lines using \ :
|
||||||
|
# foo.o: sub/foo.c ... \
|
||||||
|
# sub/foo.h ... \
|
||||||
|
# ...
|
||||||
|
|
||||||
|
"$@" -MD -MF "$tmpdepfile"
|
||||||
|
stat=$?
|
||||||
|
if test $stat -eq 0; then :
|
||||||
|
else
|
||||||
|
rm -f "$tmpdepfile"
|
||||||
|
exit $stat
|
||||||
|
fi
|
||||||
|
rm -f "$depfile"
|
||||||
|
# Each line is of the form `foo.o: dependent.h',
|
||||||
|
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
|
||||||
|
# Do two passes, one to just change these to
|
||||||
|
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||||
|
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
|
||||||
|
# Some versions of the HPUX 10.20 sed can't process this invocation
|
||||||
|
# correctly. Breaking it into two sed invocations is a workaround.
|
||||||
|
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
|
||||||
|
sed -e 's/$/ :/' >> "$depfile"
|
||||||
|
rm -f "$tmpdepfile"
|
||||||
|
;;
|
||||||
|
|
||||||
|
hp2)
|
||||||
|
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
|
||||||
|
# compilers, which have integrated preprocessors. The correct option
|
||||||
|
# to use with these is +Maked; it writes dependencies to a file named
|
||||||
|
# 'foo.d', which lands next to the object file, wherever that
|
||||||
|
# happens to be.
|
||||||
|
# Much of this is similar to the tru64 case; see comments there.
|
||||||
|
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||||
|
test "x$dir" = "x$object" && dir=
|
||||||
|
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||||
|
if test "$libtool" = yes; then
|
||||||
|
tmpdepfile1=$dir$base.d
|
||||||
|
tmpdepfile2=$dir.libs/$base.d
|
||||||
|
"$@" -Wc,+Maked
|
||||||
|
else
|
||||||
|
tmpdepfile1=$dir$base.d
|
||||||
|
tmpdepfile2=$dir$base.d
|
||||||
|
"$@" +Maked
|
||||||
|
fi
|
||||||
|
stat=$?
|
||||||
|
if test $stat -eq 0; then :
|
||||||
|
else
|
||||||
|
rm -f "$tmpdepfile1" "$tmpdepfile2"
|
||||||
|
exit $stat
|
||||||
|
fi
|
||||||
|
|
||||||
|
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
|
||||||
|
do
|
||||||
|
test -f "$tmpdepfile" && break
|
||||||
|
done
|
||||||
|
if test -f "$tmpdepfile"; then
|
||||||
|
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
|
||||||
|
# Add `dependent.h:' lines.
|
||||||
|
sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
|
||||||
|
else
|
||||||
|
echo "#dummy" > "$depfile"
|
||||||
|
fi
|
||||||
|
rm -f "$tmpdepfile" "$tmpdepfile2"
|
||||||
|
;;
|
||||||
|
|
||||||
|
tru64)
|
||||||
|
# The Tru64 compiler uses -MD to generate dependencies as a side
|
||||||
|
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
|
||||||
|
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
|
||||||
|
# dependencies in `foo.d' instead, so we check for that too.
|
||||||
|
# Subdirectories are respected.
|
||||||
|
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||||
|
test "x$dir" = "x$object" && dir=
|
||||||
|
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||||
|
|
||||||
|
if test "$libtool" = yes; then
|
||||||
|
# With Tru64 cc, shared objects can also be used to make a
|
||||||
|
# static library. This mechanism is used in libtool 1.4 series to
|
||||||
|
# handle both shared and static libraries in a single compilation.
|
||||||
|
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
|
||||||
|
#
|
||||||
|
# With libtool 1.5 this exception was removed, and libtool now
|
||||||
|
# generates 2 separate objects for the 2 libraries. These two
|
||||||
|
# compilations output dependencies in $dir.libs/$base.o.d and
|
||||||
|
# in $dir$base.o.d. We have to check for both files, because
|
||||||
|
# one of the two compilations can be disabled. We should prefer
|
||||||
|
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
|
||||||
|
# automatically cleaned when .libs/ is deleted, while ignoring
|
||||||
|
# the former would cause a distcleancheck panic.
|
||||||
|
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
|
||||||
|
tmpdepfile2=$dir$base.o.d # libtool 1.5
|
||||||
|
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
|
||||||
|
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
|
||||||
|
"$@" -Wc,-MD
|
||||||
|
else
|
||||||
|
tmpdepfile1=$dir$base.o.d
|
||||||
|
tmpdepfile2=$dir$base.d
|
||||||
|
tmpdepfile3=$dir$base.d
|
||||||
|
tmpdepfile4=$dir$base.d
|
||||||
|
"$@" -MD
|
||||||
|
fi
|
||||||
|
|
||||||
|
stat=$?
|
||||||
|
if test $stat -eq 0; then :
|
||||||
|
else
|
||||||
|
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
|
||||||
|
exit $stat
|
||||||
|
fi
|
||||||
|
|
||||||
|
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
|
||||||
|
do
|
||||||
|
test -f "$tmpdepfile" && break
|
||||||
|
done
|
||||||
|
if test -f "$tmpdepfile"; then
|
||||||
|
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
|
||||||
|
# That's a tab and a space in the [].
|
||||||
|
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
|
||||||
|
else
|
||||||
|
echo "#dummy" > "$depfile"
|
||||||
|
fi
|
||||||
|
rm -f "$tmpdepfile"
|
||||||
|
;;
|
||||||
|
|
||||||
|
#nosideeffect)
|
||||||
|
# This comment above is used by automake to tell side-effect
|
||||||
|
# dependency tracking mechanisms from slower ones.
|
||||||
|
|
||||||
|
dashmstdout)
|
||||||
|
# Important note: in order to support this mode, a compiler *must*
|
||||||
|
# always write the preprocessed file to stdout, regardless of -o.
|
||||||
|
"$@" || exit $?
|
||||||
|
|
||||||
|
# Remove the call to Libtool.
|
||||||
|
if test "$libtool" = yes; then
|
||||||
|
while test $1 != '--mode=compile'; do
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove `-o $object'.
|
||||||
|
IFS=" "
|
||||||
|
for arg
|
||||||
|
do
|
||||||
|
case $arg in
|
||||||
|
-o)
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
$object)
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
set fnord "$@" "$arg"
|
||||||
|
shift # fnord
|
||||||
|
shift # $arg
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
test -z "$dashmflag" && dashmflag=-M
|
||||||
|
# Require at least two characters before searching for `:'
|
||||||
|
# in the target name. This is to cope with DOS-style filenames:
|
||||||
|
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
|
||||||
|
"$@" $dashmflag |
|
||||||
|
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
|
||||||
|
rm -f "$depfile"
|
||||||
|
cat < "$tmpdepfile" > "$depfile"
|
||||||
|
tr ' ' '
|
||||||
|
' < "$tmpdepfile" | \
|
||||||
|
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||||
|
## correctly. Breaking it into two sed invocations is a workaround.
|
||||||
|
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||||
|
rm -f "$tmpdepfile"
|
||||||
|
;;
|
||||||
|
|
||||||
|
dashXmstdout)
|
||||||
|
# This case only exists to satisfy depend.m4. It is never actually
|
||||||
|
# run, as this mode is specially recognized in the preamble.
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
|
||||||
|
makedepend)
|
||||||
|
"$@" || exit $?
|
||||||
|
# Remove any Libtool call
|
||||||
|
if test "$libtool" = yes; then
|
||||||
|
while test $1 != '--mode=compile'; do
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
# X makedepend
|
||||||
|
shift
|
||||||
|
cleared=no
|
||||||
|
for arg in "$@"; do
|
||||||
|
case $cleared in
|
||||||
|
no)
|
||||||
|
set ""; shift
|
||||||
|
cleared=yes ;;
|
||||||
|
esac
|
||||||
|
case "$arg" in
|
||||||
|
-D*|-I*)
|
||||||
|
set fnord "$@" "$arg"; shift ;;
|
||||||
|
# Strip any option that makedepend may not understand. Remove
|
||||||
|
# the object too, otherwise makedepend will parse it as a source file.
|
||||||
|
-*|$object)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
set fnord "$@" "$arg"; shift ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
obj_suffix="`echo $object | sed 's/^.*\././'`"
|
||||||
|
touch "$tmpdepfile"
|
||||||
|
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
|
||||||
|
rm -f "$depfile"
|
||||||
|
cat < "$tmpdepfile" > "$depfile"
|
||||||
|
sed '1,2d' "$tmpdepfile" | tr ' ' '
|
||||||
|
' | \
|
||||||
|
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||||
|
## correctly. Breaking it into two sed invocations is a workaround.
|
||||||
|
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||||
|
rm -f "$tmpdepfile" "$tmpdepfile".bak
|
||||||
|
;;
|
||||||
|
|
||||||
|
cpp)
|
||||||
|
# Important note: in order to support this mode, a compiler *must*
|
||||||
|
# always write the preprocessed file to stdout.
|
||||||
|
"$@" || exit $?
|
||||||
|
|
||||||
|
# Remove the call to Libtool.
|
||||||
|
if test "$libtool" = yes; then
|
||||||
|
while test $1 != '--mode=compile'; do
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove `-o $object'.
|
||||||
|
IFS=" "
|
||||||
|
for arg
|
||||||
|
do
|
||||||
|
case $arg in
|
||||||
|
-o)
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
$object)
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
set fnord "$@" "$arg"
|
||||||
|
shift # fnord
|
||||||
|
shift # $arg
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
"$@" -E |
|
||||||
|
sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||||
|
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
|
||||||
|
sed '$ s: \\$::' > "$tmpdepfile"
|
||||||
|
rm -f "$depfile"
|
||||||
|
echo "$object : \\" > "$depfile"
|
||||||
|
cat < "$tmpdepfile" >> "$depfile"
|
||||||
|
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
|
||||||
|
rm -f "$tmpdepfile"
|
||||||
|
;;
|
||||||
|
|
||||||
|
msvisualcpp)
|
||||||
|
# Important note: in order to support this mode, a compiler *must*
|
||||||
|
# always write the preprocessed file to stdout, regardless of -o,
|
||||||
|
# because we must use -o when running libtool.
|
||||||
|
"$@" || exit $?
|
||||||
|
IFS=" "
|
||||||
|
for arg
|
||||||
|
do
|
||||||
|
case "$arg" in
|
||||||
|
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
|
||||||
|
set fnord "$@"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
set fnord "$@" "$arg"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
"$@" -E |
|
||||||
|
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
|
||||||
|
rm -f "$depfile"
|
||||||
|
echo "$object : \\" > "$depfile"
|
||||||
|
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
|
||||||
|
echo " " >> "$depfile"
|
||||||
|
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
|
||||||
|
rm -f "$tmpdepfile"
|
||||||
|
;;
|
||||||
|
|
||||||
|
none)
|
||||||
|
exec "$@"
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "Unknown depmode $depmode" 1>&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: shell-script
|
||||||
|
# sh-indentation: 2
|
||||||
|
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||||
|
# time-stamp-start: "scriptversion="
|
||||||
|
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||||
|
# time-stamp-end: "$"
|
||||||
|
# End:
|
126
src/tivomirror/tivodecode/fseeko.c
Normal file
126
src/tivomirror/tivodecode/fseeko.c
Normal file
|
@ -0,0 +1,126 @@
|
||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* fseeko.c
|
||||||
|
* 64-bit versions of fseeko/ftello()
|
||||||
|
*
|
||||||
|
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
||||||
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* IDENTIFICATION
|
||||||
|
* $PostgreSQL: pgsql/src/port/fseeko.c,v 1.20 2006/03/05 15:59:10 momjian Exp $
|
||||||
|
*
|
||||||
|
*-------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We have to use the native defines here because configure hasn't
|
||||||
|
* completed yet.
|
||||||
|
*/
|
||||||
|
#if defined(__bsdi__) || defined(__NetBSD__) || defined(WIN32)
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "tdconfig.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#ifdef HAVE_MEMORY_H
|
||||||
|
# include <memory.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
|
#ifdef WIN32
|
||||||
|
# include <io.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef bsdi
|
||||||
|
# include <pthread.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_STAT_H
|
||||||
|
# include <sys/stat.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
# define OFF_T_TYPE __int64
|
||||||
|
#else
|
||||||
|
# define OFF_T_TYPE off_t
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* On BSD/OS and NetBSD, off_t and fpos_t are the same. Standards
|
||||||
|
* say off_t is an arithmetic type, but not necessarily integral,
|
||||||
|
* while fpos_t might be neither.
|
||||||
|
*
|
||||||
|
* This is thread-safe on BSD/OS using flockfile/funlockfile.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
fseeko(FILE *stream, OFF_T_TYPE offset, int whence)
|
||||||
|
{
|
||||||
|
fpos_t floc;
|
||||||
|
#ifndef WIN32
|
||||||
|
struct stat filestat;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
switch (whence)
|
||||||
|
{
|
||||||
|
case SEEK_CUR:
|
||||||
|
#ifdef bsdi
|
||||||
|
flockfile(stream);
|
||||||
|
#endif
|
||||||
|
if (fgetpos(stream, &floc) != 0)
|
||||||
|
goto failure;
|
||||||
|
floc += offset;
|
||||||
|
break;
|
||||||
|
case SEEK_SET:
|
||||||
|
floc = offset;
|
||||||
|
break;
|
||||||
|
case SEEK_END:
|
||||||
|
#ifdef bsdi
|
||||||
|
flockfile(stream);
|
||||||
|
#endif
|
||||||
|
fflush(stream); /* force writes to fd for stat() */
|
||||||
|
#ifdef WIN32
|
||||||
|
floc = _filelengthi64(_fileno(stream));
|
||||||
|
#else
|
||||||
|
if (fstat(fileno(stream), &filestat) != 0)
|
||||||
|
goto failure;
|
||||||
|
floc = filestat.st_size;
|
||||||
|
#endif
|
||||||
|
floc += offset;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fsetpos(stream, &floc) != 0)
|
||||||
|
goto failure;
|
||||||
|
#ifdef bsdi
|
||||||
|
funlockfile(stream);
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
failure:
|
||||||
|
#ifdef bsdi
|
||||||
|
funlockfile(stream);
|
||||||
|
#endif
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
OFF_T_TYPE
|
||||||
|
ftello(FILE *stream)
|
||||||
|
{
|
||||||
|
fpos_t floc;
|
||||||
|
|
||||||
|
if (fgetpos(stream, &floc) != 0)
|
||||||
|
return -1;
|
||||||
|
return floc;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
24
src/tivomirror/tivodecode/fseeko.h
Normal file
24
src/tivomirror/tivodecode/fseeko.h
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#ifndef FSEEKO_H_
|
||||||
|
# define FSEEKO_H_
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
# if !defined(HAVE_FSEEKO) && (defined(__bsdi__) || defined(__NetBSD__) || defined(WIN32))
|
||||||
|
|
||||||
|
# ifdef WIN32
|
||||||
|
# define OFF_T_TYPE __int64
|
||||||
|
# else
|
||||||
|
# define OFF_T_TYPE off_t
|
||||||
|
# endif
|
||||||
|
|
||||||
|
extern int fseeko(FILE *stream, OFF_T_TYPE offset, int whence);
|
||||||
|
extern OFF_T_TYPE ftello(FILE *stream);
|
||||||
|
|
||||||
|
# define HAVE_FSEEKO 1
|
||||||
|
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif // FSEEKO_H_
|
126
src/tivomirror/tivodecode/getopt.c
Normal file
126
src/tivomirror/tivodecode/getopt.c
Normal file
|
@ -0,0 +1,126 @@
|
||||||
|
/* $PostgreSQL: pgsql/src/port/getopt.c,v 1.10 2006/03/11 04:38:40 momjian Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1987, 1993, 1994
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of the University nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "tdconfig.h"
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
|
# include <string.h>
|
||||||
|
#endif
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
|
static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
|
||||||
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
|
||||||
|
|
||||||
|
int opterr = 1, /* if error message should be printed */
|
||||||
|
optind = 1, /* index into parent argv vector */
|
||||||
|
optopt, /* character checked for validity */
|
||||||
|
optreset; /* reset getopt */
|
||||||
|
char *optarg; /* argument associated with option */
|
||||||
|
|
||||||
|
#define BADCH (int)'?'
|
||||||
|
#define BADARG (int)':'
|
||||||
|
#define EMSG ""
|
||||||
|
|
||||||
|
/*
|
||||||
|
* getopt
|
||||||
|
* Parse argc/argv argument vector.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
getopt(nargc, nargv, ostr)
|
||||||
|
int nargc;
|
||||||
|
char *const * nargv;
|
||||||
|
const char *ostr;
|
||||||
|
{
|
||||||
|
static char *place = EMSG; /* option letter processing */
|
||||||
|
char *oli; /* option letter list index */
|
||||||
|
|
||||||
|
if (optreset || !*place)
|
||||||
|
{ /* update scanning pointer */
|
||||||
|
optreset = 0;
|
||||||
|
if (optind >= nargc || *(place = nargv[optind]) != '-')
|
||||||
|
{
|
||||||
|
place = EMSG;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (place[1] && *++place == '-' && place[1] == '\0')
|
||||||
|
{ /* found "--" */
|
||||||
|
++optind;
|
||||||
|
place = EMSG;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} /* option letter okay? */
|
||||||
|
if ((optopt = (int) *place++) == (int) ':' ||
|
||||||
|
!(oli = strchr(ostr, optopt)))
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* if the user didn't specify '-' as an option, assume it means -1.
|
||||||
|
*/
|
||||||
|
if (optopt == (int) '-')
|
||||||
|
return -1;
|
||||||
|
if (!*place)
|
||||||
|
++optind;
|
||||||
|
if (opterr && *ostr != ':')
|
||||||
|
(void) fprintf(stderr,
|
||||||
|
"illegal option -- %c\n", optopt);
|
||||||
|
return BADCH;
|
||||||
|
}
|
||||||
|
if (*++oli != ':')
|
||||||
|
{ /* don't need argument */
|
||||||
|
optarg = NULL;
|
||||||
|
if (!*place)
|
||||||
|
++optind;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ /* need an argument */
|
||||||
|
if (*place) /* no white space */
|
||||||
|
optarg = place;
|
||||||
|
else if (nargc <= ++optind)
|
||||||
|
{ /* no arg */
|
||||||
|
place = EMSG;
|
||||||
|
if (*ostr == ':')
|
||||||
|
return BADARG;
|
||||||
|
if (opterr)
|
||||||
|
(void) fprintf(stderr,
|
||||||
|
"option requires an argument -- %c\n",
|
||||||
|
optopt);
|
||||||
|
return BADCH;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
/* white space */
|
||||||
|
optarg = nargv[optind];
|
||||||
|
place = EMSG;
|
||||||
|
++optind;
|
||||||
|
}
|
||||||
|
return optopt; /* dump back option letter */
|
||||||
|
}
|
203
src/tivomirror/tivodecode/getopt_long.c
Normal file
203
src/tivomirror/tivodecode/getopt_long.c
Normal file
|
@ -0,0 +1,203 @@
|
||||||
|
/*
|
||||||
|
* getopt_long() -- long options parser
|
||||||
|
*
|
||||||
|
* Portions Copyright (c) 1987, 1993, 1994
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* Portions Copyright (c) 2003
|
||||||
|
* PostgreSQL Global Development Group
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of the University nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* $PostgreSQL: pgsql/src/port/getopt_long.c,v 1.5 2005/10/15 02:49:51 momjian Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "tdconfig.h"
|
||||||
|
#endif
|
||||||
|
#include "getopt_long.h"
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
|
# include <string.h>
|
||||||
|
#endif
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifndef HAVE_INT_OPTRESET
|
||||||
|
int optreset;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define BADCH '?'
|
||||||
|
#define BADARG ':'
|
||||||
|
#define EMSG ""
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
getopt_long(int argc, char *const argv[],
|
||||||
|
const char *optstring,
|
||||||
|
const struct option * longopts, int *longindex)
|
||||||
|
{
|
||||||
|
static char *place = EMSG; /* option letter processing */
|
||||||
|
char *oli; /* option letter list index */
|
||||||
|
|
||||||
|
if (optreset || !*place)
|
||||||
|
{ /* update scanning pointer */
|
||||||
|
optreset = 0;
|
||||||
|
|
||||||
|
if (optind >= argc)
|
||||||
|
{
|
||||||
|
place = EMSG;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
place = argv[optind];
|
||||||
|
|
||||||
|
if (place[0] != '-')
|
||||||
|
{
|
||||||
|
place = EMSG;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
place++;
|
||||||
|
|
||||||
|
if (place[0] && place[0] == '-' && place[1] == '\0')
|
||||||
|
{ /* found "--" */
|
||||||
|
++optind;
|
||||||
|
place = EMSG;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (place[0] && place[0] == '-' && place[1])
|
||||||
|
{
|
||||||
|
/* long option */
|
||||||
|
size_t namelen;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
place++;
|
||||||
|
|
||||||
|
namelen = strcspn(place, "=");
|
||||||
|
for (i = 0; longopts[i].name != NULL; i++)
|
||||||
|
{
|
||||||
|
if (strlen(longopts[i].name) == namelen
|
||||||
|
&& strncmp(place, longopts[i].name, namelen) == 0)
|
||||||
|
{
|
||||||
|
if (longopts[i].has_arg)
|
||||||
|
{
|
||||||
|
if (place[namelen] == '=')
|
||||||
|
optarg = place + namelen + 1;
|
||||||
|
else if (optind < argc - 1)
|
||||||
|
{
|
||||||
|
optind++;
|
||||||
|
optarg = argv[optind];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (optstring[0] == ':')
|
||||||
|
return BADARG;
|
||||||
|
if (opterr)
|
||||||
|
fprintf(stderr,
|
||||||
|
"%s: option requires an argument -- %s\n",
|
||||||
|
argv[0], place);
|
||||||
|
place = EMSG;
|
||||||
|
optind++;
|
||||||
|
return BADCH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
optarg = NULL;
|
||||||
|
if (place[namelen] != 0)
|
||||||
|
{
|
||||||
|
/* XXX error? */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
optind++;
|
||||||
|
|
||||||
|
if (longindex)
|
||||||
|
*longindex = i;
|
||||||
|
|
||||||
|
place = EMSG;
|
||||||
|
|
||||||
|
if (longopts[i].flag == NULL)
|
||||||
|
return longopts[i].val;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*longopts[i].flag = longopts[i].val;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opterr && optstring[0] != ':')
|
||||||
|
fprintf(stderr,
|
||||||
|
"%s: illegal option -- %s\n", argv[0], place);
|
||||||
|
place = EMSG;
|
||||||
|
optind++;
|
||||||
|
return BADCH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* short option */
|
||||||
|
optopt = (int) *place++;
|
||||||
|
|
||||||
|
oli = strchr(optstring, optopt);
|
||||||
|
if (!oli)
|
||||||
|
{
|
||||||
|
if (!*place)
|
||||||
|
++optind;
|
||||||
|
if (opterr && *optstring != ':')
|
||||||
|
fprintf(stderr,
|
||||||
|
"%s: illegal option -- %c\n", argv[0], optopt);
|
||||||
|
return BADCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oli[1] != ':')
|
||||||
|
{ /* don't need argument */
|
||||||
|
optarg = NULL;
|
||||||
|
if (!*place)
|
||||||
|
++optind;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ /* need an argument */
|
||||||
|
if (*place) /* no white space */
|
||||||
|
optarg = place;
|
||||||
|
else if (argc <= ++optind)
|
||||||
|
{ /* no arg */
|
||||||
|
place = EMSG;
|
||||||
|
if (*optstring == ':')
|
||||||
|
return BADARG;
|
||||||
|
if (opterr)
|
||||||
|
fprintf(stderr,
|
||||||
|
"%s: option requires an argument -- %c\n",
|
||||||
|
argv[0], optopt);
|
||||||
|
return BADCH;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
/* white space */
|
||||||
|
optarg = argv[optind];
|
||||||
|
place = EMSG;
|
||||||
|
++optind;
|
||||||
|
}
|
||||||
|
return optopt;
|
||||||
|
}
|
54
src/tivomirror/tivodecode/getopt_long.h
Normal file
54
src/tivomirror/tivodecode/getopt_long.h
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* Portions Copyright (c) 1987, 1993, 1994
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* Portions Copyright (c) 2003-2006, PostgreSQL Global Development Group
|
||||||
|
*
|
||||||
|
* $PostgreSQL: pgsql/src/include/getopt_long.h,v 1.6 2005/01/01 20:44:26 tgl Exp $
|
||||||
|
*/
|
||||||
|
#ifndef GETOPT_LONG_H
|
||||||
|
#define GETOPT_LONG_H
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_GETOPT_H
|
||||||
|
#include <getopt.h>
|
||||||
|
#else
|
||||||
|
/* These are picked up from the system's getopt() facility. */
|
||||||
|
extern int opterr;
|
||||||
|
extern int optind;
|
||||||
|
extern int optopt;
|
||||||
|
extern char *optarg;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(HAVE_GETOPT) || !defined(HAVE_INT_OPTRESET)
|
||||||
|
/* Some systems have this, otherwise you need to define it somewhere. */
|
||||||
|
extern int optreset;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_STRUCT_OPTION
|
||||||
|
|
||||||
|
struct option
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
int has_arg;
|
||||||
|
int *flag;
|
||||||
|
int val;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define no_argument 0
|
||||||
|
#define required_argument 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_GETOPT_LONG
|
||||||
|
|
||||||
|
extern int getopt_long(int argc, char *const argv[],
|
||||||
|
const char *optstring,
|
||||||
|
const struct option * longopts, int *longindex);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /* GETOPT_LONG_H */
|
188
src/tivomirror/tivodecode/happyfile.c
Normal file
188
src/tivomirror/tivodecode/happyfile.c
Normal file
|
@ -0,0 +1,188 @@
|
||||||
|
/*
|
||||||
|
* tivodecode, (c) 2006, Jeremy Drake
|
||||||
|
* See COPYING file for license terms
|
||||||
|
*/
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "tdconfig.h"
|
||||||
|
#endif
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#ifdef HAVE_MEMORY_H
|
||||||
|
# include <memory.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
|
#ifdef WIN32
|
||||||
|
# include <io.h>
|
||||||
|
#endif
|
||||||
|
#include "fseeko.h"
|
||||||
|
#include "happyfile.h"
|
||||||
|
|
||||||
|
#if defined HAVE_FSEEKO
|
||||||
|
# define hftell(a) ftello(a)
|
||||||
|
# define hfseek(a, b, c) fseeko(a, b, c)
|
||||||
|
#else
|
||||||
|
# define hftell(a) ftell(a)
|
||||||
|
# define hfseek(a, b, c) fseek(a, b, c)
|
||||||
|
# warning Large file support is questionable on this platform
|
||||||
|
#endif
|
||||||
|
|
||||||
|
happy_file * hopen (char * filename, char * mode)
|
||||||
|
{
|
||||||
|
happy_file * fh = malloc (sizeof (happy_file));
|
||||||
|
fh->fh = fopen (filename, mode);
|
||||||
|
if (!fh->fh)
|
||||||
|
{
|
||||||
|
free (fh);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
fh->pos = 0;
|
||||||
|
fh->buffer_start = 0;
|
||||||
|
fh->buffer_fill = 0;
|
||||||
|
return fh;
|
||||||
|
}
|
||||||
|
|
||||||
|
happy_file * hattach (FILE * fh)
|
||||||
|
{
|
||||||
|
happy_file * hfh = malloc (sizeof (happy_file));
|
||||||
|
hfh->fh = fh;
|
||||||
|
hfh->pos = 0;
|
||||||
|
hfh->buffer_start = 0;
|
||||||
|
hfh->buffer_fill = 0;
|
||||||
|
return hfh;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hclose(happy_file * fh)
|
||||||
|
{
|
||||||
|
int x = fclose (fh->fh);
|
||||||
|
free (fh);
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hdetach(happy_file * fh)
|
||||||
|
{
|
||||||
|
free(fh);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t hread (void * ptr, size_t size, happy_file * fh)
|
||||||
|
{
|
||||||
|
size_t nbytes = 0;
|
||||||
|
|
||||||
|
if (size == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if ((fh->pos + (hoff_t)size) - fh->buffer_start <= fh->buffer_fill)
|
||||||
|
{
|
||||||
|
memcpy (ptr, fh->buffer + (fh->pos - fh->buffer_start), size);
|
||||||
|
fh->pos += (hoff_t)size;
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
else if (fh->pos < fh->buffer_start + fh->buffer_fill)
|
||||||
|
{
|
||||||
|
memcpy (ptr, fh->buffer + (fh->pos - fh->buffer_start), (size_t)(fh->buffer_fill - (fh->pos - fh->buffer_start)));
|
||||||
|
nbytes += (size_t)(fh->buffer_fill - (fh->pos - fh->buffer_start));
|
||||||
|
}
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
fh->buffer_start += fh->buffer_fill;
|
||||||
|
fh->buffer_fill = (hoff_t)fread (fh->buffer, 1, BUFFERSIZE, fh->fh);
|
||||||
|
|
||||||
|
if (fh->buffer_fill == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
memcpy((char *)ptr + nbytes, fh->buffer, ((hoff_t)(size - nbytes) < fh->buffer_fill ? (size - nbytes) : (size_t)fh->buffer_fill));
|
||||||
|
nbytes += ((hoff_t)(size - nbytes) < fh->buffer_fill ? (size - nbytes) : (size_t)fh->buffer_fill);
|
||||||
|
} while (nbytes < size);
|
||||||
|
|
||||||
|
fh->pos += (hoff_t)nbytes;
|
||||||
|
return nbytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
hoff_t htell (happy_file * fh)
|
||||||
|
{
|
||||||
|
return fh->pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hseek (happy_file * fh, hoff_t offset, int whence)
|
||||||
|
{
|
||||||
|
static char junk_buf[4096];
|
||||||
|
|
||||||
|
register int r;
|
||||||
|
|
||||||
|
switch (whence)
|
||||||
|
{
|
||||||
|
case SEEK_SET:
|
||||||
|
if (offset < fh->pos)
|
||||||
|
{
|
||||||
|
r = hfseek (fh->fh, offset, SEEK_SET);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
fh->pos = offset;
|
||||||
|
fh->buffer_start = fh->pos;
|
||||||
|
fh->buffer_fill = 0;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int t = (int)((offset - fh->pos) & 0xfff);
|
||||||
|
hoff_t u = (offset - fh->pos) >> 12;
|
||||||
|
hoff_t s;
|
||||||
|
for (s=0; s < u; s++)
|
||||||
|
{
|
||||||
|
if (hread(junk_buf, 4096, fh) != 4096)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hread(junk_buf, t, fh) != t)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SEEK_CUR:
|
||||||
|
if (offset < 0)
|
||||||
|
{
|
||||||
|
r = hfseek (fh->fh, offset, SEEK_CUR);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
fh->pos += offset;
|
||||||
|
fh->buffer_start = fh->pos;
|
||||||
|
fh->buffer_fill = 0;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int t = (int)(offset & 0xfff);
|
||||||
|
hoff_t u = offset >> 12;
|
||||||
|
hoff_t s;
|
||||||
|
for (s=0; s < u; s++)
|
||||||
|
{
|
||||||
|
if (hread(junk_buf, 4096, fh) != 4096)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hread(junk_buf, t, fh) != t)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case SEEK_END:
|
||||||
|
r = hfseek (fh->fh, offset,whence);
|
||||||
|
fh->pos = hftell(fh->fh);
|
||||||
|
fh->buffer_start = fh->pos;
|
||||||
|
fh->buffer_fill = 0;
|
||||||
|
return r;
|
||||||
|
default:
|
||||||
|
errno=EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
69
src/tivomirror/tivodecode/happyfile.h
Normal file
69
src/tivomirror/tivodecode/happyfile.h
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
/*
|
||||||
|
* tivodecode, (c) 2006, Jeremy Drake
|
||||||
|
* See COPYING file for license terms
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HAPPY_FILE_H_
|
||||||
|
#define HAPPY_FILE_H_
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#ifdef HAVE_STDLIB_H
|
||||||
|
# include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
|
# include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(WIN32)
|
||||||
|
# include <io.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BUFFERSIZE
|
||||||
|
#define BUFFERSIZE 4096
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if SIZEOF_OFF_T == 8
|
||||||
|
typedef off_t hoff_t;
|
||||||
|
#elif defined (WIN32)
|
||||||
|
typedef __int64 hoff_t;
|
||||||
|
#else
|
||||||
|
#warning Large file support is questionable on this platform
|
||||||
|
typedef off_t hoff_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
FILE * fh;
|
||||||
|
hoff_t pos;
|
||||||
|
|
||||||
|
/* buffer stuff */
|
||||||
|
hoff_t buffer_start;
|
||||||
|
hoff_t buffer_fill;
|
||||||
|
|
||||||
|
char buffer[BUFFERSIZE];
|
||||||
|
} happy_file;
|
||||||
|
|
||||||
|
happy_file * hopen (char * filename, char * mode);
|
||||||
|
happy_file * hattach (FILE * fh);
|
||||||
|
|
||||||
|
int hclose(happy_file * fh);
|
||||||
|
int hdetach(happy_file * fh);
|
||||||
|
|
||||||
|
size_t hread (void * ptr, size_t size, happy_file * fh);
|
||||||
|
size_t hwrite (const void * ptr, size_t size, happy_file * fh);
|
||||||
|
|
||||||
|
hoff_t htell (happy_file * fh);
|
||||||
|
int hseek (happy_file * fh, hoff_t offset, int whence);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
108
src/tivomirror/tivodecode/hexlib.c
Normal file
108
src/tivomirror/tivodecode/hexlib.c
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
/* useful hex manipulation routines */
|
||||||
|
/* Copyright C Qualcomm Inc 1997 */
|
||||||
|
/* @(#)hexlib.c 1.1 (AHAG) 02/08/23 */
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "tdconfig.h"
|
||||||
|
#endif
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
|
# include <string.h>
|
||||||
|
#endif
|
||||||
|
#include "hexlib.h"
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
int nerrors;
|
||||||
|
|
||||||
|
static char *hex = "0123456789abcdef";
|
||||||
|
#define HEX(c) ((int)(strchr(hex, (c)) - hex))
|
||||||
|
|
||||||
|
int
|
||||||
|
hexprint(const char *s, unsigned char *p, int n)
|
||||||
|
{
|
||||||
|
printf("%14s:", s);
|
||||||
|
while (--n >= 0) {
|
||||||
|
if (n % 20 == 19)
|
||||||
|
printf("\n%14s ", "");
|
||||||
|
printf(" %02x", *p++);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
hexread(unsigned char *buf, char *p, int n)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
while (--n >= 0) {
|
||||||
|
while (*p == ' ') ++p;
|
||||||
|
i = HEX(*p++) << 4;
|
||||||
|
i += HEX(*p++);
|
||||||
|
*buf++ = i;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
hexcheck(unsigned char *buf, char *p, int n)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
while (--n >= 0) {
|
||||||
|
while (*p == ' ') ++p;
|
||||||
|
i = HEX(*p++) << 4;
|
||||||
|
i += HEX(*p++);
|
||||||
|
if (*buf++ != i) {
|
||||||
|
printf("Expected %02x, got %02x.\n", i, buf[-1]);
|
||||||
|
++nerrors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nerrors;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define COLS 16
|
||||||
|
|
||||||
|
int
|
||||||
|
hexbulk(unsigned char *buf, int n)
|
||||||
|
{
|
||||||
|
int i=0;
|
||||||
|
int j=0;
|
||||||
|
char ch;
|
||||||
|
char hexdigit[5];
|
||||||
|
char strdigit[5];
|
||||||
|
char hexstr[100];
|
||||||
|
char strstr[100];
|
||||||
|
|
||||||
|
while ( i<n )
|
||||||
|
{
|
||||||
|
memset(hexstr, 0, 100);
|
||||||
|
memset(strstr, 0, 100);
|
||||||
|
|
||||||
|
for(j=0; (j<COLS) && (i<n); j++, i++ )
|
||||||
|
{
|
||||||
|
if ( isspace(buf[i]) )
|
||||||
|
ch = ' ';
|
||||||
|
else if ( isprint( buf[i]))
|
||||||
|
ch = buf[i];
|
||||||
|
else
|
||||||
|
ch = '.';
|
||||||
|
|
||||||
|
sprintf( hexdigit, "%02x ", buf[i] );
|
||||||
|
sprintf( strdigit, "%c", ch);
|
||||||
|
strcat( hexstr, hexdigit );
|
||||||
|
strcat( strstr, strdigit );
|
||||||
|
}
|
||||||
|
|
||||||
|
while(j<COLS)
|
||||||
|
{
|
||||||
|
strcat( hexstr, " " );
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%s %s\n", hexstr, strstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
16
src/tivomirror/tivodecode/hexlib.h
Normal file
16
src/tivomirror/tivodecode/hexlib.h
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
/* useful hex manipulation routine header */
|
||||||
|
/* Copyright C Qualcomm Inc 1997 */
|
||||||
|
/* @(#)hexlib.h 1.1 (AHAG) 02/08/23 */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
extern int nerrors;
|
||||||
|
|
||||||
|
int hexprint(const char *, unsigned char *, int n);
|
||||||
|
int hexread(unsigned char *, char *, int n);
|
||||||
|
int hexcheck(unsigned char *, char *, int n);
|
||||||
|
int hexbulk(unsigned char *, int n);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
507
src/tivomirror/tivodecode/install-sh
Executable file
507
src/tivomirror/tivodecode/install-sh
Executable file
|
@ -0,0 +1,507 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# install - install a program, script, or datafile
|
||||||
|
|
||||||
|
scriptversion=2006-10-14.15
|
||||||
|
|
||||||
|
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
||||||
|
# later released in X11R6 (xc/config/util/install.sh) with the
|
||||||
|
# following copyright and license.
|
||||||
|
#
|
||||||
|
# Copyright (C) 1994 X Consortium
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to
|
||||||
|
# deal in the Software without restriction, including without limitation the
|
||||||
|
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
# sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in
|
||||||
|
# all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||||
|
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
|
||||||
|
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
#
|
||||||
|
# Except as contained in this notice, the name of the X Consortium shall not
|
||||||
|
# be used in advertising or otherwise to promote the sale, use or other deal-
|
||||||
|
# ings in this Software without prior written authorization from the X Consor-
|
||||||
|
# tium.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# FSF changes to this file are in the public domain.
|
||||||
|
#
|
||||||
|
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||||
|
# `make' implicit rules from creating a file called install from it
|
||||||
|
# when there is no Makefile.
|
||||||
|
#
|
||||||
|
# This script is compatible with the BSD install script, but was written
|
||||||
|
# from scratch.
|
||||||
|
|
||||||
|
nl='
|
||||||
|
'
|
||||||
|
IFS=" "" $nl"
|
||||||
|
|
||||||
|
# set DOITPROG to echo to test this script
|
||||||
|
|
||||||
|
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||||
|
doit="${DOITPROG-}"
|
||||||
|
if test -z "$doit"; then
|
||||||
|
doit_exec=exec
|
||||||
|
else
|
||||||
|
doit_exec=$doit
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Put in absolute file names if you don't have them in your path;
|
||||||
|
# or use environment vars.
|
||||||
|
|
||||||
|
mvprog="${MVPROG-mv}"
|
||||||
|
cpprog="${CPPROG-cp}"
|
||||||
|
chmodprog="${CHMODPROG-chmod}"
|
||||||
|
chownprog="${CHOWNPROG-chown}"
|
||||||
|
chgrpprog="${CHGRPPROG-chgrp}"
|
||||||
|
stripprog="${STRIPPROG-strip}"
|
||||||
|
rmprog="${RMPROG-rm}"
|
||||||
|
mkdirprog="${MKDIRPROG-mkdir}"
|
||||||
|
|
||||||
|
posix_glob=
|
||||||
|
posix_mkdir=
|
||||||
|
|
||||||
|
# Desired mode of installed file.
|
||||||
|
mode=0755
|
||||||
|
|
||||||
|
chmodcmd=$chmodprog
|
||||||
|
chowncmd=
|
||||||
|
chgrpcmd=
|
||||||
|
stripcmd=
|
||||||
|
rmcmd="$rmprog -f"
|
||||||
|
mvcmd="$mvprog"
|
||||||
|
src=
|
||||||
|
dst=
|
||||||
|
dir_arg=
|
||||||
|
dstarg=
|
||||||
|
no_target_directory=
|
||||||
|
|
||||||
|
usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
|
||||||
|
or: $0 [OPTION]... SRCFILES... DIRECTORY
|
||||||
|
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
|
||||||
|
or: $0 [OPTION]... -d DIRECTORIES...
|
||||||
|
|
||||||
|
In the 1st form, copy SRCFILE to DSTFILE.
|
||||||
|
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
|
||||||
|
In the 4th, create DIRECTORIES.
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-c (ignored)
|
||||||
|
-d create directories instead of installing files.
|
||||||
|
-g GROUP $chgrpprog installed files to GROUP.
|
||||||
|
-m MODE $chmodprog installed files to MODE.
|
||||||
|
-o USER $chownprog installed files to USER.
|
||||||
|
-s $stripprog installed files.
|
||||||
|
-t DIRECTORY install into DIRECTORY.
|
||||||
|
-T report an error if DSTFILE is a directory.
|
||||||
|
--help display this help and exit.
|
||||||
|
--version display version info and exit.
|
||||||
|
|
||||||
|
Environment variables override the default commands:
|
||||||
|
CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
|
||||||
|
"
|
||||||
|
|
||||||
|
while test $# -ne 0; do
|
||||||
|
case $1 in
|
||||||
|
-c) shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
-d) dir_arg=true
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
-g) chgrpcmd="$chgrpprog $2"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
--help) echo "$usage"; exit $?;;
|
||||||
|
|
||||||
|
-m) mode=$2
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
case $mode in
|
||||||
|
*' '* | *' '* | *'
|
||||||
|
'* | *'*'* | *'?'* | *'['*)
|
||||||
|
echo "$0: invalid mode: $mode" >&2
|
||||||
|
exit 1;;
|
||||||
|
esac
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
-o) chowncmd="$chownprog $2"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
-s) stripcmd=$stripprog
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
-t) dstarg=$2
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
-T) no_target_directory=true
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
--version) echo "$0 $scriptversion"; exit $?;;
|
||||||
|
|
||||||
|
--) shift
|
||||||
|
break;;
|
||||||
|
|
||||||
|
-*) echo "$0: invalid option: $1" >&2
|
||||||
|
exit 1;;
|
||||||
|
|
||||||
|
*) break;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if test $# -ne 0 && test -z "$dir_arg$dstarg"; then
|
||||||
|
# When -d is used, all remaining arguments are directories to create.
|
||||||
|
# When -t is used, the destination is already specified.
|
||||||
|
# Otherwise, the last argument is the destination. Remove it from $@.
|
||||||
|
for arg
|
||||||
|
do
|
||||||
|
if test -n "$dstarg"; then
|
||||||
|
# $@ is not empty: it contains at least $arg.
|
||||||
|
set fnord "$@" "$dstarg"
|
||||||
|
shift # fnord
|
||||||
|
fi
|
||||||
|
shift # arg
|
||||||
|
dstarg=$arg
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test $# -eq 0; then
|
||||||
|
if test -z "$dir_arg"; then
|
||||||
|
echo "$0: no input file specified." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# It's OK to call `install-sh -d' without argument.
|
||||||
|
# This can happen when creating conditional directories.
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test -z "$dir_arg"; then
|
||||||
|
trap '(exit $?); exit' 1 2 13 15
|
||||||
|
|
||||||
|
# Set umask so as not to create temps with too-generous modes.
|
||||||
|
# However, 'strip' requires both read and write access to temps.
|
||||||
|
case $mode in
|
||||||
|
# Optimize common cases.
|
||||||
|
*644) cp_umask=133;;
|
||||||
|
*755) cp_umask=22;;
|
||||||
|
|
||||||
|
*[0-7])
|
||||||
|
if test -z "$stripcmd"; then
|
||||||
|
u_plus_rw=
|
||||||
|
else
|
||||||
|
u_plus_rw='% 200'
|
||||||
|
fi
|
||||||
|
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
|
||||||
|
*)
|
||||||
|
if test -z "$stripcmd"; then
|
||||||
|
u_plus_rw=
|
||||||
|
else
|
||||||
|
u_plus_rw=,u+rw
|
||||||
|
fi
|
||||||
|
cp_umask=$mode$u_plus_rw;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
for src
|
||||||
|
do
|
||||||
|
# Protect names starting with `-'.
|
||||||
|
case $src in
|
||||||
|
-*) src=./$src ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if test -n "$dir_arg"; then
|
||||||
|
dst=$src
|
||||||
|
dstdir=$dst
|
||||||
|
test -d "$dstdir"
|
||||||
|
dstdir_status=$?
|
||||||
|
else
|
||||||
|
|
||||||
|
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
|
||||||
|
# might cause directories to be created, which would be especially bad
|
||||||
|
# if $src (and thus $dsttmp) contains '*'.
|
||||||
|
if test ! -f "$src" && test ! -d "$src"; then
|
||||||
|
echo "$0: $src does not exist." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test -z "$dstarg"; then
|
||||||
|
echo "$0: no destination specified." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
dst=$dstarg
|
||||||
|
# Protect names starting with `-'.
|
||||||
|
case $dst in
|
||||||
|
-*) dst=./$dst ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# If destination is a directory, append the input filename; won't work
|
||||||
|
# if double slashes aren't ignored.
|
||||||
|
if test -d "$dst"; then
|
||||||
|
if test -n "$no_target_directory"; then
|
||||||
|
echo "$0: $dstarg: Is a directory" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
dstdir=$dst
|
||||||
|
dst=$dstdir/`basename "$src"`
|
||||||
|
dstdir_status=0
|
||||||
|
else
|
||||||
|
# Prefer dirname, but fall back on a substitute if dirname fails.
|
||||||
|
dstdir=`
|
||||||
|
(dirname "$dst") 2>/dev/null ||
|
||||||
|
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
|
||||||
|
X"$dst" : 'X\(//\)[^/]' \| \
|
||||||
|
X"$dst" : 'X\(//\)$' \| \
|
||||||
|
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
|
||||||
|
echo X"$dst" |
|
||||||
|
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
|
||||||
|
s//\1/
|
||||||
|
q
|
||||||
|
}
|
||||||
|
/^X\(\/\/\)[^/].*/{
|
||||||
|
s//\1/
|
||||||
|
q
|
||||||
|
}
|
||||||
|
/^X\(\/\/\)$/{
|
||||||
|
s//\1/
|
||||||
|
q
|
||||||
|
}
|
||||||
|
/^X\(\/\).*/{
|
||||||
|
s//\1/
|
||||||
|
q
|
||||||
|
}
|
||||||
|
s/.*/./; q'
|
||||||
|
`
|
||||||
|
|
||||||
|
test -d "$dstdir"
|
||||||
|
dstdir_status=$?
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
obsolete_mkdir_used=false
|
||||||
|
|
||||||
|
if test $dstdir_status != 0; then
|
||||||
|
case $posix_mkdir in
|
||||||
|
'')
|
||||||
|
# Create intermediate dirs using mode 755 as modified by the umask.
|
||||||
|
# This is like FreeBSD 'install' as of 1997-10-28.
|
||||||
|
umask=`umask`
|
||||||
|
case $stripcmd.$umask in
|
||||||
|
# Optimize common cases.
|
||||||
|
*[2367][2367]) mkdir_umask=$umask;;
|
||||||
|
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
|
||||||
|
|
||||||
|
*[0-7])
|
||||||
|
mkdir_umask=`expr $umask + 22 \
|
||||||
|
- $umask % 100 % 40 + $umask % 20 \
|
||||||
|
- $umask % 10 % 4 + $umask % 2
|
||||||
|
`;;
|
||||||
|
*) mkdir_umask=$umask,go-w;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# With -d, create the new directory with the user-specified mode.
|
||||||
|
# Otherwise, rely on $mkdir_umask.
|
||||||
|
if test -n "$dir_arg"; then
|
||||||
|
mkdir_mode=-m$mode
|
||||||
|
else
|
||||||
|
mkdir_mode=
|
||||||
|
fi
|
||||||
|
|
||||||
|
posix_mkdir=false
|
||||||
|
case $umask in
|
||||||
|
*[123567][0-7][0-7])
|
||||||
|
# POSIX mkdir -p sets u+wx bits regardless of umask, which
|
||||||
|
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
|
||||||
|
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
|
||||||
|
|
||||||
|
if (umask $mkdir_umask &&
|
||||||
|
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
if test -z "$dir_arg" || {
|
||||||
|
# Check for POSIX incompatibilities with -m.
|
||||||
|
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
|
||||||
|
# other-writeable bit of parent directory when it shouldn't.
|
||||||
|
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
|
||||||
|
ls_ld_tmpdir=`ls -ld "$tmpdir"`
|
||||||
|
case $ls_ld_tmpdir in
|
||||||
|
d????-?r-*) different_mode=700;;
|
||||||
|
d????-?--*) different_mode=755;;
|
||||||
|
*) false;;
|
||||||
|
esac &&
|
||||||
|
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
|
||||||
|
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
|
||||||
|
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
then posix_mkdir=:
|
||||||
|
fi
|
||||||
|
rmdir "$tmpdir/d" "$tmpdir"
|
||||||
|
else
|
||||||
|
# Remove any dirs left behind by ancient mkdir implementations.
|
||||||
|
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
|
||||||
|
fi
|
||||||
|
trap '' 0;;
|
||||||
|
esac;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if
|
||||||
|
$posix_mkdir && (
|
||||||
|
umask $mkdir_umask &&
|
||||||
|
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
|
||||||
|
)
|
||||||
|
then :
|
||||||
|
else
|
||||||
|
|
||||||
|
# The umask is ridiculous, or mkdir does not conform to POSIX,
|
||||||
|
# or it failed possibly due to a race condition. Create the
|
||||||
|
# directory the slow way, step by step, checking for races as we go.
|
||||||
|
|
||||||
|
case $dstdir in
|
||||||
|
/*) prefix=/ ;;
|
||||||
|
-*) prefix=./ ;;
|
||||||
|
*) prefix= ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case $posix_glob in
|
||||||
|
'')
|
||||||
|
if (set -f) 2>/dev/null; then
|
||||||
|
posix_glob=true
|
||||||
|
else
|
||||||
|
posix_glob=false
|
||||||
|
fi ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
oIFS=$IFS
|
||||||
|
IFS=/
|
||||||
|
$posix_glob && set -f
|
||||||
|
set fnord $dstdir
|
||||||
|
shift
|
||||||
|
$posix_glob && set +f
|
||||||
|
IFS=$oIFS
|
||||||
|
|
||||||
|
prefixes=
|
||||||
|
|
||||||
|
for d
|
||||||
|
do
|
||||||
|
test -z "$d" && continue
|
||||||
|
|
||||||
|
prefix=$prefix$d
|
||||||
|
if test -d "$prefix"; then
|
||||||
|
prefixes=
|
||||||
|
else
|
||||||
|
if $posix_mkdir; then
|
||||||
|
(umask=$mkdir_umask &&
|
||||||
|
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
|
||||||
|
# Don't fail if two instances are running concurrently.
|
||||||
|
test -d "$prefix" || exit 1
|
||||||
|
else
|
||||||
|
case $prefix in
|
||||||
|
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
|
||||||
|
*) qprefix=$prefix;;
|
||||||
|
esac
|
||||||
|
prefixes="$prefixes '$qprefix'"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
prefix=$prefix/
|
||||||
|
done
|
||||||
|
|
||||||
|
if test -n "$prefixes"; then
|
||||||
|
# Don't fail if two instances are running concurrently.
|
||||||
|
(umask $mkdir_umask &&
|
||||||
|
eval "\$doit_exec \$mkdirprog $prefixes") ||
|
||||||
|
test -d "$dstdir" || exit 1
|
||||||
|
obsolete_mkdir_used=true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test -n "$dir_arg"; then
|
||||||
|
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
|
||||||
|
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
|
||||||
|
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
|
||||||
|
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
|
||||||
|
else
|
||||||
|
|
||||||
|
# Make a couple of temp file names in the proper directory.
|
||||||
|
dsttmp=$dstdir/_inst.$$_
|
||||||
|
rmtmp=$dstdir/_rm.$$_
|
||||||
|
|
||||||
|
# Trap to clean up those temp files at exit.
|
||||||
|
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
|
||||||
|
|
||||||
|
# Copy the file name to the temp name.
|
||||||
|
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
|
||||||
|
|
||||||
|
# and set any options; do chmod last to preserve setuid bits.
|
||||||
|
#
|
||||||
|
# If any of these fail, we abort the whole thing. If we want to
|
||||||
|
# ignore errors from any of these, just make sure not to ignore
|
||||||
|
# errors from the above "$doit $cpprog $src $dsttmp" command.
|
||||||
|
#
|
||||||
|
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
|
||||||
|
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
|
||||||
|
&& { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
|
||||||
|
&& { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
|
||||||
|
|
||||||
|
# Now rename the file to the real destination.
|
||||||
|
{ $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null \
|
||||||
|
|| {
|
||||||
|
# The rename failed, perhaps because mv can't rename something else
|
||||||
|
# to itself, or perhaps because mv is so ancient that it does not
|
||||||
|
# support -f.
|
||||||
|
|
||||||
|
# Now remove or move aside any old file at destination location.
|
||||||
|
# We try this two ways since rm can't unlink itself on some
|
||||||
|
# systems and the destination file might be busy for other
|
||||||
|
# reasons. In this case, the final cleanup might fail but the new
|
||||||
|
# file should still install successfully.
|
||||||
|
{
|
||||||
|
if test -f "$dst"; then
|
||||||
|
$doit $rmcmd -f "$dst" 2>/dev/null \
|
||||||
|
|| { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null \
|
||||||
|
&& { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }; }\
|
||||||
|
|| {
|
||||||
|
echo "$0: cannot unlink or rename $dst" >&2
|
||||||
|
(exit 1); exit 1
|
||||||
|
}
|
||||||
|
else
|
||||||
|
:
|
||||||
|
fi
|
||||||
|
} &&
|
||||||
|
|
||||||
|
# Now rename the file to the real destination.
|
||||||
|
$doit $mvcmd "$dsttmp" "$dst"
|
||||||
|
}
|
||||||
|
} || exit 1
|
||||||
|
|
||||||
|
trap '' 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Local variables:
|
||||||
|
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||||
|
# time-stamp-start: "scriptversion="
|
||||||
|
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||||
|
# time-stamp-end: "$"
|
||||||
|
# End:
|
206
src/tivomirror/tivodecode/libtdcommon.vcproj
Normal file
206
src/tivomirror/tivodecode/libtdcommon.vcproj
Normal file
|
@ -0,0 +1,206 @@
|
||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="9.00"
|
||||||
|
Name="libtdcommon"
|
||||||
|
ProjectGUID="{491A7F57-2E09-492E-9E44-70A34A313611}"
|
||||||
|
RootNamespace="libtdcommon"
|
||||||
|
Keyword="Win32Proj"
|
||||||
|
TargetFrameworkVersion="131072"
|
||||||
|
>
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"
|
||||||
|
/>
|
||||||
|
</Platforms>
|
||||||
|
<ToolFiles>
|
||||||
|
</ToolFiles>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||||
|
IntermediateDirectory="$(ConfigurationName)"
|
||||||
|
ConfigurationType="4"
|
||||||
|
CharacterSet="0"
|
||||||
|
BuildLogFile="$(IntDir)\libtdcommon_BuildLog.htm"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;HAVE_CONFIG_H"
|
||||||
|
MinimalRebuild="true"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="1"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
ProgramDataBaseFileName="$(IntDir)\libtdcommon.pdb"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="true"
|
||||||
|
DebugInformationFormat="4"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLibrarianTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||||
|
IntermediateDirectory="$(ConfigurationName)"
|
||||||
|
ConfigurationType="4"
|
||||||
|
CharacterSet="0"
|
||||||
|
WholeProgramOptimization="1"
|
||||||
|
BuildLogFile="$(IntDir)\libtdcommon_BuildLog.htm"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;HAVE_CONFIG_H"
|
||||||
|
RuntimeLibrary="0"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
ProgramDataBaseFileName="$(IntDir)\libtdcommon.pdb"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="true"
|
||||||
|
DebugInformationFormat="3"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLibrarianTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
|
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\cli_common.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\fseeko.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\getopt.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\getopt_long.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\happyfile.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||||
|
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\cli_common.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\fseeko.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\getopt_long.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\happyfile.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Resource Files"
|
||||||
|
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||||
|
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||||
|
>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
252
src/tivomirror/tivodecode/libtivodecode.vcproj
Normal file
252
src/tivomirror/tivodecode/libtivodecode.vcproj
Normal file
|
@ -0,0 +1,252 @@
|
||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="9.00"
|
||||||
|
Name="libtivodecode"
|
||||||
|
ProjectGUID="{9DDBB216-6D06-47EB-B559-B3FB02510DC3}"
|
||||||
|
RootNamespace="libtivodecode"
|
||||||
|
Keyword="Win32Proj"
|
||||||
|
TargetFrameworkVersion="131072"
|
||||||
|
>
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"
|
||||||
|
/>
|
||||||
|
</Platforms>
|
||||||
|
<ToolFiles>
|
||||||
|
<ToolFile
|
||||||
|
RelativePath=".\tivodecode.rules"
|
||||||
|
/>
|
||||||
|
</ToolFiles>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||||
|
IntermediateDirectory="$(ConfigurationName)"
|
||||||
|
ConfigurationType="4"
|
||||||
|
CharacterSet="0"
|
||||||
|
BuildLogFile="$(IntDir)\libtivodecode_BuildLog.htm"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="copy win32 file"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;HAVE_CONFIG_H"
|
||||||
|
MinimalRebuild="true"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="1"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
ProgramDataBaseFileName="$(IntDir)\libtivodecode.pdb"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="true"
|
||||||
|
DebugInformationFormat="4"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLibrarianTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||||
|
IntermediateDirectory="$(ConfigurationName)"
|
||||||
|
ConfigurationType="4"
|
||||||
|
CharacterSet="0"
|
||||||
|
WholeProgramOptimization="1"
|
||||||
|
BuildLogFile="$(IntDir)\libtivodecode_BuildLog.htm"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="copy win32 file"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
WholeProgramOptimization="false"
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;HAVE_CONFIG_H"
|
||||||
|
RuntimeLibrary="0"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
ProgramDataBaseFileName="$(IntDir)\libtivodecode.pdb"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="true"
|
||||||
|
DebugInformationFormat="3"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLibrarianTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
|
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\hexlib.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\md5.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\sha1.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\tivo-parse.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\tivodecoder.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\turing_stream.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\TuringFast.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||||
|
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\hexlib.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\md5.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\QUTsbox.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\sha1.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\tdconfig.h.win32"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\tivo-parse.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\tivodecoder.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Turing.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\turing_stream.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\TuringMultab.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\TuringSbox.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Resource Files"
|
||||||
|
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||||
|
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||||
|
>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
13
src/tivomirror/tivodecode/m4/c-compiler.m4
Normal file
13
src/tivomirror/tivodecode/m4/c-compiler.m4
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# PGAC_PROG_CC_CFLAGS_OPT
|
||||||
|
# -----------------------
|
||||||
|
# Given a string, check if the compiler supports the string as a
|
||||||
|
# command-line option. If it does, add the string to CFLAGS.
|
||||||
|
AC_DEFUN([PGAC_PROG_CC_CFLAGS_OPT],
|
||||||
|
[AC_MSG_CHECKING([if $CC supports $1])
|
||||||
|
pgac_save_CFLAGS=$CFLAGS
|
||||||
|
CFLAGS="$pgac_save_CFLAGS $1"
|
||||||
|
_AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
|
||||||
|
AC_MSG_RESULT(yes),
|
||||||
|
[CFLAGS="$pgac_save_CFLAGS"
|
||||||
|
AC_MSG_RESULT(no)])
|
||||||
|
])# PGAC_PROG_CC_CFLAGS_OPT
|
405
src/tivomirror/tivodecode/md5.c
Normal file
405
src/tivomirror/tivodecode/md5.c
Normal file
|
@ -0,0 +1,405 @@
|
||||||
|
/* $KAME: md5.c,v 1.3 2000/02/22 14:01:17 itojun Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of the project nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* $PostgreSQL: pgsql/contrib/pgcrypto/md5.c,v 1.13 2005/07/11 15:07:59 tgl Exp $
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "tdconfig.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_MEMORY_H
|
||||||
|
# include <memory.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
|
# include <string.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "md5.h"
|
||||||
|
|
||||||
|
#define SHIFT(X, s) (((X) << (s)) | ((X) >> (32 - (s))))
|
||||||
|
|
||||||
|
#define F(X, Y, Z) (((X) & (Y)) | ((~X) & (Z)))
|
||||||
|
#define G(X, Y, Z) (((X) & (Z)) | ((Y) & (~Z)))
|
||||||
|
#define H(X, Y, Z) ((X) ^ (Y) ^ (Z))
|
||||||
|
#define I(X, Y, Z) ((Y) ^ ((X) | (~Z)))
|
||||||
|
|
||||||
|
#define ROUND1(a, b, c, d, k, s, i) \
|
||||||
|
do { \
|
||||||
|
(a) = (a) + F((b), (c), (d)) + X[(k)] + T[(i)]; \
|
||||||
|
(a) = SHIFT((a), (s)); \
|
||||||
|
(a) = (b) + (a); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define ROUND2(a, b, c, d, k, s, i) \
|
||||||
|
do { \
|
||||||
|
(a) = (a) + G((b), (c), (d)) + X[(k)] + T[(i)]; \
|
||||||
|
(a) = SHIFT((a), (s)); \
|
||||||
|
(a) = (b) + (a); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define ROUND3(a, b, c, d, k, s, i) \
|
||||||
|
do { \
|
||||||
|
(a) = (a) + H((b), (c), (d)) + X[(k)] + T[(i)]; \
|
||||||
|
(a) = SHIFT((a), (s)); \
|
||||||
|
(a) = (b) + (a); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define ROUND4(a, b, c, d, k, s, i) \
|
||||||
|
do { \
|
||||||
|
(a) = (a) + I((b), (c), (d)) + X[(k)] + T[(i)]; \
|
||||||
|
(a) = SHIFT((a), (s)); \
|
||||||
|
(a) = (b) + (a); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define Sa 7
|
||||||
|
#define Sb 12
|
||||||
|
#define Sc 17
|
||||||
|
#define Sd 22
|
||||||
|
|
||||||
|
#define Se 5
|
||||||
|
#define Sf 9
|
||||||
|
#define Sg 14
|
||||||
|
#define Sh 20
|
||||||
|
|
||||||
|
#define Si 4
|
||||||
|
#define Sj 11
|
||||||
|
#define Sk 16
|
||||||
|
#define Sl 23
|
||||||
|
|
||||||
|
#define Sm 6
|
||||||
|
#define Sn 10
|
||||||
|
#define So 15
|
||||||
|
#define Sp 21
|
||||||
|
|
||||||
|
#define MD5_A0 0x67452301
|
||||||
|
#define MD5_B0 0xefcdab89
|
||||||
|
#define MD5_C0 0x98badcfe
|
||||||
|
#define MD5_D0 0x10325476
|
||||||
|
|
||||||
|
/* Integer part of 4294967296 times abs(sin(i)), where i is in radians. */
|
||||||
|
static const unsigned int T[65] = {
|
||||||
|
0,
|
||||||
|
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
|
||||||
|
0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
|
||||||
|
0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
|
||||||
|
0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
|
||||||
|
|
||||||
|
0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
|
||||||
|
0xd62f105d, 0x2441453, 0xd8a1e681, 0xe7d3fbc8,
|
||||||
|
0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
|
||||||
|
0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
|
||||||
|
|
||||||
|
0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
|
||||||
|
0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
|
||||||
|
0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x4881d05,
|
||||||
|
0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
|
||||||
|
|
||||||
|
0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
|
||||||
|
0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
|
||||||
|
0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
|
||||||
|
0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const unsigned char md5_paddat[MD5_BUFLEN] = {
|
||||||
|
0x80, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
static void md5_calc(unsigned char *, md5_ctxt *);
|
||||||
|
|
||||||
|
void
|
||||||
|
md5_init(md5_ctxt * ctxt)
|
||||||
|
{
|
||||||
|
ctxt->md5_nl = 0;
|
||||||
|
ctxt->md5_nh = 0;
|
||||||
|
ctxt->md5_i = 0;
|
||||||
|
ctxt->md5_sta = MD5_A0;
|
||||||
|
ctxt->md5_stb = MD5_B0;
|
||||||
|
ctxt->md5_stc = MD5_C0;
|
||||||
|
ctxt->md5_std = MD5_D0;
|
||||||
|
memset(ctxt->md5_buf, 0, sizeof(ctxt->md5_buf));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
md5_loop(md5_ctxt * ctxt, const unsigned char *input, size_t len)
|
||||||
|
{
|
||||||
|
unsigned int gap,
|
||||||
|
i;
|
||||||
|
|
||||||
|
if (ctxt->md5_nl + len * 8 < ctxt->md5_nl)
|
||||||
|
ctxt->md5_nh++;
|
||||||
|
ctxt->md5_nl += (unsigned int)len * 8; /* byte to bit */
|
||||||
|
gap = MD5_BUFLEN - ctxt->md5_i;
|
||||||
|
|
||||||
|
if (len >= gap)
|
||||||
|
{
|
||||||
|
memmove(ctxt->md5_buf + ctxt->md5_i, input, gap);
|
||||||
|
md5_calc(ctxt->md5_buf, ctxt);
|
||||||
|
|
||||||
|
for (i = gap; i + MD5_BUFLEN <= len; i += MD5_BUFLEN)
|
||||||
|
md5_calc((unsigned char *) (input + i), ctxt);
|
||||||
|
|
||||||
|
ctxt->md5_i = (unsigned int)len - i;
|
||||||
|
memmove(ctxt->md5_buf, input + i, ctxt->md5_i);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
memmove(ctxt->md5_buf + ctxt->md5_i, input, len);
|
||||||
|
ctxt->md5_i += (unsigned int)len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
md5_pad(md5_ctxt * ctxt)
|
||||||
|
{
|
||||||
|
unsigned int gap;
|
||||||
|
|
||||||
|
/* Don't count up padding. Keep md5_n. */
|
||||||
|
gap = MD5_BUFLEN - ctxt->md5_i;
|
||||||
|
if (gap > 8)
|
||||||
|
{
|
||||||
|
memmove(ctxt->md5_buf + ctxt->md5_i, md5_paddat,
|
||||||
|
gap - sizeof(ctxt->md5_n8));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* including gap == 8 */
|
||||||
|
memmove(ctxt->md5_buf + ctxt->md5_i, md5_paddat, gap);
|
||||||
|
md5_calc(ctxt->md5_buf, ctxt);
|
||||||
|
memmove(ctxt->md5_buf, md5_paddat + gap,
|
||||||
|
MD5_BUFLEN - sizeof(ctxt->md5_n8));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 8 byte word */
|
||||||
|
#ifndef WORDS_BIGENDIAN
|
||||||
|
memmove(&ctxt->md5_buf[56], &ctxt->md5_n8[0], 8);
|
||||||
|
#else
|
||||||
|
ctxt->md5_buf[56] = ctxt->md5_n8[3];
|
||||||
|
ctxt->md5_buf[57] = ctxt->md5_n8[2];
|
||||||
|
ctxt->md5_buf[58] = ctxt->md5_n8[1];
|
||||||
|
ctxt->md5_buf[59] = ctxt->md5_n8[0];
|
||||||
|
ctxt->md5_buf[60] = ctxt->md5_n8[7];
|
||||||
|
ctxt->md5_buf[61] = ctxt->md5_n8[6];
|
||||||
|
ctxt->md5_buf[62] = ctxt->md5_n8[5];
|
||||||
|
ctxt->md5_buf[63] = ctxt->md5_n8[4];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
md5_calc(ctxt->md5_buf, ctxt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
md5_result(unsigned char *digest, md5_ctxt * ctxt)
|
||||||
|
{
|
||||||
|
/* 4 byte words */
|
||||||
|
#ifndef WORDS_BIGENDIAN
|
||||||
|
memmove(digest, &ctxt->md5_st8[0], 16);
|
||||||
|
#else
|
||||||
|
digest[0] = ctxt->md5_st8[3];
|
||||||
|
digest[1] = ctxt->md5_st8[2];
|
||||||
|
digest[2] = ctxt->md5_st8[1];
|
||||||
|
digest[3] = ctxt->md5_st8[0];
|
||||||
|
digest[4] = ctxt->md5_st8[7];
|
||||||
|
digest[5] = ctxt->md5_st8[6];
|
||||||
|
digest[6] = ctxt->md5_st8[5];
|
||||||
|
digest[7] = ctxt->md5_st8[4];
|
||||||
|
digest[8] = ctxt->md5_st8[11];
|
||||||
|
digest[9] = ctxt->md5_st8[10];
|
||||||
|
digest[10] = ctxt->md5_st8[9];
|
||||||
|
digest[11] = ctxt->md5_st8[8];
|
||||||
|
digest[12] = ctxt->md5_st8[15];
|
||||||
|
digest[13] = ctxt->md5_st8[14];
|
||||||
|
digest[14] = ctxt->md5_st8[13];
|
||||||
|
digest[15] = ctxt->md5_st8[12];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
static unsigned int X[16];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void
|
||||||
|
md5_calc(unsigned char *b64, md5_ctxt * ctxt)
|
||||||
|
{
|
||||||
|
unsigned int A = ctxt->md5_sta;
|
||||||
|
unsigned int B = ctxt->md5_stb;
|
||||||
|
unsigned int C = ctxt->md5_stc;
|
||||||
|
unsigned int D = ctxt->md5_std;
|
||||||
|
|
||||||
|
#ifndef WORDS_BIGENDIAN
|
||||||
|
unsigned int *X = (unsigned int *) b64;
|
||||||
|
#else
|
||||||
|
/* 4 byte words */
|
||||||
|
/* what a brute force but fast! */
|
||||||
|
unsigned char *y = (unsigned char *) X;
|
||||||
|
|
||||||
|
y[0] = b64[3];
|
||||||
|
y[1] = b64[2];
|
||||||
|
y[2] = b64[1];
|
||||||
|
y[3] = b64[0];
|
||||||
|
y[4] = b64[7];
|
||||||
|
y[5] = b64[6];
|
||||||
|
y[6] = b64[5];
|
||||||
|
y[7] = b64[4];
|
||||||
|
y[8] = b64[11];
|
||||||
|
y[9] = b64[10];
|
||||||
|
y[10] = b64[9];
|
||||||
|
y[11] = b64[8];
|
||||||
|
y[12] = b64[15];
|
||||||
|
y[13] = b64[14];
|
||||||
|
y[14] = b64[13];
|
||||||
|
y[15] = b64[12];
|
||||||
|
y[16] = b64[19];
|
||||||
|
y[17] = b64[18];
|
||||||
|
y[18] = b64[17];
|
||||||
|
y[19] = b64[16];
|
||||||
|
y[20] = b64[23];
|
||||||
|
y[21] = b64[22];
|
||||||
|
y[22] = b64[21];
|
||||||
|
y[23] = b64[20];
|
||||||
|
y[24] = b64[27];
|
||||||
|
y[25] = b64[26];
|
||||||
|
y[26] = b64[25];
|
||||||
|
y[27] = b64[24];
|
||||||
|
y[28] = b64[31];
|
||||||
|
y[29] = b64[30];
|
||||||
|
y[30] = b64[29];
|
||||||
|
y[31] = b64[28];
|
||||||
|
y[32] = b64[35];
|
||||||
|
y[33] = b64[34];
|
||||||
|
y[34] = b64[33];
|
||||||
|
y[35] = b64[32];
|
||||||
|
y[36] = b64[39];
|
||||||
|
y[37] = b64[38];
|
||||||
|
y[38] = b64[37];
|
||||||
|
y[39] = b64[36];
|
||||||
|
y[40] = b64[43];
|
||||||
|
y[41] = b64[42];
|
||||||
|
y[42] = b64[41];
|
||||||
|
y[43] = b64[40];
|
||||||
|
y[44] = b64[47];
|
||||||
|
y[45] = b64[46];
|
||||||
|
y[46] = b64[45];
|
||||||
|
y[47] = b64[44];
|
||||||
|
y[48] = b64[51];
|
||||||
|
y[49] = b64[50];
|
||||||
|
y[50] = b64[49];
|
||||||
|
y[51] = b64[48];
|
||||||
|
y[52] = b64[55];
|
||||||
|
y[53] = b64[54];
|
||||||
|
y[54] = b64[53];
|
||||||
|
y[55] = b64[52];
|
||||||
|
y[56] = b64[59];
|
||||||
|
y[57] = b64[58];
|
||||||
|
y[58] = b64[57];
|
||||||
|
y[59] = b64[56];
|
||||||
|
y[60] = b64[63];
|
||||||
|
y[61] = b64[62];
|
||||||
|
y[62] = b64[61];
|
||||||
|
y[63] = b64[60];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ROUND1(A, B, C, D, 0, Sa, 1);
|
||||||
|
ROUND1(D, A, B, C, 1, Sb, 2);
|
||||||
|
ROUND1(C, D, A, B, 2, Sc, 3);
|
||||||
|
ROUND1(B, C, D, A, 3, Sd, 4);
|
||||||
|
ROUND1(A, B, C, D, 4, Sa, 5);
|
||||||
|
ROUND1(D, A, B, C, 5, Sb, 6);
|
||||||
|
ROUND1(C, D, A, B, 6, Sc, 7);
|
||||||
|
ROUND1(B, C, D, A, 7, Sd, 8);
|
||||||
|
ROUND1(A, B, C, D, 8, Sa, 9);
|
||||||
|
ROUND1(D, A, B, C, 9, Sb, 10);
|
||||||
|
ROUND1(C, D, A, B, 10, Sc, 11);
|
||||||
|
ROUND1(B, C, D, A, 11, Sd, 12);
|
||||||
|
ROUND1(A, B, C, D, 12, Sa, 13);
|
||||||
|
ROUND1(D, A, B, C, 13, Sb, 14);
|
||||||
|
ROUND1(C, D, A, B, 14, Sc, 15);
|
||||||
|
ROUND1(B, C, D, A, 15, Sd, 16);
|
||||||
|
|
||||||
|
ROUND2(A, B, C, D, 1, Se, 17);
|
||||||
|
ROUND2(D, A, B, C, 6, Sf, 18);
|
||||||
|
ROUND2(C, D, A, B, 11, Sg, 19);
|
||||||
|
ROUND2(B, C, D, A, 0, Sh, 20);
|
||||||
|
ROUND2(A, B, C, D, 5, Se, 21);
|
||||||
|
ROUND2(D, A, B, C, 10, Sf, 22);
|
||||||
|
ROUND2(C, D, A, B, 15, Sg, 23);
|
||||||
|
ROUND2(B, C, D, A, 4, Sh, 24);
|
||||||
|
ROUND2(A, B, C, D, 9, Se, 25);
|
||||||
|
ROUND2(D, A, B, C, 14, Sf, 26);
|
||||||
|
ROUND2(C, D, A, B, 3, Sg, 27);
|
||||||
|
ROUND2(B, C, D, A, 8, Sh, 28);
|
||||||
|
ROUND2(A, B, C, D, 13, Se, 29);
|
||||||
|
ROUND2(D, A, B, C, 2, Sf, 30);
|
||||||
|
ROUND2(C, D, A, B, 7, Sg, 31);
|
||||||
|
ROUND2(B, C, D, A, 12, Sh, 32);
|
||||||
|
|
||||||
|
ROUND3(A, B, C, D, 5, Si, 33);
|
||||||
|
ROUND3(D, A, B, C, 8, Sj, 34);
|
||||||
|
ROUND3(C, D, A, B, 11, Sk, 35);
|
||||||
|
ROUND3(B, C, D, A, 14, Sl, 36);
|
||||||
|
ROUND3(A, B, C, D, 1, Si, 37);
|
||||||
|
ROUND3(D, A, B, C, 4, Sj, 38);
|
||||||
|
ROUND3(C, D, A, B, 7, Sk, 39);
|
||||||
|
ROUND3(B, C, D, A, 10, Sl, 40);
|
||||||
|
ROUND3(A, B, C, D, 13, Si, 41);
|
||||||
|
ROUND3(D, A, B, C, 0, Sj, 42);
|
||||||
|
ROUND3(C, D, A, B, 3, Sk, 43);
|
||||||
|
ROUND3(B, C, D, A, 6, Sl, 44);
|
||||||
|
ROUND3(A, B, C, D, 9, Si, 45);
|
||||||
|
ROUND3(D, A, B, C, 12, Sj, 46);
|
||||||
|
ROUND3(C, D, A, B, 15, Sk, 47);
|
||||||
|
ROUND3(B, C, D, A, 2, Sl, 48);
|
||||||
|
|
||||||
|
ROUND4(A, B, C, D, 0, Sm, 49);
|
||||||
|
ROUND4(D, A, B, C, 7, Sn, 50);
|
||||||
|
ROUND4(C, D, A, B, 14, So, 51);
|
||||||
|
ROUND4(B, C, D, A, 5, Sp, 52);
|
||||||
|
ROUND4(A, B, C, D, 12, Sm, 53);
|
||||||
|
ROUND4(D, A, B, C, 3, Sn, 54);
|
||||||
|
ROUND4(C, D, A, B, 10, So, 55);
|
||||||
|
ROUND4(B, C, D, A, 1, Sp, 56);
|
||||||
|
ROUND4(A, B, C, D, 8, Sm, 57);
|
||||||
|
ROUND4(D, A, B, C, 15, Sn, 58);
|
||||||
|
ROUND4(C, D, A, B, 6, So, 59);
|
||||||
|
ROUND4(B, C, D, A, 13, Sp, 60);
|
||||||
|
ROUND4(A, B, C, D, 4, Sm, 61);
|
||||||
|
ROUND4(D, A, B, C, 11, Sn, 62);
|
||||||
|
ROUND4(C, D, A, B, 2, So, 63);
|
||||||
|
ROUND4(B, C, D, A, 9, Sp, 64);
|
||||||
|
|
||||||
|
ctxt->md5_sta += A;
|
||||||
|
ctxt->md5_stb += B;
|
||||||
|
ctxt->md5_stc += C;
|
||||||
|
ctxt->md5_std += D;
|
||||||
|
}
|
89
src/tivomirror/tivodecode/md5.h
Normal file
89
src/tivomirror/tivodecode/md5.h
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
/* $PostgreSQL: pgsql/contrib/pgcrypto/md5.h,v 1.8 2003/11/29 22:39:28 pgsql Exp $ */
|
||||||
|
/* $KAME: md5.h,v 1.3 2000/02/22 14:01:18 itojun Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of the project nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _NETINET6_MD5_H_
|
||||||
|
#define _NETINET6_MD5_H_
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define MD5_BUFLEN 64
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
union
|
||||||
|
{
|
||||||
|
unsigned int md5_state32[4];
|
||||||
|
unsigned char md5_state8[16];
|
||||||
|
} md5_st;
|
||||||
|
|
||||||
|
#define md5_sta md5_st.md5_state32[0]
|
||||||
|
#define md5_stb md5_st.md5_state32[1]
|
||||||
|
#define md5_stc md5_st.md5_state32[2]
|
||||||
|
#define md5_std md5_st.md5_state32[3]
|
||||||
|
#define md5_st8 md5_st.md5_state8
|
||||||
|
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct {
|
||||||
|
unsigned int md5_count32_lsw;
|
||||||
|
unsigned int md5_count32_msw;
|
||||||
|
} md5_count64;
|
||||||
|
unsigned char md5_count8[8];
|
||||||
|
} md5_count;
|
||||||
|
#define md5_nl md5_count.md5_count64.md5_count32_lsw
|
||||||
|
#define md5_nh md5_count.md5_count64.md5_count32_msw
|
||||||
|
#define md5_n8 md5_count.md5_count8
|
||||||
|
|
||||||
|
unsigned int md5_i;
|
||||||
|
unsigned char md5_buf[MD5_BUFLEN];
|
||||||
|
} md5_ctxt;
|
||||||
|
|
||||||
|
extern void md5_init(md5_ctxt *);
|
||||||
|
extern void md5_loop(md5_ctxt *, const unsigned char *, size_t);
|
||||||
|
extern void md5_pad(md5_ctxt *);
|
||||||
|
extern void md5_result(unsigned char *, md5_ctxt *);
|
||||||
|
|
||||||
|
/* compatibility */
|
||||||
|
#define MD5_CTX md5_ctxt
|
||||||
|
#define MD5Init(x) md5_init((x))
|
||||||
|
#define MD5Update(x, y, z) md5_loop((x), (y), (z))
|
||||||
|
#define MD5Final(x, y) \
|
||||||
|
do { \
|
||||||
|
md5_pad((y)); \
|
||||||
|
md5_result((x), (y)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /* ! _NETINET6_MD5_H_ */
|
367
src/tivomirror/tivodecode/missing
Executable file
367
src/tivomirror/tivodecode/missing
Executable file
|
@ -0,0 +1,367 @@
|
||||||
|
#! /bin/sh
|
||||||
|
# Common stub for a few missing GNU programs while installing.
|
||||||
|
|
||||||
|
scriptversion=2006-05-10.23
|
||||||
|
|
||||||
|
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
|
||||||
|
# Free Software Foundation, Inc.
|
||||||
|
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
|
||||||
|
|
||||||
|
# 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, 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.
|
||||||
|
|
||||||
|
# As a special exception to the GNU General Public License, if you
|
||||||
|
# distribute this file as part of a program that contains a
|
||||||
|
# configuration script generated by Autoconf, you may include it under
|
||||||
|
# the same distribution terms that you use for the rest of that program.
|
||||||
|
|
||||||
|
if test $# -eq 0; then
|
||||||
|
echo 1>&2 "Try \`$0 --help' for more information"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
run=:
|
||||||
|
sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
|
||||||
|
sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
|
||||||
|
|
||||||
|
# In the cases where this matters, `missing' is being run in the
|
||||||
|
# srcdir already.
|
||||||
|
if test -f configure.ac; then
|
||||||
|
configure_ac=configure.ac
|
||||||
|
else
|
||||||
|
configure_ac=configure.in
|
||||||
|
fi
|
||||||
|
|
||||||
|
msg="missing on your system"
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
--run)
|
||||||
|
# Try to run requested program, and just exit if it succeeds.
|
||||||
|
run=
|
||||||
|
shift
|
||||||
|
"$@" && exit 0
|
||||||
|
# Exit code 63 means version mismatch. This often happens
|
||||||
|
# when the user try to use an ancient version of a tool on
|
||||||
|
# a file that requires a minimum version. In this case we
|
||||||
|
# we should proceed has if the program had been absent, or
|
||||||
|
# if --run hadn't been passed.
|
||||||
|
if test $? = 63; then
|
||||||
|
run=:
|
||||||
|
msg="probably too old"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
-h|--h|--he|--hel|--help)
|
||||||
|
echo "\
|
||||||
|
$0 [OPTION]... PROGRAM [ARGUMENT]...
|
||||||
|
|
||||||
|
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
|
||||||
|
error status if there is no known handling for PROGRAM.
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-h, --help display this help and exit
|
||||||
|
-v, --version output version information and exit
|
||||||
|
--run try to run the given command, and emulate it if it fails
|
||||||
|
|
||||||
|
Supported PROGRAM values:
|
||||||
|
aclocal touch file \`aclocal.m4'
|
||||||
|
autoconf touch file \`configure'
|
||||||
|
autoheader touch file \`config.h.in'
|
||||||
|
autom4te touch the output file, or create a stub one
|
||||||
|
automake touch all \`Makefile.in' files
|
||||||
|
bison create \`y.tab.[ch]', if possible, from existing .[ch]
|
||||||
|
flex create \`lex.yy.c', if possible, from existing .c
|
||||||
|
help2man touch the output file
|
||||||
|
lex create \`lex.yy.c', if possible, from existing .c
|
||||||
|
makeinfo touch the output file
|
||||||
|
tar try tar, gnutar, gtar, then tar without non-portable flags
|
||||||
|
yacc create \`y.tab.[ch]', if possible, from existing .[ch]
|
||||||
|
|
||||||
|
Send bug reports to <bug-automake@gnu.org>."
|
||||||
|
exit $?
|
||||||
|
;;
|
||||||
|
|
||||||
|
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
|
||||||
|
echo "missing $scriptversion (GNU Automake)"
|
||||||
|
exit $?
|
||||||
|
;;
|
||||||
|
|
||||||
|
-*)
|
||||||
|
echo 1>&2 "$0: Unknown \`$1' option"
|
||||||
|
echo 1>&2 "Try \`$0 --help' for more information"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Now exit if we have it, but it failed. Also exit now if we
|
||||||
|
# don't have it and --version was passed (most likely to detect
|
||||||
|
# the program).
|
||||||
|
case $1 in
|
||||||
|
lex|yacc)
|
||||||
|
# Not GNU programs, they don't have --version.
|
||||||
|
;;
|
||||||
|
|
||||||
|
tar)
|
||||||
|
if test -n "$run"; then
|
||||||
|
echo 1>&2 "ERROR: \`tar' requires --run"
|
||||||
|
exit 1
|
||||||
|
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
|
||||||
|
# We have it, but it failed.
|
||||||
|
exit 1
|
||||||
|
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
|
||||||
|
# Could not run --version or --help. This is probably someone
|
||||||
|
# running `$TOOL --version' or `$TOOL --help' to check whether
|
||||||
|
# $TOOL exists and not knowing $TOOL uses missing.
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# If it does not exist, or fails to run (possibly an outdated version),
|
||||||
|
# try to emulate it.
|
||||||
|
case $1 in
|
||||||
|
aclocal*)
|
||||||
|
echo 1>&2 "\
|
||||||
|
WARNING: \`$1' is $msg. You should only need it if
|
||||||
|
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
|
||||||
|
to install the \`Automake' and \`Perl' packages. Grab them from
|
||||||
|
any GNU archive site."
|
||||||
|
touch aclocal.m4
|
||||||
|
;;
|
||||||
|
|
||||||
|
autoconf)
|
||||||
|
echo 1>&2 "\
|
||||||
|
WARNING: \`$1' is $msg. You should only need it if
|
||||||
|
you modified \`${configure_ac}'. You might want to install the
|
||||||
|
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
|
||||||
|
archive site."
|
||||||
|
touch configure
|
||||||
|
;;
|
||||||
|
|
||||||
|
autoheader)
|
||||||
|
echo 1>&2 "\
|
||||||
|
WARNING: \`$1' is $msg. You should only need it if
|
||||||
|
you modified \`acconfig.h' or \`${configure_ac}'. You might want
|
||||||
|
to install the \`Autoconf' and \`GNU m4' packages. Grab them
|
||||||
|
from any GNU archive site."
|
||||||
|
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
|
||||||
|
test -z "$files" && files="config.h"
|
||||||
|
touch_files=
|
||||||
|
for f in $files; do
|
||||||
|
case $f in
|
||||||
|
*:*) touch_files="$touch_files "`echo "$f" |
|
||||||
|
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
|
||||||
|
*) touch_files="$touch_files $f.in";;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
touch $touch_files
|
||||||
|
;;
|
||||||
|
|
||||||
|
automake*)
|
||||||
|
echo 1>&2 "\
|
||||||
|
WARNING: \`$1' is $msg. You should only need it if
|
||||||
|
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
|
||||||
|
You might want to install the \`Automake' and \`Perl' packages.
|
||||||
|
Grab them from any GNU archive site."
|
||||||
|
find . -type f -name Makefile.am -print |
|
||||||
|
sed 's/\.am$/.in/' |
|
||||||
|
while read f; do touch "$f"; done
|
||||||
|
;;
|
||||||
|
|
||||||
|
autom4te)
|
||||||
|
echo 1>&2 "\
|
||||||
|
WARNING: \`$1' is needed, but is $msg.
|
||||||
|
You might have modified some files without having the
|
||||||
|
proper tools for further handling them.
|
||||||
|
You can get \`$1' as part of \`Autoconf' from any GNU
|
||||||
|
archive site."
|
||||||
|
|
||||||
|
file=`echo "$*" | sed -n "$sed_output"`
|
||||||
|
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
|
||||||
|
if test -f "$file"; then
|
||||||
|
touch $file
|
||||||
|
else
|
||||||
|
test -z "$file" || exec >$file
|
||||||
|
echo "#! /bin/sh"
|
||||||
|
echo "# Created by GNU Automake missing as a replacement of"
|
||||||
|
echo "# $ $@"
|
||||||
|
echo "exit 0"
|
||||||
|
chmod +x $file
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
bison|yacc)
|
||||||
|
echo 1>&2 "\
|
||||||
|
WARNING: \`$1' $msg. You should only need it if
|
||||||
|
you modified a \`.y' file. You may need the \`Bison' package
|
||||||
|
in order for those modifications to take effect. You can get
|
||||||
|
\`Bison' from any GNU archive site."
|
||||||
|
rm -f y.tab.c y.tab.h
|
||||||
|
if test $# -ne 1; then
|
||||||
|
eval LASTARG="\${$#}"
|
||||||
|
case $LASTARG in
|
||||||
|
*.y)
|
||||||
|
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
|
||||||
|
if test -f "$SRCFILE"; then
|
||||||
|
cp "$SRCFILE" y.tab.c
|
||||||
|
fi
|
||||||
|
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
|
||||||
|
if test -f "$SRCFILE"; then
|
||||||
|
cp "$SRCFILE" y.tab.h
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
if test ! -f y.tab.h; then
|
||||||
|
echo >y.tab.h
|
||||||
|
fi
|
||||||
|
if test ! -f y.tab.c; then
|
||||||
|
echo 'main() { return 0; }' >y.tab.c
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
lex|flex)
|
||||||
|
echo 1>&2 "\
|
||||||
|
WARNING: \`$1' is $msg. You should only need it if
|
||||||
|
you modified a \`.l' file. You may need the \`Flex' package
|
||||||
|
in order for those modifications to take effect. You can get
|
||||||
|
\`Flex' from any GNU archive site."
|
||||||
|
rm -f lex.yy.c
|
||||||
|
if test $# -ne 1; then
|
||||||
|
eval LASTARG="\${$#}"
|
||||||
|
case $LASTARG in
|
||||||
|
*.l)
|
||||||
|
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
|
||||||
|
if test -f "$SRCFILE"; then
|
||||||
|
cp "$SRCFILE" lex.yy.c
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
if test ! -f lex.yy.c; then
|
||||||
|
echo 'main() { return 0; }' >lex.yy.c
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
help2man)
|
||||||
|
echo 1>&2 "\
|
||||||
|
WARNING: \`$1' is $msg. You should only need it if
|
||||||
|
you modified a dependency of a manual page. You may need the
|
||||||
|
\`Help2man' package in order for those modifications to take
|
||||||
|
effect. You can get \`Help2man' from any GNU archive site."
|
||||||
|
|
||||||
|
file=`echo "$*" | sed -n "$sed_output"`
|
||||||
|
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
|
||||||
|
if test -f "$file"; then
|
||||||
|
touch $file
|
||||||
|
else
|
||||||
|
test -z "$file" || exec >$file
|
||||||
|
echo ".ab help2man is required to generate this page"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
makeinfo)
|
||||||
|
echo 1>&2 "\
|
||||||
|
WARNING: \`$1' is $msg. You should only need it if
|
||||||
|
you modified a \`.texi' or \`.texinfo' file, or any other file
|
||||||
|
indirectly affecting the aspect of the manual. The spurious
|
||||||
|
call might also be the consequence of using a buggy \`make' (AIX,
|
||||||
|
DU, IRIX). You might want to install the \`Texinfo' package or
|
||||||
|
the \`GNU make' package. Grab either from any GNU archive site."
|
||||||
|
# The file to touch is that specified with -o ...
|
||||||
|
file=`echo "$*" | sed -n "$sed_output"`
|
||||||
|
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
|
||||||
|
if test -z "$file"; then
|
||||||
|
# ... or it is the one specified with @setfilename ...
|
||||||
|
infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
|
||||||
|
file=`sed -n '
|
||||||
|
/^@setfilename/{
|
||||||
|
s/.* \([^ ]*\) *$/\1/
|
||||||
|
p
|
||||||
|
q
|
||||||
|
}' $infile`
|
||||||
|
# ... or it is derived from the source name (dir/f.texi becomes f.info)
|
||||||
|
test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
|
||||||
|
fi
|
||||||
|
# If the file does not exist, the user really needs makeinfo;
|
||||||
|
# let's fail without touching anything.
|
||||||
|
test -f $file || exit 1
|
||||||
|
touch $file
|
||||||
|
;;
|
||||||
|
|
||||||
|
tar)
|
||||||
|
shift
|
||||||
|
|
||||||
|
# We have already tried tar in the generic part.
|
||||||
|
# Look for gnutar/gtar before invocation to avoid ugly error
|
||||||
|
# messages.
|
||||||
|
if (gnutar --version > /dev/null 2>&1); then
|
||||||
|
gnutar "$@" && exit 0
|
||||||
|
fi
|
||||||
|
if (gtar --version > /dev/null 2>&1); then
|
||||||
|
gtar "$@" && exit 0
|
||||||
|
fi
|
||||||
|
firstarg="$1"
|
||||||
|
if shift; then
|
||||||
|
case $firstarg in
|
||||||
|
*o*)
|
||||||
|
firstarg=`echo "$firstarg" | sed s/o//`
|
||||||
|
tar "$firstarg" "$@" && exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
case $firstarg in
|
||||||
|
*h*)
|
||||||
|
firstarg=`echo "$firstarg" | sed s/h//`
|
||||||
|
tar "$firstarg" "$@" && exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo 1>&2 "\
|
||||||
|
WARNING: I can't seem to be able to run \`tar' with the given arguments.
|
||||||
|
You may want to install GNU tar or Free paxutils, or check the
|
||||||
|
command line arguments."
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo 1>&2 "\
|
||||||
|
WARNING: \`$1' is needed, and is $msg.
|
||||||
|
You might have modified some files without having the
|
||||||
|
proper tools for further handling them. Check the \`README' file,
|
||||||
|
it often tells you about the needed prerequisites for installing
|
||||||
|
this package. You may also peek at any GNU archive site, in case
|
||||||
|
some other package would contain this missing \`$1' program."
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
# Local variables:
|
||||||
|
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||||
|
# time-stamp-start: "scriptversion="
|
||||||
|
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||||
|
# time-stamp-end: "$"
|
||||||
|
# End:
|
203
src/tivomirror/tivodecode/sha1.c
Normal file
203
src/tivomirror/tivodecode/sha1.c
Normal file
|
@ -0,0 +1,203 @@
|
||||||
|
/*
|
||||||
|
SHA-1 in C
|
||||||
|
By Steve Reid <steve@edmweb.com>
|
||||||
|
100% Public Domain
|
||||||
|
|
||||||
|
Test Vectors (from FIPS PUB 180-1)
|
||||||
|
"abc"
|
||||||
|
A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
|
||||||
|
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
|
||||||
|
84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
|
||||||
|
A million repetitions of "a"
|
||||||
|
34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* #define SHA1HANDSOFF * Copies data before messing with it. */
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "tdconfig.h"
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
|
# include <string.h>
|
||||||
|
#endif
|
||||||
|
#include "sha1.h"
|
||||||
|
#ifdef WIN32
|
||||||
|
# include <windows.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
|
# include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_NETINET_IN_H
|
||||||
|
# include <netinet/in.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void sha1_transform (unsigned int state[5], unsigned char buffer[64]);
|
||||||
|
|
||||||
|
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
|
||||||
|
|
||||||
|
/* blk0() and blk() perform the initial expand. */
|
||||||
|
/* I got the idea of expanding during the round function from SSLeay */
|
||||||
|
|
||||||
|
# define blk0(i) (block->l[i] = htonl (block->l[i]))
|
||||||
|
|
||||||
|
#define blk(i) (block->l[i & 15] = rol (block->l[(i + 13) & 15] ^ block->l[(i + 8) & 15] \
|
||||||
|
^ block->l[(i + 2) & 15] ^ block->l[i & 15], 1))
|
||||||
|
|
||||||
|
/* (R0 + R1), R2, R3, R4 are the different operations used in SHA1 */
|
||||||
|
#define R0(v,w,x,y,z,i) z += ((w & (x ^ y)) ^ y) + blk0(i) + 0x5A827999 + rol(v, 5); w = rol(w, 30);
|
||||||
|
#define R1(v,w,x,y,z,i) z += ((w & (x ^ y)) ^ y) + blk (i) + 0x5A827999 + rol(v, 5); w = rol(w, 30);
|
||||||
|
#define R2(v,w,x,y,z,i) z += (w ^ x ^ y) + blk(i) + 0x6ED9EBA1 + rol(v, 5); w = rol(w, 30);
|
||||||
|
#define R3(v,w,x,y,z,i) z += (((w | x) & y) | (w & x)) + blk(i) + 0x8F1BBCDC + rol(v, 5); w = rol(w, 30);
|
||||||
|
#define R4(v,w,x,y,z,i) z += (w ^ x ^ y) + blk(i) + 0xCA62C1D6 + rol(v, 5); w = rol(w, 30);
|
||||||
|
|
||||||
|
|
||||||
|
/* Hash a single 512-bit block. This is the core of the algorithm. */
|
||||||
|
|
||||||
|
static void sha1_transform (unsigned int state[5], unsigned char buffer[64])
|
||||||
|
{
|
||||||
|
unsigned int a, b, c, d, e;
|
||||||
|
|
||||||
|
typedef union {
|
||||||
|
unsigned char c[64];
|
||||||
|
unsigned int l[16];
|
||||||
|
} CHAR64LONG16;
|
||||||
|
|
||||||
|
CHAR64LONG16 * block;
|
||||||
|
|
||||||
|
#ifdef SHA1HANDSOFF
|
||||||
|
static unsigned char workspace[64];
|
||||||
|
block = (CHAR64LONG16 *)workspace;
|
||||||
|
memcpy(block, buffer, 64);
|
||||||
|
#else
|
||||||
|
block = (CHAR64LONG16 *)buffer;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Copy context->state[] to working vars */
|
||||||
|
a = state[0];
|
||||||
|
b = state[1];
|
||||||
|
c = state[2];
|
||||||
|
d = state[3];
|
||||||
|
e = state[4];
|
||||||
|
|
||||||
|
/* 4 rounds of 20 operations each. Loop unrolled. */
|
||||||
|
R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
|
||||||
|
R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
|
||||||
|
R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
|
||||||
|
R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
|
||||||
|
R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
|
||||||
|
R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
|
||||||
|
R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
|
||||||
|
R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
|
||||||
|
R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
|
||||||
|
R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
|
||||||
|
R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
|
||||||
|
R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
|
||||||
|
R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
|
||||||
|
R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
|
||||||
|
R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
|
||||||
|
R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
|
||||||
|
R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
|
||||||
|
R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
|
||||||
|
R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
|
||||||
|
R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
|
||||||
|
|
||||||
|
/* Add the working vars back into context.state[] */
|
||||||
|
state[0] += a;
|
||||||
|
state[1] += b;
|
||||||
|
state[2] += c;
|
||||||
|
state[3] += d;
|
||||||
|
state[4] += e;
|
||||||
|
|
||||||
|
/* Wipe variables */
|
||||||
|
a = b = c = d = e = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* sha1_init - Initialize new context */
|
||||||
|
|
||||||
|
void sha1_init(SHA1_CTX * context)
|
||||||
|
{
|
||||||
|
/* SHA1 initialization constants */
|
||||||
|
context->state[0] = 0x67452301;
|
||||||
|
context->state[1] = 0xEFCDAB89;
|
||||||
|
context->state[2] = 0x98BADCFE;
|
||||||
|
context->state[3] = 0x10325476;
|
||||||
|
context->state[4] = 0xC3D2E1F0;
|
||||||
|
context->count[0] = context->count[1] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Run your data through this. */
|
||||||
|
|
||||||
|
void sha1_update(SHA1_CTX * context, unsigned char * data, size_t len)
|
||||||
|
{
|
||||||
|
unsigned int i, j;
|
||||||
|
|
||||||
|
j = (context->count[0] >> 3) & 63;
|
||||||
|
|
||||||
|
if ((context->count[0] += (unsigned int)len << 3) < (len << 3))
|
||||||
|
context->count[1]++;
|
||||||
|
|
||||||
|
context->count[1] += (unsigned int)(len >> 29);
|
||||||
|
|
||||||
|
if ((j + len) > 63)
|
||||||
|
{
|
||||||
|
memcpy (&context->buffer[j], data, (i = 64 - j));
|
||||||
|
sha1_transform (context->state, context->buffer);
|
||||||
|
|
||||||
|
for ( ; i + 63 < len; i += 64)
|
||||||
|
{
|
||||||
|
memcpy (context->buffer, &data[i], 64);
|
||||||
|
sha1_transform (context->state, context->buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
j = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy (&context->buffer[j], &data[i], len - i);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Add padding and return the message digest. */
|
||||||
|
|
||||||
|
void sha1_final(unsigned char digest[20], SHA1_CTX * context)
|
||||||
|
{
|
||||||
|
unsigned int i, j;
|
||||||
|
unsigned char finalcount[8];
|
||||||
|
|
||||||
|
for (i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
|
||||||
|
>> ((3 - (i & 3)) * 8) ) & 255); /* Endian independent */
|
||||||
|
}
|
||||||
|
|
||||||
|
sha1_update (context, (unsigned char *)"\200", 1);
|
||||||
|
|
||||||
|
while ((context->count[0] & 504) != 448)
|
||||||
|
{
|
||||||
|
sha1_update (context, (unsigned char *)"\0", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
sha1_update (context, finalcount, 8); /* Should cause a sha1_transform() */
|
||||||
|
|
||||||
|
for (i = 0; i < 20; i++)
|
||||||
|
{
|
||||||
|
digest[i] = (unsigned char)
|
||||||
|
((context->state[i >> 2] >> ((3 - (i & 3)) * 8)) & 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wipe variables */
|
||||||
|
i = j = 0;
|
||||||
|
memset(context->buffer, 0, 64);
|
||||||
|
memset(context->state, 0, 20);
|
||||||
|
memset(context->count, 0, 8);
|
||||||
|
memset(&finalcount, 0, 8);
|
||||||
|
|
||||||
|
#ifdef SHA1HANDSOFF /* make sha1_transform overwrite it's own static vars */
|
||||||
|
sha1_transform(context->state, context->buffer);
|
||||||
|
#endif
|
||||||
|
}
|
24
src/tivomirror/tivodecode/sha1.h
Normal file
24
src/tivomirror/tivodecode/sha1.h
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* tivodecode, (c) 2006, Jeremy Drake
|
||||||
|
* See COPYING file for license terms
|
||||||
|
*/
|
||||||
|
#ifndef SHA1_H_
|
||||||
|
#define SHA1_H_
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
unsigned int state[5];
|
||||||
|
unsigned int count[2];
|
||||||
|
unsigned char buffer[64];
|
||||||
|
} SHA1_CTX;
|
||||||
|
|
||||||
|
void sha1_init (SHA1_CTX * context);
|
||||||
|
void sha1_update (SHA1_CTX * context, unsigned char * data, size_t len);
|
||||||
|
void sha1_final (unsigned char digest[20], SHA1_CTX * context);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
227
src/tivomirror/tivodecode/tdcat.c
Normal file
227
src/tivomirror/tivodecode/tdcat.c
Normal file
|
@ -0,0 +1,227 @@
|
||||||
|
/*
|
||||||
|
* tivodecode, (c) 2006, Jeremy Drake
|
||||||
|
* See COPYING file for license terms
|
||||||
|
*
|
||||||
|
* derived from mpegcat, copyright 2006 Kees Cook, used with permission
|
||||||
|
*/
|
||||||
|
#include "tivodecoder.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#ifdef HAVE_STDLIB_H
|
||||||
|
# include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
|
# include <string.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_CTYPE_H
|
||||||
|
# include <ctype.h>
|
||||||
|
#endif
|
||||||
|
#include "getopt_long.h"
|
||||||
|
#include "happyfile.h"
|
||||||
|
#include "cli_common.h"
|
||||||
|
|
||||||
|
static int hread_wrapper (void * mem, int size, void * fh)
|
||||||
|
{
|
||||||
|
return (int)hread (mem, size, (happy_file *)fh);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct option long_options[] = {
|
||||||
|
{"mak", 1, 0, 'm'},
|
||||||
|
{"out", 1, 0, 'o'},
|
||||||
|
{"help", 0, 0, 'h'},
|
||||||
|
{"version", 0, 0, 'V'},
|
||||||
|
{"chunk-1", 0, 0, '1'},
|
||||||
|
{"chunk-2", 0, 0, '2'},
|
||||||
|
{0, 0, 0, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
static void do_help(char * arg0, int exitval)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Usage: %s [--help] {--mak|-m} mak [{--out|-o} outfile] [{-2|--chunk-2}] <tivofile>\n\n", arg0);
|
||||||
|
#define ERROUT(s) fprintf(stderr, s)
|
||||||
|
ERROUT (" --mak, -m media access key (required)\n");
|
||||||
|
ERROUT (" --out, -o output file (default stdout)\n");
|
||||||
|
ERROUT (" --chunk-1, -1 output chunk 1 (default if neither chunk specified)\n");
|
||||||
|
ERROUT (" --chunk-2, -2 output chunk 2\n");
|
||||||
|
ERROUT (" --version, -V print the version information and exit\n");
|
||||||
|
ERROUT (" --help, -h print this help and exit\n\n");
|
||||||
|
ERROUT ("The file names specified for the output file or the tivo file may be -, which\n");
|
||||||
|
ERROUT ("means stdout or stdin respectively\n\n");
|
||||||
|
#undef ERROUT
|
||||||
|
|
||||||
|
exit (exitval);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int o_chunk_1 = 0;
|
||||||
|
int o_chunk_2 = 0;
|
||||||
|
|
||||||
|
char * tivofile = NULL;
|
||||||
|
char * outfile = NULL;
|
||||||
|
char mak[12];
|
||||||
|
|
||||||
|
int makgiven = 0;
|
||||||
|
|
||||||
|
FILE * ofh;
|
||||||
|
happy_file * hfh=NULL;
|
||||||
|
turing_state metaturing;
|
||||||
|
|
||||||
|
tivo_stream_header head;
|
||||||
|
tivo_stream_chunk *chunk;
|
||||||
|
hoff_t current_meta_stream_pos = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
memset(mak, 0, sizeof(mak));
|
||||||
|
memset(&metaturing, 0, sizeof(metaturing));
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
int c = getopt_long (argc, argv, "m:o:12hV", long_options, 0);
|
||||||
|
|
||||||
|
if (c == -1)
|
||||||
|
break;
|
||||||
|
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case 'm':
|
||||||
|
strncpy(mak, optarg, 11);
|
||||||
|
mak[11] = '\0';
|
||||||
|
makgiven = 1;
|
||||||
|
break;
|
||||||
|
case 'o':
|
||||||
|
outfile = optarg;
|
||||||
|
break;
|
||||||
|
case '1':
|
||||||
|
o_chunk_1 = 1;
|
||||||
|
break;
|
||||||
|
case '2':
|
||||||
|
o_chunk_2 = 1;
|
||||||
|
break;
|
||||||
|
case 'h':
|
||||||
|
case '?':
|
||||||
|
do_help(argv[0], 1);
|
||||||
|
break;
|
||||||
|
case 'V':
|
||||||
|
do_version(10);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
do_help(argv[0], 3);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optind < argc)
|
||||||
|
{
|
||||||
|
tivofile=argv[optind++];
|
||||||
|
if (optind < argc)
|
||||||
|
do_help(argv[0], 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!makgiven)
|
||||||
|
makgiven = get_mak_from_conf_file(mak);
|
||||||
|
|
||||||
|
if (!makgiven || !tivofile)
|
||||||
|
{
|
||||||
|
do_help(argv[0], 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strcmp(tivofile, "-"))
|
||||||
|
{
|
||||||
|
// JKOZEE-Make sure stdin is set to binary on Windows
|
||||||
|
#ifdef WIN32
|
||||||
|
int result = _setmode(_fileno(stdin), _O_BINARY );
|
||||||
|
if( result == -1 ) {
|
||||||
|
perror( "Cannot set stdin to binary mode" );
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
hfh=hattach(stdin);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!(hfh=hopen(tivofile, "rb")))
|
||||||
|
{
|
||||||
|
perror(tivofile);
|
||||||
|
return 6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!outfile || !strcmp(outfile, "-"))
|
||||||
|
{
|
||||||
|
// JKOZEE-Make sure stdout is set to binary on Windows
|
||||||
|
#ifdef WIN32
|
||||||
|
int result = _setmode(_fileno(stdout), _O_BINARY );
|
||||||
|
if( result == -1 ) {
|
||||||
|
perror( "Cannot set stdout to binary mode" );
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
ofh = stdout;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!(ofh = fopen(outfile, "wb")))
|
||||||
|
{
|
||||||
|
perror("opening output file");
|
||||||
|
return 7;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!o_chunk_1 && !o_chunk_2)
|
||||||
|
o_chunk_1 = 1;
|
||||||
|
|
||||||
|
PRINT_QUALCOMM_MSG();
|
||||||
|
|
||||||
|
/* parse the tivo headers manually here, since we care about more
|
||||||
|
* than the init_turing_from_file function will get
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (read_tivo_header (hfh, &head, &hread_wrapper))
|
||||||
|
return 8;
|
||||||
|
|
||||||
|
for (i = 0; i < head.chunks; i++)
|
||||||
|
{
|
||||||
|
hoff_t chunk_start = htell(hfh) + SIZEOF_STREAM_CHUNK;
|
||||||
|
|
||||||
|
if ((chunk = read_tivo_chunk (hfh, &hread_wrapper)) == NULL)
|
||||||
|
return 8;
|
||||||
|
|
||||||
|
if (chunk->data_size && chunk->type == TIVO_CHUNK_PLAINTEXT_XML)
|
||||||
|
{
|
||||||
|
setup_metadata_key (&metaturing, chunk, mak);
|
||||||
|
free (chunk);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((o_chunk_1 && chunk->id == 1) || (o_chunk_2 && chunk->id == 2))
|
||||||
|
{
|
||||||
|
prepare_frame(&metaturing, 0, 0);
|
||||||
|
skip_turing_data(&metaturing, (size_t)(chunk_start - current_meta_stream_pos));
|
||||||
|
decrypt_buffer(&metaturing, chunk->data, chunk->data_size);
|
||||||
|
current_meta_stream_pos = chunk_start + chunk->data_size;
|
||||||
|
|
||||||
|
if (fwrite (chunk->data, 1, chunk->data_size, ofh) != chunk->data_size)
|
||||||
|
{
|
||||||
|
perror("write chunk");
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(chunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
destruct_turing(&metaturing);
|
||||||
|
|
||||||
|
if (hfh->fh == stdin)
|
||||||
|
hdetach(hfh);
|
||||||
|
else
|
||||||
|
hclose(hfh);
|
||||||
|
|
||||||
|
if (ofh != stdout)
|
||||||
|
fclose(ofh);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* vi:set ai ts=4 sw=4 expandtab: */
|
203
src/tivomirror/tivodecode/tdcat.vcproj
Normal file
203
src/tivomirror/tivodecode/tdcat.vcproj
Normal file
|
@ -0,0 +1,203 @@
|
||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="9.00"
|
||||||
|
Name="tdcat"
|
||||||
|
ProjectGUID="{66AEBB90-9BD8-497E-B546-9409110E9F21}"
|
||||||
|
RootNamespace="tdcat"
|
||||||
|
Keyword="Win32Proj"
|
||||||
|
TargetFrameworkVersion="131072"
|
||||||
|
>
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"
|
||||||
|
/>
|
||||||
|
</Platforms>
|
||||||
|
<ToolFiles>
|
||||||
|
</ToolFiles>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||||
|
IntermediateDirectory="$(ConfigurationName)"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="0"
|
||||||
|
WholeProgramOptimization="0"
|
||||||
|
BuildLogFile="$(IntDir)\tdcat_BuildLog.htm"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;HAVE_CONFIG_H"
|
||||||
|
MinimalRebuild="true"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="1"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
ProgramDataBaseFileName="$(IntDir)\tdcat.pdb"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="true"
|
||||||
|
DebugInformationFormat="4"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="ws2_32.lib"
|
||||||
|
LinkIncremental="2"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
SubSystem="1"
|
||||||
|
RandomizedBaseAddress="1"
|
||||||
|
DataExecutionPrevention="0"
|
||||||
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||||
|
IntermediateDirectory="$(ConfigurationName)"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="0"
|
||||||
|
WholeProgramOptimization="1"
|
||||||
|
BuildLogFile="$(IntDir)\tdcat_BuildLog.htm"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;HAVE_CONFIG_H"
|
||||||
|
RuntimeLibrary="0"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
ProgramDataBaseFileName="$(IntDir)\tdcat.pdb"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="true"
|
||||||
|
DebugInformationFormat="3"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="ws2_32.lib"
|
||||||
|
LinkIncremental="1"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
SubSystem="1"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
RandomizedBaseAddress="1"
|
||||||
|
DataExecutionPrevention="0"
|
||||||
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
|
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\tdcat.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||||
|
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||||
|
>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Resource Files"
|
||||||
|
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||||
|
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||||
|
>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
139
src/tivomirror/tivodecode/tdconfig.h.in
Normal file
139
src/tivomirror/tivodecode/tdconfig.h.in
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
/* tdconfig.h.in. Generated from configure.in by autoheader. */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <ctype.h> header file. */
|
||||||
|
#undef HAVE_CTYPE_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `fseeko' function. */
|
||||||
|
#undef HAVE_FSEEKO
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `getopt' function. */
|
||||||
|
#undef HAVE_GETOPT
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <getopt.h> header file. */
|
||||||
|
#undef HAVE_GETOPT_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `getopt_long' function. */
|
||||||
|
#undef HAVE_GETOPT_LONG
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
|
#undef HAVE_INTTYPES_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the global variable 'int optreset'. */
|
||||||
|
#undef HAVE_INT_OPTRESET
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <memory.h> header file. */
|
||||||
|
#undef HAVE_MEMORY_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||||
|
#undef HAVE_NETINET_IN_H
|
||||||
|
|
||||||
|
/* Define to 1 if the system has the type `size_t'. */
|
||||||
|
#undef HAVE_SIZE_T
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdint.h> header file. */
|
||||||
|
#undef HAVE_STDINT_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||||
|
#undef HAVE_STDLIB_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <strings.h> header file. */
|
||||||
|
#undef HAVE_STRINGS_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <string.h> header file. */
|
||||||
|
#undef HAVE_STRING_H
|
||||||
|
|
||||||
|
/* Define to 1 if the system has the type `struct option'. */
|
||||||
|
#undef HAVE_STRUCT_OPTION
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||||
|
#undef HAVE_SYS_STAT_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||||
|
#undef HAVE_SYS_TYPES_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
|
#undef HAVE_UNISTD_H
|
||||||
|
|
||||||
|
/* Define to 1 if the system has the type `unsigned long'. */
|
||||||
|
#undef HAVE_UNSIGNED_LONG
|
||||||
|
|
||||||
|
/* Define to 1 if the system has the type `unsigned long long'. */
|
||||||
|
#undef HAVE_UNSIGNED_LONG_LONG
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <winsock2.h> header file. */
|
||||||
|
#undef HAVE_WINSOCK2_H
|
||||||
|
|
||||||
|
/* Name of package */
|
||||||
|
#undef PACKAGE
|
||||||
|
|
||||||
|
/* Define to the address where bug reports for this package should be sent. */
|
||||||
|
#undef PACKAGE_BUGREPORT
|
||||||
|
|
||||||
|
/* Define to the full name of this package. */
|
||||||
|
#undef PACKAGE_NAME
|
||||||
|
|
||||||
|
/* Define to the full name and version of this package. */
|
||||||
|
#undef PACKAGE_STRING
|
||||||
|
|
||||||
|
/* Define to the one symbol short name of this package. */
|
||||||
|
#undef PACKAGE_TARNAME
|
||||||
|
|
||||||
|
/* Define to the version of this package. */
|
||||||
|
#undef PACKAGE_VERSION
|
||||||
|
|
||||||
|
/* The size of `off_t', as computed by sizeof. */
|
||||||
|
#undef SIZEOF_OFF_T
|
||||||
|
|
||||||
|
/* The size of `size_t', as computed by sizeof. */
|
||||||
|
#undef SIZEOF_SIZE_T
|
||||||
|
|
||||||
|
/* The size of `unsigned long', as computed by sizeof. */
|
||||||
|
#undef SIZEOF_UNSIGNED_LONG
|
||||||
|
|
||||||
|
/* The size of `unsigned long long', as computed by sizeof. */
|
||||||
|
#undef SIZEOF_UNSIGNED_LONG_LONG
|
||||||
|
|
||||||
|
/* Define to 1 if you have the ANSI C header files. */
|
||||||
|
#undef STDC_HEADERS
|
||||||
|
|
||||||
|
/* Version number of package */
|
||||||
|
#undef VERSION
|
||||||
|
|
||||||
|
/* Define to 1 if your processor stores words with the most significant byte
|
||||||
|
first (like Motorola and SPARC, unlike Intel and VAX). */
|
||||||
|
#undef WORDS_BIGENDIAN
|
||||||
|
|
||||||
|
/* Define to 1 if on AIX 3.
|
||||||
|
System headers sometimes define this.
|
||||||
|
We just want to avoid a redefinition error message. */
|
||||||
|
#ifndef _ALL_SOURCE
|
||||||
|
# undef _ALL_SOURCE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||||
|
#undef _FILE_OFFSET_BITS
|
||||||
|
|
||||||
|
/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
|
||||||
|
#undef _LARGEFILE_SOURCE
|
||||||
|
|
||||||
|
/* Define for large files, on AIX-style hosts. */
|
||||||
|
#undef _LARGE_FILES
|
||||||
|
|
||||||
|
/* Define to 1 if on MINIX. */
|
||||||
|
#undef _MINIX
|
||||||
|
|
||||||
|
/* Define to 2 if the system does not provide POSIX.1 features except with
|
||||||
|
this defined. */
|
||||||
|
#undef _POSIX_1_SOURCE
|
||||||
|
|
||||||
|
/* Define to 1 if you need to in order for `stat' and other things to work. */
|
||||||
|
#undef _POSIX_SOURCE
|
||||||
|
|
||||||
|
/* Define to `__inline__' or `__inline' if that's what the C compiler
|
||||||
|
calls it, or to nothing if 'inline' is not supported under any name. */
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#undef inline
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Define to `long int' if <sys/types.h> does not define. */
|
||||||
|
#undef off_t
|
150
src/tivomirror/tivodecode/tdconfig.h.win32
Normal file
150
src/tivomirror/tivodecode/tdconfig.h.win32
Normal file
|
@ -0,0 +1,150 @@
|
||||||
|
/* tdconfig.h. Generated from tdconfig.h.in by configure. */
|
||||||
|
/* tdconfig.h.in. Generated from configure.in by autoheader. */
|
||||||
|
|
||||||
|
/* This file is generated from MingW ./configure, and with the following
|
||||||
|
* changes to be valid for Visual C++ (and compatible):
|
||||||
|
*
|
||||||
|
* HAVE_CBRT, HAVE_FUNCNAME_FUNC, HAVE_FUNCNAME_FUNCTION, HAVE_GETOPT,
|
||||||
|
* HAVE_GETOPT_H, HAVE_GETOPT_LONG, HAVE_RINT, HAVE_STRINGS_H,
|
||||||
|
* HAVE_STRTOLL, HAVE_STRTOULL, HAVE_STRUCT_OPTION, ENABLE_THREAD_SAFETY
|
||||||
|
*
|
||||||
|
* For now, also HAVE_IPV6, HAVE_UNISTD_H
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <ctype.h> header file. */
|
||||||
|
#define HAVE_CTYPE_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `fseeko' function. */
|
||||||
|
/* #undef HAVE_FSEEKO */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `getopt' function. */
|
||||||
|
//#define HAVE_GETOPT 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <getopt.h> header file. */
|
||||||
|
//#define HAVE_GETOPT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `getopt_long' function. */
|
||||||
|
//#define HAVE_GETOPT_LONG 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
|
#define HAVE_INTTYPES_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the global variable 'int optreset'. */
|
||||||
|
#define HAVE_INT_OPTRESET 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <memory.h> header file. */
|
||||||
|
#define HAVE_MEMORY_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||||
|
/* #undef HAVE_NETINET_IN_H */
|
||||||
|
|
||||||
|
/* Define to 1 if the system has the type `size_t'. */
|
||||||
|
#define HAVE_SIZE_T 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdint.h> header file. */
|
||||||
|
#define HAVE_STDINT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||||
|
#define HAVE_STDLIB_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <strings.h> header file. */
|
||||||
|
//#define HAVE_STRINGS_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <string.h> header file. */
|
||||||
|
#define HAVE_STRING_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if the system has the type `struct option'. */
|
||||||
|
//#define HAVE_STRUCT_OPTION 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||||
|
#define HAVE_SYS_STAT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||||
|
#define HAVE_SYS_TYPES_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
|
//#define HAVE_UNISTD_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if the system has the type `unsigned long'. */
|
||||||
|
#define HAVE_UNSIGNED_LONG 1
|
||||||
|
|
||||||
|
/* Define to 1 if the system has the type `unsigned long long'. */
|
||||||
|
#define HAVE_UNSIGNED_LONG_LONG 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <winsock2.h> header file. */
|
||||||
|
#define HAVE_WINSOCK2_H 1
|
||||||
|
|
||||||
|
/* Name of package */
|
||||||
|
#define PACKAGE "tivodecode"
|
||||||
|
|
||||||
|
/* Define to the address where bug reports for this package should be sent. */
|
||||||
|
#define PACKAGE_BUGREPORT ""
|
||||||
|
|
||||||
|
/* Define to the full name of this package. */
|
||||||
|
#define PACKAGE_NAME "tivodecode"
|
||||||
|
|
||||||
|
/* Define to the full name and version of this package. */
|
||||||
|
#define PACKAGE_STRING "tivodecode 0.3pre4"
|
||||||
|
|
||||||
|
/* Define to the one symbol short name of this package. */
|
||||||
|
#define PACKAGE_TARNAME "tivodecode"
|
||||||
|
|
||||||
|
/* Define to the version of this package. */
|
||||||
|
#define PACKAGE_VERSION "0.3pre4"
|
||||||
|
|
||||||
|
/* The size of `off_t', as computed by sizeof. */
|
||||||
|
#define SIZEOF_OFF_T 4
|
||||||
|
|
||||||
|
/* The size of `size_t', as computed by sizeof. */
|
||||||
|
#define SIZEOF_SIZE_T 4
|
||||||
|
|
||||||
|
/* The size of `unsigned long', as computed by sizeof. */
|
||||||
|
#define SIZEOF_UNSIGNED_LONG 4
|
||||||
|
|
||||||
|
/* The size of `unsigned long long', as computed by sizeof. */
|
||||||
|
#define SIZEOF_UNSIGNED_LONG_LONG 8
|
||||||
|
|
||||||
|
/* Define to 1 if you have the ANSI C header files. */
|
||||||
|
#define STDC_HEADERS 1
|
||||||
|
|
||||||
|
/* Version number of package */
|
||||||
|
#define VERSION "0.3pre4"
|
||||||
|
|
||||||
|
/* Define to 1 if your processor stores words with the most significant byte
|
||||||
|
first (like Motorola and SPARC, unlike Intel and VAX). */
|
||||||
|
/* #undef WORDS_BIGENDIAN */
|
||||||
|
|
||||||
|
/* Define to 1 if on AIX 3.
|
||||||
|
System headers sometimes define this.
|
||||||
|
We just want to avoid a redefinition error message. */
|
||||||
|
#ifndef _ALL_SOURCE
|
||||||
|
/* # undef _ALL_SOURCE */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||||
|
/* #undef _FILE_OFFSET_BITS */
|
||||||
|
|
||||||
|
/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
|
||||||
|
/* #undef _LARGEFILE_SOURCE */
|
||||||
|
|
||||||
|
/* Define for large files, on AIX-style hosts. */
|
||||||
|
/* #undef _LARGE_FILES */
|
||||||
|
|
||||||
|
/* Define to 1 if on MINIX. */
|
||||||
|
/* #undef _MINIX */
|
||||||
|
|
||||||
|
/* Define to 2 if the system does not provide POSIX.1 features except with
|
||||||
|
this defined. */
|
||||||
|
/* #undef _POSIX_1_SOURCE */
|
||||||
|
|
||||||
|
/* Define to 1 if you need to in order for `stat' and other things to work. */
|
||||||
|
/* #undef _POSIX_SOURCE */
|
||||||
|
|
||||||
|
/* Define to `__inline__' or `__inline' if that's what the C compiler
|
||||||
|
calls it, or to nothing if 'inline' is not supported under any name. */
|
||||||
|
#ifndef __cplusplus
|
||||||
|
/* #undef inline */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Define to `long int' if <sys/types.h> does not define. */
|
||||||
|
/* #undef off_t */
|
176
src/tivomirror/tivodecode/tivo-parse.c
Normal file
176
src/tivomirror/tivodecode/tivo-parse.c
Normal file
|
@ -0,0 +1,176 @@
|
||||||
|
/*
|
||||||
|
* tivodecode, (c) 2006, Jeremy Drake
|
||||||
|
* See COPYING file for license terms
|
||||||
|
*/
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "tdconfig.h"
|
||||||
|
#endif
|
||||||
|
#include <stdio.h>
|
||||||
|
#ifdef HAVE_STDLIB_H
|
||||||
|
# include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
|
# include <string.h>
|
||||||
|
#endif
|
||||||
|
#ifdef WIN32
|
||||||
|
# include <windows.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
|
# include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_NETINET_IN_H
|
||||||
|
# include <netinet/in.h>
|
||||||
|
#endif
|
||||||
|
#include "sha1.h"
|
||||||
|
#include "tivo-parse.h"
|
||||||
|
|
||||||
|
#include "hexlib.h"
|
||||||
|
|
||||||
|
#define LOAD_NET_UNALIGNED_HELP(ptr, offset, len) ((unsigned int)ptr[offset] << (((len - 1) << 3) - (offset << 3)))
|
||||||
|
|
||||||
|
#define NETLONG_UNALIGNED(ptr) ( \
|
||||||
|
LOAD_NET_UNALIGNED_HELP(ptr, 0, 4) | \
|
||||||
|
LOAD_NET_UNALIGNED_HELP(ptr, 1, 4) | \
|
||||||
|
LOAD_NET_UNALIGNED_HELP(ptr, 2, 4) | \
|
||||||
|
LOAD_NET_UNALIGNED_HELP(ptr, 3, 4) \
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
int isBigEndian()
|
||||||
|
{
|
||||||
|
unsigned char EndianTest[2] = {1,0};
|
||||||
|
short x = *(short *)EndianTest;
|
||||||
|
|
||||||
|
if( x == 1 )
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long portable_ntohl( unsigned char * pVal )
|
||||||
|
{
|
||||||
|
unsigned long s = 0;
|
||||||
|
if ( isBigEndian() )
|
||||||
|
{
|
||||||
|
return *(unsigned long *)pVal;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
s = (pVal[0] << 24) | (pVal[1] << 16) | (pVal[2]<<8) | pVal[3];
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned short portable_ntohs( unsigned char * pVal )
|
||||||
|
{
|
||||||
|
unsigned short s = 0;
|
||||||
|
if ( isBigEndian() )
|
||||||
|
{
|
||||||
|
return *(unsigned short *)pVal;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
s = (pVal[0] << 8) | pVal[1];
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int read_tivo_header(void * file, tivo_stream_header * head, read_func_t read_handler)
|
||||||
|
{
|
||||||
|
struct {
|
||||||
|
char filetype[4];
|
||||||
|
/* all fields are in network byte order */
|
||||||
|
unsigned short dummy_0004;
|
||||||
|
unsigned short dummy_0006;
|
||||||
|
unsigned short dummy_0008;
|
||||||
|
unsigned char mpeg_offset[4]; /* unsigned int */
|
||||||
|
unsigned short chunks;
|
||||||
|
} raw_tivo_header;
|
||||||
|
|
||||||
|
|
||||||
|
if (read_handler (&raw_tivo_header, SIZEOF_STREAM_HEADER, file) != SIZEOF_STREAM_HEADER)
|
||||||
|
{
|
||||||
|
perror ("read head");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(head->filetype, raw_tivo_header.filetype, 4);
|
||||||
|
head->dummy_0004 = ntohs(raw_tivo_header.dummy_0004);
|
||||||
|
head->dummy_0006 = ntohs(raw_tivo_header.dummy_0006);
|
||||||
|
head->dummy_0008 = ntohs(raw_tivo_header.dummy_0008);
|
||||||
|
head->mpeg_offset = NETLONG_UNALIGNED(raw_tivo_header.mpeg_offset);
|
||||||
|
head->chunks = ntohs(raw_tivo_header.chunks);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
tivo_stream_chunk * read_tivo_chunk(void * file, read_func_t read_handler)
|
||||||
|
{
|
||||||
|
tivo_stream_chunk * chunk;
|
||||||
|
unsigned int chunk_sz;
|
||||||
|
tivo_stream_chunk raw_chunk_header;
|
||||||
|
|
||||||
|
if (read_handler (&raw_chunk_header, SIZEOF_STREAM_CHUNK, file) != SIZEOF_STREAM_CHUNK)
|
||||||
|
{
|
||||||
|
perror("read chunk head");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
chunk_sz = ntohl(raw_chunk_header.chunk_size);
|
||||||
|
|
||||||
|
/* allocate the memory for the chunk */
|
||||||
|
if (!(chunk = (tivo_stream_chunk *)malloc(chunk_sz)))
|
||||||
|
{
|
||||||
|
perror("malloc");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// network byte order conversion
|
||||||
|
chunk->chunk_size = chunk_sz;
|
||||||
|
chunk->data_size = ntohl(raw_chunk_header.data_size);
|
||||||
|
chunk->id = ntohs(raw_chunk_header.id );
|
||||||
|
chunk->type = ntohs(raw_chunk_header.type );
|
||||||
|
|
||||||
|
/* read the rest of the chunk */
|
||||||
|
if (read_handler(chunk->data, (int)chunk_sz - SIZEOF_STREAM_CHUNK, file)
|
||||||
|
!= chunk_sz - SIZEOF_STREAM_CHUNK)
|
||||||
|
{
|
||||||
|
perror("read chunk data");
|
||||||
|
free(chunk);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return chunk;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dump_tivo_header(tivo_stream_header * head)
|
||||||
|
{
|
||||||
|
if ( !head )
|
||||||
|
return;
|
||||||
|
|
||||||
|
printf("Head File Type : %s\n", head->filetype );
|
||||||
|
printf("Head Dummy4 : %04x\n", head->dummy_0004 );
|
||||||
|
printf("Head Dummy6 : %04x\n", head->dummy_0006 );
|
||||||
|
printf("Head Dummy8 : %04x\n", head->dummy_0008 );
|
||||||
|
printf("MPEG offset : %d\n", head->mpeg_offset );
|
||||||
|
printf("Head Chunks : %d\n", head->chunks );
|
||||||
|
printf("\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void dump_tivo_chunk(tivo_stream_chunk * chunk)
|
||||||
|
{
|
||||||
|
if ( !chunk )
|
||||||
|
return;
|
||||||
|
|
||||||
|
printf("Chunk Size : %d\n", chunk->chunk_size );
|
||||||
|
printf("Data Size : %d\n", chunk->data_size );
|
||||||
|
printf("Chunk ID : %d\n", chunk->id );
|
||||||
|
printf("Chunk Type : %d\n", chunk->type );
|
||||||
|
printf("Chunk Data : \n" );
|
||||||
|
hexbulk( (unsigned char *)chunk->data, (int) chunk->data_size );
|
||||||
|
printf("\n");
|
||||||
|
return;
|
||||||
|
}
|
68
src/tivomirror/tivodecode/tivo-parse.h
Normal file
68
src/tivomirror/tivodecode/tivo-parse.h
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
/*
|
||||||
|
* tivodecode, (c) 2006, Jeremy Drake
|
||||||
|
* See COPYING file for license terms
|
||||||
|
*/
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#ifndef TIVO_PARSE_H_
|
||||||
|
#define TIVO_PARSE_H_
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initial header formats lifted from ezrec's posting:
|
||||||
|
* http://www.dealdatabase.com/forum/showthread.php?t=41132
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* All elements are in big-endian format and are packed */
|
||||||
|
|
||||||
|
#define SIZEOF_STREAM_HEADER 16
|
||||||
|
typedef struct tivo_stream_header_s {
|
||||||
|
char filetype[4]; /* the string 'TiVo' */
|
||||||
|
unsigned short dummy_0004;
|
||||||
|
unsigned short dummy_0006;
|
||||||
|
unsigned short dummy_0008;
|
||||||
|
unsigned int mpeg_offset; /* 0-based offset of MPEG stream */
|
||||||
|
unsigned short chunks; /* Number of metadata chunks */
|
||||||
|
} tivo_stream_header;
|
||||||
|
|
||||||
|
#define TIVO_CHUNK_PLAINTEXT_XML 0
|
||||||
|
#define TIVO_CHUNK_ENCRYPTED_XML 1
|
||||||
|
|
||||||
|
#define SIZEOF_STREAM_CHUNK 12
|
||||||
|
typedef struct tivo_stream_chunk_s {
|
||||||
|
unsigned int chunk_size; /* Size of chunk */
|
||||||
|
unsigned int data_size; /* Length of the payload */
|
||||||
|
unsigned short id; /* Chunk ID */
|
||||||
|
unsigned short type; /* Subtype */
|
||||||
|
unsigned char data[1]; /* Variable length data */
|
||||||
|
} tivo_stream_chunk;
|
||||||
|
|
||||||
|
/* genericized read function so that different underlying implementations can
|
||||||
|
* be swapped out for more of a library setup
|
||||||
|
*/
|
||||||
|
typedef int (*read_func_t) (void * mem, int size, void * fh);
|
||||||
|
|
||||||
|
int read_tivo_header(void * file, tivo_stream_header * head, read_func_t read_handler);
|
||||||
|
tivo_stream_chunk * read_tivo_chunk(void * file, read_func_t read_handler);
|
||||||
|
|
||||||
|
void dump_tivo_header(tivo_stream_header * head);
|
||||||
|
void dump_tivo_chunk(tivo_stream_chunk * chunk);
|
||||||
|
|
||||||
|
extern int isBigEndian();
|
||||||
|
extern unsigned short portable_ntohs( unsigned char * pVal );
|
||||||
|
extern unsigned long portable_ntohl( unsigned char * pVal );
|
||||||
|
|
||||||
|
#define VERBOSE(...) if ( o_verbose >= 1 ) { printf(__VA_ARGS__); }
|
||||||
|
#define VVERBOSE(...) if ( o_verbose >= 2 ) { printf(__VA_ARGS__); }
|
||||||
|
#define VVVERBOSE(...) if ( o_verbose >= 3 ) { printf(__VA_ARGS__); }
|
||||||
|
|
||||||
|
#define IS_VERBOSE ( o_verbose >= 1 )
|
||||||
|
#define IS_VVERBOSE ( o_verbose >= 2 )
|
||||||
|
#define IS_VVVERBOSE ( o_verbose >= 3 )
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
396
src/tivomirror/tivodecode/tivodecode.c
Normal file
396
src/tivomirror/tivodecode/tivodecode.c
Normal file
|
@ -0,0 +1,396 @@
|
||||||
|
/*
|
||||||
|
* tivodecode, (c) 2006, Jeremy Drake
|
||||||
|
* See COPYING file for license terms
|
||||||
|
*
|
||||||
|
* derived from mpegcat, copyright 2006 Kees Cook, used with permission
|
||||||
|
*/
|
||||||
|
#include "tivodecoder.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#ifdef HAVE_STDLIB_H
|
||||||
|
# include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
|
# include <string.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_CTYPE_H
|
||||||
|
# include <ctype.h>
|
||||||
|
#endif
|
||||||
|
#include "getopt_long.h"
|
||||||
|
#include "happyfile.h"
|
||||||
|
#include "cli_common.h"
|
||||||
|
#include "tivo-parse.h"
|
||||||
|
|
||||||
|
int o_ts_pkt_dump = 0;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
TIVO_FORMAT_NONE,
|
||||||
|
TIVO_FORMAT_PS,
|
||||||
|
TIVO_FORMAT_TS,
|
||||||
|
TIVO_FORMAT_MAX
|
||||||
|
}
|
||||||
|
tivo_format_type;
|
||||||
|
|
||||||
|
static int hread_wrapper (void * mem, int size, void * fh)
|
||||||
|
{
|
||||||
|
return (int)hread (mem, size, (happy_file *)fh);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int fwrite_wrapper (void * mem, int size, void * fh)
|
||||||
|
{
|
||||||
|
return (int)fwrite (mem, 1, size, (FILE *)fh);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct option long_options[] = {
|
||||||
|
{"mak", 1, 0, 'm'},
|
||||||
|
{"out", 1, 0, 'o'},
|
||||||
|
{"help", 0, 0, 'h'},
|
||||||
|
{"verbose", 0, 0, 'v'},
|
||||||
|
{"pkt-dump", 1, 0, 'p'},
|
||||||
|
{"version", 0, 0, 'V'},
|
||||||
|
{"no-verify", 0, 0, 'n'},
|
||||||
|
{"metadata", 0, 0, 'D'},
|
||||||
|
{"no-video", 0, 0, 'x'},
|
||||||
|
{0, 0, 0, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
static void do_help(char * arg0, int exitval)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Usage: %s [--help] [--verbose|-v] [--no-verify|-n] [--pkt-dump|-p] pkt_num {--mak|-m} mak [--metadata|-D] [{--out|-o} outfile] <tivofile>\n\n", arg0);
|
||||||
|
#define ERROUT(s) fprintf(stderr, s)
|
||||||
|
ERROUT (" --mak, -m media access key (required)\n");
|
||||||
|
ERROUT (" --out, -o output file (default stdout)\n");
|
||||||
|
ERROUT (" --verbose, -v verbose\n");
|
||||||
|
ERROUT (" --pkt-dump, -p verbose logging for specific TS packet number\n");
|
||||||
|
ERROUT (" --metadata, -D dump TiVo recording metadata\n");
|
||||||
|
ERROUT (" --no-verify, -n do not verify MAK while decoding\n");
|
||||||
|
ERROUT (" --no-video, -x don't decode video, exit after metadata\n");
|
||||||
|
ERROUT (" --version, -V print the version information and exit\n");
|
||||||
|
ERROUT (" --help, -h print this help and exit\n\n");
|
||||||
|
ERROUT ("The file names specified for the output file or the tivo file may be -, which\n");
|
||||||
|
ERROUT ("means stdout or stdin respectively\n\n");
|
||||||
|
#undef ERROUT
|
||||||
|
|
||||||
|
exit (exitval);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int o_no_video = 0;
|
||||||
|
int o_dump_chunks = 1;
|
||||||
|
int o_dump_metadata = 0;
|
||||||
|
unsigned int marker;
|
||||||
|
unsigned char byte;
|
||||||
|
char first = 1;
|
||||||
|
|
||||||
|
tivo_format_type format = TIVO_FORMAT_NONE;
|
||||||
|
|
||||||
|
int running = 1;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
char * tivofile = NULL;
|
||||||
|
char * outfile = NULL;
|
||||||
|
char mak[12];
|
||||||
|
|
||||||
|
int makgiven = 0;
|
||||||
|
|
||||||
|
turing_state turing;
|
||||||
|
|
||||||
|
FILE * ofh;
|
||||||
|
happy_file * hfh=NULL;
|
||||||
|
// file position options
|
||||||
|
hoff_t begin_at = 0;
|
||||||
|
|
||||||
|
memset(&turing, 0, sizeof(turing));
|
||||||
|
memset(mak, 0, sizeof(mak));
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
int c = getopt_long (argc, argv, "m:o:hnDxvV", long_options, 0);
|
||||||
|
|
||||||
|
if (c == -1)
|
||||||
|
break;
|
||||||
|
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case 'm':
|
||||||
|
strncpy(mak, optarg, 11);
|
||||||
|
mak[11] = '\0';
|
||||||
|
makgiven = 1;
|
||||||
|
break;
|
||||||
|
case 'p':
|
||||||
|
sscanf(optarg, "%d", &o_ts_pkt_dump);
|
||||||
|
break;
|
||||||
|
case 'o':
|
||||||
|
outfile = optarg;
|
||||||
|
break;
|
||||||
|
case 'h':
|
||||||
|
do_help(argv[0], 1);
|
||||||
|
break;
|
||||||
|
case 'v':
|
||||||
|
o_verbose++;
|
||||||
|
break;
|
||||||
|
case 'n':
|
||||||
|
o_no_verify = 1;
|
||||||
|
break;
|
||||||
|
case 'D' :
|
||||||
|
o_dump_metadata = 1;
|
||||||
|
break;
|
||||||
|
case 'x':
|
||||||
|
o_no_video = 1;
|
||||||
|
break;
|
||||||
|
case '?':
|
||||||
|
do_help(argv[0], 2);
|
||||||
|
break;
|
||||||
|
case 'V':
|
||||||
|
do_version(10);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
do_help(argv[0], 3);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optind < argc)
|
||||||
|
{
|
||||||
|
tivofile=argv[optind++];
|
||||||
|
if (optind < argc)
|
||||||
|
do_help(argv[0], 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!makgiven)
|
||||||
|
makgiven = get_mak_from_conf_file(mak);
|
||||||
|
|
||||||
|
if (!makgiven || !tivofile)
|
||||||
|
{
|
||||||
|
do_help(argv[0], 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strcmp(tivofile, "-"))
|
||||||
|
{
|
||||||
|
// JKOZEE-Make sure stdin is set to binary on Windows
|
||||||
|
#ifdef WIN32
|
||||||
|
int result = _setmode(_fileno(stdin), _O_BINARY );
|
||||||
|
if( result == -1 ) {
|
||||||
|
perror( "Cannot set stdin to binary mode" );
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
hfh=hattach(stdin);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!(hfh=hopen(tivofile, "rb")))
|
||||||
|
{
|
||||||
|
perror(tivofile);
|
||||||
|
return 6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!outfile || !strcmp(outfile, "-"))
|
||||||
|
{
|
||||||
|
// JKOZEE-Make sure stdout is set to binary on Windows
|
||||||
|
#ifdef WIN32
|
||||||
|
int result = _setmode(_fileno(stdout), _O_BINARY );
|
||||||
|
if( result == -1 ) {
|
||||||
|
perror( "Cannot set stdout to binary mode" );
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
ofh = stdout;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!(ofh = fopen(outfile, "wb")))
|
||||||
|
{
|
||||||
|
perror("opening output file");
|
||||||
|
return 7;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PRINT_QUALCOMM_MSG();
|
||||||
|
|
||||||
|
if (o_dump_chunks)
|
||||||
|
{
|
||||||
|
/* parse the tivo headers manually here, since we care about more
|
||||||
|
* than the init_turing_from_file function will get
|
||||||
|
*/
|
||||||
|
tivo_stream_header head;
|
||||||
|
tivo_stream_chunk *chunk;
|
||||||
|
turing_state metaturing;
|
||||||
|
hoff_t current_meta_stream_pos = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
memset(&metaturing, 0, sizeof(metaturing));
|
||||||
|
|
||||||
|
if (read_tivo_header (hfh, &head, &hread_wrapper))
|
||||||
|
return 8;
|
||||||
|
|
||||||
|
VVVERBOSE("TiVo Head\n");
|
||||||
|
if ( IS_VVVERBOSE )
|
||||||
|
dump_tivo_header(&head);
|
||||||
|
|
||||||
|
begin_at = head.mpeg_offset;
|
||||||
|
|
||||||
|
if ( head.dummy_0006 & 0x20 )
|
||||||
|
{
|
||||||
|
format = TIVO_FORMAT_TS;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
format = TIVO_FORMAT_PS;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=0; i<head.chunks; i++)
|
||||||
|
{
|
||||||
|
/* TODO: find a better way to present the chunks */
|
||||||
|
/* maybe a simple tar format writer */
|
||||||
|
char buf[4096];
|
||||||
|
hoff_t chunk_start = htell(hfh) + SIZEOF_STREAM_CHUNK;
|
||||||
|
|
||||||
|
if ((chunk = read_tivo_chunk (hfh, &hread_wrapper)) == NULL)
|
||||||
|
return 8;
|
||||||
|
|
||||||
|
if (chunk->data_size && chunk->type == TIVO_CHUNK_PLAINTEXT_XML )
|
||||||
|
{
|
||||||
|
if ( IS_VVVERBOSE )
|
||||||
|
dump_tivo_chunk(chunk);
|
||||||
|
|
||||||
|
if (!o_no_video)
|
||||||
|
setup_turing_key (&turing, chunk, mak);
|
||||||
|
setup_metadata_key (&metaturing, chunk, mak);
|
||||||
|
free (chunk);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ( o_dump_metadata )
|
||||||
|
{
|
||||||
|
FILE * chunkfh;
|
||||||
|
|
||||||
|
sprintf(buf, "%s-%02d-%04x.xml", "chunk", i, chunk->id);
|
||||||
|
|
||||||
|
chunkfh = fopen(buf, "wb");
|
||||||
|
if (!chunkfh)
|
||||||
|
{
|
||||||
|
perror("create metadata file");
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
prepare_frame(&metaturing, 0, 0);
|
||||||
|
skip_turing_data(&metaturing, (size_t)(chunk_start - current_meta_stream_pos));
|
||||||
|
decrypt_buffer(&metaturing, chunk->data, chunk->data_size);
|
||||||
|
current_meta_stream_pos = chunk_start + chunk->data_size;
|
||||||
|
|
||||||
|
if (IS_VVVERBOSE)
|
||||||
|
dump_tivo_chunk(chunk);
|
||||||
|
|
||||||
|
if (fwrite (chunk->data, 1, chunk->data_size, chunkfh) != chunk->data_size)
|
||||||
|
{
|
||||||
|
perror("write chunk");
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(chunkfh);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(chunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
destruct_turing(&metaturing);
|
||||||
|
if (o_no_video)
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (o_no_video)
|
||||||
|
exit(0);
|
||||||
|
|
||||||
|
if ((begin_at = init_turing_from_file (&turing, hfh, &hread_wrapper, mak)) < 0)
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hseek(hfh, begin_at, SEEK_SET) < 0)
|
||||||
|
{
|
||||||
|
perror ("seek");
|
||||||
|
return 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( format == TIVO_FORMAT_TS )
|
||||||
|
{
|
||||||
|
running = 1;
|
||||||
|
while ( running )
|
||||||
|
{
|
||||||
|
ret = process_ts_frame(&turing, htell(hfh), hfh, &hread_wrapper, ofh, &fwrite_wrapper);
|
||||||
|
if ( ret < 0 )
|
||||||
|
{
|
||||||
|
perror ("processing frame");
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
else if ( ret == 0 )
|
||||||
|
{
|
||||||
|
fprintf(stderr, "End of File\n");
|
||||||
|
running = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( format == TIVO_FORMAT_PS )
|
||||||
|
{
|
||||||
|
marker = 0xFFFFFFFF;
|
||||||
|
while (running)
|
||||||
|
{
|
||||||
|
if ((marker & 0xFFFFFF00) == 0x100)
|
||||||
|
{
|
||||||
|
ret = process_ps_frame(byte, &turing, htell(hfh), hfh, &hread_wrapper, ofh, &fwrite_wrapper);
|
||||||
|
|
||||||
|
if (ret == 1)
|
||||||
|
{
|
||||||
|
marker = 0xFFFFFFFF;
|
||||||
|
}
|
||||||
|
else if (ret == 0)
|
||||||
|
{
|
||||||
|
fwrite(&byte, 1, 1, ofh);
|
||||||
|
}
|
||||||
|
else if (ret < 0)
|
||||||
|
{
|
||||||
|
perror ("processing frame");
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!first)
|
||||||
|
{
|
||||||
|
fwrite(&byte, 1, 1, ofh);
|
||||||
|
}
|
||||||
|
marker <<= 8;
|
||||||
|
if (hread(&byte, 1, hfh) == 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "End of File\n");
|
||||||
|
running = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
marker |= byte;
|
||||||
|
first = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
perror ("invalid TiVo format");
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
destruct_turing (&turing);
|
||||||
|
|
||||||
|
if (hfh->fh == stdin)
|
||||||
|
hdetach(hfh);
|
||||||
|
else
|
||||||
|
hclose(hfh);
|
||||||
|
|
||||||
|
if (ofh != stdout)
|
||||||
|
fclose(ofh);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* vi:set ai ts=4 sw=4 expandtab: */
|
19
src/tivomirror/tivodecode/tivodecode.rules
Normal file
19
src/tivomirror/tivodecode/tivodecode.rules
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<VisualStudioToolFile
|
||||||
|
Name="copy win32 file"
|
||||||
|
Version="8.00"
|
||||||
|
>
|
||||||
|
<Rules>
|
||||||
|
<CustomBuildRule
|
||||||
|
Name="copy win32 file"
|
||||||
|
DisplayName="copy win32 file"
|
||||||
|
CommandLine="copy $(InputName).win32 $(InputName)"
|
||||||
|
Outputs="$(InputName)"
|
||||||
|
FileExtensions="*.win32"
|
||||||
|
ExecutionDescription="copying $(InputName).win32 to $(InputName)"
|
||||||
|
>
|
||||||
|
<Properties>
|
||||||
|
</Properties>
|
||||||
|
</CustomBuildRule>
|
||||||
|
</Rules>
|
||||||
|
</VisualStudioToolFile>
|
49
src/tivomirror/tivodecode/tivodecode.sln
Normal file
49
src/tivomirror/tivodecode/tivodecode.sln
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||||
|
# Visual C++ Express 2008
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tivodecode", "tivodecode.vcproj", "{AB0538B4-79BB-463D-AE34-5C7ACD90D0BA}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{491A7F57-2E09-492E-9E44-70A34A313611} = {491A7F57-2E09-492E-9E44-70A34A313611}
|
||||||
|
{9DDBB216-6D06-47EB-B559-B3FB02510DC3} = {9DDBB216-6D06-47EB-B559-B3FB02510DC3}
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libtivodecode", "libtivodecode.vcproj", "{9DDBB216-6D06-47EB-B559-B3FB02510DC3}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tdcat", "tdcat.vcproj", "{66AEBB90-9BD8-497E-B546-9409110E9F21}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{491A7F57-2E09-492E-9E44-70A34A313611} = {491A7F57-2E09-492E-9E44-70A34A313611}
|
||||||
|
{9DDBB216-6D06-47EB-B559-B3FB02510DC3} = {9DDBB216-6D06-47EB-B559-B3FB02510DC3}
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libtdcommon", "libtdcommon.vcproj", "{491A7F57-2E09-492E-9E44-70A34A313611}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{9DDBB216-6D06-47EB-B559-B3FB02510DC3} = {9DDBB216-6D06-47EB-B559-B3FB02510DC3}
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Win32 = Debug|Win32
|
||||||
|
Release|Win32 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{AB0538B4-79BB-463D-AE34-5C7ACD90D0BA}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{AB0538B4-79BB-463D-AE34-5C7ACD90D0BA}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{AB0538B4-79BB-463D-AE34-5C7ACD90D0BA}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{AB0538B4-79BB-463D-AE34-5C7ACD90D0BA}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{9DDBB216-6D06-47EB-B559-B3FB02510DC3}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{9DDBB216-6D06-47EB-B559-B3FB02510DC3}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{9DDBB216-6D06-47EB-B559-B3FB02510DC3}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{9DDBB216-6D06-47EB-B559-B3FB02510DC3}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{66AEBB90-9BD8-497E-B546-9409110E9F21}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{66AEBB90-9BD8-497E-B546-9409110E9F21}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{66AEBB90-9BD8-497E-B546-9409110E9F21}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{66AEBB90-9BD8-497E-B546-9409110E9F21}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{491A7F57-2E09-492E-9E44-70A34A313611}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{491A7F57-2E09-492E-9E44-70A34A313611}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{491A7F57-2E09-492E-9E44-70A34A313611}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{491A7F57-2E09-492E-9E44-70A34A313611}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
BIN
src/tivomirror/tivodecode/tivodecode.suo
Normal file
BIN
src/tivomirror/tivodecode/tivodecode.suo
Normal file
Binary file not shown.
202
src/tivomirror/tivodecode/tivodecode.vcproj
Normal file
202
src/tivomirror/tivodecode/tivodecode.vcproj
Normal file
|
@ -0,0 +1,202 @@
|
||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="9.00"
|
||||||
|
Name="tivodecode"
|
||||||
|
ProjectGUID="{AB0538B4-79BB-463D-AE34-5C7ACD90D0BA}"
|
||||||
|
RootNamespace="tivodecode"
|
||||||
|
Keyword="Win32Proj"
|
||||||
|
TargetFrameworkVersion="131072"
|
||||||
|
>
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"
|
||||||
|
/>
|
||||||
|
</Platforms>
|
||||||
|
<ToolFiles>
|
||||||
|
</ToolFiles>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
OutputDirectory="Debug"
|
||||||
|
IntermediateDirectory="Debug"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="0"
|
||||||
|
BuildLogFile="$(IntDir)\tivodecode_BuildLog.htm"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;HAVE_CONFIG_H"
|
||||||
|
MinimalRebuild="true"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="1"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
ProgramDataBaseFileName="$(IntDir)\tivodecode.pdb"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="true"
|
||||||
|
DebugInformationFormat="4"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="ws2_32.lib"
|
||||||
|
LinkIncremental="2"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
SubSystem="1"
|
||||||
|
RandomizedBaseAddress="1"
|
||||||
|
DataExecutionPrevention="0"
|
||||||
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
OutputDirectory="Release"
|
||||||
|
IntermediateDirectory="Release"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="0"
|
||||||
|
WholeProgramOptimization="1"
|
||||||
|
BuildLogFile="$(IntDir)\tivodecode_BuildLog.htm"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE;HAVE_CONFIG_H"
|
||||||
|
RuntimeLibrary="0"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
ProgramDataBaseFileName="$(IntDir)\tivodecode.pdb"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="true"
|
||||||
|
DebugInformationFormat="3"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="ws2_32.lib"
|
||||||
|
LinkIncremental="1"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
SubSystem="1"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
RandomizedBaseAddress="1"
|
||||||
|
DataExecutionPrevention="0"
|
||||||
|
TargetMachine="1"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCALinkTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXDCMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCBscMakeTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCFxCopTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"
|
||||||
|
/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||||
|
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||||
|
>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Resource Files"
|
||||||
|
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
|
||||||
|
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||||
|
>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
|
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\tivodecode.c"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
1391
src/tivomirror/tivodecode/tivodecoder.c
Normal file
1391
src/tivomirror/tivodecode/tivodecoder.c
Normal file
File diff suppressed because it is too large
Load diff
248
src/tivomirror/tivodecode/tivodecoder.h
Normal file
248
src/tivomirror/tivodecode/tivodecoder.h
Normal file
|
@ -0,0 +1,248 @@
|
||||||
|
/*
|
||||||
|
* tivodecode, (c) 2006, Jeremy Drake
|
||||||
|
* See COPYING file for license terms
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TIVO_DECODER_H_
|
||||||
|
#define TIVO_DECODER_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "tdconfig.h"
|
||||||
|
#include <stddef.h>
|
||||||
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
|
#include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
#include "turing_stream.h"
|
||||||
|
|
||||||
|
|
||||||
|
#if SIZEOF_OFF_T == 8
|
||||||
|
# define OFF_T_TYPE off_t
|
||||||
|
# define OFF_T_FORMAT "llu"
|
||||||
|
#elif defined(WIN32)
|
||||||
|
# define OFF_T_TYPE __int64
|
||||||
|
# define OFF_T_FORMAT "llu"
|
||||||
|
#else
|
||||||
|
# warning "Not compiling for large file (>2G) support!"
|
||||||
|
# define OFF_T_TYPE off_t
|
||||||
|
# define OFF_T_FORMAT "lu"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef int (*write_func_t) (void * mem, int size, void * fh);
|
||||||
|
|
||||||
|
#define PICTURE_START_CODE 0x00
|
||||||
|
#define SLICE_START_CODE_MIN 0x01
|
||||||
|
#define SLICE_START_CODE_MAX 0xAF
|
||||||
|
#define USER_DATA_START_CODE 0xB2
|
||||||
|
#define SEQUENCE_HEADER_CODE 0xB3
|
||||||
|
#define SEQUENCE_ERROR_CODE 0xB4
|
||||||
|
#define EXTENSION_START_CODE 0xB5
|
||||||
|
#define SEQUENCE_END_CODE 0xB7
|
||||||
|
#define GROUP_START_CODE 0xB8
|
||||||
|
#define SYSTEM_START_CODE_MIN 0xB9
|
||||||
|
#define SYSTEM_START_CODE_MAX 0xFF
|
||||||
|
#define ISO_END_CODE 0xB9
|
||||||
|
#define PACK_START_CODE 0xBA
|
||||||
|
#define SYSTEM_START_CODE 0xBB
|
||||||
|
#define VIDEO_ELEMENTARY_STREAM 0xe0
|
||||||
|
|
||||||
|
#define TRANSPORT_STREAM 0x47
|
||||||
|
|
||||||
|
#define TS_FRAME_SIZE 188
|
||||||
|
|
||||||
|
|
||||||
|
//============================
|
||||||
|
// PS Specific data structures
|
||||||
|
//============================
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
PACK_NONE,
|
||||||
|
PACK_SPECIAL,
|
||||||
|
PACK_PES_SIMPLE, // packet length == data length
|
||||||
|
PACK_PES_COMPLEX, // crazy headers need skipping
|
||||||
|
}
|
||||||
|
packet_type;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
// the byte value match for the packet tags
|
||||||
|
unsigned char code_match_lo; // low end of the range of matches
|
||||||
|
unsigned char code_match_hi; // high end of the range of matches
|
||||||
|
|
||||||
|
// what kind of PES is it?
|
||||||
|
packet_type packet;
|
||||||
|
}
|
||||||
|
packet_tag_info;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//============================
|
||||||
|
// TS Specific data structures
|
||||||
|
//============================
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
TS_PID_TYPE_RESERVED = 1,
|
||||||
|
TS_PID_TYPE_NULL_PACKET,
|
||||||
|
TS_PID_TYPE_PROGRAM_ASSOCIATION_TABLE,
|
||||||
|
TS_PID_TYPE_PROGRAM_MAP_TABLE,
|
||||||
|
TS_PID_TYPE_CONDITIONAL_ACCESS_TABLE,
|
||||||
|
TS_PID_TYPE_NETWORK_INFORMATION_TABLE,
|
||||||
|
TS_PID_TYPE_SERVICE_DESCRIPTION_TABLE,
|
||||||
|
TS_PID_TYPE_EVENT_INFORMATION_TABLE,
|
||||||
|
TS_PID_TYPE_RUNNING_STATUS_TABLE,
|
||||||
|
TS_PID_TYPE_TIME_DATE_TABLE,
|
||||||
|
TS_PID_TYPE_AUDIO_VIDEO_PRIVATE_DATA,
|
||||||
|
TS_PID_TYPE_NONE
|
||||||
|
} ts_packet_pid_types;
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
TS_STREAM_TYPE_AUDIO = 1,
|
||||||
|
TS_STREAM_TYPE_VIDEO,
|
||||||
|
TS_STREAM_TYPE_PRIVATE_DATA,
|
||||||
|
TS_STREAM_TYPE_OTHER,
|
||||||
|
TS_STREAM_TYPE_NONE
|
||||||
|
} ts_stream_types;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
// the 16-bit value match for the packet pids
|
||||||
|
unsigned char code_match_lo; // low end of the range of matches
|
||||||
|
unsigned char code_match_hi; // high end of the range of matches
|
||||||
|
|
||||||
|
// what kind of TS packet is it?
|
||||||
|
ts_stream_types ts_stream_type;
|
||||||
|
}
|
||||||
|
ts_pmt_stream_type_info;
|
||||||
|
|
||||||
|
|
||||||
|
#define TS_STREAM_ELEMENT_MAX 10
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
// the 16-bit value match for the packet pids
|
||||||
|
unsigned short code_match_lo; // low end of the range of matches
|
||||||
|
unsigned short code_match_hi; // high end of the range of matches
|
||||||
|
|
||||||
|
// what kind of TS packet is it?
|
||||||
|
ts_packet_pid_types ts_packet;
|
||||||
|
}
|
||||||
|
ts_packet_tag_info;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _TS_header
|
||||||
|
{
|
||||||
|
unsigned int sync_byte:8;
|
||||||
|
unsigned int transport_error_indicator:1;
|
||||||
|
unsigned int payload_unit_start_indicator:1;
|
||||||
|
unsigned int transport_priority:1;
|
||||||
|
unsigned int pid:13;
|
||||||
|
unsigned int transport_scrambling_control:2;
|
||||||
|
unsigned int adaptation_field_exists:1;
|
||||||
|
unsigned int payload_data_exists:1;
|
||||||
|
unsigned int continuity_counter:4;
|
||||||
|
}
|
||||||
|
TS_Header;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _TS_adaptation_field
|
||||||
|
{
|
||||||
|
unsigned short adaptation_field_length:8;
|
||||||
|
unsigned short discontinuity_indicator:1;
|
||||||
|
unsigned short random_access_indicator:1;
|
||||||
|
unsigned short elementary_stream_priority_indicator:1;
|
||||||
|
unsigned short pcr_flag:1;
|
||||||
|
unsigned short opcr_flag:1;
|
||||||
|
unsigned short splicing_point_flag:1;
|
||||||
|
unsigned short transport_private_data_flag:1;
|
||||||
|
unsigned short adaptation_field_extension_flag:1;
|
||||||
|
}
|
||||||
|
TS_Adaptation_Field;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _TS_PAT_data
|
||||||
|
{
|
||||||
|
unsigned char version_number;
|
||||||
|
unsigned char current_next_indicator;
|
||||||
|
unsigned char section_number;
|
||||||
|
unsigned char last_section_number;
|
||||||
|
unsigned short program_map_pid;
|
||||||
|
} TS_PAT_data;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _TS_Turing_Stuff
|
||||||
|
{
|
||||||
|
int block_no;
|
||||||
|
int crypted;
|
||||||
|
unsigned char unknown_field[4];
|
||||||
|
unsigned char key[16];
|
||||||
|
} TS_Turing_Stuff;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _TS_Prog_Elements
|
||||||
|
{
|
||||||
|
unsigned char stream_type_id;
|
||||||
|
unsigned int stream_pid;
|
||||||
|
unsigned char stream_id;
|
||||||
|
ts_stream_types stream_type;
|
||||||
|
TS_Turing_Stuff turing_stuff;
|
||||||
|
} TS_Stream_Element;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _TS_PES_Packet
|
||||||
|
{
|
||||||
|
unsigned char stream_id;
|
||||||
|
unsigned short pkt_length;
|
||||||
|
unsigned char marker_bits:2;
|
||||||
|
unsigned char scrambling_control:2;
|
||||||
|
unsigned char priority:1;
|
||||||
|
unsigned char data_alignment_indicator:1;
|
||||||
|
unsigned char copyright:1;
|
||||||
|
unsigned char original_or_copy:1;
|
||||||
|
unsigned char PTS_DTS_indicator:2;
|
||||||
|
unsigned char ESCR_flag:1;
|
||||||
|
unsigned char ES_rate_flag:1;
|
||||||
|
unsigned char DSM_trick_mode_flag:1;
|
||||||
|
unsigned char additional_copy_info_flag:1;
|
||||||
|
unsigned char CRC_flag:1;
|
||||||
|
unsigned char extension_flag:1;
|
||||||
|
unsigned char PES_header_length;
|
||||||
|
} PES_packet;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _TS_Stream
|
||||||
|
{
|
||||||
|
unsigned char * pPacket;
|
||||||
|
unsigned int payload_offset;
|
||||||
|
unsigned int initial_offset;
|
||||||
|
unsigned int packet_counter;
|
||||||
|
TS_Header ts_header;
|
||||||
|
TS_Adaptation_Field ts_adapt;
|
||||||
|
TS_PAT_data ts_pat;
|
||||||
|
ts_packet_pid_types ts_packet_type;
|
||||||
|
TS_Stream_Element ts_stream_elem[TS_STREAM_ELEMENT_MAX];
|
||||||
|
PES_packet ts_pes_packet;
|
||||||
|
} TS_Stream;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* called for each frame
|
||||||
|
*/
|
||||||
|
int process_ps_frame(unsigned char code, turing_state * turing, OFF_T_TYPE packet_start, void * packet_stream, read_func_t read_handler, void * ofh, write_func_t write_handler);
|
||||||
|
int process_ts_frame(turing_state * turing, OFF_T_TYPE packet_start, void * packet_stream, read_func_t read_handler, void * ofh, write_func_t write_handler);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
290
src/tivomirror/tivodecode/turing_stream.c
Normal file
290
src/tivomirror/tivodecode/turing_stream.c
Normal file
|
@ -0,0 +1,290 @@
|
||||||
|
/*
|
||||||
|
* tivodecode, (c) 2006, Jeremy Drake
|
||||||
|
* See COPYING file for license terms
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Decoder for Turing
|
||||||
|
*
|
||||||
|
* Copyright C 2002, Qualcomm Inc. Written by Greg Rose
|
||||||
|
* Hacked into use for TiVoToGo decoding by FDM, 2005.
|
||||||
|
* Majorly re-hacked into use for TiVoToGo decoding by Jeremy Drake, 2005.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
This software is free for commercial and non-commercial use subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
1. Copyright remains vested in QUALCOMM Incorporated, and Copyright
|
||||||
|
notices in the code are not to be removed. If this package is used in
|
||||||
|
a product, QUALCOMM should be given attribution as the author of the
|
||||||
|
Turing encryption algorithm. This can be in the form of a textual
|
||||||
|
message at program startup or in documentation (online or textual)
|
||||||
|
provided with the package.
|
||||||
|
|
||||||
|
2. Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
a. Redistributions of source code must retain the copyright notice,
|
||||||
|
this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
b. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
|
||||||
|
c. All advertising materials mentioning features or use of this
|
||||||
|
software must display the following acknowledgement: This product
|
||||||
|
includes software developed by QUALCOMM Incorporated.
|
||||||
|
|
||||||
|
3. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND AGAINST
|
||||||
|
INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
|
||||||
|
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
4. The license and distribution terms for any publically available version
|
||||||
|
or derivative of this code cannot be changed, that is, this code cannot
|
||||||
|
simply be copied and put under another distribution license including
|
||||||
|
the GNU Public License.
|
||||||
|
|
||||||
|
5. The Turing family of encryption algorithms are covered by patents in
|
||||||
|
the United States of America and other countries. A free and
|
||||||
|
irrevocable license is hereby granted for the use of such patents to
|
||||||
|
the extent required to utilize the Turing family of encryption
|
||||||
|
algorithms for any purpose, subject to the condition that any
|
||||||
|
commercial product utilising any of the Turing family of encryption
|
||||||
|
algorithms should show the words "Encryption by QUALCOMM" either on the
|
||||||
|
product or in the associated documentation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "tdconfig.h"
|
||||||
|
#endif
|
||||||
|
#include "Turing.h" /* interface definitions */
|
||||||
|
|
||||||
|
/* testing and timing harness */
|
||||||
|
#ifdef HAVE_STDLIB_H
|
||||||
|
# include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
#include <stdio.h>
|
||||||
|
#ifdef HAVE_STRING_H
|
||||||
|
# include <string.h>
|
||||||
|
#endif
|
||||||
|
//#include <time.h>
|
||||||
|
#include "hexlib.h"
|
||||||
|
#include "md5.h"
|
||||||
|
#include "sha1.h"
|
||||||
|
#include "tivo-parse.h"
|
||||||
|
#include "turing_stream.h"
|
||||||
|
|
||||||
|
// from tivodecode.c, verbose option
|
||||||
|
extern int o_verbose;
|
||||||
|
|
||||||
|
unsigned int init_turing_from_file(turing_state * turing, void * tivofile, read_func_t read_handler, char * mak)
|
||||||
|
{
|
||||||
|
tivo_stream_header head;
|
||||||
|
tivo_stream_chunk *xml;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (read_tivo_header (tivofile, &head, read_handler))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
for (i = 0; i < head.chunks; i++)
|
||||||
|
{
|
||||||
|
if ((xml = read_tivo_chunk (tivofile, read_handler)) == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (xml->data_size && xml->type == TIVO_CHUNK_PLAINTEXT_XML )
|
||||||
|
{
|
||||||
|
setup_turing_key (turing, xml, mak);
|
||||||
|
free(xml);
|
||||||
|
return head.mpeg_offset;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
free(xml);
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup_turing_key(turing_state * turing, tivo_stream_chunk * xml, char * mak)
|
||||||
|
{
|
||||||
|
SHA1_CTX context;
|
||||||
|
|
||||||
|
sha1_init(&context);
|
||||||
|
sha1_update(&context, (unsigned char *)mak, strlen(mak));
|
||||||
|
sha1_update(&context, xml->data, xml->data_size);
|
||||||
|
sha1_final(turing->turingkey, &context);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define static_strlen(str) (sizeof(str) - 1)
|
||||||
|
|
||||||
|
void setup_metadata_key(turing_state * turing, tivo_stream_chunk * xml, char * mak)
|
||||||
|
{
|
||||||
|
static const char lookup[] = "0123456789abcdef";
|
||||||
|
static const unsigned char media_mak_prefix[] = "tivo:TiVo DVR:";
|
||||||
|
MD5_CTX md5;
|
||||||
|
int i;
|
||||||
|
unsigned char md5result[16];
|
||||||
|
char metakey[33];
|
||||||
|
|
||||||
|
|
||||||
|
MD5Init(&md5);
|
||||||
|
MD5Update(&md5, media_mak_prefix, static_strlen(media_mak_prefix));
|
||||||
|
MD5Update(&md5, (unsigned char *)mak, strlen(mak));
|
||||||
|
MD5Final(md5result, &md5);
|
||||||
|
|
||||||
|
for (i = 0; i < 16; ++i)
|
||||||
|
{
|
||||||
|
metakey[2*i + 0] = lookup[(md5result[i] >> 4) & 0xf];
|
||||||
|
metakey[2*i + 1] = lookup[ md5result[i] & 0xf];
|
||||||
|
}
|
||||||
|
metakey[32] = '\0';
|
||||||
|
|
||||||
|
/* this is done the same as the normal one, only replacing the mak
|
||||||
|
* with the metakey
|
||||||
|
*/
|
||||||
|
setup_turing_key(turing, xml, metakey);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void prepare_frame_helper(turing_state * turing, unsigned char stream_id, int block_id)
|
||||||
|
{
|
||||||
|
SHA1_CTX context;
|
||||||
|
unsigned char turkey[20];
|
||||||
|
unsigned char turiv [20];
|
||||||
|
|
||||||
|
turing->active->stream_id = stream_id;
|
||||||
|
turing->active->block_id = block_id;
|
||||||
|
|
||||||
|
turing->turingkey[16] = stream_id;
|
||||||
|
turing->turingkey[17] = (block_id & 0xFF0000) >> 16;
|
||||||
|
turing->turingkey[18] = (block_id & 0x00FF00) >> 8;
|
||||||
|
turing->turingkey[19] = (block_id & 0x0000FF) >> 0;
|
||||||
|
|
||||||
|
sha1_init(&context);
|
||||||
|
sha1_update(&context, turing->turingkey, 17);
|
||||||
|
sha1_final(turkey, &context);
|
||||||
|
//hexbulk(turkey, 20);
|
||||||
|
|
||||||
|
sha1_init(&context);
|
||||||
|
sha1_update(&context, turing->turingkey, 20);
|
||||||
|
sha1_final(turiv, &context);
|
||||||
|
//hexbulk(turiv, 20);
|
||||||
|
|
||||||
|
turing->active->cipher_pos = 0;
|
||||||
|
|
||||||
|
TuringKey(turing->active->internal, turkey, 20);
|
||||||
|
TuringIV(turing->active->internal, turiv, 20);
|
||||||
|
|
||||||
|
memset(turing->active->cipher_data, 0, MAXSTREAM);
|
||||||
|
|
||||||
|
turing->active->cipher_len = TuringGen(turing->active->internal, turing->active->cipher_data);
|
||||||
|
|
||||||
|
//hexbulk(turing->active->cipher_data, turing->active->cipher_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define CREATE_TURING_LISTITM(turing, nxt, stream_id, block_id) \
|
||||||
|
do { \
|
||||||
|
(turing)->active = calloc (1, sizeof (turing_state_stream)); \
|
||||||
|
(turing)->active->next = (nxt); \
|
||||||
|
(nxt) = (turing)->active; \
|
||||||
|
(turing)->active->internal = TuringAlloc(); \
|
||||||
|
if (o_verbose) \
|
||||||
|
fprintf(stdout, "Creating turing stream for packet type %02x\n", (stream_id)); \
|
||||||
|
prepare_frame_helper((turing), (stream_id), (block_id)); \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
|
|
||||||
|
void prepare_frame(turing_state * turing, unsigned char stream_id, int block_id)
|
||||||
|
{
|
||||||
|
if (turing->active)
|
||||||
|
{
|
||||||
|
if (turing->active->stream_id != stream_id)
|
||||||
|
{
|
||||||
|
turing_state_stream * start = turing->active;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
turing->active = turing->active->next;
|
||||||
|
}
|
||||||
|
while (turing->active->stream_id != stream_id && turing->active != start);
|
||||||
|
|
||||||
|
if (turing->active->stream_id != stream_id)
|
||||||
|
{
|
||||||
|
/* did not find a state for this stream type */
|
||||||
|
CREATE_TURING_LISTITM (turing, start->next, stream_id, block_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (turing->active->block_id != block_id)
|
||||||
|
{
|
||||||
|
prepare_frame_helper(turing, stream_id, block_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* first stream type seen */
|
||||||
|
CREATE_TURING_LISTITM (turing, turing->active, stream_id, block_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void decrypt_buffer(turing_state * turing, unsigned char * buffer, size_t buffer_length)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
for (i = 0; i < buffer_length; ++i)
|
||||||
|
{
|
||||||
|
if (turing->active->cipher_pos >= turing->active->cipher_len)
|
||||||
|
{
|
||||||
|
turing->active->cipher_len = TuringGen(turing->active->internal, turing->active->cipher_data);
|
||||||
|
turing->active->cipher_pos = 0;
|
||||||
|
//hexbulk(turing->active->cipher_data, turing->active->cipher_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer[i] ^= turing->active->cipher_data[turing->active->cipher_pos++];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void skip_turing_data(turing_state * turing, size_t bytes_to_skip)
|
||||||
|
{
|
||||||
|
if (turing->active->cipher_pos + bytes_to_skip < (size_t)turing->active->cipher_len)
|
||||||
|
turing->active->cipher_pos += (int)bytes_to_skip;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
bytes_to_skip -= turing->active->cipher_len - turing->active->cipher_pos;
|
||||||
|
turing->active->cipher_len = TuringGen(turing->active->internal, turing->active->cipher_data);
|
||||||
|
turing->active->cipher_pos = 0;
|
||||||
|
} while (bytes_to_skip >= (size_t)turing->active->cipher_len);
|
||||||
|
|
||||||
|
turing->active->cipher_pos = (int)bytes_to_skip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void destruct_turing(turing_state * turing)
|
||||||
|
{
|
||||||
|
if (turing->active)
|
||||||
|
{
|
||||||
|
turing_state_stream * start = turing->active;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
turing_state_stream * prev = turing->active;
|
||||||
|
TuringFree(turing->active->internal);
|
||||||
|
turing->active = turing->active->next;
|
||||||
|
free (prev);
|
||||||
|
}
|
||||||
|
while (turing->active != start);
|
||||||
|
}
|
||||||
|
|
||||||
|
turing->active = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* vi:set ai ts=4 sw=4 expandtab: */
|
65
src/tivomirror/tivodecode/turing_stream.h
Normal file
65
src/tivomirror/tivodecode/turing_stream.h
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
/*
|
||||||
|
* tivodecode, (c) 2006, Jeremy Drake
|
||||||
|
* See COPYING file for license terms
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TURING_STREAM_H_
|
||||||
|
#define TURING_STREAM_H_
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
/*following copied from Turing.h, so we can avoid including it here */
|
||||||
|
#define MAXSTREAM 340 /* bytes, maximum stream generated by one call */
|
||||||
|
|
||||||
|
#include "tivo-parse.h"
|
||||||
|
|
||||||
|
#if defined(HAVE_SIZE_T) && SIZEOF_SIZE_T == 8
|
||||||
|
typedef size_t td_uint64_t;
|
||||||
|
#define HAVE_TD_UINT64_T 1
|
||||||
|
#elif defined(HAVE_UNSIGNED_LONG) && SIZEOF_UNSIGNED_LONG == 8
|
||||||
|
typedef unsigned long td_uint64_t;
|
||||||
|
#define HAVE_TD_UINT64_T 1
|
||||||
|
#elif defined(HAVE_UNSIGNED_LONG_LONG) && SIZEOF_UNSIGNED_LONG_LONG == 8
|
||||||
|
typedef unsigned long long td_uint64_t;
|
||||||
|
#define HAVE_TD_UINT64_T 1
|
||||||
|
#else
|
||||||
|
typedef unsigned long td_uint64_t;
|
||||||
|
/* #undef HAVE_TD_UINT64_T */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct turing_state_stream
|
||||||
|
{
|
||||||
|
unsigned int cipher_pos;
|
||||||
|
unsigned int cipher_len;
|
||||||
|
|
||||||
|
unsigned int block_id;
|
||||||
|
unsigned char stream_id;
|
||||||
|
|
||||||
|
struct turing_state_stream * next;
|
||||||
|
|
||||||
|
void * internal;
|
||||||
|
unsigned char cipher_data[MAXSTREAM + sizeof(td_uint64_t)];
|
||||||
|
} turing_state_stream;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
unsigned char turingkey[20];
|
||||||
|
|
||||||
|
turing_state_stream * active;
|
||||||
|
} turing_state;
|
||||||
|
|
||||||
|
unsigned int init_turing_from_file(turing_state * turing, void * tivofile, read_func_t read_handler, char * mak);
|
||||||
|
void setup_metadata_key(turing_state * turing, tivo_stream_chunk * xml, char * mak);
|
||||||
|
void setup_turing_key(turing_state * turing, tivo_stream_chunk * xml, char * mak);
|
||||||
|
void prepare_frame(turing_state * turing, unsigned char stream_id, int block_id);
|
||||||
|
void decrypt_buffer(turing_state * turing, unsigned char * buffer, size_t buffer_length);
|
||||||
|
void skip_turing_data(turing_state * turing, size_t bytes_to_skip);
|
||||||
|
void destruct_turing(turing_state * turing);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif // TURING_STREAM_H_
|
||||||
|
|
571
src/tivomirror/tivomirror
Executable file
571
src/tivomirror/tivomirror
Executable file
|
@ -0,0 +1,571 @@
|
||||||
|
#!/usr/local/bin/python
|
||||||
|
|
||||||
|
# $Schlepperbande: src/tivomirror/tivomirror,v 1.69 2015/09/05 11:56:07 stb Exp $
|
||||||
|
#
|
||||||
|
# Stefans Script, um die Sendungen vom Tivo runterzuladen und in MPEG4
|
||||||
|
# zu transkodieren.
|
||||||
|
# Wird auf disklesslibber per Crontab-Eintrag stuendlich gestartet:
|
||||||
|
# flock -n /tmp/tivomirror.log -c 'tivomirror >.tivomirror.log 2>&1 </dev/null'
|
||||||
|
|
||||||
|
import sys
|
||||||
|
reload(sys)
|
||||||
|
sys.setdefaultencoding('utf-8')
|
||||||
|
|
||||||
|
import anydbm
|
||||||
|
import cookielib
|
||||||
|
import datetime
|
||||||
|
import getopt
|
||||||
|
import errno
|
||||||
|
import functools
|
||||||
|
import logging
|
||||||
|
import logging.handlers
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import requests
|
||||||
|
import signal
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import threading
|
||||||
|
import time
|
||||||
|
import urllib2
|
||||||
|
import xml.dom.minidom
|
||||||
|
import tivomp4
|
||||||
|
|
||||||
|
host = "tivo.lassitu.de"
|
||||||
|
#host = "wavehh.lassitu.de:30080"
|
||||||
|
mak = "7194378159"
|
||||||
|
targetdir = "/p2/media/video/TV"
|
||||||
|
gig = 1024.0 * 1024 * 1024
|
||||||
|
minfree = 10 * gig
|
||||||
|
ignoreepisodetitle = False
|
||||||
|
|
||||||
|
arset = dict()
|
||||||
|
|
||||||
|
includes = dict()
|
||||||
|
includes['Anthony Bourdain Parts Unknown'] = 1
|
||||||
|
includes['Better Call Saul'] = 1
|
||||||
|
includes['Brooklyn Nine-Nine'] = 1
|
||||||
|
includes['Bull'] = 1
|
||||||
|
includes['College Football'] = 1
|
||||||
|
includes['Conan'] = 1
|
||||||
|
includes["Dirk Gently's Holistic Detective Agency"] = 1
|
||||||
|
includes['The Expanse'] = 1
|
||||||
|
includes['Family Guy'] = 1
|
||||||
|
includes['Full Frontal With Samantha Bee'] = 1
|
||||||
|
includes['Hot in Cleveland'] = 1
|
||||||
|
includes["How It's Made"] = 1
|
||||||
|
includes["How Do They Do It?"] = 1
|
||||||
|
includes["How We Got to Now With Steven Johnson"] = 1
|
||||||
|
includes['Inside Amy Schumer'] = 1
|
||||||
|
includes['Join or Die With Craig Ferguson'] = 1
|
||||||
|
includes['Last Week Tonight With John Oliver'] = 1
|
||||||
|
includes['Louie'] = 1
|
||||||
|
includes['Mad Men'] = 1
|
||||||
|
includes['Modern Family'] = 1
|
||||||
|
includes['MythBusters'] = 1
|
||||||
|
includes['MythBusters: The Search'] = 1
|
||||||
|
includes['NCIS'] = 1
|
||||||
|
includes['NCIS: New Orleans'] = 1
|
||||||
|
#includes['NFL Football'] = 1
|
||||||
|
includes['Person of Interest'] = 1
|
||||||
|
includes['Saturday Night Live'] = 1
|
||||||
|
includes['Sesame Street'] = 1
|
||||||
|
includes["Somebody's Gotta Do It With Mike Rowe"] = 1
|
||||||
|
includes['StarTalk'] = 1
|
||||||
|
includes['The Big Bang Theory'] = 1
|
||||||
|
includes['The Daily Show With Trevor Noah'] = 1
|
||||||
|
includes['The Late Show With Stephen Colbert'] = 1
|
||||||
|
#includes['The Late Late Show With James Corden'] = 1
|
||||||
|
includes['The Muppets'] = 1
|
||||||
|
includes['The X-Files'] = 1
|
||||||
|
#includes['The Tonight Show Starring Jimmy Fallon'] = 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger('tivomirror')
|
||||||
|
logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
|
|
||||||
|
class flushfile(object):
|
||||||
|
def __init__(self, f):
|
||||||
|
self.f = f
|
||||||
|
def write(self, x):
|
||||||
|
self.f.write(x)
|
||||||
|
self.f.flush()
|
||||||
|
sys.stdout = flushfile(sys.stdout)
|
||||||
|
|
||||||
|
tmp = "/tmp"
|
||||||
|
|
||||||
|
# prepare global requests sesssion to download the TOC and the episodes
|
||||||
|
requests.packages.urllib3.disable_warnings()
|
||||||
|
session = requests.session()
|
||||||
|
session.verify = False
|
||||||
|
session.auth = requests.auth.HTTPDigestAuth("tivo", mak)
|
||||||
|
session.keep_alive = False
|
||||||
|
|
||||||
|
|
||||||
|
class TimeoutError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def timeout(seconds=10, error_message=os.strerror(errno.ETIMEDOUT)):
|
||||||
|
def decorator(func):
|
||||||
|
def _handle_timeout(signum, frame):
|
||||||
|
raise TimeoutError(error_message)
|
||||||
|
|
||||||
|
def wrapper(*args, **kwargs):
|
||||||
|
signal.signal(signal.SIGALRM, _handle_timeout)
|
||||||
|
signal.alarm(seconds)
|
||||||
|
try:
|
||||||
|
result = func(*args, **kwargs)
|
||||||
|
finally:
|
||||||
|
signal.alarm(0)
|
||||||
|
return result
|
||||||
|
|
||||||
|
return functools.wraps(func)(wrapper)
|
||||||
|
|
||||||
|
return decorator
|
||||||
|
|
||||||
|
|
||||||
|
def trimDescription(desc):
|
||||||
|
desc = desc.strip()
|
||||||
|
i = desc.rfind(". Copyright Tribune Media Services, Inc.");
|
||||||
|
if i > 0:
|
||||||
|
desc = desc[0:i]
|
||||||
|
i = desc.rfind(". * Copyright Rovi, Inc");
|
||||||
|
if i > 0:
|
||||||
|
desc = desc[0:i]
|
||||||
|
if len(desc) > 80:
|
||||||
|
desc = desc[0:80]
|
||||||
|
return desc
|
||||||
|
|
||||||
|
class TivoException(Exception):
|
||||||
|
def __init__(self, value):
|
||||||
|
self.value = value
|
||||||
|
def __str__(self):
|
||||||
|
return repr(self.value)
|
||||||
|
|
||||||
|
class TivoItem:
|
||||||
|
def __init__(self, i):
|
||||||
|
self.title = getTagText(i, "Title")
|
||||||
|
self.episode = getTagText(i, "EpisodeTitle")
|
||||||
|
self.episodeNumber = getTagText(i, "EpisodeNumber")
|
||||||
|
self.description = trimDescription(getTagText(i, "Description"))
|
||||||
|
d = getTagText(i, "CaptureDate")
|
||||||
|
self.date = datetime.datetime.utcfromtimestamp(int(d, 16))
|
||||||
|
self.time = int(d, base=0)
|
||||||
|
self.datestr = self.date.strftime("%Y%m%d-%H%M")
|
||||||
|
self.url = getTagText(i, "Url")
|
||||||
|
self.inprogress = getTagText(i, "InProgress")
|
||||||
|
self.available = getTagText(i, "Available")
|
||||||
|
self.sourcesize = int(getTagText(i, "SourceSize"))
|
||||||
|
self.highdef = getTagText(i, "HighDefinition")
|
||||||
|
self.ar = 43
|
||||||
|
self.unique = True
|
||||||
|
if arset.has_key(self.title):
|
||||||
|
self.ar = arset[self.title]
|
||||||
|
elif self.highdef == "Yes":
|
||||||
|
self.ar = "hd"
|
||||||
|
if ignoreepisodetitle:
|
||||||
|
self.episode = self.datestr
|
||||||
|
if self.episode == "":
|
||||||
|
if self.description != "":
|
||||||
|
self.episode = self.description
|
||||||
|
else:
|
||||||
|
self.episode = self.datestr
|
||||||
|
self.formatnames()
|
||||||
|
def makeNotUnique(self):
|
||||||
|
self.unique = False
|
||||||
|
self.formatnames()
|
||||||
|
def formatnames(self):
|
||||||
|
if self.episodeNumber and self.episodeNumber != u'0':
|
||||||
|
en = int(self.episodeNumber)
|
||||||
|
if en >= 100:
|
||||||
|
self.name = "%s S%02dE%02d %s" % (self.title, en / 100, en % 100, self.episode)
|
||||||
|
else:
|
||||||
|
self.name = "%s E%s %s" % (self.title, self.episodeNumber, self.episode)
|
||||||
|
elif self.unique:
|
||||||
|
self.name = "%s - %s" % (self.title, self.episode)
|
||||||
|
else:
|
||||||
|
self.name = "%s - %s - %s" % (self.title, self.datestr, self.episode)
|
||||||
|
self.dir = "%s/%s" % (targetdir, re.sub("[:/]", "-", self.title))
|
||||||
|
self.file = "%s/%s" % (self.dir, re.sub("[:/]", "-", self.name))
|
||||||
|
self.name = self.name.encode("utf-8");
|
||||||
|
self.dir = self.dir.encode("utf-8");
|
||||||
|
self.file = self.file.encode("utf-8");
|
||||||
|
def __str__(self):
|
||||||
|
return repr(self.title)
|
||||||
|
|
||||||
|
|
||||||
|
class TivoToc:
|
||||||
|
def __init__(self):
|
||||||
|
self.dom = None
|
||||||
|
self.filename = "toc.xml"
|
||||||
|
self.uniquedb = anydbm.open("unique.db", "c")
|
||||||
|
self.items = []
|
||||||
|
pass
|
||||||
|
|
||||||
|
def load(self):
|
||||||
|
fd = open(self.filename, "r")
|
||||||
|
self.dom = xml.dom.minidom.parseString(fd.read())
|
||||||
|
fd.close()
|
||||||
|
return self.dom
|
||||||
|
|
||||||
|
def save(self):
|
||||||
|
fd = open(self.filename, "w")
|
||||||
|
fd.write(self.dom.toprettyxml())
|
||||||
|
fd.close()
|
||||||
|
|
||||||
|
def download_chunk(self, offset):
|
||||||
|
global session
|
||||||
|
|
||||||
|
params = {
|
||||||
|
'Command': 'QueryContainer',
|
||||||
|
'Container': '/NowPlaying',
|
||||||
|
'Recurse': 'Yes',
|
||||||
|
'ItemCount': '50',
|
||||||
|
'AnchorOffset': offset
|
||||||
|
}
|
||||||
|
url = "https://{}/TiVoConnect".format(host)
|
||||||
|
logger.debug(" offset %d" % (offset))
|
||||||
|
r = session.get(url, params=params, timeout=30, verify=False)
|
||||||
|
if r.status_code != 200:
|
||||||
|
r.raise_for_status()
|
||||||
|
return r.text
|
||||||
|
|
||||||
|
def download(self):
|
||||||
|
offset = 0
|
||||||
|
itemCount = 1
|
||||||
|
self.dom = None
|
||||||
|
root = None
|
||||||
|
logger.info("*** Getting listing")
|
||||||
|
while itemCount > 0:
|
||||||
|
dom = xml.dom.minidom.parseString(self.download_chunk(offset))
|
||||||
|
if self.dom == None:
|
||||||
|
self.dom = dom
|
||||||
|
root = self.dom.childNodes.item(0)
|
||||||
|
else:
|
||||||
|
for child in dom.childNodes.item(0).childNodes:
|
||||||
|
if child.nodeName == "Item":
|
||||||
|
root.appendChild(child.cloneNode(True))
|
||||||
|
itemCount = int(getElementText(dom.documentElement.childNodes, "ItemCount"))
|
||||||
|
offset += itemCount
|
||||||
|
return self.dom
|
||||||
|
|
||||||
|
def getItems(self):
|
||||||
|
self.titles = {}
|
||||||
|
for node in self.dom.getElementsByTagName("Item"):
|
||||||
|
item = TivoItem(node)
|
||||||
|
self.items.append(item)
|
||||||
|
if item.title not in self.titles:
|
||||||
|
self.titles[item.title] = []
|
||||||
|
self.titles[item.title].append(item)
|
||||||
|
# see if we have items that end up having an identical name; mark
|
||||||
|
# the program title in uniquedb if that's the case
|
||||||
|
for title in self.titles:
|
||||||
|
names = {}
|
||||||
|
for item in self.titles[title]:
|
||||||
|
if item.name not in names:
|
||||||
|
names[item.name] = []
|
||||||
|
names[item.name].append(item)
|
||||||
|
for name in names:
|
||||||
|
if len(names[name]) > 1:
|
||||||
|
self.uniquedb[title.encode("utf-8")] = "1"
|
||||||
|
if getattr(self.uniquedb, "sync", None) and callable(self.uniquedb.sync):
|
||||||
|
self.uniquedb.sync()
|
||||||
|
for item in self.items:
|
||||||
|
if self.uniquedb.has_key(item.title.encode("utf-8")):
|
||||||
|
item.makeNotUnique()
|
||||||
|
return self.items
|
||||||
|
|
||||||
|
|
||||||
|
def getText(nodelist):
|
||||||
|
rc = ""
|
||||||
|
for node in nodelist:
|
||||||
|
if node.nodeType == node.TEXT_NODE:
|
||||||
|
rc = rc + node.data
|
||||||
|
return rc
|
||||||
|
|
||||||
|
def getTagText(element, tagname):
|
||||||
|
try:
|
||||||
|
return getText(element.getElementsByTagName(tagname)[0].childNodes)
|
||||||
|
except IndexError:
|
||||||
|
return ""
|
||||||
|
|
||||||
|
def getElementText(nodes, name):
|
||||||
|
for node in nodes:
|
||||||
|
if node.nodeType == xml.dom.Node.ELEMENT_NODE and node.nodeName == name:
|
||||||
|
return getText(node.childNodes)
|
||||||
|
return None
|
||||||
|
|
||||||
|
def getAvail(dir):
|
||||||
|
s = os.statvfs(dir)
|
||||||
|
return s.f_bsize * s.f_bavail
|
||||||
|
|
||||||
|
|
||||||
|
def quit_process(pid):
|
||||||
|
try:
|
||||||
|
os.kill(pid, signal.SIGQUIT)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class FdLogger(threading.Thread):
|
||||||
|
def __init__(self, logger, lvl, fd):
|
||||||
|
self.logger = logger
|
||||||
|
self.lvl = lvl
|
||||||
|
self.fd = fd
|
||||||
|
threading.Thread.__init__(self)
|
||||||
|
self.daemon = True
|
||||||
|
self.start()
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
try:
|
||||||
|
# for line in fd buffers, so use this instead
|
||||||
|
for line in iter(self.fd.readline, b''):
|
||||||
|
self.logger.log(self.lvl, ": %s", line.strip('\n'))
|
||||||
|
self.fd.close()
|
||||||
|
except Exception:
|
||||||
|
self.logger.exception("")
|
||||||
|
|
||||||
|
|
||||||
|
@timeout(43200)
|
||||||
|
#@timeout(7200)
|
||||||
|
def download(item, mak, target):
|
||||||
|
global session
|
||||||
|
count = 0
|
||||||
|
start = time.time()
|
||||||
|
upd = start
|
||||||
|
url = item.url
|
||||||
|
#url = re.sub("tivo.lassitu.de:80", "wavehh.lassitu.de:30080", url)
|
||||||
|
#url = re.sub("wavehh.lassitu.de:80", "wavehh.lassitu.de:30080", url)
|
||||||
|
#url = re.sub("tivo.lassitu.de:80", "localhost:8888", url)
|
||||||
|
#url = re.sub("tivo.lassitu.de:80", "krokodil-vpn.zs64.net:8888", url)
|
||||||
|
logger.info("--- downloading \"%s\"" % (url))
|
||||||
|
start = time.time()
|
||||||
|
r = session.get(url, stream=True, verify=False)
|
||||||
|
#r = session.get(url, stream=True, proxies={"http":"http://wavehh:8888","https":"http://wavehh:8888"})
|
||||||
|
r.raise_for_status()
|
||||||
|
|
||||||
|
try:
|
||||||
|
p_decode = subprocess.Popen(["tivodecode", "--mak", mak, \
|
||||||
|
"--no-verify", "--out", target, "-"], stdin=subprocess.PIPE,
|
||||||
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
FdLogger(logger, logging.INFO, p_decode.stdout)
|
||||||
|
FdLogger(logger, logging.INFO, p_decode.stderr)
|
||||||
|
def info(signum, frame):
|
||||||
|
upd = time.time()
|
||||||
|
dur = now - start
|
||||||
|
mb = count / 1e6
|
||||||
|
print "%5.1f%% %5.3f GB downloaded in %.0f min, %.3f MB/s" % (
|
||||||
|
100.0 * count / item.sourcesize,
|
||||||
|
mb / 1e3, dur / 60, mb / dur)
|
||||||
|
try:
|
||||||
|
signal.signal(signal.SIGINFO, info)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
while True:
|
||||||
|
time.sleep(0) # yield to logger threads
|
||||||
|
chunk = r.raw.read(65536)
|
||||||
|
if chunk:
|
||||||
|
p_decode.stdin.write(chunk)
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
count += len(chunk)
|
||||||
|
now = time.time()
|
||||||
|
if (now - upd) > 60:
|
||||||
|
upd = now
|
||||||
|
dur = now - start
|
||||||
|
mb = count / 1e6
|
||||||
|
logger.debug(" %5.1f%% %5.3f GB downloaded in %.0f min, %.3f MB/s" % (
|
||||||
|
100.0 * count / item.sourcesize,
|
||||||
|
mb / 1e3, dur / 60, mb / dur))
|
||||||
|
except Exception as e:
|
||||||
|
logger.error("problem decoding: %s" % (e))
|
||||||
|
raise
|
||||||
|
finally:
|
||||||
|
try:
|
||||||
|
signal.signal(signal.SIGINFO, signal.SIG_IGN)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
elapsed = time.time() - start
|
||||||
|
throughput = count / elapsed
|
||||||
|
logger.info("%5.3fGB transferred in %d:%02d, %.1f MB/s" % (
|
||||||
|
count/1e9, int(elapsed/3600), int(elapsed / 60) % 60, throughput/1e6))
|
||||||
|
try:
|
||||||
|
p_decode.stdin.close()
|
||||||
|
p_decode.poll()
|
||||||
|
if p_decode.returncode == None:
|
||||||
|
time.sleep(1)
|
||||||
|
p_decode.poll()
|
||||||
|
if p_decode.returncode == None:
|
||||||
|
logger.debug("terminating tivodecode")
|
||||||
|
p_decode.terminate()
|
||||||
|
except Exception, e:
|
||||||
|
pass
|
||||||
|
p_decode.wait()
|
||||||
|
logger.info("tivodecode exited with %s" % (p_decode.returncode))
|
||||||
|
size = os.path.getsize(target)
|
||||||
|
if size < 1024:
|
||||||
|
logger.error("error downloading file: too small")
|
||||||
|
os.remove(target)
|
||||||
|
raise TivoException("downloaded file is too small")
|
||||||
|
|
||||||
|
|
||||||
|
def download_decode(item, mak):
|
||||||
|
target = "%s.mpg" % item.file
|
||||||
|
mp4 = "%s.mp4" % item.file
|
||||||
|
try:
|
||||||
|
os.makedirs(item.dir)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
if 0 & os.path.exists(target):
|
||||||
|
logger.info(" reusing existing download file")
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
download(item, mak, target)
|
||||||
|
except Exception, e:
|
||||||
|
exc_info = sys.exc_info()
|
||||||
|
try:
|
||||||
|
os.remove(target)
|
||||||
|
except Exception, e2:
|
||||||
|
pass
|
||||||
|
raise exc_info[1], None, exc_info[2]
|
||||||
|
#tivomp4.transcode(target, mp4, item.ar)
|
||||||
|
try:
|
||||||
|
os.utime(target, (item.time, item.time))
|
||||||
|
#os.utime(mp4, [item.date, item.date])
|
||||||
|
except Exception, e:
|
||||||
|
logger.error("Problem setting timestamp: %" % (e))
|
||||||
|
|
||||||
|
|
||||||
|
def download_one(item, downloaddb):
|
||||||
|
global logger, mak
|
||||||
|
logger.info("*** downloading \"%s\": %.3fGB" % (item.name, item.sourcesize / 1e9))
|
||||||
|
try:
|
||||||
|
download_decode(item, mak)
|
||||||
|
downloaddb[item.name] = item.datestr
|
||||||
|
if getattr(downloaddb, "sync", None) and callable(downloaddb.sync):
|
||||||
|
downloaddb.sync()
|
||||||
|
logger.debug("Sleeping 30 seconds before moving on...")
|
||||||
|
time.sleep(30)
|
||||||
|
except TivoException, e:
|
||||||
|
logger.info("Error processing \"%s\": %s" % (item.name, e))
|
||||||
|
|
||||||
|
|
||||||
|
def wantitem(item, downloaddb):
|
||||||
|
if item.inprogress == "Yes":
|
||||||
|
return "recording"
|
||||||
|
if item.available == "No":
|
||||||
|
return "not available"
|
||||||
|
if downloaddb.has_key(item.name):
|
||||||
|
return "already downloaded"
|
||||||
|
#if excludes.has_key(item.title) or excludes.has_key(item.episode) or excludes.has_key(item.name):
|
||||||
|
# return "excluded"
|
||||||
|
if includes.has_key(item.title) or includes.has_key(item.episode) or includes.has_key(item.name):
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
return "not included"
|
||||||
|
return ""
|
||||||
|
|
||||||
|
|
||||||
|
def mirror(toc, downloaddb, one=False):
|
||||||
|
avail = getAvail(targetdir)
|
||||||
|
if avail < minfree:
|
||||||
|
logger.error("%s: %.1fG available, at least %.1fG needed, stopping" % \
|
||||||
|
(targetdir, avail / gig, minfree / gig))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
items = toc.getItems()
|
||||||
|
logger.info("*** %d shows listed" % (len(items)))
|
||||||
|
for item in items:
|
||||||
|
reason = wantitem(item, downloaddb)
|
||||||
|
if reason != "":
|
||||||
|
logger.debug("*** skipping \"%s\": %s" % (item.name, reason))
|
||||||
|
else:
|
||||||
|
download_one(item, downloaddb)
|
||||||
|
if one:
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
|
def download_episode(toc, downloaddb, episode):
|
||||||
|
items = toc.getItems()
|
||||||
|
for item in items:
|
||||||
|
if item.title == episode or item.name == episode or item.episode == episode:
|
||||||
|
download_one(item, downloaddb)
|
||||||
|
|
||||||
|
|
||||||
|
def printtoc(toc, downloaddb):
|
||||||
|
items = toc.getItems()
|
||||||
|
print "*** %d shows listed" % (len(items))
|
||||||
|
shows = {}
|
||||||
|
for item in items:
|
||||||
|
if item.title not in shows:
|
||||||
|
shows[item.title] = []
|
||||||
|
shows[item.title].append(item)
|
||||||
|
for title in sorted(shows):
|
||||||
|
for item in sorted(shows[title], key=lambda i: i.name):
|
||||||
|
reason = wantitem(item, downloaddb)
|
||||||
|
if (reason != ""):
|
||||||
|
print "%-7.7s: %s" % (reason, item.name)
|
||||||
|
continue
|
||||||
|
print "*** downloading %s (%.3fGB)" % (item.name, item.sourcesize / 1e9)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
global ignoreepisodetitle, logger
|
||||||
|
curdir = os.getcwd()
|
||||||
|
os.chdir(os.path.expanduser("~") + "/.tivo")
|
||||||
|
handler = logging.handlers.RotatingFileHandler("tivomirror.log", maxBytes=2*1024*1024, backupCount=5)
|
||||||
|
handler.setFormatter(logging.Formatter(fmt='tivomirror[%d] %%(asctime)s %%(levelname)6.6s %%(message)s' % (os.getpid()),
|
||||||
|
datefmt='%H:%M:%S'))
|
||||||
|
logger.addHandler(handler)
|
||||||
|
downloaddb = anydbm.open("downloads.db", "c")
|
||||||
|
toc = TivoToc()
|
||||||
|
cmd = "list"
|
||||||
|
updateToc = False
|
||||||
|
|
||||||
|
try:
|
||||||
|
options, remainder = getopt.getopt(sys.argv[1:], 'dvuT',
|
||||||
|
['ignoreepisodetitle', 'debug', 'verbose', 'update'])
|
||||||
|
|
||||||
|
for opt, arg in options:
|
||||||
|
if opt in ('-d', '--debug'):
|
||||||
|
logger.setLevel(logging.DEBUG)
|
||||||
|
if opt in ('-v', '--verbose'):
|
||||||
|
handler = logging.StreamHandler()
|
||||||
|
logger.addHandler(handler)
|
||||||
|
if opt in ('-u', '--update'):
|
||||||
|
updateToc = True
|
||||||
|
if opt in ('-T', '--ignoreepisodetitle'):
|
||||||
|
ignoreepisodetitle = True
|
||||||
|
|
||||||
|
if len(remainder) >= 1:
|
||||||
|
cmd = remainder[0]
|
||||||
|
|
||||||
|
if updateToc or cmd == "mirror":
|
||||||
|
toc.download()
|
||||||
|
toc.save()
|
||||||
|
else:
|
||||||
|
toc.load()
|
||||||
|
|
||||||
|
if cmd == "mirror":
|
||||||
|
mirror(toc, downloaddb)
|
||||||
|
elif cmd == "mirrorone":
|
||||||
|
mirror(toc, downloaddb, True)
|
||||||
|
elif cmd == "list":
|
||||||
|
printtoc(toc, downloaddb)
|
||||||
|
elif cmd == "download":
|
||||||
|
download_episode(toc, downloaddb, remainder[1])
|
||||||
|
else:
|
||||||
|
logger.error("invalid command %s" % (cmd))
|
||||||
|
print >>sys.stderr, "invalid command %s" % (cmd)
|
||||||
|
sys.exit(64)
|
||||||
|
|
||||||
|
downloaddb.close()
|
||||||
|
except Exception:
|
||||||
|
logger.exception("")
|
||||||
|
logger.info("*** Completed")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
115
src/tivomirror/transcode-to-mp4.py
Executable file
115
src/tivomirror/transcode-to-mp4.py
Executable file
|
@ -0,0 +1,115 @@
|
||||||
|
#!/usr/local/bin/python
|
||||||
|
|
||||||
|
import getopt
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
format = 5
|
||||||
|
|
||||||
|
|
||||||
|
def transcode(src, tgt, fmt):
|
||||||
|
global format
|
||||||
|
transcode_opts = [ "ffmpeg" ];
|
||||||
|
#transcode_opts = [ "ffmpeg-devel" ];
|
||||||
|
#transcode_opts.extend(["-t", "240"]) # testing only
|
||||||
|
#transcode_opts.extend(["-loglevel", "debug"])
|
||||||
|
transcode_opts.extend(["-i", src])
|
||||||
|
|
||||||
|
transcode_opts.extend(["-threads", "0"])
|
||||||
|
transcode_opts.extend(["-y", "-deinterlace"])
|
||||||
|
#transcode_opts.extend(["-ac", "2", "-ab", "128k"])
|
||||||
|
transcode_opts.extend(["-c:a", "libfdk_aac", "-ab", "192k"])
|
||||||
|
if format == 5:
|
||||||
|
transcode_opts.extend(["-vcodec", "libx265", "-x265-params", "crf=28"])
|
||||||
|
else:
|
||||||
|
transcode_opts.extend(["-vcodec", "libx264"])
|
||||||
|
transcode_opts.extend(["-tune", "film", "-profile", "main"])
|
||||||
|
if fmt == "hd":
|
||||||
|
transcode_opts.extend(["-s", "1280x720"])
|
||||||
|
#transcode_opts.extend(["-b:v", "3000k"])
|
||||||
|
transcode_opts.append(tgt)
|
||||||
|
elif fmt == "hdsmall":
|
||||||
|
transcode_opts.extend(["-s", "640x360"])
|
||||||
|
transcode_opts.extend(["-b:v", "1000k"])
|
||||||
|
transcode_opts.extend(["-vsync", "1"])
|
||||||
|
transcode_opts.append(tgt)
|
||||||
|
else:
|
||||||
|
transcode_opts.extend(["-b:v", "900k", "-bt", "900k"])
|
||||||
|
if str(fmt) == "169":
|
||||||
|
transcode_opts.extend(["-vf", "crop=640:360"])
|
||||||
|
transcode_opts.extend(["-aspect", "16:9"])
|
||||||
|
elif str(fmt) == "149":
|
||||||
|
transcode_opts.extend(["-vf", "crop=640:412"])
|
||||||
|
transcode_opts.extend(["-aspect", "14:9"])
|
||||||
|
transcode_opts.extend(["-vsync", "1"])
|
||||||
|
transcode_opts.append(tgt)
|
||||||
|
#if getInfo(src)[0] == "a":
|
||||||
|
#transcode_opts.extend(["-map", "0.1:0.0", "-map", "0.0:0.0"])
|
||||||
|
#transcode_opts.extend(["-map", "0.1:0.1", "-map", "0.0:0.1"])
|
||||||
|
|
||||||
|
print " \"%s\"" % "\" \"".join(transcode_opts)
|
||||||
|
subprocess.check_call(transcode_opts)
|
||||||
|
|
||||||
|
|
||||||
|
def getInfo(src):
|
||||||
|
c = []
|
||||||
|
o = [ "ffmpeg" ];
|
||||||
|
o.extend(["-i", src])
|
||||||
|
try:
|
||||||
|
p = subprocess.Popen(o, stderr=subprocess.PIPE)
|
||||||
|
(out, err) = p.communicate()
|
||||||
|
except subprocess.CalledProcessError, e:
|
||||||
|
pass
|
||||||
|
for l in err.split("\n"):
|
||||||
|
if l.find("Stream #") >=0:
|
||||||
|
w = l.split()
|
||||||
|
print w
|
||||||
|
if w[2] == "Audio:":
|
||||||
|
c.extend(["a"])
|
||||||
|
elif w[2] == "Video:":
|
||||||
|
c.extend(["v"])
|
||||||
|
else:
|
||||||
|
c.extend(["?"])
|
||||||
|
return c
|
||||||
|
|
||||||
|
class Usage(Exception):
|
||||||
|
def __init__(self, msg):
|
||||||
|
self.msg = msg;
|
||||||
|
def __str__(self):
|
||||||
|
return repr(self.msg)
|
||||||
|
|
||||||
|
|
||||||
|
def main(argv=None):
|
||||||
|
global format
|
||||||
|
if argv is None:
|
||||||
|
argv = sys.argv
|
||||||
|
try:
|
||||||
|
try:
|
||||||
|
opts, args = getopt.getopt(argv[1:], "hi:45", ["help"])
|
||||||
|
except getopt.error, msg:
|
||||||
|
raise Usage(msg)
|
||||||
|
for (o, v) in opts:
|
||||||
|
print "%s" % (o)
|
||||||
|
if o == "-h":
|
||||||
|
print >>sys.stderr, "help text"
|
||||||
|
return 0
|
||||||
|
if o == "-i":
|
||||||
|
print getInfo(v)
|
||||||
|
return 0
|
||||||
|
if o == "-4":
|
||||||
|
format = 4
|
||||||
|
if o == "-5":
|
||||||
|
format = 5
|
||||||
|
if len(args) != 3:
|
||||||
|
raise Usage("wrong number of arguments")
|
||||||
|
transcode(args[1], args[2], args[0])
|
||||||
|
except Usage, err:
|
||||||
|
print >>sys.stderr, err.msg
|
||||||
|
print >>sys.stderr, "tivomp4 format source destination"
|
||||||
|
print >>sys.stderr, "for help use --help"
|
||||||
|
return 64
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
1
tivodb
1
tivodb
|
@ -1 +0,0 @@
|
||||||
wrapper
|
|
|
@ -1 +0,0 @@
|
||||||
wrapper
|
|
657
tivomirror.py
657
tivomirror.py
|
@ -1,657 +0,0 @@
|
||||||
#!/usr/local/bin/python3.8
|
|
||||||
# -*- coding: utf8 -*-
|
|
||||||
|
|
||||||
# Download shows from the Tivo
|
|
||||||
|
|
||||||
import sys
|
|
||||||
#import importlib
|
|
||||||
#importlib.reload(sys)
|
|
||||||
#sys.setdefaultencoding('utf-8')
|
|
||||||
|
|
||||||
import dbm
|
|
||||||
import http.cookiejar
|
|
||||||
import datetime
|
|
||||||
import getopt
|
|
||||||
import errno
|
|
||||||
import fcntl
|
|
||||||
import functools
|
|
||||||
import logging
|
|
||||||
import logging.handlers
|
|
||||||
import os
|
|
||||||
import pytz
|
|
||||||
import re
|
|
||||||
import requests
|
|
||||||
import signal
|
|
||||||
import shutil
|
|
||||||
import subprocess
|
|
||||||
import sys
|
|
||||||
import threading
|
|
||||||
import time
|
|
||||||
import urllib.request, urllib.error, urllib.parse
|
|
||||||
import xml.dom.minidom
|
|
||||||
import yaml
|
|
||||||
|
|
||||||
from contextlib import contextmanager
|
|
||||||
from io import TextIOWrapper
|
|
||||||
|
|
||||||
|
|
||||||
class Config:
|
|
||||||
config = '~/.tivo/config.yaml'
|
|
||||||
lockfile = config + '.lock'
|
|
||||||
cookies = "cookies.txt"
|
|
||||||
gig = 1024.0 * 1024 * 1024
|
|
||||||
headers = requests.utils.default_headers()
|
|
||||||
host = "tivo.lassitu.de"
|
|
||||||
ignoreepisodetitle = False
|
|
||||||
mak = "7194378159"
|
|
||||||
minfree = 10 * gig
|
|
||||||
proxies = None
|
|
||||||
targetdir = "/p2/media/video/TV"
|
|
||||||
tivodecode = "tivodecode"
|
|
||||||
useragent = 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0'
|
|
||||||
|
|
||||||
def __init__(self, file=None):
|
|
||||||
self.postprocess = None
|
|
||||||
if file:
|
|
||||||
self.config = file
|
|
||||||
self.load(self.config)
|
|
||||||
|
|
||||||
self.headers.update({ 'User-Agent': self.useragent })
|
|
||||||
requests.packages.urllib3.disable_warnings()
|
|
||||||
self.session = requests.session()
|
|
||||||
self.session.verify = False
|
|
||||||
self.session.auth = requests.auth.HTTPDigestAuth("tivo", self.mak)
|
|
||||||
self.session.keep_alive = False
|
|
||||||
self.session.proxies = self.proxies
|
|
||||||
|
|
||||||
def load(self, file):
|
|
||||||
file = os.path.expanduser(file)
|
|
||||||
with open(file, 'r') as f:
|
|
||||||
y = yaml.safe_load(f)
|
|
||||||
|
|
||||||
for key in y:
|
|
||||||
setattr(self, key, y[key])
|
|
||||||
|
|
||||||
for show in self.shows:
|
|
||||||
if isinstance(show, dict):
|
|
||||||
if 'series' in show:
|
|
||||||
IncludeShow(show['series'],
|
|
||||||
short=show.get('short', show['series']),
|
|
||||||
unique=show.get('unique'))
|
|
||||||
else:
|
|
||||||
logger.error("Need either a string, or a dict with 'series' and 'short' entries for a show, got \"{}\".".format\
|
|
||||||
(show))
|
|
||||||
sys.exit(1)
|
|
||||||
else:
|
|
||||||
IncludeShow(show)
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
return "Config options for tivomirror (singleton)"
|
|
||||||
|
|
||||||
config = None
|
|
||||||
|
|
||||||
class IncludeShow:
|
|
||||||
includes = dict()
|
|
||||||
|
|
||||||
def __init__(self, title, short=None, unique=True):
|
|
||||||
self.short = short
|
|
||||||
self.title = title
|
|
||||||
self.timestamp = False
|
|
||||||
self.unique = unique or unique == None
|
|
||||||
self.includes[title] = self
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger('tivomirror')
|
|
||||||
logger.setLevel(logging.INFO)
|
|
||||||
|
|
||||||
|
|
||||||
class flushfile(object):
|
|
||||||
def __init__(self, f):
|
|
||||||
self.f = f
|
|
||||||
def write(self, x):
|
|
||||||
self.f.write(x)
|
|
||||||
self.f.flush()
|
|
||||||
#sys.stdout = flushfile(sys.stdout)
|
|
||||||
|
|
||||||
tmp = "/tmp"
|
|
||||||
|
|
||||||
# prepare global requests sesssion to download the TOC and the episodes
|
|
||||||
|
|
||||||
|
|
||||||
def roundTime(dt=None, roundTo=60):
|
|
||||||
"""
|
|
||||||
http://stackoverflow.com/questions/3463930/how-to-round-the-minute-of-a-datetime-object-python
|
|
||||||
"""
|
|
||||||
if dt == None : dt = datetime.datetime.now()
|
|
||||||
seconds = (dt.replace(tzinfo=None) - dt.min).seconds
|
|
||||||
rounding = (seconds+roundTo/2) // roundTo * roundTo
|
|
||||||
return dt + datetime.timedelta(0,rounding-seconds,-dt.microsecond)
|
|
||||||
|
|
||||||
|
|
||||||
class TimeoutError(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def timeout(seconds=10, error_message=os.strerror(errno.ETIMEDOUT)):
|
|
||||||
def decorator(func):
|
|
||||||
def _handle_timeout(signum, frame):
|
|
||||||
raise TimeoutError(error_message)
|
|
||||||
|
|
||||||
def wrapper(*args, **kwargs):
|
|
||||||
signal.signal(signal.SIGALRM, _handle_timeout)
|
|
||||||
signal.alarm(seconds)
|
|
||||||
try:
|
|
||||||
result = func(*args, **kwargs)
|
|
||||||
finally:
|
|
||||||
signal.alarm(0)
|
|
||||||
return result
|
|
||||||
|
|
||||||
return functools.wraps(func)(wrapper)
|
|
||||||
|
|
||||||
return decorator
|
|
||||||
|
|
||||||
|
|
||||||
def trimDescription(desc):
|
|
||||||
desc = desc.strip()
|
|
||||||
i = desc.rfind(". Copyright Tribune Media Services, Inc.");
|
|
||||||
if i > 0:
|
|
||||||
desc = desc[0:i]
|
|
||||||
i = desc.rfind(". * Copyright Rovi, Inc");
|
|
||||||
if i > 0:
|
|
||||||
desc = desc[0:i]
|
|
||||||
i = desc.rfind(". Copyright Rovi, Inc");
|
|
||||||
if i > 0:
|
|
||||||
desc = desc[0:i]
|
|
||||||
if len(desc) > 80:
|
|
||||||
desc = desc[0:80]
|
|
||||||
return desc
|
|
||||||
|
|
||||||
def saveCookies(session, filename):
|
|
||||||
cj = http.cookiejar.MozillaCookieJar(filename)
|
|
||||||
for cookie in session.cookies:
|
|
||||||
logger.debug("storing cookie {}".format(cookie))
|
|
||||||
cj.set_cookie(cookie)
|
|
||||||
logger.debug("Saving cookies to {}".format(cj))
|
|
||||||
cj.save(ignore_discard=True, ignore_expires=True)
|
|
||||||
|
|
||||||
|
|
||||||
class TivoException(Exception):
|
|
||||||
def __init__(self, value):
|
|
||||||
self.value = value
|
|
||||||
def __str__(self):
|
|
||||||
return repr(self.value)
|
|
||||||
|
|
||||||
class TivoItem:
|
|
||||||
def __init__(self, i):
|
|
||||||
self.title = getTagText(i, "Title")
|
|
||||||
self.episode = getTagText(i, "EpisodeTitle")
|
|
||||||
self.episodeNumber = getTagText(i, "EpisodeNumber")
|
|
||||||
self.description = trimDescription(getTagText(i, "Description"))
|
|
||||||
d = getTagText(i, "CaptureDate")
|
|
||||||
self.date = datetime.datetime.fromtimestamp(int(d, 16), pytz.utc)
|
|
||||||
self.time = int(d, base=0)
|
|
||||||
est = pytz.timezone('US/Eastern')
|
|
||||||
eastern = roundTime(self.date, 15*60).astimezone(est)
|
|
||||||
self.datestr = self.date.strftime("%Y%m%d-%H%M")
|
|
||||||
self.shortdate = eastern.strftime("%m%d-%H%M")
|
|
||||||
self.url = getTagText(i, "Url")
|
|
||||||
self.url = self.url + "&Format=video/x-tivo-mpeg-ts"
|
|
||||||
self.inprogress = getTagText(i, "InProgress")
|
|
||||||
self.available = getTagText(i, "Available")
|
|
||||||
self.sourcesize = int(getTagText(i, "SourceSize"))
|
|
||||||
self.highdef = getTagText(i, "HighDefinition")
|
|
||||||
self.unique = True
|
|
||||||
if config.ignoreepisodetitle:
|
|
||||||
self.episode = self.datestr
|
|
||||||
if self.episode == "":
|
|
||||||
if self.description != "":
|
|
||||||
self.episode = self.description
|
|
||||||
else:
|
|
||||||
self.episode = self.datestr
|
|
||||||
self.formatnames()
|
|
||||||
def makeNotUnique(self):
|
|
||||||
self.unique = False
|
|
||||||
self.formatnames()
|
|
||||||
def formatnames(self):
|
|
||||||
if self.episodeNumber and self.episodeNumber != '0':
|
|
||||||
en = int(self.episodeNumber)
|
|
||||||
if en >= 100:
|
|
||||||
self.name = "{} S{:02d}E{:02d} {}".format(self.title, int(en / 100), int(en % 100), self.episode)
|
|
||||||
else:
|
|
||||||
self.name = "{} E{} {}".format(self.title, self.episodeNumber, self.episode)
|
|
||||||
elif self.unique:
|
|
||||||
self.name = "{} - {}".format(self.title, self.episode)
|
|
||||||
else:
|
|
||||||
self.name = "{} - {} - {}".format(self.title, self.datestr, self.episode)
|
|
||||||
self.dir = "{}/{}".format(config.targetdir, re.sub("[:/]", "-", self.title))
|
|
||||||
self.file = "{}/{}".format(self.dir, re.sub("[:/]", "-", self.name))
|
|
||||||
#self.name = self.name.encode("utf-8");
|
|
||||||
#self.dir = self.dir.encode("utf-8");
|
|
||||||
#self.file = self.file.encode("utf-8");
|
|
||||||
def getPath(self, options):
|
|
||||||
title = self.title
|
|
||||||
if options.short:
|
|
||||||
title = options.short
|
|
||||||
if self.episodeNumber and self.episodeNumber != '0':
|
|
||||||
en = int(self.episodeNumber)
|
|
||||||
if en >= 100:
|
|
||||||
name = "{} S{:02d}E{:02d} {}".format(title, en / 100, en % 100, self.episode)
|
|
||||||
else:
|
|
||||||
name = "{} E{} {}".format(title, self.episodeNumber, self.episode)
|
|
||||||
elif self.unique:
|
|
||||||
name = "{} - {}".format(title, self.episode)
|
|
||||||
else:
|
|
||||||
name = "{} - {} {}".format(title, self.shortdate, self.episode)
|
|
||||||
path = "{}/{}".format(self.dir, re.sub("[:/]", "-", name))
|
|
||||||
return path
|
|
||||||
#return path.encode("utf-8");
|
|
||||||
def __str__(self):
|
|
||||||
return repr(self.title)
|
|
||||||
|
|
||||||
|
|
||||||
class TivoToc:
|
|
||||||
def __init__(self):
|
|
||||||
self.dom = None
|
|
||||||
self.filename = "toc.xml"
|
|
||||||
self.uniquedb = dbm.open("unique.db", "c")
|
|
||||||
self.items = []
|
|
||||||
pass
|
|
||||||
|
|
||||||
def load(self):
|
|
||||||
fd = open(self.filename, "r")
|
|
||||||
self.dom = xml.dom.minidom.parseString(fd.read())
|
|
||||||
fd.close()
|
|
||||||
return self.dom
|
|
||||||
|
|
||||||
def save(self):
|
|
||||||
fd = open(self.filename, "w")
|
|
||||||
fd.write(self.dom.toprettyxml())
|
|
||||||
fd.close()
|
|
||||||
|
|
||||||
def download_chunk(self, offset):
|
|
||||||
global config
|
|
||||||
|
|
||||||
params = {
|
|
||||||
'Command': 'QueryContainer',
|
|
||||||
'Container': '/NowPlaying',
|
|
||||||
'Recurse': 'Yes',
|
|
||||||
'ItemCount': '50',
|
|
||||||
'AnchorOffset': offset
|
|
||||||
}
|
|
||||||
url = "https://{}/TiVoConnect".format(config.host)
|
|
||||||
logger.debug(" offset {}".format(offset))
|
|
||||||
r = config.session.get(url, params=params, timeout=30, verify=False, proxies=config.proxies, headers=config.headers)
|
|
||||||
if r.status_code != 200:
|
|
||||||
r.raise_for_status()
|
|
||||||
return r.text
|
|
||||||
|
|
||||||
def download(self):
|
|
||||||
global config
|
|
||||||
offset = 0
|
|
||||||
itemCount = 1
|
|
||||||
self.dom = None
|
|
||||||
root = None
|
|
||||||
logger.info("*** Getting listing")
|
|
||||||
while itemCount > 0:
|
|
||||||
dom = xml.dom.minidom.parseString(self.download_chunk(offset))
|
|
||||||
if self.dom == None:
|
|
||||||
self.dom = dom
|
|
||||||
root = self.dom.childNodes.item(0)
|
|
||||||
else:
|
|
||||||
for child in dom.childNodes.item(0).childNodes:
|
|
||||||
if child.nodeName == "Item":
|
|
||||||
root.appendChild(child.cloneNode(True))
|
|
||||||
itemCount = int(getElementText(dom.documentElement.childNodes, "ItemCount"))
|
|
||||||
offset += itemCount
|
|
||||||
saveCookies(config.session, config.cookies)
|
|
||||||
return self.dom
|
|
||||||
|
|
||||||
def getItems(self):
|
|
||||||
self.titles = {}
|
|
||||||
for node in self.dom.getElementsByTagName("Item"):
|
|
||||||
item = TivoItem(node)
|
|
||||||
self.items.append(item)
|
|
||||||
if item.title not in self.titles:
|
|
||||||
self.titles[item.title] = []
|
|
||||||
self.titles[item.title].append(item)
|
|
||||||
# see if we have items that end up having an identical name; mark
|
|
||||||
# the program title in uniquedb if that's the case
|
|
||||||
for title in self.titles:
|
|
||||||
names = {}
|
|
||||||
for item in self.titles[title]:
|
|
||||||
if item.name not in names:
|
|
||||||
names[item.name] = []
|
|
||||||
names[item.name].append(item)
|
|
||||||
for name in names:
|
|
||||||
if len(names[name]) > 1 and title not in self.uniquedb:
|
|
||||||
self.uniquedb[title] = "1"
|
|
||||||
# utf8title = title.encode("utf-8")
|
|
||||||
# if len(names[name]) > 1 and utf8title not in self.uniquedb:
|
|
||||||
# self.uniquedb[utf8title] = "1"
|
|
||||||
if getattr(self.uniquedb, "sync", None) and callable(self.uniquedb.sync):
|
|
||||||
self.uniquedb.sync()
|
|
||||||
# update all items based on config and uniquedb
|
|
||||||
for item in self.items:
|
|
||||||
multiple = None
|
|
||||||
options = IncludeShow.includes.get(title)
|
|
||||||
if options and not options.unique:
|
|
||||||
item.makeNotUnique()
|
|
||||||
return self.items
|
|
||||||
|
|
||||||
|
|
||||||
def getText(nodelist):
|
|
||||||
rc = ""
|
|
||||||
for node in nodelist:
|
|
||||||
if node.nodeType == node.TEXT_NODE:
|
|
||||||
rc = rc + node.data
|
|
||||||
return rc
|
|
||||||
|
|
||||||
def getTagText(element, tagname):
|
|
||||||
try:
|
|
||||||
return getText(element.getElementsByTagName(tagname)[0].childNodes)
|
|
||||||
except IndexError:
|
|
||||||
return ""
|
|
||||||
|
|
||||||
def getElementText(nodes, name):
|
|
||||||
for node in nodes:
|
|
||||||
if node.nodeType == xml.dom.Node.ELEMENT_NODE and node.nodeName == name:
|
|
||||||
return getText(node.childNodes)
|
|
||||||
return None
|
|
||||||
|
|
||||||
def getAvail(dir):
|
|
||||||
s = os.statvfs(dir)
|
|
||||||
return s.f_bsize * s.f_bavail
|
|
||||||
|
|
||||||
|
|
||||||
class FdLogger(threading.Thread):
|
|
||||||
def __init__(self, logger, lvl, fd):
|
|
||||||
self.logger = logger
|
|
||||||
self.lvl = lvl
|
|
||||||
self.fd = fd
|
|
||||||
threading.Thread.__init__(self)
|
|
||||||
self.daemon = True
|
|
||||||
self.start()
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
try:
|
|
||||||
# for line in fd buffers, so use this instead
|
|
||||||
for line in iter(self.fd.readline, b''):
|
|
||||||
line = line.strip('\n')
|
|
||||||
if line.strip() != "":
|
|
||||||
self.logger.log(self.lvl, ": %s", line)
|
|
||||||
self.fd.close()
|
|
||||||
except Exception:
|
|
||||||
self.logger.exception("")
|
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
|
||||||
def exclusive():
|
|
||||||
with open(os.path.expanduser(config.lockfile), 'w') as f:
|
|
||||||
try:
|
|
||||||
fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
|
||||||
except BlockingIOError as e:
|
|
||||||
raise TivoException('another tivomirror instance is already running')
|
|
||||||
yield 'locked'
|
|
||||||
fcntl.lockf(f, fcntl.LOCK_UN)
|
|
||||||
|
|
||||||
@timeout(43200)
|
|
||||||
def download_item(item, mak, target):
|
|
||||||
global config
|
|
||||||
count = 0
|
|
||||||
start = time.time()
|
|
||||||
upd = start
|
|
||||||
url = item.url
|
|
||||||
#url = re.sub("tivo.lassitu.de:80", "wavehh.lassitu.de:30080", url)
|
|
||||||
logger.info("--- downloading \"{}\"".format(url))
|
|
||||||
logger.info(" {}".format(target))
|
|
||||||
start = time.time()
|
|
||||||
r = config.session.get(url, stream=True, verify=False, proxies=config.proxies, headers=config.headers)
|
|
||||||
r.raise_for_status()
|
|
||||||
|
|
||||||
try:
|
|
||||||
p_decode = subprocess.Popen([config.tivodecode, "--mak", mak, \
|
|
||||||
"--no-verify", "--out", target, "-"], stdin=subprocess.PIPE,
|
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
||||||
FdLogger(logger, logging.INFO, TextIOWrapper(p_decode.stdout))
|
|
||||||
FdLogger(logger, logging.INFO, TextIOWrapper(p_decode.stderr))
|
|
||||||
def info(signum, frame):
|
|
||||||
upd = time.time()
|
|
||||||
dur = now - start
|
|
||||||
mb = count / 1e6
|
|
||||||
print("{:5.1f}% {:5.3f} GB downloaded in {:.0f} min, {:.3f} MB/s".format(
|
|
||||||
100.0 * count / item.sourcesize,
|
|
||||||
mb / 1e3, dur / 60, mb / dur))
|
|
||||||
try:
|
|
||||||
signal.signal(signal.SIGINFO, info)
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
while True:
|
|
||||||
time.sleep(0) # yield to logger threads
|
|
||||||
chunk = r.raw.read(256*1024)
|
|
||||||
if not chunk:
|
|
||||||
break
|
|
||||||
p_decode.stdin.write(chunk)
|
|
||||||
count += len(chunk)
|
|
||||||
now = time.time()
|
|
||||||
if (now - upd) > 60:
|
|
||||||
upd = now
|
|
||||||
dur = now - start
|
|
||||||
mb = count / 1e6
|
|
||||||
logger.debug(" {:5.1f}% {:5.3f} GB downloaded in {:0.0f} min, {:0.3f} MB/s".format(
|
|
||||||
100.0 * count / item.sourcesize,
|
|
||||||
mb / 1e3, dur / 60, mb / dur))
|
|
||||||
except Exception as e:
|
|
||||||
logger.error("problem decoding: {}".format(e))
|
|
||||||
raise
|
|
||||||
finally:
|
|
||||||
try:
|
|
||||||
signal.signal(signal.SIGINFO, signal.SIG_IGN)
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
elapsed = time.time() - start
|
|
||||||
throughput = count / elapsed
|
|
||||||
logger.info("{:5.3f} GB transferred in {:d}:{:02d}, {:.1f} MB/s".format(
|
|
||||||
count/1e9, int(elapsed/3600), int(elapsed / 60) % 60, throughput/1e6))
|
|
||||||
try:
|
|
||||||
p_decode.stdin.close()
|
|
||||||
p_decode.poll()
|
|
||||||
if p_decode.returncode == None:
|
|
||||||
time.sleep(1)
|
|
||||||
p_decode.poll()
|
|
||||||
if p_decode.returncode == None:
|
|
||||||
logger.debug("terminating tivodecode")
|
|
||||||
p_decode.terminate()
|
|
||||||
except Exception as e:
|
|
||||||
pass
|
|
||||||
p_decode.wait()
|
|
||||||
logger.info("tivodecode exited with {}".format(p_decode.returncode))
|
|
||||||
size = os.path.getsize(target)
|
|
||||||
if size < 1024 or size < item.sourcesize * 0.8:
|
|
||||||
logger.error("error downloading file: too small")
|
|
||||||
os.remove(target)
|
|
||||||
raise TivoException("downloaded file is too small")
|
|
||||||
|
|
||||||
|
|
||||||
def download_decode(item, options, mak):
|
|
||||||
item.target = "{}.mpg".format(item.getPath(options))
|
|
||||||
try:
|
|
||||||
os.makedirs(item.dir)
|
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
download_item(item, mak, item.target)
|
|
||||||
except Exception as e:
|
|
||||||
exc_info = sys.exc_info()
|
|
||||||
try:
|
|
||||||
os.remove(item.target)
|
|
||||||
except Exception as e2:
|
|
||||||
pass
|
|
||||||
raise exc_info[1].with_traceback(exc_info[2])
|
|
||||||
try:
|
|
||||||
os.utime(item.target, (item.time, item.time))
|
|
||||||
except Exception as e:
|
|
||||||
logger.error("Problem setting timestamp: {}".format(e))
|
|
||||||
|
|
||||||
|
|
||||||
def download_one(item, downloaddb, options):
|
|
||||||
global config, logger
|
|
||||||
logger.info("*** downloading \"{}\": {:.3f} GB".format(item.name, item.sourcesize / 1e9))
|
|
||||||
# sys.exit(1)
|
|
||||||
try:
|
|
||||||
download_decode(item, options, config.mak)
|
|
||||||
downloaddb[item.name] = item.datestr
|
|
||||||
if getattr(downloaddb, "sync", None) and callable(downloaddb.sync):
|
|
||||||
downloaddb.sync()
|
|
||||||
if config.postprocess:
|
|
||||||
cmd = config.postprocess
|
|
||||||
try:
|
|
||||||
cmd = cmd.format(item=item, options=options, config=config)
|
|
||||||
r = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
|
|
||||||
logger.debug("Post-process {}: {}".format(cmd, r))
|
|
||||||
except Exception as e:
|
|
||||||
logger.warn("Error running postprocess command '{}' for item {}: {}".format(cmd, item, e))
|
|
||||||
logger.debug("Sleeping 30 seconds before moving on...")
|
|
||||||
time.sleep(30)
|
|
||||||
except TivoException as e:
|
|
||||||
logger.info("Error processing \"{}\": {}".format(item.name, e))
|
|
||||||
|
|
||||||
|
|
||||||
def wantitem(item, downloaddb):
|
|
||||||
if item.inprogress == "Yes":
|
|
||||||
return "recording"
|
|
||||||
if item.available == "No":
|
|
||||||
return "not available"
|
|
||||||
if item.name in downloaddb:
|
|
||||||
return "already downloaded"
|
|
||||||
for i in (item.title, item.episode, item.name):
|
|
||||||
if i in IncludeShow.includes:
|
|
||||||
return IncludeShow.includes[i]
|
|
||||||
return "not included"
|
|
||||||
|
|
||||||
|
|
||||||
def mirror(toc, downloaddb, one=False):
|
|
||||||
avail = getAvail(config.targetdir)
|
|
||||||
if avail < config.minfree:
|
|
||||||
logger.error("{}: {:.1f} GB available, at least {:.1f} GB needed, stopping".format\
|
|
||||||
(config.targetdir, avail / config.gig, config.minfree / config.gig))
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
with exclusive() as lock:
|
|
||||||
items = toc.getItems()
|
|
||||||
logger.info("*** {} shows listed".format(len(items)))
|
|
||||||
for item in items:
|
|
||||||
options = wantitem(item, downloaddb)
|
|
||||||
if isinstance(options, str):
|
|
||||||
logger.debug("*** skipping \"{}\": {}".format(item.name, options))
|
|
||||||
else:
|
|
||||||
download_one(item, downloaddb, options)
|
|
||||||
if one:
|
|
||||||
break
|
|
||||||
|
|
||||||
|
|
||||||
def download_episode(toc, downloaddb, episode):
|
|
||||||
with exclusive() as lock:
|
|
||||||
items = toc.getItems()
|
|
||||||
options = {}
|
|
||||||
for item in items:
|
|
||||||
if item.title == episode or item.name == episode or item.episode == episode:
|
|
||||||
for i in (item.title, item.episode, item.name):
|
|
||||||
if i in IncludeShow.includes:
|
|
||||||
options = IncludeShow.includes[i]
|
|
||||||
download_one(item, downloaddb, options)
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
def printtoc(toc, downloaddb):
|
|
||||||
with exclusive() as lock:
|
|
||||||
items = toc.getItems()
|
|
||||||
print("*** {} shows listed".format(len(items)))
|
|
||||||
shows = {}
|
|
||||||
for item in items:
|
|
||||||
if item.title not in shows:
|
|
||||||
shows[item.title] = []
|
|
||||||
shows[item.title].append(item)
|
|
||||||
for title in sorted(shows):
|
|
||||||
for item in sorted(shows[title], key=lambda i: i.name):
|
|
||||||
options = wantitem(item, downloaddb)
|
|
||||||
if isinstance(options, str):
|
|
||||||
print("{:>7.7s}: {}".format(options, item.name))
|
|
||||||
continue
|
|
||||||
print("*** downloading {} ({:.3f} GB)".format(item.name, item.sourcesize / 1e9))
|
|
||||||
print("*** {} shows listed".format(len(items)))
|
|
||||||
|
|
||||||
|
|
||||||
def usage():
|
|
||||||
print('usage: tivomirror -dvuT [-c config] cmd', file=sys.stderr)
|
|
||||||
print(' cmd is one of download, list, mirror, mirrorone', file=sys.stderr)
|
|
||||||
sys.exit(64)
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
global config, logger
|
|
||||||
curdir = os.getcwd()
|
|
||||||
os.chdir(os.path.expanduser("~/.tivo"))
|
|
||||||
handler = logging.handlers.RotatingFileHandler("tivomirror.log", maxBytes=2*1024*1024, backupCount=5)
|
|
||||||
handler.setFormatter(logging.Formatter(fmt='tivomirror[{}] %(asctime)s %(levelname)6.6s %(message)s'.format(os.getpid()),
|
|
||||||
datefmt='%d-%m %H:%M:%S'))
|
|
||||||
logger.addHandler(handler)
|
|
||||||
downloaddb = dbm.open("downloads.db", "c")
|
|
||||||
toc = TivoToc()
|
|
||||||
cmd = "list"
|
|
||||||
updateToc = False
|
|
||||||
conffile = None
|
|
||||||
|
|
||||||
try:
|
|
||||||
options, remainder = getopt.getopt(sys.argv[1:], 'c:dhvuT?',
|
|
||||||
['config', 'ignoreepisodetitle', 'debug', 'verbose', 'update', help])
|
|
||||||
|
|
||||||
for opt, arg in options:
|
|
||||||
if opt in ('-c', '--config'):
|
|
||||||
conffile = arg
|
|
||||||
if opt in ('-d', '--debug'):
|
|
||||||
logger.setLevel(logging.DEBUG)
|
|
||||||
if opt in ('-v', '--verbose'):
|
|
||||||
handler = logging.StreamHandler()
|
|
||||||
logger.addHandler(handler)
|
|
||||||
if opt in ('-u', '--update'):
|
|
||||||
updateToc = True
|
|
||||||
if opt in ('-T', '--ignoreepisodetitle'):
|
|
||||||
config.ignoreepisodetitle = True
|
|
||||||
if opt in ('-h', '-?', '--help'):
|
|
||||||
usage()
|
|
||||||
|
|
||||||
config = Config(conffile)
|
|
||||||
|
|
||||||
if len(remainder) >= 1:
|
|
||||||
cmd = remainder[0]
|
|
||||||
|
|
||||||
if updateToc or cmd == "mirror":
|
|
||||||
toc.download()
|
|
||||||
toc.save()
|
|
||||||
else:
|
|
||||||
toc.load()
|
|
||||||
|
|
||||||
if cmd == "mirror":
|
|
||||||
mirror(toc, downloaddb)
|
|
||||||
elif cmd == "mirrorone":
|
|
||||||
mirror(toc, downloaddb, True)
|
|
||||||
elif cmd == "list":
|
|
||||||
printtoc(toc, downloaddb)
|
|
||||||
elif cmd == "download":
|
|
||||||
download_episode(toc, downloaddb, remainder[1])
|
|
||||||
else:
|
|
||||||
logger.error("invalid command {}".format(cmd))
|
|
||||||
print("invalid command {}".format(cmd), file=sys.stderr)
|
|
||||||
usage()
|
|
||||||
|
|
||||||
downloaddb.close()
|
|
||||||
except getopt.GetoptError as e:
|
|
||||||
print('Error parsing options: {}'.format(e), file=sys.stderr)
|
|
||||||
usage()
|
|
||||||
except Exception:
|
|
||||||
logger.exception("")
|
|
||||||
logger.info("*** Completed")
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
6
wrapper
6
wrapper
|
@ -1,6 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
here="$(dirname $0)"
|
|
||||||
this="$(basename $0)"
|
|
||||||
. ${here}/.venv/bin/activate
|
|
||||||
exec python ${here}/${this}.py $@
|
|
Loading…
Reference in a new issue