~ubuntu-branches/debian/experimental/nzbget/experimental

« back to all changes in this revision

Viewing changes to lib/par2/commandline.h

  • Committer: Package Import Robot
  • Author(s): Andreas Moog
  • Date: 2014-12-25 12:58:06 UTC
  • mfrom: (1.2.1) (3.1.4 sid)
  • Revision ID: package-import@ubuntu.com-20141225125806-vnzgajhm7mju9933
Tags: 14.1+dfsg-1
* New Upstream release (Closes: #768863)
* debian/patches:
  - Remove 0010_unnecessary_gcryptdep.patch, included upstream
  - Refresh remaining patches
* debian/control:
  - Remove no longer needed build-depends on libpar2-dev and libsigc++-dev
* debian/nzbget.conf
  - Update sample configuration file to include new options introduced by
    new upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//  This file is part of par2cmdline (a PAR 2.0 compatible file verification and
 
2
//  repair tool). See http://parchive.sourceforge.net for details of PAR 2.0.
 
3
//
 
4
//  Copyright (c) 2003 Peter Brian Clements
 
5
//
 
6
//  par2cmdline is free software; you can redistribute it and/or modify
 
7
//  it under the terms of the GNU General Public License as published by
 
8
//  the Free Software Foundation; either version 2 of the License, or
 
9
//  (at your option) any later version.
 
10
//
 
11
//  par2cmdline is distributed in the hope that it will be useful,
 
12
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
//  GNU General Public License for more details.
 
15
//
 
16
//  You should have received a copy of the GNU General Public License
 
17
//  along with this program; if not, write to the Free Software
 
18
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 
19
 
 
20
#ifndef __COMMANDLINE_H__
 
21
#define __COMMANDLINE_H__
 
22
 
 
23
// The CommandLine object is responsible for understanding the format
 
24
// of the command line parameters are parsing the command line to
 
25
// extract details as to what the user wants to do.
 
26
 
 
27
class CommandLine
 
28
{
 
29
public:
 
30
  CommandLine(void);
 
31
 
 
32
  // Parse the supplied command line arguments. 
 
33
  bool Parse(int argc, char *argv[]);
 
34
 
 
35
  // Display details of the correct format for command line parameters.
 
36
  static void usage(void);
 
37
 
 
38
  // What operation will we be carrying out
 
39
  typedef enum
 
40
  {
 
41
    opNone = 0,
 
42
    opCreate,        // Create new PAR2 recovery volumes
 
43
    opVerify,        // Verify but don't repair damaged data files
 
44
    opRepair         // Verify and if possible repair damaged data files
 
45
  } Operation;
 
46
 
 
47
  typedef enum
 
48
  {
 
49
    verUnknown = 0,
 
50
    verPar1,         // Processing PAR 1.0 files
 
51
    verPar2          // Processing PAR 2.0 files
 
52
  } Version;
 
53
 
 
54
  typedef enum
 
55
  {
 
56
    scUnknown = 0,
 
57
    scVariable,      // Each PAR2 file will have 2x as many blocks as previous
 
58
    scLimited,       // Limit PAR2 file size
 
59
    scUniform        // All PAR2 files the same size
 
60
  } Scheme;
 
61
 
 
62
  typedef enum
 
63
  {
 
64
    nlUnknown = 0,
 
65
    nlSilent,       // Absolutely no output (other than errors)
 
66
    nlQuiet,        // Bare minimum of output
 
67
    nlNormal,       // Normal level of output
 
68
    nlNoisy,        // Lots of output
 
69
    nlDebug         // Extra debugging information
 
70
  } NoiseLevel;
 
71
 
 
72
  // Any extra files listed on the command line
 
73
  class ExtraFile
 
74
  {
 
75
  public:
 
76
    ExtraFile(void);
 
77
    ExtraFile(const ExtraFile&);
 
78
    ExtraFile& operator=(const ExtraFile&);
 
79
 
 
80
    ExtraFile(const string &name, u64 size);
 
81
 
 
82
    string FileName(void) const {return filename;}
 
83
    u64 FileSize(void) const {return filesize;}
 
84
 
 
85
  protected:
 
86
    string filename;
 
87
    u64    filesize;
 
88
  };
 
89
 
 
90
public:
 
91
  // Accessor functions for the command line parameters
 
92
 
 
93
  CommandLine::Operation GetOperation(void) const          {return operation;}
 
94
  CommandLine::Version   GetVersion(void) const            {return version;}
 
95
  u64                    GetBlockSize(void) const          {return blocksize;}
 
96
  u32                    GetBlockCount(void) const         {return blockcount;}
 
97
  u32                    GetRedundancy(void) const         {return redundancy;}
 
98
  u32                    GetFirstRecoveryBlock(void) const {return firstblock;}
 
99
  u32                    GetRecoveryFileCount(void) const  {return recoveryfilecount;}
 
100
  u32                    GetRecoveryBlockCount(void) const {return recoveryblockcount;}
 
101
  CommandLine::Scheme    GetRecoveryFileScheme(void) const {return recoveryfilescheme;}
 
102
  size_t                 GetMemoryLimit(void) const        {return memorylimit;}
 
103
  u64                    GetLargestSourceSize(void) const  {return largestsourcesize;}
 
104
  u64                    GetTotalSourceSize(void) const    {return totalsourcesize;}
 
105
  CommandLine::NoiseLevel GetNoiseLevel(void) const        {return noiselevel;}
 
106
 
 
107
  string                              GetParFilename(void) const {return parfilename;}
 
108
  const list<CommandLine::ExtraFile>& GetExtraFiles(void) const  {return extrafiles;}
 
109
 
 
110
protected:
 
111
  Operation operation;         // The operation to be carried out.
 
112
  Version version;             // What version files will be processed.
 
113
 
 
114
  NoiseLevel noiselevel;       // How much display output should there be.
 
115
 
 
116
  u32 blockcount;              // How many blocks the source files should 
 
117
                               // be virtually split into.
 
118
 
 
119
  u64 blocksize;               // What virtual block size to use.
 
120
 
 
121
  u32 firstblock;              // What the exponent value for the first
 
122
                               // recovery block will be.
 
123
 
 
124
  Scheme recoveryfilescheme;   // How the the size of the recovery files should
 
125
                               // be calculated.
 
126
 
 
127
  u32 recoveryfilecount;       // How many recovery files should be created.
 
128
 
 
129
  u32 recoveryblockcount;      // How many recovery blocks should be created.
 
130
  bool recoveryblockcountset;  // Set if the recoveryblockcount as been specified
 
131
 
 
132
  u32 redundancy;              // What percentage of recovery data should
 
133
                               // be created.
 
134
  bool redundancyset;          // Set if the redundancy has been specified
 
135
 
 
136
  string parfilename;          // The name of the PAR2 file to create, or
 
137
                               // the name of the first PAR2 file to read
 
138
                               // when verifying or repairing.
 
139
 
 
140
  list<ExtraFile> extrafiles;  // The list of other files specified on the
 
141
                               // command line. When creating, this will be
 
142
                               // the source files, and when verifying or
 
143
                               // repairing, this will be additional PAR2
 
144
                               // files or data files to be examined.
 
145
 
 
146
  u64 totalsourcesize;         // Total size of the source files.
 
147
 
 
148
  u64 largestsourcesize;       // Size of the largest source file.
 
149
 
 
150
  size_t memorylimit;          // How much memory is permitted to be used
 
151
                               // for the output buffer when creating
 
152
                               // or repairing.
 
153
};
 
154
 
 
155
typedef list<CommandLine::ExtraFile>::const_iterator ExtraFileIterator;
 
156
 
 
157
#endif // __COMMANDLINE_H__