]>
Commit | Line | Data |
---|---|---|
6d38011b DK |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
3 | /* ###################################################################### | |
e0a78caa | 4 | The scenario file is designed to work as an intermediate file between |
6d38011b DK |
5 | APT and the resolver. Its on propose very similar to a dpkg status file |
6 | ##################################################################### */ | |
7 | /*}}}*/ | |
8 | // Include Files /*{{{*/ | |
ea542140 DK |
9 | #include <config.h> |
10 | ||
6d38011b DK |
11 | #include <apt-pkg/edspindexfile.h> |
12 | #include <apt-pkg/edsplistparser.h> | |
6d38011b | 13 | #include <apt-pkg/error.h> |
472ff00e | 14 | #include <apt-pkg/fileutl.h> |
453b82a3 | 15 | #include <apt-pkg/indexfile.h> |
453b82a3 | 16 | #include <apt-pkg/pkgcache.h> |
453b82a3 | 17 | #include <apt-pkg/pkgrecords.h> |
6d38011b | 18 | |
453b82a3 DK |
19 | #include <stddef.h> |
20 | #include <unistd.h> | |
21 | #include <string> | |
6d38011b DK |
22 | /*}}}*/ |
23 | ||
d59671c9 DK |
24 | // EDSP-like Index /*{{{*/ |
25 | edspLikeIndex::edspLikeIndex(std::string const &File) : pkgDebianIndexRealFile(File, true) | |
6d38011b DK |
26 | { |
27 | } | |
d59671c9 | 28 | std::string edspLikeIndex::GetArchitecture() const |
c9443c01 DK |
29 | { |
30 | return std::string(); | |
31 | } | |
d59671c9 | 32 | bool edspLikeIndex::HasPackages() const |
c9443c01 DK |
33 | { |
34 | return true; | |
35 | } | |
d59671c9 | 36 | bool edspLikeIndex::Exists() const |
c9443c01 DK |
37 | { |
38 | return true; | |
39 | } | |
d59671c9 | 40 | uint8_t edspLikeIndex::GetIndexFlags() const |
c9443c01 DK |
41 | { |
42 | return 0; | |
43 | } | |
d59671c9 | 44 | bool edspLikeIndex::OpenListFile(FileFd &Pkg, std::string const &FileName) |
c9443c01 | 45 | { |
7f58427b | 46 | if (FileName.empty() == false && FileName != "/nonexistent/stdin") |
c9443c01 DK |
47 | return pkgDebianIndexRealFile::OpenListFile(Pkg, FileName); |
48 | if (Pkg.OpenDescriptor(STDIN_FILENO, FileFd::ReadOnly) == false) | |
49 | return _error->Error("Problem opening %s",FileName.c_str()); | |
6d38011b | 50 | return true; |
d59671c9 DK |
51 | } |
52 | /*}}}*/ | |
53 | // EDSP Index /*{{{*/ | |
54 | edspIndex::edspIndex(std::string const &File) : edspLikeIndex(File) | |
55 | { | |
56 | } | |
57 | std::string edspIndex::GetComponent() const | |
58 | { | |
59 | return "edsp"; | |
c9443c01 DK |
60 | } |
61 | pkgCacheListParser * edspIndex::CreateListParser(FileFd &Pkg) | |
62 | { | |
63 | if (Pkg.IsOpen() == false) | |
64 | return NULL; | |
65 | _error->PushToStack(); | |
66 | pkgCacheListParser * const Parser = new edspListParser(&Pkg); | |
67 | bool const newError = _error->PendingError(); | |
68 | _error->MergeWithStack(); | |
69 | return newError ? NULL : Parser; | |
6d38011b DK |
70 | } |
71 | /*}}}*/ | |
f74d99c6 DK |
72 | // EIPP Index /*{{{*/ |
73 | eippIndex::eippIndex(std::string const &File) : edspLikeIndex(File) | |
74 | { | |
75 | } | |
76 | std::string eippIndex::GetComponent() const | |
77 | { | |
78 | return "eipp"; | |
79 | } | |
80 | pkgCacheListParser * eippIndex::CreateListParser(FileFd &Pkg) | |
81 | { | |
82 | if (Pkg.IsOpen() == false) | |
83 | return NULL; | |
84 | _error->PushToStack(); | |
85 | pkgCacheListParser * const Parser = new eippListParser(&Pkg); | |
86 | bool const newError = _error->PendingError(); | |
87 | _error->MergeWithStack(); | |
88 | return newError ? NULL : Parser; | |
89 | } | |
90 | /*}}}*/ | |
c9443c01 | 91 | |
6d38011b | 92 | // Index File types for APT /*{{{*/ |
dce45dbe | 93 | class APT_HIDDEN edspIFType: public pkgIndexFile::Type |
6d38011b DK |
94 | { |
95 | public: | |
c9443c01 | 96 | virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator const &) const APT_OVERRIDE |
6d38011b DK |
97 | { |
98 | // we don't have a record parser for this type as the file is not presistent | |
99 | return NULL; | |
100 | }; | |
e0a78caa | 101 | edspIFType() {Label = "EDSP scenario file";}; |
6d38011b | 102 | }; |
c9443c01 | 103 | APT_HIDDEN edspIFType _apt_Edsp; |
6d38011b DK |
104 | const pkgIndexFile::Type *edspIndex::GetType() const |
105 | { | |
c9443c01 | 106 | return &_apt_Edsp; |
6d38011b | 107 | } |
f74d99c6 DK |
108 | |
109 | class APT_HIDDEN eippIFType: public pkgIndexFile::Type | |
110 | { | |
111 | public: | |
112 | virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator const &) const APT_OVERRIDE | |
113 | { | |
114 | // we don't have a record parser for this type as the file is not presistent | |
115 | return NULL; | |
116 | }; | |
117 | eippIFType() {Label = "EIPP scenario file";}; | |
118 | }; | |
119 | APT_HIDDEN eippIFType _apt_Eipp; | |
120 | const pkgIndexFile::Type *eippIndex::GetType() const | |
121 | { | |
122 | return &_apt_Eipp; | |
123 | } | |
6d38011b | 124 | /*}}}*/ |
c8a4ce6c | 125 | |
d59671c9 | 126 | edspLikeIndex::~edspLikeIndex() {} |
c8a4ce6c | 127 | edspIndex::~edspIndex() {} |
f74d99c6 | 128 | eippIndex::~eippIndex() {} |