]>
Commit | Line | Data |
---|---|---|
b2e465d6 AL |
1 | #include <apt-pkg/debfile.h> |
2 | #include <apt-pkg/error.h> | |
472ff00e | 3 | #include <apt-pkg/fileutl.h> |
b2e465d6 AL |
4 | |
5 | #include <iostream> | |
6 | #include <unistd.h> | |
7 | ||
5a8748f1 AL |
8 | using namespace std; |
9 | ||
b2e465d6 AL |
10 | bool ExtractMember(const char *File,const char *Member) |
11 | { | |
12 | FileFd Fd(File,FileFd::ReadOnly); | |
13 | debDebFile Deb(Fd); | |
14 | if(_error->PendingError() == true) | |
15 | return false; | |
16 | ||
17 | debDebFile::MemControlExtract Extract(Member); | |
18 | if (Extract.Read(Deb) == false) | |
19 | return false; | |
20 | ||
21 | if (Extract.Control == 0) | |
22 | return true; | |
23 | ||
24 | write(STDOUT_FILENO,Extract.Control,Extract.Length); | |
25 | return true; | |
26 | } | |
27 | ||
28 | int main(int argc, const char *argv[]) | |
29 | { | |
30 | if (argc < 2) | |
31 | { | |
32 | cerr << "Need two arguments, a .deb and the control member" << endl; | |
33 | return 100; | |
34 | } | |
35 | ||
36 | if (ExtractMember(argv[1],argv[2]) == false) | |
37 | { | |
38 | _error->DumpErrors(); | |
39 | return 100; | |
40 | } | |
41 | ||
42 | return 0; | |
43 | } |