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