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