apt @VERSION@
|
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 using std::string; 00018 using std::vector; 00019 00020 class pkgTagSection; 00021 class FileFd; 00022 class indexRecords; 00023 class pkgCdromStatus; 00024 00025 class IndexCopy /*{{{*/ 00026 { 00028 void *d; 00029 00030 protected: 00031 00032 pkgTagSection *Section; 00033 00034 string ChopDirs(string Path,unsigned int Depth); 00035 bool ReconstructPrefix(string &Prefix,string OrigPath,string CD, 00036 string File); 00037 bool ReconstructChop(unsigned long &Chop,string Dir,string File); 00038 void ConvertToSourceList(string CD,string &Path); 00039 bool GrabFirst(string Path,string &To,unsigned int Depth); 00040 virtual bool GetFile(string &Filename,unsigned long &Size) = 0; 00041 virtual bool RewriteEntry(FILE *Target,string File) = 0; 00042 virtual const char *GetFileName() = 0; 00043 virtual const char *Type() = 0; 00044 00045 public: 00046 00047 bool CopyPackages(string CDROM,string Name,vector<string> &List, 00048 pkgCdromStatus *log); 00049 virtual ~IndexCopy() {}; 00050 }; 00051 /*}}}*/ 00052 class PackageCopy : public IndexCopy /*{{{*/ 00053 { 00054 protected: 00055 00056 virtual bool GetFile(string &Filename,unsigned long &Size); 00057 virtual bool RewriteEntry(FILE *Target,string File); 00058 virtual const char *GetFileName() {return "Packages";}; 00059 virtual const char *Type() {return "Package";}; 00060 00061 }; 00062 /*}}}*/ 00063 class SourceCopy : public IndexCopy /*{{{*/ 00064 { 00065 protected: 00066 00067 virtual bool GetFile(string &Filename,unsigned long &Size); 00068 virtual bool RewriteEntry(FILE *Target,string File); 00069 virtual const char *GetFileName() {return "Sources";}; 00070 virtual const char *Type() {return "Source";}; 00071 00072 }; 00073 /*}}}*/ 00074 class TranslationsCopy /*{{{*/ 00075 { 00076 protected: 00077 pkgTagSection *Section; 00078 00079 public: 00080 bool CopyTranslations(string CDROM,string Name,vector<string> &List, 00081 pkgCdromStatus *log); 00082 }; 00083 /*}}}*/ 00084 class SigVerify /*{{{*/ 00085 { 00087 void *d; 00088 00089 bool Verify(string prefix,string file, indexRecords *records); 00090 bool CopyMetaIndex(string CDROM, string CDName, 00091 string prefix, string file); 00092 00093 public: 00094 bool CopyAndVerify(string CDROM,string Name,vector<string> &SigList, 00095 vector<string> PkgList,vector<string> SrcList); 00096 00098 static bool RunGPGV(std::string const &File, std::string const &FileOut, 00099 int const &statusfd, int fd[2]); 00100 inline static bool RunGPGV(std::string const &File, std::string const &FileOut, 00101 int const &statusfd = -1) { 00102 int fd[2]; 00103 return RunGPGV(File, FileOut, statusfd, fd); 00104 }; 00105 }; 00106 /*}}}*/ 00107 00108 #endif