apt
1.5
|
00001 // -*- mode: cpp; mode: fold -*- 00002 // Description /*{{{*/ 00003 // $Id: indexcopy.h,v 1.3 2001/05/27 04:46:54 jgg Exp $ 00004 /* ###################################################################### 00005 00006 Index Copying - Aid for copying and verifying the index files 00007 00008 ##################################################################### */ 00009 /*}}}*/ 00010 #ifndef INDEXCOPY_H 00011 #define INDEXCOPY_H 00012 00013 #include <vector> 00014 #include <string> 00015 #include <stdio.h> 00016 00017 #ifndef APT_8_CLEANER_HEADERS 00018 using std::string; 00019 using std::vector; 00020 #endif 00021 00022 class pkgTagSection; 00023 class FileFd; 00024 class indexRecords; 00025 class pkgCdromStatus; 00026 00027 class IndexCopy /*{{{*/ 00028 { 00030 void *d; 00031 00032 protected: 00033 00034 pkgTagSection *Section; 00035 00036 std::string ChopDirs(std::string Path,unsigned int Depth); 00037 bool ReconstructPrefix(std::string &Prefix,std::string OrigPath,std::string CD, 00038 std::string File); 00039 bool ReconstructChop(unsigned long &Chop,std::string Dir,std::string File); 00040 void ConvertToSourceList(std::string CD,std::string &Path); 00041 bool GrabFirst(std::string Path,std::string &To,unsigned int Depth); 00042 virtual bool GetFile(std::string &Filename,unsigned long long &Size) = 0; 00043 virtual bool RewriteEntry(FILE *Target,std::string File) = 0; 00044 virtual const char *GetFileName() = 0; 00045 virtual const char *Type() = 0; 00046 00047 public: 00048 00049 bool CopyPackages(std::string CDROM,std::string Name,std::vector<std::string> &List, 00050 pkgCdromStatus *log); 00051 virtual ~IndexCopy() {}; 00052 }; 00053 /*}}}*/ 00054 class PackageCopy : public IndexCopy /*{{{*/ 00055 { 00056 protected: 00057 00058 virtual bool GetFile(std::string &Filename,unsigned long long &Size); 00059 virtual bool RewriteEntry(FILE *Target,std::string File); 00060 virtual const char *GetFileName() {return "Packages";}; 00061 virtual const char *Type() {return "Package";}; 00062 00063 }; 00064 /*}}}*/ 00065 class SourceCopy : public IndexCopy /*{{{*/ 00066 { 00067 protected: 00068 00069 virtual bool GetFile(std::string &Filename,unsigned long long &Size); 00070 virtual bool RewriteEntry(FILE *Target,std::string File); 00071 virtual const char *GetFileName() {return "Sources";}; 00072 virtual const char *Type() {return "Source";}; 00073 00074 }; 00075 /*}}}*/ 00076 class TranslationsCopy /*{{{*/ 00077 { 00078 protected: 00079 pkgTagSection *Section; 00080 00081 public: 00082 bool CopyTranslations(std::string CDROM,std::string Name,std::vector<std::string> &List, 00083 pkgCdromStatus *log); 00084 }; 00085 /*}}}*/ 00086 class SigVerify /*{{{*/ 00087 { 00089 void *d; 00090 00091 bool Verify(std::string prefix,std::string file, indexRecords *records); 00092 bool CopyMetaIndex(std::string CDROM, std::string CDName, 00093 std::string prefix, std::string file); 00094 00095 public: 00096 bool CopyAndVerify(std::string CDROM,std::string Name,std::vector<std::string> &SigList, 00097 std::vector<std::string> PkgList,std::vector<std::string> SrcList); 00098 00100 static bool RunGPGV(std::string const &File, std::string const &FileOut, 00101 int const &statusfd, int fd[2]); 00102 inline static bool RunGPGV(std::string const &File, std::string const &FileOut, 00103 int const &statusfd = -1) { 00104 int fd[2]; 00105 return RunGPGV(File, FileOut, statusfd, fd); 00106 }; 00107 }; 00108 /*}}}*/ 00109 00110 #endif