import 0.3

This commit is contained in:
jolan 2004-01-23 05:20:48 +00:00
parent 50d42dabc2
commit 92fa84a4cd
20 changed files with 541 additions and 0 deletions

View File

@ -0,0 +1,28 @@
# $OpenBSD: Makefile,v 1.1.1.1 2004/01/23 05:20:48 jolan Exp $
COMMENT= "command line implementation of the PAR v2.0 specification"
DISTNAME= par2cmdline-0.3
CATEGORIES= archivers
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=parchive/}
HOMEPAGE= http://parchive.sourceforge.net/\#client_par2cmdline
MAINTAINER= Jolan Luff <jolan@openbsd.org>
# GPL
PERMIT_DISTFILES_CDROM= Yes
PERMIT_DISTFILES_FTP= Yes
PERMIT_PACKAGE_CDROM= Yes
PERMIT_PACKAGE_FTP= Yes
MODULES=gcc3
MODGCC3_ARCHES= sparc64
MODGCC3_LANGS= C++
CONFIGURE_STYLE=gnu
post-install:
${INSTALL_DATA_DIR} ${PREFIX}/share/doc/par2cmdline
${INSTALL_DATA} ${WRKSRC}/README ${PREFIX}/share/doc/par2cmdline
.include <bsd.port.mk>

View File

@ -0,0 +1,3 @@
MD5 (par2cmdline-0.3.tar.gz) = 705c97bc41b862d281dd41c219a60849
RMD160 (par2cmdline-0.3.tar.gz) = d4bd5a5c8f3bd1218f1e61fa1b981c5b22c26ed1
SHA1 (par2cmdline-0.3.tar.gz) = 4202ffec5d5fa1e9d83da8e0c6e936832082f17d

View File

@ -0,0 +1,11 @@
$OpenBSD: patch-Makefile_in,v 1.1.1.1 2004/01/23 05:20:48 jolan Exp $
--- Makefile.in.orig 2003-07-15 05:34:19.000000000 -0500
+++ Makefile.in 2004-01-19 01:50:36.000000000 -0600
@@ -637,7 +637,6 @@ install-data-am:
install-exec-am: install-binPROGRAMS
@$(NORMAL_INSTALL)
- $(MAKE) $(AM_MAKEFLAGS) install-exec-hook
install-info: install-info-am

View File

@ -0,0 +1,16 @@
$OpenBSD: patch-README,v 1.1.1.1 2004/01/23 05:20:48 jolan Exp $
--- README.orig 2003-05-26 13:01:29.000000000 -0500
+++ README 2004-01-19 01:47:51.000000000 -0600
@@ -81,12 +81,6 @@ The command line parameters for par2cmdl
par2 v(erify) [options] <par2 file> [files]
par2 r(epair) [options] <par2 file> [files]
- Also:
-
- par2create [options] <par2 file> [files]
- par2verify [options] <par2 file> [files]
- par2repair [options] <par2 file> [files]
-
Options:
-b<n> : Set the Block-Count

View File

@ -0,0 +1,16 @@
$OpenBSD: patch-commandline_cpp,v 1.1.1.1 2004/01/23 05:20:48 jolan Exp $
--- commandline.cpp.orig 2003-06-24 08:11:02.000000000 -0500
+++ commandline.cpp 2004-01-19 01:47:14.000000000 -0600
@@ -82,12 +82,6 @@ void CommandLine::usage(void)
" par2 v(erify) [options] <par2 file> [files] : Verify files using PAR2 file\n"
" par2 r(epair) [options] <par2 file> [files] : Repair files using PAR2 files\n"
"\n"
- "Also:\n"
- "\n"
- " par2create [options] <par2 file> [files]\n"
- " par2verify [options] <par2 file> [files]\n"
- " par2repair [options] <par2 file> [files]\n"
- "\n"
"Options:\n"
"\n"
" -b<n> : Set the Block-Count\n"

View File

@ -0,0 +1,21 @@
$OpenBSD: patch-diskfile_cpp,v 1.1.1.1 2004/01/23 05:20:48 jolan Exp $
--- diskfile.cpp.orig 2003-05-26 13:01:14.000000000 -0500
+++ diskfile.cpp 2004-01-19 02:04:20.000000000 -0600
@@ -17,6 +17,8 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#include <sys/param.h>
+
#include "par2cmdline.h"
#ifdef _MSC_VER
@@ -550,7 +552,7 @@ string DiskFile::GetCanonicalPathname(st
return filename;
// Get the current directory
- char curdir[1000];
+ char curdir[MAXPATHLEN];
if (0 == getcwd(curdir, sizeof(curdir)))
{
return filename;

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-galois_h,v 1.1.1.1 2004/01/23 05:20:48 jolan Exp $
--- galois.h.orig 2003-06-13 18:22:04.000000000 -0500
+++ galois.h 2004-01-21 18:06:05.000000000 -0600
@@ -156,7 +156,7 @@ GaloisTable<bits,generator,valuetype> Ga
template <const unsigned int bits, const unsigned int generator, typename valuetype>
-inline Galois<bits,generator,valuetype>::Galois(Galois<bits,generator,valuetype>::ValueType v)
+inline Galois<bits,generator,valuetype>::Galois(typename Galois<bits,generator,valuetype>::ValueType v)
{
value = v;
}

View File

@ -0,0 +1,52 @@
$OpenBSD: patch-md5_h,v 1.1.1.1 2004/01/23 05:20:48 jolan Exp $
--- md5.h.orig 2003-05-26 13:01:20.000000000 -0500
+++ md5.h 2004-01-22 15:52:42.000000000 -0600
@@ -114,14 +114,7 @@ protected:
inline bool MD5Hash::operator==(const MD5Hash &other) const
{
- for (unsigned int i=0; i<4; i++)
- {
- if (((u32*)&hash)[i] != ((u32*)&other.hash)[i])
- {
- return false;
- }
- }
- return true;
+ return (0==memcmp(&hash, &other.hash, sizeof(hash)));
}
inline bool MD5Hash::operator!=(const MD5Hash &other) const
{
@@ -130,25 +123,13 @@ inline bool MD5Hash::operator!=(const MD
inline bool MD5Hash::operator<(const MD5Hash &other) const
{
- if (*(u32*)(&hash[12]) < *(u32*)(&other.hash[12]))
- return true;
- else if (*(u32*)(&hash[12]) > *(u32*)(&other.hash[12]))
- return false;
-
- else if (*(u32*)(&hash[8]) < *(u32*)(&other.hash[8]))
- return true;
- else if (*(u32*)(&hash[8]) > *(u32*)(&other.hash[8]))
- return false;
-
- else if (*(u32*)(&hash[4]) < *(u32*)(&other.hash[4]))
- return true;
- else if (*(u32*)(&hash[4]) > *(u32*)(&other.hash[4]))
- return false;
-
- else if (*(u32*)(&hash[0]) < *(u32*)(&other.hash[0]))
- return true;
- else
- return false;
+ size_t index = 15;
+ while (index > 0 && hash[index] == other.hash[index])
+ {
+ index--;
+ }
+
+ return hash[index] < other.hash[index];
}
inline bool MD5Hash::operator>=(const MD5Hash &other) const
{

View File

@ -0,0 +1,13 @@
$OpenBSD: patch-par1fileformat_h,v 1.1.1.1 2004/01/23 05:20:48 jolan Exp $
--- par1fileformat.h.orig 2003-05-26 13:01:20.000000000 -0500
+++ par1fileformat.h 2004-01-21 18:06:05.000000000 -0600
@@ -77,8 +77,7 @@ enum FILEENTRYSTATUS
inline bool operator == (const PAR1MAGIC &left, const PAR1MAGIC &right)
{
- return ((u32*)&left)[0] == ((u32*)&right)[0] &&
- ((u32*)&left)[1] == ((u32*)&right)[1];
+ return (0==memcmp(&left, &right, sizeof(left)));
}
inline bool operator != (const PAR1MAGIC &left, const PAR1MAGIC &right)

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-par1repairer_cpp,v 1.1.1.1 2004/01/23 05:20:48 jolan Exp $
--- par1repairer.cpp.orig 2003-06-11 08:45:01.000000000 -0500
+++ par1repairer.cpp 2004-01-21 18:06:05.000000000 -0600
@@ -372,7 +372,7 @@ bool Par1Repairer::LoadRecoveryFile(stri
blocksize = fileentry->filesize;
// Copy whole of file entry
- memcpy((void*)fileentry, (void*)current, fileentry->entrysize);
+ memcpy((void*)fileentry, (void*)current, (size_t)(u64)fileentry->entrysize);
// Create source file and add it to the appropriate list
Par1RepairerSourceFile *sourcefile = new Par1RepairerSourceFile(fileentry, searchpath);

View File

@ -0,0 +1,19 @@
$OpenBSD: patch-par1repairersourcefile_cpp,v 1.1.1.1 2004/01/23 05:20:48 jolan Exp $
--- par1repairersourcefile.cpp.orig 2003-05-26 13:01:20.000000000 -0500
+++ par1repairersourcefile.cpp 2004-01-21 18:06:05.000000000 -0600
@@ -60,9 +60,12 @@ Par1RepairerSourceFile::Par1RepairerSour
// Strip the path from the filename
string::size_type where;
- if (string::npos != (where = filename.find_last_of('\\')) ||
- string::npos != (where = filename.find_last_of('/')) ||
- string::npos != (where = filename.find_last_of(':')))
+ if (string::npos != (where = filename.find_last_of('\\'))
+ || string::npos != (where = filename.find_last_of('/'))
+#ifdef WIN32
+ || string::npos != (where = filename.find_last_of(':'))
+#endif
+ )
{
filename = filename.substr(where+1);
}

View File

@ -0,0 +1,20 @@
$OpenBSD: patch-par2cmdline_h,v 1.1.1.1 2004/01/23 05:20:48 jolan Exp $
--- par2cmdline.h.orig 2003-06-07 17:43:38.000000000 -0500
+++ par2cmdline.h 2004-01-21 18:06:05.000000000 -0600
@@ -35,6 +35,7 @@
#include <ctype.h>
#include <iostream>
+#include <iomanip>
#include <cassert>
@@ -105,7 +106,7 @@ typedef unsigned int size_t;
# endif
#endif
-#if STC_HEADERS
+#if STDC_HEADERS
# include <string.h>
#else
# if !HAVE_STRCHR

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-par2creator_cpp,v 1.1.1.1 2004/01/23 05:20:48 jolan Exp $
--- par2creator.cpp.orig 2003-06-24 09:13:59.000000000 -0500
+++ par2creator.cpp 2004-01-21 18:06:05.000000000 -0600
@@ -835,7 +835,7 @@ bool Par2Creator::ProcessData(u64 blocko
return false;
}
- cout << "Wrote " << recoveryblockcount * chunksize << " bytes to disk" << endl;
+ cout << "Wrote " << recoveryblockcount * blocklength << " bytes to disk" << endl;
return true;
}

View File

@ -0,0 +1,25 @@
$OpenBSD: patch-par2fileformat_h,v 1.1.1.1 2004/01/23 05:20:48 jolan Exp $
--- par2fileformat.h.orig 2003-05-26 13:01:25.000000000 -0500
+++ par2fileformat.h 2004-01-21 18:06:05.000000000 -0600
@@ -169,8 +169,7 @@ struct RECOVERYBLOCKPACKET
inline bool operator == (const MAGIC &left, const MAGIC &right)
{
- return ((u32*)&left)[0] == ((u32*)&right)[0] &&
- ((u32*)&left)[1] == ((u32*)&right)[1];
+ return (0==memcmp(&left, &right, sizeof(left)));
}
inline bool operator != (const MAGIC &left, const MAGIC &right)
@@ -180,10 +179,7 @@ inline bool operator != (const MAGIC &le
inline bool operator == (const PACKETTYPE &left, const PACKETTYPE &right)
{
- return ((u32*)&left)[0] == ((u32*)&right)[0] &&
- ((u32*)&left)[1] == ((u32*)&right)[1] &&
- ((u32*)&left)[2] == ((u32*)&right)[2] &&
- ((u32*)&left)[3] == ((u32*)&right)[3];
+ return (0==memcmp(&left, &right, sizeof(left)));
}
inline bool operator != (const PACKETTYPE &left, const PACKETTYPE &right)

View File

@ -0,0 +1,153 @@
$OpenBSD: patch-par2repairer_cpp,v 1.1.1.1 2004/01/23 05:20:48 jolan Exp $
--- par2repairer.cpp.orig 2003-05-26 13:01:26.000000000 -0500
+++ par2repairer.cpp 2004-01-21 18:06:05.000000000 -0600
@@ -341,7 +341,7 @@ bool Par2Repairer::LoadPacketsFromFile(s
// Did we find the magic
if (current <= limit)
{
- header = *(PACKET_HEADER*)current;
+ memcpy(&header, current, sizeof(header));
break;
}
}
@@ -820,6 +820,9 @@ bool Par2Repairer::CheckPacketConsistenc
continue;
}
+ // Compute and store the block count from the filesize and blocksize
+ sf->second->SetBlockCount(blocksize);
+
// Do we have a verification packet
VerificationPacket *verificationpacket = sf->second->GetVerificationPacket();
if (verificationpacket == 0)
@@ -916,14 +919,14 @@ bool Par2Repairer::AllocateSourceBlocks(
Par2RepairerSourceFile *sourcefile = *sf;
if (sourcefile)
{
- sourceblockcount += sourcefile->GetVerificationPacket()->BlockCount();
+ sourceblockcount += sourcefile->BlockCount();
}
else
{
// No details for this source file so we don't know what the
// total number of source blocks is
- sourceblockcount = 0;
- break;
+// sourceblockcount = 0;
+// break;
}
++sf;
@@ -955,16 +958,19 @@ bool Par2Repairer::AllocateSourceBlocks(
{
Par2RepairerSourceFile *sourcefile = *sf;
- totalsize += sourcefile->GetDescriptionPacket()->FileSize();
- u32 blockcount = sourcefile->GetVerificationPacket()->BlockCount();
+ if (sourcefile)
+ {
+ totalsize += sourcefile->GetDescriptionPacket()->FileSize();
+ u32 blockcount = sourcefile->BlockCount();
- // Allocate the source and target DataBlocks to the sourcefile
- sourcefile->SetBlocks(blocknumber, blockcount, sourceblock, targetblock, blocksize);
+ // Allocate the source and target DataBlocks to the sourcefile
+ sourcefile->SetBlocks(blocknumber, blockcount, sourceblock, targetblock, blocksize);
- blocknumber++;
+ blocknumber++;
- sourceblock += blockcount;
- targetblock += blockcount;
+ sourceblock += blockcount;
+ targetblock += blockcount;
+ }
++sf;
++filenumber;
@@ -1069,7 +1075,7 @@ bool Par2Repairer::VerifySourceFiles(voi
// Was this one of the recoverable files
if (filenumber < mainpacket->RecoverableFileCount())
{
- cerr << "No details available for recoverable file number " << filenumber+1 << ". Recovery will not be possible." << endl;
+ cerr << "No details available for recoverable file number " << filenumber+1 << "." << endl << "Recovery will not be possible." << endl;
// Set error but let verification of other files continue
finalresult = false;
@@ -1676,42 +1682,49 @@ void Par2Repairer::UpdateVerificationRes
{
Par2RepairerSourceFile *sourcefile = *sf;
- // Was a perfect match for the file found
- if (sourcefile->GetCompleteFile() != 0)
+ if (sourcefile)
{
- // Is it the target file or a different one
- if (sourcefile->GetCompleteFile() == sourcefile->GetTargetFile())
+ // Was a perfect match for the file found
+ if (sourcefile->GetCompleteFile() != 0)
{
- completefilecount++;
+ // Is it the target file or a different one
+ if (sourcefile->GetCompleteFile() == sourcefile->GetTargetFile())
+ {
+ completefilecount++;
+ }
+ else
+ {
+ renamedfilecount++;
+ }
+
+ availableblockcount += sourcefile->BlockCount();
}
else
{
- renamedfilecount++;
- }
+ // Count the number of blocks that have been found
+ vector<DataBlock>::iterator sb = sourcefile->SourceBlocks();
+ for (u32 blocknumber=0; blocknumber<sourcefile->BlockCount(); ++blocknumber, ++sb)
+ {
+ DataBlock &datablock = *sb;
+
+ if (datablock.IsSet())
+ availableblockcount++;
+ }
- availableblockcount += sourcefile->BlockCount();
+ // Does the target file exist
+ if (sourcefile->GetTargetExists())
+ {
+ damagedfilecount++;
+ }
+ else
+ {
+ missingfilecount++;
+ }
+ }
}
else
{
- // Count the number of blocks that have been found
- vector<DataBlock>::iterator sb = sourcefile->SourceBlocks();
- for (u32 blocknumber=0; blocknumber<sourcefile->BlockCount(); ++blocknumber, ++sb)
- {
- DataBlock &datablock = *sb;
-
- if (datablock.IsSet())
- availableblockcount++;
- }
-
- // Does the target file exist
- if (sourcefile->GetTargetExists())
- {
- damagedfilecount++;
- }
- else
- {
- missingfilecount++;
- }
+ missingfilecount++;
}
++filenumber;

View File

@ -0,0 +1,36 @@
$OpenBSD: patch-par2repairersourcefile_cpp,v 1.1.1.1 2004/01/23 05:20:48 jolan Exp $
--- par2repairersourcefile.cpp.orig 2003-05-26 13:01:27.000000000 -0500
+++ par2repairersourcefile.cpp 2004-01-21 18:06:05.000000000 -0600
@@ -68,9 +68,12 @@ void Par2RepairerSourceFile::ComputeTarg
// Strip the path from the filename
string::size_type where;
- if (string::npos != (where = filename.find_last_of('\\')) ||
- string::npos != (where = filename.find_last_of('/')) ||
- string::npos != (where = filename.find_last_of(':')))
+ if (string::npos != (where = filename.find_last_of('\\'))
+ || string::npos != (where = filename.find_last_of('/'))
+#ifdef WIN32
+ || string::npos != (where = filename.find_last_of(':'))
+#endif
+ )
{
filename = filename.substr(where+1);
}
@@ -141,3 +144,16 @@ void Par2RepairerSourceFile::SetBlocks(u
}
}
}
+
+// Determine the block count from the file size and block size.
+void Par2RepairerSourceFile::SetBlockCount(u64 blocksize)
+{
+ if (descriptionpacket)
+ {
+ blockcount = (u32)((descriptionpacket->FileSize() + blocksize-1) / blocksize);
+ }
+ else
+ {
+ blockcount = 0;
+ }
+}

View File

@ -0,0 +1,13 @@
$OpenBSD: patch-par2repairersourcefile_h,v 1.1.1.1 2004/01/23 05:20:48 jolan Exp $
--- par2repairersourcefile.h.orig 2003-05-26 13:01:28.000000000 -0500
+++ par2repairersourcefile.h 2004-01-21 18:06:05.000000000 -0600
@@ -55,6 +55,9 @@ public:
vector<DataBlock>::iterator _targetblocks,
u64 blocksize);
+ // Determine the block count from the file size and block size.
+ void SetBlockCount(u64 blocksize);
+
// Set/Get which DiskFile will contain the final repaired version of the file
void SetTargetFile(DiskFile *diskfile);
DiskFile* GetTargetFile(void) const;

View File

@ -0,0 +1,73 @@
$OpenBSD: patch-reedsolomon_h,v 1.1.1.1 2004/01/23 05:20:48 jolan Exp $
--- reedsolomon.h.orig 2003-05-26 13:01:31.000000000 -0500
+++ reedsolomon.h 2004-01-21 18:06:05.000000000 -0600
@@ -326,9 +326,7 @@ inline bool ReedSolomon<g>::Compute(void
// Perform Gaussian Elimination and then delete the right matrix (which
// will no longer be required).
bool success = GaussElim(outcount, incount, leftmatrix, rightmatrix, datamissing);
-cout << "GaussElim done" << endl;
delete [] rightmatrix;
-cout << "Exiting RS::Compute" << endl;
return success;
}
@@ -339,6 +337,29 @@ cout << "Exiting RS::Compute" << endl;
template<class g>
inline bool ReedSolomon<g>::GaussElim(unsigned int rows, unsigned int leftcols, G *leftmatrix, G *rightmatrix, unsigned int datamissing)
{
+#ifdef DUMPRSMATRIX
+ for (unsigned int row=0; row<rows; row++)
+ {
+ cout << ((row==0) ? "/" : (row==rows-1) ? "\\" : "|");
+ for (unsigned int col=0; col<leftcols; col++)
+ {
+ cout << " "
+ << hex << setw(G::Bits>8?4:2) << setfill('0')
+ << (unsigned int)leftmatrix[row*leftcols+col];
+ }
+ cout << ((row==0) ? " \\ /" : (row==rows-1) ? " / \\" : " | |");
+ for (unsigned int col=0; col<rows; col++)
+ {
+ cout << " "
+ << hex << setw(G::Bits>8?4:2) << setfill('0')
+ << (unsigned int)rightmatrix[row*rows+col];
+ }
+ cout << ((row==0) ? " \\" : (row==rows-1) ? " /" : " | |");
+ cout << endl;
+
+ cout << dec << setw(0) << setfill(' ');
+ }
+#endif
// Because the matrices being operated on are Vandermonde matrices
// they are guaranteed not to be singular.
@@ -442,7 +463,29 @@ inline bool ReedSolomon<g>::GaussElim(un
}
}
cout << "Solving: done." << endl;
+#ifdef DUMPRSMATRIX
+ for (unsigned int row=0; row<rows; row++)
+ {
+ cout << ((row==0) ? "/" : (row==rows-1) ? "\\" : "|");
+ for (unsigned int col=0; col<leftcols; col++)
+ {
+ cout << " "
+ << hex << setw(G::Bits>8?4:2) << setfill('0')
+ << (unsigned int)leftmatrix[row*leftcols+col];
+ }
+ cout << ((row==0) ? " \\ /" : (row==rows-1) ? " / \\" : " | |");
+ for (unsigned int col=0; col<rows; col++)
+ {
+ cout << " "
+ << hex << setw(G::Bits>8?4:2) << setfill('0')
+ << (unsigned int)rightmatrix[row*rows+col];
+ }
+ cout << ((row==0) ? " \\" : (row==rows-1) ? " /" : " | |");
+ cout << endl;
+ cout << dec << setw(0) << setfill(' ');
+ }
+#endif
return true;
}

View File

@ -0,0 +1,2 @@
par2cmdline is a command line implementation of the PAR v2.0
specification.

View File

@ -0,0 +1,4 @@
@comment $OpenBSD: PLIST,v 1.1.1.1 2004/01/23 05:20:48 jolan Exp $
bin/par2
share/doc/par2cmdline/README
@dirrm share/doc/par2cmdline