apt @VERSION@

indexcopy.h

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