]> git.saurik.com Git - apt.git/blob - apt-pkg/indexcopy.h
apt-pkg/contrib/netrc.cc: use a slightly smaller login/password size
[apt.git] / apt-pkg / indexcopy.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: indexcopy.h,v 1.3 2001/05/27 04:46:54 jgg Exp $
4 /* ######################################################################
5
6 Index Copying - Aid for copying and verifying the index files
7
8 ##################################################################### */
9 /*}}}*/
10 #ifndef INDEXCOPY_H
11 #define INDEXCOPY_H
12
13 #include <vector>
14 #include <string>
15 #include <stdio.h>
16
17 #ifndef APT_8_CLEANER_HEADERS
18 using std::string;
19 using std::vector;
20 #endif
21
22 class pkgTagSection;
23 class FileFd;
24 class indexRecords;
25 class pkgCdromStatus;
26
27 class IndexCopy /*{{{*/
28 {
29 /** \brief dpointer placeholder (for later in case we need it) */
30 void *d;
31
32 protected:
33
34 pkgTagSection *Section;
35
36 std::string ChopDirs(std::string Path,unsigned int Depth);
37 bool ReconstructPrefix(std::string &Prefix,std::string OrigPath,std::string CD,
38 std::string File);
39 bool ReconstructChop(unsigned long &Chop,std::string Dir,std::string File);
40 void ConvertToSourceList(std::string CD,std::string &Path);
41 bool GrabFirst(std::string Path,std::string &To,unsigned int Depth);
42 virtual bool GetFile(std::string &Filename,unsigned long long &Size) = 0;
43 virtual bool RewriteEntry(FILE *Target,std::string File) = 0;
44 virtual const char *GetFileName() = 0;
45 virtual const char *Type() = 0;
46
47 public:
48
49 bool CopyPackages(std::string CDROM,std::string Name,std::vector<std::string> &List,
50 pkgCdromStatus *log);
51 virtual ~IndexCopy() {};
52 };
53 /*}}}*/
54 class PackageCopy : public IndexCopy /*{{{*/
55 {
56 protected:
57
58 virtual bool GetFile(std::string &Filename,unsigned long long &Size);
59 virtual bool RewriteEntry(FILE *Target,std::string File);
60 virtual const char *GetFileName() {return "Packages";};
61 virtual const char *Type() {return "Package";};
62
63 };
64 /*}}}*/
65 class SourceCopy : public IndexCopy /*{{{*/
66 {
67 protected:
68
69 virtual bool GetFile(std::string &Filename,unsigned long long &Size);
70 virtual bool RewriteEntry(FILE *Target,std::string File);
71 virtual const char *GetFileName() {return "Sources";};
72 virtual const char *Type() {return "Source";};
73
74 };
75 /*}}}*/
76 class TranslationsCopy /*{{{*/
77 {
78 protected:
79 pkgTagSection *Section;
80
81 public:
82 bool CopyTranslations(std::string CDROM,std::string Name,std::vector<std::string> &List,
83 pkgCdromStatus *log);
84 };
85 /*}}}*/
86 class SigVerify /*{{{*/
87 {
88 /** \brief dpointer placeholder (for later in case we need it) */
89 void *d;
90
91 bool Verify(std::string prefix,std::string file, indexRecords *records);
92 bool CopyMetaIndex(std::string CDROM, std::string CDName,
93 std::string prefix, std::string file);
94
95 public:
96 bool CopyAndVerify(std::string CDROM,std::string Name,std::vector<std::string> &SigList,
97 std::vector<std::string> PkgList,std::vector<std::string> SrcList);
98
99 /** \brief generates and run the command to verify a file with gpgv */
100 static bool RunGPGV(std::string const &File, std::string const &FileOut,
101 int const &statusfd, int fd[2]);
102 inline static bool RunGPGV(std::string const &File, std::string const &FileOut,
103 int const &statusfd = -1) {
104 int fd[2];
105 return RunGPGV(File, FileOut, statusfd, fd);
106 };
107 };
108 /*}}}*/
109
110 #endif