00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00017 #ifndef JIGDO_FILE_CMD_HH
00018 #define JIGDO_FILE_CMD_HH
00019
00020 #include <config.h>
00021
00022 #include <iosfwd>
00023 #include <string>
00024
00025 #include <jigdoconfig.hh>
00026 #include <scan.hh>
00027 #include <md5sum.hh>
00028 #include <mkimage.hh>
00029 #include <mktemplate.hh>
00030
00031
00034 struct AnyReporter : public MkTemplate::ProgressReporter,
00035 public JigdoCache::ProgressReporter,
00036 public JigdoDesc::ProgressReporter,
00037 public MD5Sum::ProgressReporter,
00038 public JigdoConfig::ProgressReporter {
00039 virtual void error(const string& message) {
00040 MD5Sum::ProgressReporter::error(message);
00041 }
00042 virtual void info(const string& message) {
00043 MD5Sum::ProgressReporter::info(message);
00044 }
00045 virtual void coutInfo(const string& message) {
00046 cout << message << endl;
00047 }
00048 };
00049
00050
00052 class JigdoFileCmd {
00053 friend int main(int argc, char* argv[]);
00054
00055
00056 enum Command {
00057 MAKE_TEMPLATE, MAKE_IMAGE,
00058 PRINT_MISSING, PRINT_MISSING_ALL,
00059 SCAN, VERIFY, LIST_TEMPLATE, MD5SUM
00060 };
00061
00062
00063
00064 # if WINDOWS
00065 static const char* const binaryName;
00066 # else
00067 friend const string& binName();
00068 static string binaryName;
00069 # endif
00070
00071
00072 static RecurseDir fileNames;
00073 static string imageFile;
00074 static string jigdoFile;
00075 static string templFile;
00076 static string jigdoMergeFile;
00077 static string cacheFile;
00078 static size_t optCacheExpiry;
00079 static vector<string> optLabels;
00080 static vector<string> optUris;
00081 static size_t blockLength;
00082 static size_t md5BlockLength;
00083 static size_t readAmount;
00084 static int optZipQuality;
00085 static bool optBzip2;
00086 static bool optForce;
00087 static bool optMkImageCheck;
00088 static bool optCheckFiles;
00089 static bool optScanWholeFile;
00090
00091 static bool optGreedyMatching;
00092 static bool optAddImage;
00093 static bool optAddServers;
00094 static bool optHex;
00095 static string optDebug;
00096
00097 static AnyReporter* optReporter;
00098 static string optMatchExec;
00099
00100
00105 static Command cmdOptions(int argc, char* argv[]);
00106
00107
00112 static int makeTemplate();
00113 static int makeImage();
00114 static int printMissing(Command command = PRINT_MISSING);
00115 static int scanFiles();
00116 static int verifyImage();
00117 static int listTemplate();
00118 static int md5sumFiles();
00120
00125 static int addLabels(JigdoCache& cache);
00126 static void addUris(ConfigFile& config);
00127 static bool printMissing_lookup(JigdoConfig& jc, const string& query,
00128 bool printAll);
00130 };
00131
00132
00135 #if WINDOWS
00136 inline const char* binName() {
00137 return "jigdo-file";
00138 }
00139 #else
00140 inline const string& binName() {
00141 return JigdoFileCmd::binaryName;
00142 }
00143 #endif
00144
00147 extern void exit_tryHelp();
00148
00149
00150 #endif